forked from OSchip/llvm-project
[RGT] DistroTest: Separate environment-specific test functions
This allows using GTEST_SKIP() to identify un-executed tests. Found by the Rotten Green Tests project.
This commit is contained in:
parent
6fc11d4d3e
commit
e22e2774d9
|
@ -360,16 +360,17 @@ TEST(DistroTest, DetectWindowsAndCrossCompile) {
|
|||
unsigned Count{};
|
||||
};
|
||||
|
||||
llvm::Triple Host(llvm::sys::getProcessTriple());
|
||||
if (!Host.isOSWindows())
|
||||
GTEST_SKIP();
|
||||
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> RFS =
|
||||
llvm::vfs::getRealFileSystem();
|
||||
llvm::Triple Host(llvm::sys::getProcessTriple());
|
||||
|
||||
CountingFileSystem CFileSystem;
|
||||
Distro LinuxDistro{CFileSystem, llvm::Triple("unknown-pc-linux")};
|
||||
if (Host.isOSWindows()) {
|
||||
ASSERT_EQ(Distro(Distro::UnknownDistro), LinuxDistro);
|
||||
ASSERT_GT(CFileSystem.Count, 0U);
|
||||
}
|
||||
ASSERT_EQ(Distro(Distro::UnknownDistro), LinuxDistro);
|
||||
ASSERT_GT(CFileSystem.Count, 0U);
|
||||
|
||||
Distro WinDistro{CFileSystem, llvm::Triple("unknown-pc-windows")};
|
||||
ASSERT_EQ(Distro(Distro::UnknownDistro), WinDistro);
|
||||
|
@ -377,20 +378,25 @@ TEST(DistroTest, DetectWindowsAndCrossCompile) {
|
|||
|
||||
// When running on Windows along with a real file system, ensure that no
|
||||
// distro is returned if targeting Linux
|
||||
if (Host.isOSWindows()) {
|
||||
Distro LinuxRealDistro{*RFS, llvm::Triple("unknown-pc-linux")};
|
||||
ASSERT_EQ(Distro(Distro::UnknownDistro), LinuxRealDistro);
|
||||
}
|
||||
// When running on Linux, check if the distro is the same as the host when
|
||||
// targeting Linux
|
||||
if (Host.isOSLinux()) {
|
||||
Distro HostDistro{*RFS, Host};
|
||||
Distro LinuxRealDistro{*RFS, llvm::Triple("unknown-pc-linux")};
|
||||
ASSERT_EQ(HostDistro, LinuxRealDistro);
|
||||
}
|
||||
Distro LinuxRealDistro{*RFS, llvm::Triple("unknown-pc-linux")};
|
||||
ASSERT_EQ(Distro(Distro::UnknownDistro), LinuxRealDistro);
|
||||
|
||||
Distro WinRealDistro{*RFS, llvm::Triple("unknown-pc-windows")};
|
||||
ASSERT_EQ(Distro(Distro::UnknownDistro), WinRealDistro);
|
||||
}
|
||||
|
||||
TEST(DistroTest, DetectLinux) {
|
||||
llvm::Triple Host(llvm::sys::getProcessTriple());
|
||||
if (!Host.isOSLinux())
|
||||
GTEST_SKIP();
|
||||
|
||||
// When running on Linux, check if the distro is the same as the host when
|
||||
// targeting Linux
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> RFS =
|
||||
llvm::vfs::getRealFileSystem();
|
||||
Distro HostDistro{*RFS, Host};
|
||||
Distro LinuxRealDistro{*RFS, llvm::Triple("unknown-pc-linux")};
|
||||
ASSERT_EQ(HostDistro, LinuxRealDistro);
|
||||
}
|
||||
|
||||
} // end anonymous namespace
|
||||
|
|
Loading…
Reference in New Issue