Skip to content

[lldb][unittest] Use shared once_flag in DiagnosticEventTest #80788

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

chelcassanova
Copy link
Contributor

Incorporates the changes from
#80786 to use a once_flag from TestUtilities instead of a local flag in order to prevent hitting an assertion that the debugger was initialized again in another test.

@llvmbot
Copy link
Member

llvmbot commented Feb 6, 2024

@llvm/pr-subscribers-lldb

Author: Chelsea Cassanova (chelcassanova)

Changes

Incorporates the changes from
#80786 to use a once_flag from TestUtilities instead of a local flag in order to prevent hitting an assertion that the debugger was initialized again in another test.


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

1 Files Affected:

  • (modified) lldb/unittests/Core/DiagnosticEventTest.cpp (+2-3)
diff --git a/lldb/unittests/Core/DiagnosticEventTest.cpp b/lldb/unittests/Core/DiagnosticEventTest.cpp
index bca8f3789955a..98ea7ca8d0a88 100644
--- a/lldb/unittests/Core/DiagnosticEventTest.cpp
+++ b/lldb/unittests/Core/DiagnosticEventTest.cpp
@@ -11,6 +11,7 @@
 #include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
 #include "Plugins/Platform/MacOSX/PlatformRemoteMacOSX.h"
 #include "TestingSupport/SubsystemRAII.h"
+#include "TestingSupport/TestUtilities.h"
 #include "lldb/Core/Debugger.h"
 #include "lldb/Core/DebuggerEvents.h"
 #include "lldb/Host/FileSystem.h"
@@ -26,8 +27,6 @@ using namespace lldb_private::repro;
 static const constexpr std::chrono::seconds TIMEOUT(0);
 static const constexpr size_t DEBUGGERS = 3;
 
-static std::once_flag debugger_initialize_flag;
-
 namespace {
 class DiagnosticEventTest : public ::testing::Test {
 public:
@@ -35,7 +34,7 @@ class DiagnosticEventTest : public ::testing::Test {
     FileSystem::Initialize();
     HostInfo::Initialize();
     PlatformMacOSX::Initialize();
-    std::call_once(debugger_initialize_flag,
+    std::call_once(TestUtilities::debugger_initialize_flag,
                    []() { Debugger::Initialize(nullptr); });
     ArchSpec arch("x86_64-apple-macosx-");
     Platform::SetHostPlatform(

Copy link
Collaborator

@jasonmolenda jasonmolenda left a comment

Choose a reason for hiding this comment

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

LGTM, I think the name should be prefixed with a g_ which we normally do for global/class static members, but otherwise cool.

Incorporates the changes from
llvm#80786 to use a once_flag from
`TestUtilities` instead of a local flag in order to prevent hitting an
assertion that the debugger was initialized again in another test.
@chelcassanova chelcassanova force-pushed the diagnostic-test-debugger-flag branch from 728d726 to 32f091c Compare February 6, 2024 03:11
@chelcassanova chelcassanova merged commit 5690027 into llvm:main Feb 6, 2024
chelcassanova added a commit to chelcassanova/llvm-project that referenced this pull request Feb 7, 2024
)

Incorporates the changes from
llvm#80786 to use a once_flag from
`TestUtilities` instead of a local flag in order to prevent hitting an
assertion that the debugger was initialized again in another test.

(cherry picked from commit 5690027)
chelcassanova added a commit to swiftlang/llvm-project that referenced this pull request Feb 8, 2024
…ing support (#8141)

* [lldb][unittest] Add call_once flag to initialize debugger (llvm#80786)

I tried adding a new unit test to the core test
suite (llvm#79533) but it broke the
test suite on AArch64 Linux due to hitting an assertion for calling
`Debugger::Initialize` more than once. When the unit test suite is
invoked as a standalone binary the test suite state is shared, and
`Debugger::Initialize` gets called in `DiagnosticEventTest.cpp` before
being called in `ProgressReportTest.cpp`.

`DiagnosticEventTest.cpp` uses a call_once flag to initialize the
debugger but it's local to that test. This commit adds a once_flag to
`TestUtilities` so that `Debugger::Initialize` can be called once by the
tests that use it.

(cherry picked from commit 3885483)

* [lldb][unittest] Use shared once_flag in DiagnosticEventTest (llvm#80788)

Incorporates the changes from
llvm#80786 to use a once_flag from
`TestUtilities` instead of a local flag in order to prevent hitting an
assertion that the debugger was initialized again in another test.

(cherry picked from commit 5690027)
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.

3 participants