Skip to content

[lldb] Fix plugin manager test failure on windows #134173

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
merged 1 commit into from
Apr 3, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions lldb/unittests/Core/PluginManagerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,21 @@ using namespace lldb;
using namespace lldb_private;

// Mock system runtime plugin create functions.
SystemRuntime *CreateSystemRuntimePluginA(Process *process) { return nullptr; }
// Make them all return different values to avoid the ICF optimization
// from combining them into the same function. The values returned
// are not valid SystemRuntime pointers, but they are unique and
// sufficient for testing.
SystemRuntime *CreateSystemRuntimePluginA(Process *process) {
return (SystemRuntime *)0x1;
}

SystemRuntime *CreateSystemRuntimePluginB(Process *process) { return nullptr; }
SystemRuntime *CreateSystemRuntimePluginB(Process *process) {
return (SystemRuntime *)0x2;
}

SystemRuntime *CreateSystemRuntimePluginC(Process *process) { return nullptr; }
SystemRuntime *CreateSystemRuntimePluginC(Process *process) {
return (SystemRuntime *)0x3;
}

// Test class for testing the PluginManager.
// The PluginManager modifies global state when registering new plugins. This
Expand All @@ -24,6 +34,10 @@ class PluginManagerTest : public testing::Test {

// Add mock system runtime plugins for testing.
void RegisterMockSystemRuntimePlugins() {
// Make sure the create functions all have different addresses.
ASSERT_NE(CreateSystemRuntimePluginA, CreateSystemRuntimePluginB);
ASSERT_NE(CreateSystemRuntimePluginB, CreateSystemRuntimePluginC);

ASSERT_TRUE(PluginManager::RegisterPlugin("a", "test instance A",
CreateSystemRuntimePluginA));
ASSERT_TRUE(PluginManager::RegisterPlugin("b", "test instance B",
Expand Down