1 #include <fcntl.h> 2 #include <gtest/gtest.h> 3 #include <sys/stat.h> 4 5 using namespace testing::ext; 6 7 class StatFstat64Test : public testing::Test { SetUp()8 void SetUp() override {} TearDown()9 void TearDown() override {} 10 }; 11 12 /** 13 * @tc.name: fstat64_001 14 * @tc.desc: Verify the functionality of the fstat64() function by creating a directory, opening a file within that 15 * directory, retrieving the file status information using fstat64(), and performing checks to ensure 16 * successful execution of each step. 17 * @tc.type: FUNC 18 **/ 19 HWTEST_F(StatFstat64Test, fstat64_001, TestSize.Level1) 20 { 21 const char* dirName = "test_fstat64.txt"; 22 mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO; 23 int result1 = mkdir(dirName, mode); 24 ASSERT_NE(-1, result1); 25 26 int fd = open("test_fstat64.txt", O_RDONLY); 27 ASSERT_NE(-1, fd); 28 struct stat64 statBuf; 29 int result2 = fstat64(fd, &statBuf); 30 EXPECT_NE(-1, result2); 31 close(fd); 32 remove("test_fstat64.txt"); 33 }