[llvm] r360259 - [Support] Fix unit test for fs::is_local

Petar Jovanovic via llvm-commits llvm-commits at lists.llvm.org
Wed May 8 07:42:14 PDT 2019


Author: petarj
Date: Wed May  8 07:42:13 2019
New Revision: 360259

URL: http://llvm.org/viewvc/llvm-project?rev=360259&view=rev
Log:
[Support] Fix unit test for fs::is_local

Close the temporary file after the test is done using it.
If it is not closed and the file was created on NFS, it will cause the test
to fail. The problem happens in the cleanup process afterwards. It first
tries to delete the file but it is not really deleted. Afterwards, the
program fails to delete the directory containing the file, causing the whole
test to fail.

Patch by Milos Stojanovic.

Modified:
    llvm/trunk/unittests/Support/Path.cpp

Modified: llvm/trunk/unittests/Support/Path.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/Path.cpp?rev=360259&r1=360258&r2=360259&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/Path.cpp (original)
+++ llvm/trunk/unittests/Support/Path.cpp Wed May  8 07:42:13 2019
@@ -1517,6 +1517,7 @@ TEST_F(FileSystemTest, is_local) {
   bool TempFileIsLocal;
   ASSERT_NO_ERROR(fs::is_local(FD, TempFileIsLocal));
   EXPECT_EQ(TempFileIsLocal, fs::is_local(FD));
+  ::close(FD);
 
   // Expect that the file and its parent directory are equally local or equally
   // remote.




More information about the llvm-commits mailing list