@@ -47,13 +47,18 @@ class HostTest : public testing::Test {
47
47
HostTest () : Host(Triple::normalize(sys::getProcessTriple())) {}
48
48
};
49
49
50
- TEST_F (HostTest, NumPhysicalCores) {
50
+ TEST_F (HostTest, NumPhysicalCoresSupported) {
51
+ if (!isSupportedArchAndOS ())
52
+ GTEST_SKIP ();
51
53
int Num = sys::getHostNumPhysicalCores ();
54
+ ASSERT_GT (Num, 0 );
55
+ }
52
56
57
+ TEST_F (HostTest, NumPhysicalCoresUnsupported) {
53
58
if (isSupportedArchAndOS ())
54
- ASSERT_GT (Num, 0 );
55
- else
56
- ASSERT_EQ (Num, -1 );
59
+ GTEST_SKIP ( );
60
+ int Num = sys::getHostNumPhysicalCores ();
61
+ ASSERT_EQ (Num, -1 );
57
62
}
58
63
59
64
TEST (getLinuxHostCPUName, ARM) {
@@ -412,7 +417,7 @@ TEST_F(HostTest, DummyRunAndGetCommandOutputUse) {
412
417
TEST_F (HostTest, getMacOSHostVersion) {
413
418
llvm::Triple HostTriple (llvm::sys::getProcessTriple ());
414
419
if (!HostTriple.isMacOSX ())
415
- return ;
420
+ GTEST_SKIP () ;
416
421
417
422
const char *SwVersPath = " /usr/bin/sw_vers" ;
418
423
StringRef argv[] = {SwVersPath, " -productVersion" };
@@ -441,43 +446,59 @@ TEST_F(HostTest, getMacOSHostVersion) {
441
446
}
442
447
}
443
448
444
- TEST_F (HostTest, AIXVersionDetect) {
445
- llvm::Triple HostTriple (llvm::sys::getProcessTriple ());
446
- if (HostTriple.getOS () != Triple::AIX)
447
- return ;
448
-
449
- llvm::Triple ConfiguredHostTriple (LLVM_HOST_TRIPLE);
450
- ASSERT_EQ (ConfiguredHostTriple.getOS (), Triple::AIX);
451
-
449
+ // Helper to return AIX system version. Must return void to use ASSERT_*.
450
+ static void getAIXSystemVersion (VersionTuple &SystemVersion) {
452
451
const char *ExePath = " /usr/bin/oslevel" ;
453
452
StringRef argv[] = {ExePath};
454
453
std::unique_ptr<char []> Buffer;
455
454
off_t Size;
456
455
ASSERT_EQ (runAndGetCommandOutput (ExePath, argv, Buffer, Size), true );
457
456
StringRef SystemVersionStr = StringRef (Buffer.get (), Size).rtrim ();
458
457
459
- VersionTuple SystemVersion =
458
+ SystemVersion =
460
459
llvm::Triple ((Twine (" powerpc-ibm-aix" ) + SystemVersionStr))
461
460
.getOSVersion ();
461
+ }
462
+
463
+ TEST_F (HostTest, AIXHostVersionDetect) {
464
+ llvm::Triple HostTriple (llvm::sys::getProcessTriple ());
465
+ if (HostTriple.getOS () != Triple::AIX)
466
+ GTEST_SKIP ();
467
+
468
+ llvm::Triple ConfiguredHostTriple (LLVM_HOST_TRIPLE);
469
+ ASSERT_EQ (ConfiguredHostTriple.getOS (), Triple::AIX);
470
+
471
+ VersionTuple SystemVersion;
472
+ getAIXSystemVersion (SystemVersion);
462
473
463
474
// Ensure that the host triple version (major) and release (minor) numbers,
464
475
// unless explicitly configured, match with those of the current system.
465
- if (!ConfiguredHostTriple.getOSMajorVersion ()) {
466
- VersionTuple HostVersion = HostTriple.getOSVersion ();
467
- ASSERT_EQ (SystemVersion.getMajor (), HostVersion.getMajor ());
468
- ASSERT_EQ (SystemVersion.getMinor (), HostVersion.getMinor ());
476
+ auto SysMajor = SystemVersion.getMajor ();
477
+ auto SysMinor = SystemVersion.getMinor ();
478
+ VersionTuple HostVersion = HostTriple.getOSVersion ();
479
+ if (ConfiguredHostTriple.getOSMajorVersion ()) {
480
+ // Explicitly configured, force a match. We do it this way so the
481
+ // asserts are always executed.
482
+ SysMajor = HostVersion.getMajor ();
483
+ SysMinor = HostVersion.getMinor ();
469
484
}
485
+ ASSERT_EQ (SysMajor, HostVersion.getMajor ());
486
+ ASSERT_EQ (SysMinor, HostVersion.getMinor ());
487
+ }
470
488
489
+ TEST_F (HostTest, AIXTargetVersionDetect) {
471
490
llvm::Triple TargetTriple (llvm::sys::getDefaultTargetTriple ());
472
491
if (TargetTriple.getOS () != Triple::AIX)
473
- return ;
492
+ GTEST_SKIP () ;
474
493
475
494
// Ensure that the target triple version (major) and release (minor) numbers
476
495
// match with those of the current system.
477
496
llvm::Triple ConfiguredTargetTriple (LLVM_DEFAULT_TARGET_TRIPLE);
478
497
if (ConfiguredTargetTriple.getOSMajorVersion ())
479
- return ; // The version was configured explicitly; skip.
498
+ GTEST_SKIP () ; // The version was configured explicitly; skip.
480
499
500
+ VersionTuple SystemVersion;
501
+ getAIXSystemVersion (SystemVersion);
481
502
VersionTuple TargetVersion = TargetTriple.getOSVersion ();
482
503
ASSERT_EQ (SystemVersion.getMajor (), TargetVersion.getMajor ());
483
504
ASSERT_EQ (SystemVersion.getMinor (), TargetVersion.getMinor ());
@@ -486,7 +507,7 @@ TEST_F(HostTest, AIXVersionDetect) {
486
507
TEST_F (HostTest, AIXHostCPUDetect) {
487
508
llvm::Triple HostTriple (llvm::sys::getProcessTriple ());
488
509
if (HostTriple.getOS () != Triple::AIX)
489
- return ;
510
+ GTEST_SKIP () ;
490
511
491
512
// Return a value based on the current processor implementation mode.
492
513
const char *ExePath = " /usr/sbin/getsystype" ;
0 commit comments