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 constexpr int SIZE_1024 = 1024; 11 12 class UnistdFtruncate64Test : public testing::Test { SetUp()13 void SetUp() override {} TearDown()14 void TearDown() override {} 15 }; 16 17 /** 18 * @tc.name: ftruncate64_001 19 * @tc.desc: Checked whether the ftruncate64 function successfully truncated the file to the specified size and updated 20 * the file size accordingly. 21 * @tc.type: FUNC 22 * */ 23 HWTEST_F(UnistdFtruncate64Test, ftruncate64_001, TestSize.Level1) 24 { 25 FILE* fptr = fopen("test.txt", "w"); 26 EXPECT_EQ(0, ftruncate64(fileno(fptr), SIZE_1024)); 27 28 struct stat statbuff; 29 EXPECT_EQ(0, stat("test.txt", &statbuff)); 30 EXPECT_EQ(SIZE_1024, statbuff.st_size); 31 32 fclose(fptr); 33 remove("test.txt"); 34 }