1 #include <fcntl.h> 2 #include <gtest/gtest.h> 3 #include <stdlib.h> 4 #include <sys/auxv.h> 5 #include <sys/uio.h> 6 #include <unistd.h> 7 8 using namespace testing::ext; 9 10 class UnistdFdatasyncTest : public testing::Test { SetUp()11 void SetUp() override {} TearDown()12 void TearDown() override {} 13 }; 14 15 /** 16 * @tc.name: fdatasync_001 17 * @tc.desc: Verify whether the fdatasync function behaves as expected under different file descriptor states. 18 * @tc.type: FUNC 19 */ 20 HWTEST_F(UnistdFdatasyncTest, fdatasync_001, TestSize.Level1) 21 { 22 int fd; 23 24 EXPECT_NE(-1, fd = open("/data/local/tmp", O_RDONLY)); 25 EXPECT_EQ(0, fdatasync(fd)); 26 close(fd); 27 28 EXPECT_NE(0, fd = open("/data/local/tmp", O_RDWR)); 29 EXPECT_EQ(-1, fdatasync(fd)); 30 close(fd); 31 }