summaryrefslogtreecommitdiff
path: root/lld/unittests
diff options
context:
space:
mode:
authorMartin Storsjo <martin@martin.st>2018-05-11 18:19:02 +0000
committerMartin Storsjo <martin@martin.st>2018-05-11 18:19:02 +0000
commita33140b02235be7dd0b05a3a3597fde9d1cd83c3 (patch)
treec414ad019b67ba6448493b55e47f1daaa82da9f4 /lld/unittests
parenta2681a92af46b172a605a5326c8f6581549d3abf (diff)
[MachO] Don't write test files to /tmp, remove them afterwards.
This matches what is done in MachONormalizedFileBinaryWriterTests.cpp already. Differential Revision: https://reviews.llvm.org/D46743
Diffstat (limited to 'lld/unittests')
-rw-r--r--lld/unittests/MachOTests/MachONormalizedFileBinaryReaderTests.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/lld/unittests/MachOTests/MachONormalizedFileBinaryReaderTests.cpp b/lld/unittests/MachOTests/MachONormalizedFileBinaryReaderTests.cpp
index 3e8793a0ef4..336bbdba626 100644
--- a/lld/unittests/MachOTests/MachONormalizedFileBinaryReaderTests.cpp
+++ b/lld/unittests/MachOTests/MachONormalizedFileBinaryReaderTests.cpp
@@ -12,14 +12,17 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/BinaryFormat/MachO.h"
#include "llvm/Support/Error.h"
+#include "llvm/Support/FileSystem.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/YAMLTraits.h"
#include "gtest/gtest.h"
#include <cstdint>
#include <memory>
+using llvm::SmallString;
using llvm::StringRef;
using llvm::MemoryBuffer;
+using llvm::Twine;
using namespace lld::mach_o::normalized;
using namespace llvm::MachO;
@@ -741,9 +744,11 @@ TEST(BinaryReaderTest, hello_obj_ppc) {
EXPECT_EQ(printfLabel.type, N_UNDF);
EXPECT_EQ(printfLabel.scope, SymbolScope(N_EXT));
- auto ec = writeBinary(*f, "/tmp/foo.o");
- // FIXME: We want to do EXPECT_FALSE(ec) but that fails on some Windows bots,
- // probably due to /tmp not being available.
- // For now just consume the error without checking it.
- consumeError(std::move(ec));
+ SmallString<128> tmpFl;
+ std::error_code ec =
+ llvm::sys::fs::createTemporaryFile(Twine("xx"), "o", tmpFl);
+ EXPECT_FALSE(ec);
+ llvm::Error ec2 = writeBinary(*f, tmpFl);
+ EXPECT_FALSE(ec2);
+ llvm::sys::fs::remove(tmpFl);
}