summaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2010-12-03 01:21:28 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2010-12-03 01:21:28 +0000
commit3cb84ef65dd417bc152fdaa173127966ca949318 (patch)
tree133d904ceb53dd1218f7c6857f0087c837960393 /unittests
parentf4e7b167a09df546b4b339ca9ebc445f747a724a (diff)
downloadllvm-3cb84ef65dd417bc152fdaa173127966ca949318.tar.gz
llvm-3cb84ef65dd417bc152fdaa173127966ca949318.tar.bz2
llvm-3cb84ef65dd417bc152fdaa173127966ca949318.tar.xz
Support/FileSystem: Add unique_file and exists implementations.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120776 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/Support/Path.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/unittests/Support/Path.cpp b/unittests/Support/Path.cpp
index a3d96ecf34..ecf818b5d4 100644
--- a/unittests/Support/Path.cpp
+++ b/unittests/Support/Path.cpp
@@ -7,11 +7,13 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/Support/FileSystem.h"
#include "llvm/Support/PathV2.h"
#include "gtest/gtest.h"
using namespace llvm;
+using namespace llvm::sys;
#define TEST_OUT(func, result) outs() << " " #func ": " << result << '\n';
@@ -131,6 +133,22 @@ TEST(Support, Path) {
outs().flush();
}
+
+ int FileDescriptor;
+ SmallString<64> TempPath;
+ if (error_code ec = sys::fs::unique_file("%%-%%-%%-%%.temp",
+ FileDescriptor, TempPath))
+ ASSERT_FALSE(ec.message().c_str());
+
+ bool TempFileExists;
+ ASSERT_FALSE(sys::fs::exists(Twine(TempPath), TempFileExists));
+ EXPECT_TRUE(TempFileExists);
+
+ ::close(FileDescriptor);
+ ::remove(TempPath.begin());
+
+ ASSERT_FALSE(fs::exists(Twine(TempPath), TempFileExists));
+ EXPECT_FALSE(TempFileExists);
}
} // anonymous namespace