• 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      : mkdtemp_0100
21  * @tc.desc      : Create a temporary directory with the correct parameters
22  * @tc.level     : Level 0
23  */
mkdtemp_0100(void)24 void mkdtemp_0100(void)
25 {
26     char temp_dir[] = "test-XXXXXX";
27     char *ret = mkdtemp(temp_dir);
28     EXPECT_PTRNE("mkdtemp_0100", ret, NULL);
29     if (ret) {
30         EXPECT_NE("mkdtemp_0100", ret[0], CMPFLAG);
31     }
32 }
33 
34 /**
35  * @tc.name      : mkdtemp_0200
36  * @tc.desc      : Create temp directory with wrong template parameter
37  * @tc.level     : Level 2
38  */
mkdtemp_0200(void)39 void mkdtemp_0200(void)
40 {
41     char temp_dir[] = "test";
42     char *ret = mkdtemp(temp_dir);
43     EXPECT_PTREQ("mkdtemp_0200", ret, NULL);
44 }
45 
46 /**
47  * @tc.name      : mkdtemp_0300
48  * @tc.desc      : Create temp directory with wrong template argument (wrong template length)
49  * @tc.level     : Level 2
50  */
mkdtemp_0300(void)51 void mkdtemp_0300(void)
52 {
53     char temp_dir[] = "test-XX";
54     char *ret = mkdtemp(temp_dir);
55     EXPECT_PTREQ("mkdtemp_0300", ret, NULL);
56 }
57 
main(void)58 int main(void)
59 {
60     mkdtemp_0100();
61     mkdtemp_0200();
62     mkdtemp_0300();
63     return t_status;
64 }