• 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 <unistd.h>
17 #include <sys/stat.h>
18 #include "functionalext.h"
19 
20 const int SUCCESS = 0;
21 const int FAILED = -1;
22 
23 /**
24  * @tc.name      : mkdir_0100
25  * @tc.desc      : The parameters are valid and the directoty can be created.
26  * @tc.level     : Level 0
27  */
mkdir_0100(void)28 void mkdir_0100(void)
29 {
30     char *path = "mkdirtest";
31     if (access(path, F_OK) != 0) {
32         int ret = mkdir(path, 0777);
33         EXPECT_EQ("mkdir_0100", ret, SUCCESS);
34         remove(path);
35     } else {
36         remove(path);
37         int ret = mkdir(path, 0777);
38         EXPECT_EQ("mkdir_0100", ret, SUCCESS);
39         remove(path);
40     }
41     path = NULL;
42 }
43 
44 /**
45  * @tc.name      : mkdir_0200
46  * @tc.desc      : The path parameters is invalid,the directoty cannot be created.
47  * @tc.level     : Level 2
48  */
mkdir_0200(void)49 void mkdir_0200(void)
50 {
51     char *path = "mkdirtest";
52     if (access(path, F_OK) == 0) {
53         int ret = mkdir(path, 0777);
54         EXPECT_EQ("mkdir_0200", ret, FAILED);
55         remove(path);
56     } else {
57         int retcreate = mkdir(path, 0777);
58         EXPECT_EQ("mkdir_0200", retcreate, SUCCESS);
59         int ret = mkdir(path, 0777);
60         EXPECT_EQ("mkdir_0200", ret, FAILED);
61         remove(path);
62     }
63     path = NULL;
64 }
65 
main(int argc,char * argv[])66 int main(int argc, char *argv[])
67 {
68     mkdir_0100();
69     mkdir_0200();
70 
71     return t_status;
72 }