• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <fcntl.h>
2 #include <gtest/gtest.h>
3 
4 using namespace testing::ext;
5 
6 #define TEST_LEN 10
7 
8 class FcntlPosixfadvise64Test : public testing::Test {
SetUp()9     void SetUp() override {}
TearDown()10     void TearDown() override {}
11 };
12 
13 /**
14  * @tc.name: posix_fadvise64_001
15  * @tc.desc: Correct parameters, set file preload size.
16  * @tc.type: FUNC
17  * */
18 HWTEST_F(FcntlPosixfadvise64Test, posix_fadvise64_001, TestSize.Level1)
19 {
20     FILE* fp = tmpfile();
21     if (!fp) {
22         return;
23     }
24     int fd = fileno(fp);
25     if (fd == -1) {
26         fclose(fp);
27         return;
28     }
29     int result1 = posix_fadvise64(fd, 0, TEST_LEN, POSIX_FADV_NORMAL);
30     int result2 = posix_fadvise64(fd, 0, TEST_LEN, POSIX_FADV_SEQUENTIAL);
31     int result3 = posix_fadvise64(fd, 0, TEST_LEN, POSIX_FADV_RANDOM);
32     int result4 = posix_fadvise64(fd, 0, TEST_LEN, POSIX_FADV_NOREUSE);
33     int result5 = posix_fadvise64(fd, 0, TEST_LEN, POSIX_FADV_WILLNEED);
34     int result6 = posix_fadvise64(fd, 0, TEST_LEN, POSIX_FADV_DONTNEED);
35     EXPECT_EQ(0, result1);
36     EXPECT_EQ(0, result2);
37     EXPECT_EQ(0, result3);
38     EXPECT_EQ(0, result4);
39     EXPECT_EQ(0, result5);
40     EXPECT_EQ(0, result6);
41     fclose(fp);
42 }