llvm.org GIT mirror llvm / bb05e42
Use createTemporaryFile in SampleProfTest Create a temporary file in the system temporary directory instead of creating a file in the current directory, which may be not writable. (Fix for an issue introduced in r342283.) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342386 91177308-0d34-0410-b5e6-96231b3b80d8 Alexander Kornienko 1 year, 1 month ago
1 changed file(s) with 5 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
4141
4242 SampleProfTest() : Writer(), Reader() {}
4343
44 void createWriter(SampleProfileFormat Format, const std::string &Profile) {
44 void createWriter(SampleProfileFormat Format, StringRef Profile) {
4545 std::error_code EC;
4646 std::unique_ptr OS(
4747 new raw_fd_ostream(Profile, EC, sys::fs::F_None));
5050 Writer = std::move(WriterOrErr.get());
5151 }
5252
53 void readProfile(const Module &M, const std::string &Profile) {
53 void readProfile(const Module &M, StringRef Profile) {
5454 auto ReaderOrErr = SampleProfileReader::create(Profile, Context);
5555 ASSERT_TRUE(NoError(ReaderOrErr.getError()));
5656 Reader = std::move(ReaderOrErr.get());
5858 }
5959
6060 void testRoundTrip(SampleProfileFormat Format) {
61 std::string Profile = std::string("profile.") + std::to_string(Format);
61 SmallVector ProfilePath;
62 ASSERT_TRUE(NoError(llvm::sys::fs::createTemporaryFile("profile", "", ProfilePath)));
63 StringRef Profile(ProfilePath.data(), ProfilePath.size());
6264 createWriter(Format, Profile);
6365
6466 StringRef FooName("_Z3fooi");