Skip to content

Conversation

@oontvoo
Copy link
Member

@oontvoo oontvoo commented Mar 5, 2025

Use the SubsystemRAII to unregister the fake manager at end of tests
(Should fix #129910)

Unregister the fake manager at end of test
(llvm#129910)
@oontvoo oontvoo requested a review from JDevlieghere as a code owner March 5, 2025 19:46
@llvmbot llvmbot added the lldb label Mar 5, 2025
@llvmbot
Copy link
Member

llvmbot commented Mar 5, 2025

@llvm/pr-subscribers-lldb

Author: Vy Nguyen (oontvoo)

Changes

Unregister the fake manager at end of test
(#129910)


Full diff: https://github.com/llvm/llvm-project/pull/129921.diff

1 Files Affected:

  • (modified) lldb/unittests/Core/TelemetryTest.cpp (+7-1)
diff --git a/lldb/unittests/Core/TelemetryTest.cpp b/lldb/unittests/Core/TelemetryTest.cpp
index 0e9f329110872..5b762ae816362 100644
--- a/lldb/unittests/Core/TelemetryTest.cpp
+++ b/lldb/unittests/Core/TelemetryTest.cpp
@@ -11,6 +11,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Telemetry/Telemetry.h"
+#include "TestingSupport/SubsystemRAII.h"
 #include "llvm/Testing/Support/Error.h"
 #include "gtest/gtest.h"
 #include <memory>
@@ -77,8 +78,13 @@ class FakePlugin : public telemetry::TelemetryManager {
 
 using namespace lldb_private::telemetry;
 
+class TelemetryTest : public testing::Test {
+ public:
+  SubsystemRAII<FakePlugin> subsystems;
+};
+
 #if LLVM_ENABLE_TELEMETRY
-#define TELEMETRY_TEST(suite, test) TEST(suite, test)
+#define TELEMETRY_TEST(suite, test) TEST_F(suite, test)
 #else
 #define TELEMETRY_TEST(suite, test) TEST(DISABLED_##suite, test)
 #endif

@oontvoo
Copy link
Member Author

oontvoo commented Mar 5, 2025

P.S: Verified that it no longer crashed:

vyng@web:~/repo/oontvoo/llvm-project/build$ lldb ./tools/lldb/unittests/Core/LLDBCoreTests 
(lldb) target create "./tools/lldb/unittests/Core/LLDBCoreTests"
Current executable set to '~/repo/oontvoo/llvm-project/build/tools/lldb/unittests/Core/LLDBCoreTests' (x86_64).
(lldb) env GTEST_SHUFFLE=1
(lldb) env GTEST_TOTAL_SHARDS=17
(lldb)  env GTEST_SHARD_INDEX=13
(lldb) env
target.env-vars (dictionary of strings) =
  GTEST_SHARD_INDEX=13
  GTEST_SHUFFLE=1
  GTEST_TOTAL_SHARDS=17
(lldb) run
Process 3437730 launched: '~/repo/oontvoo/llvm-project/build/tools/lldb/unittests/Core/LLDBCoreTests' (x86_64)
Note: This is test shard 14 of 17.
Note: Randomizing tests' orders with a seed of 61877 .
[==========] Running 4 tests from 4 test suites.
[----------] Global test environment set-up.
[----------] 1 test from TelemetryTest
[ RUN      ] TelemetryTest.PluginTest
[       OK ] TelemetryTest.PluginTest (0 ms)
[----------] 1 test from TelemetryTest (0 ms total)

[----------] 1 test from DumpDataExtractorTest
[ RUN      ] DumpDataExtractorTest.MultiLine
[       OK ] DumpDataExtractorTest.MultiLine (0 ms)
[----------] 1 test from DumpDataExtractorTest (0 ms total)

[----------] 1 test from ProgressReportTest
[ RUN      ] ProgressReportTest.TestMinimumReportTime
[       OK ] ProgressReportTest.TestMinimumReportTime (1503 ms)
[----------] 1 test from ProgressReportTest (1503 ms total)

[----------] 1 test from MangledTest
[ RUN      ] MangledTest.EmptyForInvalidName
[       OK ] MangledTest.EmptyForInvalidName (0 ms)
[----------] 1 test from MangledTest (0 ms total)

[----------] Global test environment tear-down
[==========] 4 tests from 4 test suites ran. (1503 ms total)
[  PASSED  ] 4 tests.
Process 3437730 exited with status = 0 (0x00000000) 
(lldb) quit

Copy link
Member

@JDevlieghere JDevlieghere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@oontvoo oontvoo merged commit 275eab9 into llvm:main Mar 5, 2025
10 checks passed
@oontvoo oontvoo deleted the fix_test branch May 19, 2025 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LLDBCoreTests are crashing because of Telemetry

3 participants