From: Martin Storsjö Date: Thu, 7 Oct 2021 11:31:32 +0000 (+0000) Subject: [unittests] [DWARF] Generalize path separator expectations X-Git-Tag: upstream/15.0.7~26591 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f0955922a258aa6d59379b254df2d1b4ab9676af;p=platform%2Fupstream%2Fllvm.git [unittests] [DWARF] Generalize path separator expectations This fixes unit tests if running on Windows with a build configured to prefer forward slashes. Differential Revision: https://reviews.llvm.org/D113257 --- diff --git a/llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp b/llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp index d40bf64..82aaa45 100644 --- a/llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp +++ b/llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp @@ -183,11 +183,9 @@ TEST(DWARFDie, getDeclFile) { std::string DeclFile = MainDie.getDeclFile( DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath); -#if defined(_WIN32) - EXPECT_EQ(DeclFile, "/tmp\\main.cpp"); -#else - EXPECT_EQ(DeclFile, "/tmp/main.cpp"); -#endif + std::string Ref = + ("/tmp" + llvm::sys::path::get_separator() + "main.cpp").str(); + EXPECT_EQ(DeclFile, Ref); } TEST(DWARFDie, getDeclFileAbstractOrigin) { @@ -291,11 +289,9 @@ TEST(DWARFDie, getDeclFileAbstractOrigin) { std::string DeclFile = MainDie.getDeclFile( DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath); -#if defined(_WIN32) - EXPECT_EQ(DeclFile, "/tmp\\main.cpp"); -#else - EXPECT_EQ(DeclFile, "/tmp/main.cpp"); -#endif + std::string Ref = + ("/tmp" + llvm::sys::path::get_separator() + "main.cpp").str(); + EXPECT_EQ(DeclFile, Ref); } TEST(DWARFDie, getDeclFileSpecification) { @@ -398,11 +394,9 @@ TEST(DWARFDie, getDeclFileSpecification) { std::string DeclFile = MainDie.getDeclFile( DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath); -#if defined(_WIN32) - EXPECT_EQ(DeclFile, "/tmp\\main.cpp"); -#else - EXPECT_EQ(DeclFile, "/tmp/main.cpp"); -#endif + std::string Ref = + ("/tmp" + llvm::sys::path::get_separator() + "main.cpp").str(); + EXPECT_EQ(DeclFile, Ref); } TEST(DWARFDie, getDeclFileAbstractOriginAcrossCUBoundary) { @@ -522,11 +516,9 @@ TEST(DWARFDie, getDeclFileAbstractOriginAcrossCUBoundary) { std::string DeclFile = MainDie.getDeclFile( DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath); -#if defined(_WIN32) - EXPECT_EQ(DeclFile, "/tmp\\main.cpp"); -#else - EXPECT_EQ(DeclFile, "/tmp/main.cpp"); -#endif + std::string Ref = + ("/tmp" + llvm::sys::path::get_separator() + "main.cpp").str(); + EXPECT_EQ(DeclFile, Ref); } TEST(DWARFDie, getDeclFileSpecificationAcrossCUBoundary) { @@ -646,11 +638,9 @@ TEST(DWARFDie, getDeclFileSpecificationAcrossCUBoundary) { std::string DeclFile = MainDie.getDeclFile( DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath); -#if defined(_WIN32) - EXPECT_EQ(DeclFile, "/tmp\\main.cpp"); -#else - EXPECT_EQ(DeclFile, "/tmp/main.cpp"); -#endif + std::string Ref = + ("/tmp" + llvm::sys::path::get_separator() + "main.cpp").str(); + EXPECT_EQ(DeclFile, Ref); } } // end anonymous namespace