1 #include <fcntl.h> 2 #include <gtest/gtest.h> 3 4 using namespace testing::ext; 5 6 constexpr int BUF_SIZE = 128; 7 8 class TempMkostemps64Test : public testing::Test { SetUp()9 void SetUp() override {} TearDown()10 void TearDown() override {} 11 }; 12 13 /** 14 * @tc.name: mkstemps64_001 15 * @tc.desc: Provide the correct template, create a temporary file. 16 * @tc.type: FUNC 17 * */ 18 HWTEST_F(TempMkostemps64Test, mkstemps64_001, TestSize.Level1) 19 { 20 char tmpFile[] = "/data/mkstemps64_XXXXXX.dat"; 21 int fd = mkstemps64(tmpFile, strlen(".dat")); 22 EXPECT_NE(-1, fd); 23 if (fd != -1) { 24 int cnt = write(fd, tmpFile, strlen(tmpFile)); 25 EXPECT_TRUE(cnt == strlen(tmpFile)); 26 close(fd); 27 char rmFile[BUF_SIZE]; 28 int len = sprintf(rmFile, "rm %s", tmpFile); 29 if (len > 0) { 30 system(rmFile); 31 } 32 } 33 }