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);
// 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