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 <dirent.h>
17 #include "functionalext.h"
18
19 /**
20 * @tc.name : readdir_0100
21 * @tc.desc : The parameter is valid and can return the next directory entry
22 * point of the parameter dir directory stream.
23 * @tc.level : Level 0
24 */
readdir_0100(void)25 void readdir_0100(void)
26 {
27 DIR *dir;
28 struct dirent *ret;
29 dir = opendir("/etc");
30 ret = readdir(dir);
31 EXPECT_TRUE("readdir_0100", ret != NULL);
32 closedir(dir);
33 }
34
35 /**
36 * @tc.name : readdir_0200
37 * @tc.desc : The parameter is invalid, cannot return the next directory entry
38 * point of the parameter dir directory stream.
39 * @tc.level : Level 2
40 */
readdir_0200(void)41 void readdir_0200(void)
42 {
43 DIR *dir = (DIR *)"";
44 struct dirent *ret;
45 ret = readdir(dir);
46 EXPECT_TRUE("readdir_0200", NULL == ret);
47 }
48
main(int argc,char * argv[])49 int main(int argc, char *argv[])
50 {
51 readdir_0100();
52 readdir_0200();
53
54 return t_status;
55 }