• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 TempMkstemp64Test : public testing::Test {
SetUp()9     void SetUp() override {}
TearDown()10     void TearDown() override {}
11 };
12 
13 /**
14  * @tc.name: mkstemp64_001
15  * @tc.desc: Verify mkstemp process success. Provide the correct template and no fixed suffix, create a
16  *                 temporary file.
17  * @tc.type: FUNC
18  * */
19 HWTEST_F(TempMkstemp64Test, mkstemp64_001, TestSize.Level1)
20 {
21     char tmpFile[] = "/data/mkstemp64_XXXXXX";
22     int fd = mkstemp64(tmpFile);
23     EXPECT_NE(-1, fd);
24     if (fd != -1) {
25         int cnt = write(fd, tmpFile, strlen(tmpFile));
26         EXPECT_TRUE(cnt == strlen(tmpFile));
27         close(fd);
28         char rmFile[BUF_SIZE];
29         int len = sprintf(rmFile, "rm %s", tmpFile);
30         if (len > 0) {
31             system(rmFile);
32         }
33     }
34 }