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 <sys/inotify.h>
17 #include "functionalext.h"
18
19 /**
20 * @tc.name : inotify_init1_0100
21 * @tc.desc : Verify inotify_init1 process success. when param flag is 0
22 * @tc.level : Level 0
23 */
inotify_init1_0100(void)24 void inotify_init1_0100(void)
25 {
26 errno = 0;
27 int fd = inotify_init1(0);
28 EXPECT_NE("inotify_init1_0100", fd, -1);
29 EXPECT_EQ("inotify_init1_0100", errno, 0);
30 close(fd);
31 }
32
33 /**
34 * @tc.name : inotify_init1_0200
35 * @tc.desc : Verify inotify_init1 process success. when param flag is IN_NONBLOCK
36 * @tc.level : Level 0
37 */
inotify_init1_0200(void)38 void inotify_init1_0200(void)
39 {
40 errno = 0;
41 int fd = inotify_init1(IN_NONBLOCK);
42 EXPECT_NE("inotify_init1_0200", fd, -1);
43 EXPECT_EQ("inotify_init1_0200", errno, 0);
44 close(fd);
45 }
46
47 /**
48 * @tc.name : inotify_init1_0300
49 * @tc.desc : Verify inotify_init1 process success. when param flag is IN_CLOEXEC
50 * @tc.level : Level 0
51 */
inotify_init1_0300(void)52 void inotify_init1_0300(void)
53 {
54 errno = 0;
55 int fd = inotify_init1(IN_CLOEXEC);
56 EXPECT_NE("inotify_init1_0300", fd, -1);
57 EXPECT_EQ("inotify_init1_0300", errno, 0);
58 close(fd);
59 }
60
61 /**
62 * @tc.name : inotify_init1_0400
63 * @tc.desc : Verify inotify_init1 process success. when param flag is invalid
64 * @tc.level : Level 2
65 */
inotify_init1_0400(void)66 void inotify_init1_0400(void)
67 {
68 errno = 0;
69 int fd = inotify_init1(-1);
70 EXPECT_EQ("inotify_init1_0400", fd, -1);
71 EXPECT_EQ("inotify_init1_0400", errno, EINVAL);
72 close(fd);
73 }
74
main(void)75 int main(void)
76 {
77 inotify_init1_0100();
78 inotify_init1_0200();
79 inotify_init1_0300();
80 inotify_init1_0400();
81 return t_status;
82 }
83