summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/Support/LockFileManagerTest.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-03-25 13:19:03 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-03-25 13:19:03 +0000
commit663ac28603a52bf533be08a828d895f323d046f9 (patch)
treeeb0200a5d323c291516a7f9db475a16d20acc3bf /llvm/unittests/Support/LockFileManagerTest.cpp
parent8c3e9b2515acd326de63b418624b51fd2d278eb0 (diff)
downloadbcm5719-llvm-663ac28603a52bf533be08a828d895f323d046f9.tar.gz
bcm5719-llvm-663ac28603a52bf533be08a828d895f323d046f9.zip
Fix these tests on windows.
It is impossible to create a hard link to a non existing file, so create a dummy file, create the link an delete the dummy file. On windows one cannot remove the current directory, so chdir first. llvm-svn: 204719
Diffstat (limited to 'llvm/unittests/Support/LockFileManagerTest.cpp')
-rw-r--r--llvm/unittests/Support/LockFileManagerTest.cpp25
1 files changed, 10 insertions, 15 deletions
diff --git a/llvm/unittests/Support/LockFileManagerTest.cpp b/llvm/unittests/Support/LockFileManagerTest.cpp
index b80cdf9b66f..93fa10bee07 100644
--- a/llvm/unittests/Support/LockFileManagerTest.cpp
+++ b/llvm/unittests/Support/LockFileManagerTest.cpp
@@ -59,14 +59,18 @@ TEST(LockFileManagerTest, LinkLockExists) {
SmallString<64> TmpFileLock(TmpDir);
sys::path::append(TmpFileLock, "file.lock-000");
+ int FD;
+ EC = sys::fs::openFileForWrite(StringRef(TmpFileLock), FD, sys::fs::F_None);
+ ASSERT_FALSE(EC);
+
+ int Ret = close(FD);
+ ASSERT_EQ(Ret, 0);
+
EC = sys::fs::create_link(TmpFileLock.str(), FileLocK.str());
-#if defined(_WIN32)
- // Win32 cannot create link with nonexistent file, since create_link is
- // implemented as hard link.
- ASSERT_EQ(EC, errc::no_such_file_or_directory);
-#else
ASSERT_FALSE(EC);
-#endif
+
+ EC = sys::fs::remove(StringRef(TmpFileLock));
+ ASSERT_FALSE(EC);
{
// The lock file doesn't point to a real file, so we should successfully
@@ -113,20 +117,11 @@ TEST(LockFileManagerTest, RelativePath) {
EC = sys::fs::remove("inner");
ASSERT_FALSE(EC);
- EC = sys::fs::remove(StringRef(TmpDir));
-#if defined(_WIN32)
- // Win32 cannot remove working directory.
- ASSERT_EQ(EC, errc::permission_denied);
-#else
- ASSERT_FALSE(EC);
-#endif
chdir(OrigPath);
-#if defined(_WIN32)
EC = sys::fs::remove(StringRef(TmpDir));
ASSERT_FALSE(EC);
-#endif
}
} // end anonymous namespace
OpenPOWER on IntegriCloud