OSDN Git Service

[llvm-exegesis] Create test files in temporary directory.
authorClement Courbet <courbet@google.com>
Fri, 13 Apr 2018 13:37:07 +0000 (13:37 +0000)
committerClement Courbet <courbet@google.com>
Fri, 13 Apr 2018 13:37:07 +0000 (13:37 +0000)
Currently the test fails in sandboxed environnements.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330015 91177308-0d34-0410-b5e6-96231b3b80d8

unittests/tools/llvm-exegesis/BenchmarkResultTest.cpp

index 5b3277d..d1239a4 100644 (file)
@@ -10,6 +10,7 @@
 #include "BenchmarkResult.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/YAMLTraits.h"
 #include "llvm/Support/raw_ostream.h"
 #include "gmock/gmock.h"
@@ -34,7 +35,11 @@ TEST(BenchmarkResultTest, WriteToAndReadFromDisk) {
   ToDisk.Measurements.push_back(BenchmarkMeasure{"b", 2, ""});
   ToDisk.Error = "error";
 
-  const llvm::StringRef Filename("data.yaml");
+  llvm::SmallString<64> Filename;
+  std::error_code EC;
+  EC = llvm::sys::fs::createUniqueDirectory("BenchmarkResultTestDir", Filename);
+  ASSERT_FALSE(EC);
+  llvm::sys::path::append(Filename, "data.yaml");
 
   ToDisk.writeYamlOrDie(Filename);