Cleanup the interface for creating soft or hard links.
[oota-llvm.git] / unittests / Support / FileOutputBufferTest.cpp
index c7ca1ab6a612f2355f430f9a2cdecee939b89aa0..6d62999ab87e56fea48eb10192e7c8073c548343 100644 (file)
@@ -30,12 +30,8 @@ TEST(FileOutputBuffer, Test) {
   // Create unique temporary directory for these tests
   SmallString<128> TestDirectory;
   {
-    int fd;
     ASSERT_NO_ERROR(
-      fs::unique_file("FileOutputBuffer-test-%%-%%-%%-%%/dir", fd,
-                      TestDirectory));
-    ::close(fd);
-    TestDirectory = path::parent_path(TestDirectory);
+        fs::createUniqueDirectory("FileOutputBuffer-test", TestDirectory));
   }
 
   // TEST 1: Verify commit case.
@@ -60,6 +56,7 @@ TEST(FileOutputBuffer, Test) {
   uint64_t File1Size;
   ASSERT_NO_ERROR(fs::file_size(Twine(File1), File1Size));
   ASSERT_EQ(File1Size, 8192ULL);
+  ASSERT_NO_ERROR(fs::remove(File1.str()));
 
        // TEST 2: Verify abort case.
   SmallString<128> File2(TestDirectory);
@@ -71,10 +68,11 @@ TEST(FileOutputBuffer, Test) {
     memcpy(Buffer2->getBufferStart(), "AABBCCDDEEFFGGHHIIJJ", 20);
     // Do *not* commit buffer.
   }
-  // Verify file does not exist (because buffer not commited).
+  // Verify file does not exist (because buffer not committed).
   bool Exists = false;
   ASSERT_NO_ERROR(fs::exists(Twine(File2), Exists));
   EXPECT_FALSE(Exists);
+  ASSERT_NO_ERROR(fs::remove(File2.str()));
 
   // TEST 3: Verify sizing down case.
   SmallString<128> File3(TestDirectory);
@@ -98,6 +96,7 @@ TEST(FileOutputBuffer, Test) {
   uint64_t File3Size;
   ASSERT_NO_ERROR(fs::file_size(Twine(File3), File3Size));
   ASSERT_EQ(File3Size, 5000ULL);
+  ASSERT_NO_ERROR(fs::remove(File3.str()));
 
   // TEST 4: Verify file can be made executable.
   SmallString<128> File4(TestDirectory);
@@ -116,9 +115,9 @@ TEST(FileOutputBuffer, Test) {
   ASSERT_NO_ERROR(fs::status(Twine(File4), Status));
   bool IsExecutable = (Status.permissions() & fs::owner_exe);
   EXPECT_TRUE(IsExecutable);
+  ASSERT_NO_ERROR(fs::remove(File4.str()));
 
   // Clean up.
-  uint32_t RemovedCount;
-  ASSERT_NO_ERROR(fs::remove_all(TestDirectory.str(), RemovedCount));
+  ASSERT_NO_ERROR(fs::remove(TestDirectory.str()));
 }
 } // anonymous namespace