diff options
author | Rui Ueyama <ruiu@google.com> | 2016-09-02 17:19:28 +0000 |
---|---|---|
committer | Rui Ueyama <ruiu@google.com> | 2016-09-02 17:19:28 +0000 |
commit | 572c5eac13a8e6fb6459a272bba3417f1da5b9b0 (patch) | |
tree | 9b69ef2711ee62a9cd23baece8ebf86304fd9406 /lld/unittests | |
parent | 8fc236d8bf714a793b143b17a3a4432c5910bfea (diff) |
Fix potential test failures.
Windows does not allow opened files to be removed. This patch
fixes two types of errors.
- Output file being the same as input file. Because LLD itself
holds a file descriptor of the input file, it cannot create an
output file with the same name as a new file.
- Removing files before releasing MemoryBuffer objects.
These tests are not failing no because MemoryBuffer happens to
decide not to use mmap on these files. But we shouldn't rely on
that behavior.
Diffstat (limited to 'lld/unittests')
-rw-r--r-- | lld/unittests/MachOTests/MachONormalizedFileBinaryWriterTests.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lld/unittests/MachOTests/MachONormalizedFileBinaryWriterTests.cpp b/lld/unittests/MachOTests/MachONormalizedFileBinaryWriterTests.cpp index f44950a8d5a..51196e6eeba 100644 --- a/lld/unittests/MachOTests/MachONormalizedFileBinaryWriterTests.cpp +++ b/lld/unittests/MachOTests/MachONormalizedFileBinaryWriterTests.cpp @@ -219,6 +219,7 @@ TEST(BinaryWriterTest, obj_relocs_x86_64) { EXPECT_EQ(signed4.isExtern, true); EXPECT_EQ(signed4.symbol, 1U); + bufferOwner.reset(nullptr); std::error_code ec = llvm::sys::fs::remove(Twine(tmpFl)); EXPECT_FALSE(ec); } @@ -329,6 +330,7 @@ TEST(BinaryWriterTest, obj_relocs_x86) { EXPECT_EQ(tlv.symbol, 1U); //llvm::errs() << "temp = " << tmpFl << "\n"; + bufferOwner.reset(nullptr); std::error_code ec = llvm::sys::fs::remove(Twine(tmpFl)); EXPECT_FALSE(ec); } @@ -458,6 +460,7 @@ TEST(BinaryWriterTest, obj_relocs_armv7) { EXPECT_EQ(absPointer.symbol, 2U); //llvm::errs() << "temp = " << tmpFl << "\n"; + bufferOwner.reset(nullptr); std::error_code ec = llvm::sys::fs::remove(Twine(tmpFl)); EXPECT_FALSE(ec); } @@ -687,6 +690,7 @@ TEST(BinaryWriterTest, obj_relocs_ppc) { EXPECT_EQ(absloa2.length, 2); EXPECT_EQ(absloa2.symbol, 0U); + bufferOwner.reset(nullptr); std::error_code ec = llvm::sys::fs::remove(Twine(tmpFl)); EXPECT_FALSE(ec); } |