• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <gtest/gtest.h>
2 #include <sys/inotify.h>
3 
4 using namespace testing::ext;
5 
6 class LinuxInotifyaddwatchTest : public ::testing::Test {
SetUp()7     void SetUp() override {}
TearDown()8     void TearDown() override {}
9 };
10 
11 constexpr int TEST_DATA_COUNT = 2;
12 
13 struct InotifyTestData {
14     int fd;
15     int wd;
16     uint32_t mask;
17 };
18 
19 /**
20  * @tc.name: inotify_add_watch_001
21  * @tc.desc: This test verifies the effectiveness of inotify_add_watch make multiple calls to the test function and
22  *           verify that its return value matches expectations.
23  * @tc.type: FUNC
24  */
25 HWTEST_F(LinuxInotifyaddwatchTest, inotify_add_watch_001, TestSize.Level1)
26 {
27     InotifyTestData data[TEST_DATA_COUNT] = {
28         { .fd = -1, .wd = -1, .mask = IN_ACCESS },
29         { .fd = -1, .wd = -1, .mask = IN_MODIFY },
30     };
31     for (int i = 0; i < TEST_DATA_COUNT; i++) {
32         data[i].wd = inotify_add_watch(data[i].fd, "/path/to/file", data[i].mask);
33         EXPECT_EQ(-1, data[i].wd);
34     }
35 }