[llvm] [BOLT][test] Allow uninstantiated tests when no matching targets are enabled (PR #217604)

Rong Mantle Bao via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 20 05:39:43 PDT 2026


https://github.com/CSharperMantle created https://github.com/llvm/llvm-project/pull/217604

When neither X86 nor AArch64 is enabled, e.g. when only enabling the RISCV target, `check-bolt-unit` triggers GTest's uninitialized suite errors on the following cases:

```plain-text
BOLT-Unit :: Core/./CoreTests/GoogleTestVerification/UninstantiatedParameterizedTestSuite<BinaryContextTester>
BOLT-Unit :: Core/./CoreTests/GoogleTestVerification/UninstantiatedParameterizedTestSuite<MCPlusBuilderTester>
BOLT-Unit :: Core/./CoreTests/GoogleTestVerification/UninstantiatedParameterizedTestSuite<MemoryMapsTester>
BOLT-Unit :: Profile/./ProfileTests/GoogleTestVerification/UninstantiatedParameterizedTestSuite<PerfScriptTestHelper>
```

... which looks like the following:

```plain-text
********************                                                                                                                                                20:28 [95/2055]
FAIL: BOLT-Unit :: Core/./CoreTests/6/9 (7 of 12)
******************** TEST 'BOLT-Unit :: Core/./CoreTests/6/9' FAILED ********************
Script(shard):
--
GTEST_OUTPUT=json:/home/csmantle/workspace/llvm-project/build/tools/bolt/unittests/Core/./CoreTests-BOLT-Unit-718646-6-9.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=9 GTEST_SHARD_INDE
X=6 /home/csmantle/workspace/llvm-project/build/tools/bolt/unittests/Core/./CoreTests
--

Script:
--
/home/csmantle/workspace/llvm-project/build/tools/bolt/unittests/Core/./CoreTests --gtest_filter=GoogleTestVerification.UninstantiatedParameterizedTestSuite<BinaryContextTester>
--
/home/csmantle/workspace/llvm-project/bolt/unittests/Core/BinaryContext.cpp:211: Failure
Parameterized test suite BinaryContextTester is defined via TEST_P, but never instantiated. None of the test cases will run. Either no INSTANTIATE_TEST_SUITE_P is provided or the
only ones provided expand to nothing.

Ideally, TEST_P definitions should only ever be included as part of binaries that intend to use them. (As opposed to, for example, being placed in a library that may be linked in
to get other utilities.)

To suppress this error for this test suite, insert the following line (in a non-header) in the namespace it is defined in:

GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(BinaryContextTester);


/home/csmantle/workspace/llvm-project/bolt/unittests/Core/BinaryContext.cpp:211
Parameterized test suite BinaryContextTester is defined via TEST_P, but never instantiated. None of the test cases will run. Either no INSTANTIATE_TEST_SUITE_P is provided or the
only ones provided expand to nothing.

Ideally, TEST_P definitions should only ever be included as part of binaries that intend to use them. (As opposed to, for example, being placed in a library that may be linked in
to get other utilities.)

To suppress this error for this test suite, insert the following line (in a non-header) in the namespace it is defined in:

GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(BinaryContextTester);
```

Add gated `GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST` to suppress such warnings until appropriate tests have been implemented.

>From 9c90581cd50b848a967d926cea9332530469fd44 Mon Sep 17 00:00:00 2001
From: Rong Bao <rong.bao at csmantle.top>
Date: Mon, 11 May 2026 23:10:32 +0800
Subject: [PATCH] [BOLT][test] Allow uninstantiated tests when no matching
 targets are enabled

When neither X86 nor AArch64 is enabled, e.g. when only enabling the
RISCV target, check-bolt-unit triggers GTest's uninitialized suite
errors on the following cases:

        BOLT-Unit :: Core/./CoreTests/GoogleTestVerification/UninstantiatedParameterizedTestSuite<BinaryContextTester>
        BOLT-Unit :: Core/./CoreTests/GoogleTestVerification/UninstantiatedParameterizedTestSuite<MCPlusBuilderTester>
        BOLT-Unit :: Core/./CoreTests/GoogleTestVerification/UninstantiatedParameterizedTestSuite<MemoryMapsTester>
        BOLT-Unit :: Profile/./ProfileTests/GoogleTestVerification/UninstantiatedParameterizedTestSuite<PerfScriptTestHelper>

Add gated GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST to suppress such
warnings until appropriate tests have been implemented.
---
 bolt/unittests/Core/BinaryContext.cpp  | 4 ++++
 bolt/unittests/Core/MCPlusBuilder.cpp  | 4 ++++
 bolt/unittests/Core/MemoryMaps.cpp     | 4 ++++
 bolt/unittests/Profile/PerfScripts.cpp | 4 ++++
 4 files changed, 16 insertions(+)

diff --git a/bolt/unittests/Core/BinaryContext.cpp b/bolt/unittests/Core/BinaryContext.cpp
index 1713b56938391..c7c23ba33dcf9 100644
--- a/bolt/unittests/Core/BinaryContext.cpp
+++ b/bolt/unittests/Core/BinaryContext.cpp
@@ -270,3 +270,7 @@ TEST_P(BinaryContextTester, BaseAddressSegmentsSmallerThanAlignment) {
   ASSERT_TRUE(BaseAddress.has_value());
   ASSERT_EQ(*BaseAddress, 0xaaaaaaaa0000ULL);
 }
+
+#if !defined(X86_AVAILABLE) && !defined(AARCH64_AVAILABLE)
+GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(BinaryContextTester);
+#endif // !defined(X86_AVAILABLE) && !defined(AARCH64_AVAILABLE)
diff --git a/bolt/unittests/Core/MCPlusBuilder.cpp b/bolt/unittests/Core/MCPlusBuilder.cpp
index a692f45f551eb..5a4690fdba66f 100644
--- a/bolt/unittests/Core/MCPlusBuilder.cpp
+++ b/bolt/unittests/Core/MCPlusBuilder.cpp
@@ -993,3 +993,7 @@ TEST_P(MCPlusBuilderTester, Annotation) {
   ASSERT_DEATH(BC->MIB->addEHInfo(Inst, MCPlus::MCLandingPad(LPSymbol, Value)),
                "annotation value out of range");
 }
+
+#if !defined(X86_AVAILABLE) && !defined(AARCH64_AVAILABLE)
+GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(MCPlusBuilderTester);
+#endif // !defined(X86_AVAILABLE) && !defined(AARCH64_AVAILABLE)
diff --git a/bolt/unittests/Core/MemoryMaps.cpp b/bolt/unittests/Core/MemoryMaps.cpp
index cf842b6324957..a53bb4c6240a8 100644
--- a/bolt/unittests/Core/MemoryMaps.cpp
+++ b/bolt/unittests/Core/MemoryMaps.cpp
@@ -176,3 +176,7 @@ TEST_P(MemoryMapsTester, MultipleSegmentsMismatchedBaseAddress) {
       "Base address on multiple segment mappings should match");
   sys::fs::remove(Path);
 }
+
+#if !defined(X86_AVAILABLE) && !defined(AARCH64_AVAILABLE)
+GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(MemoryMapsTester);
+#endif // !defined(X86_AVAILABLE) && !defined(AARCH64_AVAILABLE)
diff --git a/bolt/unittests/Profile/PerfScripts.cpp b/bolt/unittests/Profile/PerfScripts.cpp
index 813540abd0053..bf7560ad67434 100644
--- a/bolt/unittests/Profile/PerfScripts.cpp
+++ b/bolt/unittests/Profile/PerfScripts.cpp
@@ -240,3 +240,7 @@ TEST_P(PerfScriptTestHelper, ParseAndCheckFileHeader) {
   // should be 'size == 3' after the parsing this dummy MainEvents.
   parseAndCheckPerfScriptProfile(Buffer, Pid, 3);
 }
+
+#if !defined(X86_AVAILABLE) && !defined(AARCH64_AVAILABLE)
+GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(PerfScriptTestHelper);
+#endif // !defined(X86_AVAILABLE) && !defined(AARCH64_AVAILABLE)



More information about the llvm-commits mailing list