xref: /llvm-project/clang/unittests/Driver/DistroTest.cpp (revision 1abd4c94d7575e4cd288e0024c1ec79f17b048a9)
1 //===- unittests/Driver/DistroTest.cpp --- ToolChains tests ---------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Unit tests for Distro detection.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "clang/Driver/Distro.h"
14 #include "llvm/Support/VirtualFileSystem.h"
15 #include "llvm/Support/raw_ostream.h"
16 #include "gtest/gtest.h"
17 using namespace clang;
18 using namespace clang::driver;
19 
20 namespace {
21 
22 // The tests include all release-related files for each distribution
23 // in the VFS, in order to make sure that earlier tests do not
24 // accidentally result in incorrect distribution guess.
25 
26 TEST(DistroTest, DetectUbuntu) {
27   llvm::vfs::InMemoryFileSystem UbuntuTrustyFileSystem;
28   // Ubuntu uses Debian Sid version.
29   UbuntuTrustyFileSystem.addFile("/etc/debian_version", 0,
30       llvm::MemoryBuffer::getMemBuffer("jessie/sid\n"));
31   UbuntuTrustyFileSystem.addFile("/etc/lsb-release", 0,
32       llvm::MemoryBuffer::getMemBuffer("DISTRIB_ID=Ubuntu\n"
33                                        "DISTRIB_RELEASE=14.04\n"
34                                        "DISTRIB_CODENAME=trusty\n"
35                                        "DISTRIB_DESCRIPTION=\"Ubuntu 14.04 LTS\"\n"));
36   UbuntuTrustyFileSystem.addFile("/etc/os-release", 0,
37       llvm::MemoryBuffer::getMemBuffer("NAME=\"Ubuntu\"\n"
38                                        "VERSION=\"14.04, Trusty Tahr\"\n"
39                                        "ID=ubuntu\n"
40                                        "ID_LIKE=debian\n"
41                                        "PRETTY_NAME=\"Ubuntu 14.04 LTS\"\n"
42                                        "VERSION_ID=\"14.04\"\n"
43                                        "HOME_URL=\"http://www.ubuntu.com/\"\n"
44                                        "SUPPORT_URL=\"http://help.ubuntu.com/\"\n"
45                                        "BUG_REPORT_URL=\"http://bugs.launchpad.net/ubuntu/\"\n"));
46 
47   Distro UbuntuTrusty{UbuntuTrustyFileSystem, llvm::Triple("unknown-pc-linux")};
48   ASSERT_EQ(Distro(Distro::UbuntuTrusty), UbuntuTrusty);
49   ASSERT_TRUE(UbuntuTrusty.IsUbuntu());
50   ASSERT_FALSE(UbuntuTrusty.IsRedhat());
51   ASSERT_FALSE(UbuntuTrusty.IsOpenSUSE());
52   ASSERT_FALSE(UbuntuTrusty.IsDebian());
53   ASSERT_FALSE(UbuntuTrusty.IsGentoo());
54 
55   Distro UbuntuTrusty2{UbuntuTrustyFileSystem, llvm::Triple("unknown-pc-windows")};
56   ASSERT_EQ(Distro(Distro::UnknownDistro), UbuntuTrusty2);
57 
58   llvm::vfs::InMemoryFileSystem UbuntuYakketyFileSystem;
59   UbuntuYakketyFileSystem.addFile("/etc/debian_version", 0,
60       llvm::MemoryBuffer::getMemBuffer("stretch/sid\n"));
61   UbuntuYakketyFileSystem.addFile("/etc/lsb-release", 0,
62       llvm::MemoryBuffer::getMemBuffer("DISTRIB_ID=Ubuntu\n"
63                                        "DISTRIB_RELEASE=16.10\n"
64                                        "DISTRIB_CODENAME=yakkety\n"
65                                        "DISTRIB_DESCRIPTION=\"Ubuntu 16.10\"\n"));
66   UbuntuYakketyFileSystem.addFile("/etc/os-release", 0,
67       llvm::MemoryBuffer::getMemBuffer("NAME=\"Ubuntu\"\n"
68                                        "VERSION=\"16.10 (Yakkety Yak)\"\n"
69                                        "ID=ubuntu\n"
70                                        "ID_LIKE=debian\n"
71                                        "PRETTY_NAME=\"Ubuntu 16.10\"\n"
72                                        "VERSION_ID=\"16.10\"\n"
73                                        "HOME_URL=\"http://www.ubuntu.com/\"\n"
74                                        "SUPPORT_URL=\"http://help.ubuntu.com/\"\n"
75                                        "BUG_REPORT_URL=\"http://bugs.launchpad.net/ubuntu/\"\n"
76                                        "PRIVACY_POLICY_URL=\"http://www.ubuntu.com/legal/terms-and-policies/privacy-policy\"\n"
77                                        "VERSION_CODENAME=yakkety\n"
78                                        "UBUNTU_CODENAME=yakkety\n"));
79 
80   Distro UbuntuYakkety{UbuntuYakketyFileSystem, llvm::Triple("unknown-pc-linux")};
81   ASSERT_EQ(Distro(Distro::UbuntuYakkety), UbuntuYakkety);
82   ASSERT_TRUE(UbuntuYakkety.IsUbuntu());
83   ASSERT_FALSE(UbuntuYakkety.IsRedhat());
84   ASSERT_FALSE(UbuntuYakkety.IsOpenSUSE());
85   ASSERT_FALSE(UbuntuYakkety.IsDebian());
86   ASSERT_FALSE(UbuntuYakkety.IsGentoo());
87 }
88 
89 TEST(DistroTest, DetectRedhat) {
90   llvm::vfs::InMemoryFileSystem Fedora25FileSystem;
91   Fedora25FileSystem.addFile("/etc/system-release-cpe", 0,
92       llvm::MemoryBuffer::getMemBuffer("cpe:/o:fedoraproject:fedora:25\n"));
93   // Both files are symlinks to fedora-release.
94   Fedora25FileSystem.addFile("/etc/system-release", 0,
95       llvm::MemoryBuffer::getMemBuffer("Fedora release 25 (Twenty Five)\n"));
96   Fedora25FileSystem.addFile("/etc/redhat-release", 0,
97       llvm::MemoryBuffer::getMemBuffer("Fedora release 25 (Twenty Five)\n"));
98   Fedora25FileSystem.addFile("/etc/fedora-release", 0,
99       llvm::MemoryBuffer::getMemBuffer("Fedora release 25 (Twenty Five)\n"));
100   Fedora25FileSystem.addFile("/etc/os-release", 0,
101       llvm::MemoryBuffer::getMemBuffer("NAME=Fedora\n"
102                                        "VERSION=\"25 (Twenty Five)\"\n"
103                                        "ID=fedora\n"
104                                        "VERSION_ID=25\n"
105                                        "PRETTY_NAME=\"Fedora 25 (Twenty Five)\"\n"
106                                        "ANSI_COLOR=\"0;34\"\n"
107                                        "CPE_NAME=\"cpe:/o:fedoraproject:fedora:25\"\n"
108                                        "HOME_URL=\"https://fedoraproject.org/\"\n"
109                                        "BUG_REPORT_URL=\"https://bugzilla.redhat.com/\"\n"
110                                        "REDHAT_BUGZILLA_PRODUCT=\"Fedora\"\n"
111                                        "REDHAT_BUGZILLA_PRODUCT_VERSION=25\n"
112                                        "REDHAT_SUPPORT_PRODUCT=\"Fedora\"\n"
113                                        "REDHAT_SUPPORT_PRODUCT_VERSION=25\n"
114                                        "PRIVACY_POLICY_URL=https://fedoraproject.org/wiki/Legal:PrivacyPolicy\n"));
115   Distro Fedora25{Fedora25FileSystem, llvm::Triple("unknown-pc-linux")};
116   ASSERT_EQ(Distro(Distro::Fedora), Fedora25);
117   ASSERT_FALSE(Fedora25.IsUbuntu());
118   ASSERT_TRUE(Fedora25.IsRedhat());
119   ASSERT_FALSE(Fedora25.IsOpenSUSE());
120   ASSERT_FALSE(Fedora25.IsDebian());
121   ASSERT_FALSE(Fedora25.IsGentoo());
122 
123   llvm::vfs::InMemoryFileSystem CentOS7FileSystem;
124   CentOS7FileSystem.addFile("/etc/system-release-cpe", 0,
125       llvm::MemoryBuffer::getMemBuffer("cpe:/o:centos:centos:7\n"));
126   // Both files are symlinks to centos-release.
127   CentOS7FileSystem.addFile("/etc/system-release", 0,
128       llvm::MemoryBuffer::getMemBuffer("CentOS Linux release 7.2.1511 (Core) \n"));
129   CentOS7FileSystem.addFile("/etc/redhat-release", 0,
130       llvm::MemoryBuffer::getMemBuffer("CentOS Linux release 7.2.1511 (Core) \n"));
131   CentOS7FileSystem.addFile("/etc/centos-release", 0,
132       llvm::MemoryBuffer::getMemBuffer("CentOS Linux release 7.2.1511 (Core) \n"));
133   CentOS7FileSystem.addFile("/etc/centos-release-upstream", 0,
134       llvm::MemoryBuffer::getMemBuffer("Derived from Red Hat Enterprise Linux 7.2 (Source)\n"));
135   CentOS7FileSystem.addFile("/etc/os-release", 0,
136       llvm::MemoryBuffer::getMemBuffer("NAME=\"CentOS Linux\"\n"
137                                        "VERSION=\"7 (Core)\"\n"
138                                        "ID=\"centos\"\n"
139                                        "ID_LIKE=\"rhel fedora\"\n"
140                                        "VERSION_ID=\"7\"\n"
141                                        "PRETTY_NAME=\"CentOS Linux 7 (Core)\"\n"
142                                        "ANSI_COLOR=\"0;31\"\n"
143                                        "CPE_NAME=\"cpe:/o:centos:centos:7\"\n"
144                                        "HOME_URL=\"https://www.centos.org/\"\n"
145                                        "BUG_REPORT_URL=\"https://bugs.centos.org/\"\n"
146                                        "\n"
147                                        "CENTOS_MANTISBT_PROJECT=\"CentOS-7\"\n"
148                                        "CENTOS_MANTISBT_PROJECT_VERSION=\"7\"\n"
149                                        "REDHAT_SUPPORT_PRODUCT=\"centos\"\n"
150                                        "REDHAT_SUPPORT_PRODUCT_VERSION=\"7\"\n"));
151 
152   Distro CentOS7{CentOS7FileSystem, llvm::Triple("unknown-pc-linux")};
153   ASSERT_EQ(Distro(Distro::RHEL7), CentOS7);
154   ASSERT_FALSE(CentOS7.IsUbuntu());
155   ASSERT_TRUE(CentOS7.IsRedhat());
156   ASSERT_FALSE(CentOS7.IsOpenSUSE());
157   ASSERT_FALSE(CentOS7.IsDebian());
158   ASSERT_FALSE(CentOS7.IsGentoo());
159 }
160 
161 TEST(DistroTest, DetectOpenSUSE) {
162   llvm::vfs::InMemoryFileSystem OpenSUSELeap421FileSystem;
163   OpenSUSELeap421FileSystem.addFile("/etc/SuSE-release", 0,
164       llvm::MemoryBuffer::getMemBuffer("openSUSE 42.1 (x86_64)\n"
165                                        "VERSION = 42.1\n"
166                                        "CODENAME = Malachite\n"
167                                        "# /etc/SuSE-release is deprecated and will be removed in the future, use /etc/os-release instead\n"));
168   OpenSUSELeap421FileSystem.addFile("/etc/os-release", 0,
169       llvm::MemoryBuffer::getMemBuffer("NAME=\"openSUSE Leap\"\n"
170                                        "VERSION=\"42.1\"\n"
171                                        "VERSION_ID=\"42.1\"\n"
172                                        "PRETTY_NAME=\"openSUSE Leap 42.1 (x86_64)\"\n"
173                                        "ID=opensuse\n"
174                                        "ANSI_COLOR=\"0;32\"\n"
175                                        "CPE_NAME=\"cpe:/o:opensuse:opensuse:42.1\"\n"
176                                        "BUG_REPORT_URL=\"https://bugs.opensuse.org\"\n"
177                                        "HOME_URL=\"https://opensuse.org/\"\n"
178                                        "ID_LIKE=\"suse\"\n"));
179 
180   Distro OpenSUSELeap421{OpenSUSELeap421FileSystem, llvm::Triple("unknown-pc-linux")};
181   ASSERT_EQ(Distro(Distro::OpenSUSE), OpenSUSELeap421);
182   ASSERT_FALSE(OpenSUSELeap421.IsUbuntu());
183   ASSERT_FALSE(OpenSUSELeap421.IsRedhat());
184   ASSERT_TRUE(OpenSUSELeap421.IsOpenSUSE());
185   ASSERT_FALSE(OpenSUSELeap421.IsDebian());
186   ASSERT_FALSE(OpenSUSELeap421.IsGentoo());
187 
188   llvm::vfs::InMemoryFileSystem OpenSUSE132FileSystem;
189   OpenSUSE132FileSystem.addFile("/etc/SuSE-release", 0,
190       llvm::MemoryBuffer::getMemBuffer("openSUSE 13.2 (x86_64)\n"
191                                        "VERSION = 13.2\n"
192                                        "CODENAME = Harlequin\n"
193                                        "# /etc/SuSE-release is deprecated and will be removed in the future, use /etc/os-release instead\n"));
194   OpenSUSE132FileSystem.addFile("/etc/os-release", 0,
195       llvm::MemoryBuffer::getMemBuffer("NAME=openSUSE\n"
196                                        "VERSION=\"13.2 (Harlequin)\"\n"
197                                        "VERSION_ID=\"13.2\"\n"
198                                        "PRETTY_NAME=\"openSUSE 13.2 (Harlequin) (x86_64)\"\n"
199                                        "ID=opensuse\n"
200                                        "ANSI_COLOR=\"0;32\"\n"
201                                        "CPE_NAME=\"cpe:/o:opensuse:opensuse:13.2\"\n"
202                                        "BUG_REPORT_URL=\"https://bugs.opensuse.org\"\n"
203                                        "HOME_URL=\"https://opensuse.org/\"\n"
204                                        "ID_LIKE=\"suse\"\n"));
205 
206   Distro OpenSUSE132{OpenSUSE132FileSystem, llvm::Triple("unknown-pc-linux")};
207   ASSERT_EQ(Distro(Distro::OpenSUSE), OpenSUSE132);
208   ASSERT_FALSE(OpenSUSE132.IsUbuntu());
209   ASSERT_FALSE(OpenSUSE132.IsRedhat());
210   ASSERT_TRUE(OpenSUSE132.IsOpenSUSE());
211   ASSERT_FALSE(OpenSUSE132.IsDebian());
212   ASSERT_FALSE(OpenSUSE132.IsGentoo());
213 
214   llvm::vfs::InMemoryFileSystem SLES10FileSystem;
215   SLES10FileSystem.addFile("/etc/SuSE-release", 0,
216       llvm::MemoryBuffer::getMemBuffer("SUSE Linux Enterprise Server 10 (x86_64)\n"
217                                        "VERSION = 10\n"
218                                        "PATCHLEVEL = 4\n"));
219   SLES10FileSystem.addFile("/etc/lsb_release", 0,
220       llvm::MemoryBuffer::getMemBuffer("LSB_VERSION=\"core-2.0-noarch:core-3.0-noarch:core-2.0-x86_64:core-3.0-x86_64\"\n"));
221 
222   // SLES10 is unsupported and therefore evaluates to unknown
223   Distro SLES10{SLES10FileSystem, llvm::Triple("unknown-pc-linux")};
224   ASSERT_EQ(Distro(Distro::UnknownDistro), SLES10);
225   ASSERT_FALSE(SLES10.IsUbuntu());
226   ASSERT_FALSE(SLES10.IsRedhat());
227   ASSERT_FALSE(SLES10.IsOpenSUSE());
228   ASSERT_FALSE(SLES10.IsDebian());
229   ASSERT_FALSE(SLES10.IsGentoo());
230 }
231 
232 TEST(DistroTest, DetectDebian) {
233   llvm::vfs::InMemoryFileSystem DebianJessieFileSystem;
234   DebianJessieFileSystem.addFile("/etc/debian_version", 0,
235                                  llvm::MemoryBuffer::getMemBuffer("8.6\n"));
236   DebianJessieFileSystem.addFile("/etc/os-release", 0,
237       llvm::MemoryBuffer::getMemBuffer("PRETTY_NAME=\"Debian GNU/Linux 8 (jessie)\"\n"
238                                        "NAME=\"Debian GNU/Linux\"\n"
239                                        "VERSION_ID=\"8\"\n"
240                                        "VERSION=\"8 (jessie)\"\n"
241                                        "ID=debian\n"
242                                        "HOME_URL=\"http://www.debian.org/\"\n"
243                                        "SUPPORT_URL=\"http://www.debian.org/support\"\n"
244                                        "BUG_REPORT_URL=\"https://bugs.debian.org/\"\n"));
245 
246   Distro DebianJessie{DebianJessieFileSystem, llvm::Triple("unknown-pc-linux")};
247   ASSERT_EQ(Distro(Distro::DebianJessie), DebianJessie);
248   ASSERT_FALSE(DebianJessie.IsUbuntu());
249   ASSERT_FALSE(DebianJessie.IsRedhat());
250   ASSERT_FALSE(DebianJessie.IsOpenSUSE());
251   ASSERT_TRUE(DebianJessie.IsDebian());
252   ASSERT_FALSE(DebianJessie.IsGentoo());
253 
254   llvm::vfs::InMemoryFileSystem DebianStretchSidFileSystem;
255   DebianStretchSidFileSystem.addFile("/etc/debian_version", 0,
256                                  llvm::MemoryBuffer::getMemBuffer("stretch/sid\n"));
257   DebianStretchSidFileSystem.addFile("/etc/os-release", 0,
258       llvm::MemoryBuffer::getMemBuffer("PRETTY_NAME=\"Debian GNU/Linux stretch/sid\"\n"
259                                        "NAME=\"Debian GNU/Linux\"\n"
260                                        "ID=debian\n"
261                                        "HOME_URL=\"http://www.debian.org/\"\n"
262                                        "SUPPORT_URL=\"http://www.debian.org/support\"\n"
263                                        "BUG_REPORT_URL=\"https://bugs.debian.org/\"\n"));
264 
265   Distro DebianStretchSid{DebianStretchSidFileSystem, llvm::Triple("unknown-pc-linux")};
266   ASSERT_EQ(Distro(Distro::DebianStretch), DebianStretchSid);
267   ASSERT_FALSE(DebianStretchSid.IsUbuntu());
268   ASSERT_FALSE(DebianStretchSid.IsRedhat());
269   ASSERT_FALSE(DebianStretchSid.IsOpenSUSE());
270   ASSERT_TRUE(DebianStretchSid.IsDebian());
271   ASSERT_FALSE(DebianStretchSid.IsGentoo());
272 }
273 
274 TEST(DistroTest, DetectExherbo) {
275   llvm::vfs::InMemoryFileSystem ExherboFileSystem;
276   ExherboFileSystem.addFile("/etc/exherbo-release", 0, // (ASCII art)
277                                  llvm::MemoryBuffer::getMemBuffer(""));
278   ExherboFileSystem.addFile("/etc/os-release", 0,
279       llvm::MemoryBuffer::getMemBuffer("NAME=\"Exherbo\"\n"
280                                        "PRETTY_NAME=\"Exherbo Linux\"\n"
281                                        "ID=\"exherbo\"\n"
282                                        "ANSI_COLOR=\"0;32\"\n"
283                                        "HOME_URL=\"https://www.exherbo.org/\"\n"
284                                        "SUPPORT_URL=\"irc://irc.freenode.net/#exherbo\"\n"
285                                        "BUG_REPORT_URL=\"https://bugs.exherbo.org/\"\n"));
286 
287   Distro Exherbo{ExherboFileSystem, llvm::Triple("unknown-pc-linux")};
288   ASSERT_EQ(Distro(Distro::Exherbo), Exherbo);
289   ASSERT_FALSE(Exherbo.IsUbuntu());
290   ASSERT_FALSE(Exherbo.IsRedhat());
291   ASSERT_FALSE(Exherbo.IsOpenSUSE());
292   ASSERT_FALSE(Exherbo.IsDebian());
293   ASSERT_FALSE(Exherbo.IsGentoo());
294 }
295 
296 TEST(DistroTest, DetectArchLinux) {
297   llvm::vfs::InMemoryFileSystem ArchLinuxFileSystem;
298   ArchLinuxFileSystem.addFile("/etc/arch-release", 0, // (empty)
299                                  llvm::MemoryBuffer::getMemBuffer(""));
300   ArchLinuxFileSystem.addFile("/etc/os-release", 0,
301       llvm::MemoryBuffer::getMemBuffer("NAME=\"Arch Linux\"\n"
302                                        "ID=arch\n"
303                                        "PRETTY_NAME=\"Arch Linux\"\n"
304                                        "ANSI_COLOR=\"0;36\"\n"
305                                        "HOME_URL=\"https://www.archlinux.org/\"\n"
306                                        "SUPPORT_URL=\"https://bbs.archlinux.org/\"\n"
307                                        "BUG_REPORT_URL=\"https://bugs.archlinux.org/\"\n"));
308 
309   Distro ArchLinux{ArchLinuxFileSystem, llvm::Triple("unknown-pc-linux")};
310   ASSERT_EQ(Distro(Distro::ArchLinux), ArchLinux);
311   ASSERT_FALSE(ArchLinux.IsUbuntu());
312   ASSERT_FALSE(ArchLinux.IsRedhat());
313   ASSERT_FALSE(ArchLinux.IsOpenSUSE());
314   ASSERT_FALSE(ArchLinux.IsDebian());
315   ASSERT_FALSE(ArchLinux.IsGentoo());
316 }
317 
318 TEST(DistroTest, DetectGentoo) {
319   llvm::vfs::InMemoryFileSystem GentooFileSystem;
320   GentooFileSystem.addFile(
321       "/etc/gentoo-release", 0,
322       llvm::MemoryBuffer::getMemBuffer("Gentoo Base System release 2.6"));
323   GentooFileSystem.addFile(
324       "/etc/os-release", 0,
325       llvm::MemoryBuffer::getMemBuffer(
326           "NAME=Gentoo\n"
327           "ID=gentoo\n"
328           "PRETTY_NAME=\"Gentoo/Linux\"\n"
329           "ANSI_COLOR=\"1;32\"\n"
330           "HOME_URL=\"https://www.gentoo.org/\"\n"
331           "SUPPORT_URL=\"https://www.gentoo.org/support/\"\n"
332           "BUG_REPORT_URL=\"https://bugs.gentoo.org/\"\n"));
333 
334   Distro Gentoo{GentooFileSystem, llvm::Triple("unknown-pc-linux")};
335   ASSERT_EQ(Distro(Distro::Gentoo), Gentoo);
336   ASSERT_FALSE(Gentoo.IsUbuntu());
337   ASSERT_FALSE(Gentoo.IsRedhat());
338   ASSERT_FALSE(Gentoo.IsOpenSUSE());
339   ASSERT_FALSE(Gentoo.IsDebian());
340   ASSERT_TRUE(Gentoo.IsGentoo());
341 }
342 
343 TEST(DistroTest, DetectWindowsAndCrossCompile) {
344 
345   class CountingFileSystem : public llvm::vfs::ProxyFileSystem {
346   public:
347     CountingFileSystem() : ProxyFileSystem(llvm::vfs::getRealFileSystem()) {}
348 
349     llvm::ErrorOr<llvm::vfs::Status> status(const llvm::Twine &Path) override {
350       ++Count;
351       return llvm::vfs::ProxyFileSystem::status(Path);
352     }
353 
354     llvm::ErrorOr<std::unique_ptr<llvm::vfs::File>>
355     openFileForRead(const llvm::Twine &Path) override {
356       ++Count;
357       return llvm::vfs::ProxyFileSystem::openFileForRead(Path);
358     }
359 
360     unsigned Count{};
361   };
362 
363   llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> RFS =
364       llvm::vfs::getRealFileSystem();
365   llvm::Triple Host(llvm::sys::getProcessTriple());
366 
367   CountingFileSystem CFileSystem;
368   Distro LinuxDistro{CFileSystem, llvm::Triple("unknown-pc-linux")};
369   if (Host.isOSWindows()) {
370     ASSERT_EQ(Distro(Distro::UnknownDistro), LinuxDistro);
371     ASSERT_GT(CFileSystem.Count, 0U);
372   }
373 
374   Distro WinDistro{CFileSystem, llvm::Triple("unknown-pc-windows")};
375   ASSERT_EQ(Distro(Distro::UnknownDistro), WinDistro);
376   ASSERT_GT(CFileSystem.Count, 0U);
377 
378   // When running on Windows along with a real file system, ensure that no
379   // distro is returned if targeting Linux
380   if (Host.isOSWindows()) {
381     Distro LinuxRealDistro{*RFS, llvm::Triple("unknown-pc-linux")};
382     ASSERT_EQ(Distro(Distro::UnknownDistro), LinuxRealDistro);
383   }
384   // When running on Linux, check if the distro is the same as the host when
385   // targeting Linux
386   if (Host.isOSLinux()) {
387     Distro HostDistro{*RFS, Host};
388     Distro LinuxRealDistro{*RFS, llvm::Triple("unknown-pc-linux")};
389     ASSERT_EQ(HostDistro, LinuxRealDistro);
390   }
391 
392   Distro WinRealDistro{*RFS, llvm::Triple("unknown-pc-windows")};
393   ASSERT_EQ(Distro(Distro::UnknownDistro), WinRealDistro);
394 }
395 
396 } // end anonymous namespace
397