Write file to tmp directory (#141668)

This makes the test more portable. In google, the test was failing
because a test cannot write to its own directory in a sandbox.
This commit is contained in:
Walter Lee
2025-05-27 21:15:34 -04:00
committed by GitHub
parent 90232cb833
commit e2f118df1d

View File

@@ -74,8 +74,11 @@ TEST(OffloadingBundleTest, checkExtractCodeObject) {
int64_t Offset = 8192;
int64_t Size = 4048;
Error Err = extractCodeObject(**ObjOrErr, Offset, Size,
StringRef("checkExtractCodeObject.co"));
llvm::unittest::TempDir Tmp("tmpdir", /*Unique=*/true);
SmallString<128> FileName(Tmp.path().begin(), Tmp.path().end());
sys::path::append(FileName, "checkExtractCodeObject.co");
Error Err = extractCodeObject(**ObjOrErr, Offset, Size, StringRef(FileName));
EXPECT_FALSE(errorToBool(std::move(Err)));
}