• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *   http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <stdlib.h>
17 #include "functionalext.h"
18 
19 /**
20  * @tc.name      : mktemp_0100
21  * @tc.desc      : Create a temporary file with the correct parameters
22  * @tc.level     : Level 0
23  */
mktemp_0100(void)24 void mktemp_0100(void)
25 {
26     char temp_file[] = "test-XXXXXX";
27     char *ret = mktemp(temp_file);
28     EXPECT_PTRNE("mktemp_0100", ret, NULL);
29     if (ret) {
30         EXPECT_NE("mktemp_0100", ret[0], 0);
31     }
32 }
33 
34 /**
35  * @tc.name      : mktemp_0200
36  * @tc.desc      : Create temp file with wrong template parameter
37  * @tc.level     : Level 2
38  */
mktemp_0200(void)39 void mktemp_0200(void)
40 {
41     char temp_file[] = "test";
42     char *ret = mktemp(temp_file);
43     EXPECT_PTRNE("mktemp_0200", ret, NULL);
44     if (ret) {
45         EXPECT_EQ("mktemp_0200", ret[0], 0);
46     }
47 }
48 
49 /**
50  * @tc.name      : mktemp_0300
51  * @tc.desc      : Create temp file with wrong template argument (wrong template length)
52  * @tc.level     : Level 2
53  */
mktemp_0300(void)54 void mktemp_0300(void)
55 {
56     char temp_file[] = "test-XX";
57     char *ret = mktemp(temp_file);
58     EXPECT_PTRNE("mktemp_0300", ret, NULL);
59     if (ret) {
60         EXPECT_EQ("mktemp_0300", ret[0], 0);
61     }
62 }
63 
main(void)64 int main(void)
65 {
66     mktemp_0100();
67     mktemp_0200();
68     mktemp_0300();
69     return t_status;
70 }