Files
clang-p2996/lldb/test/Shell/Commands/command-plugin-enable+disable.test
David Peixotto d4fe522eb4 Add commands to list/enable/disable plugins (#134418)
This commit adds three new commands for managing plugins. The `list`
command will show which plugins are currently registered and their
enabled state. The `enable` and `disable` commands can be used to enable
or disable plugins.

A disabled plugin will not show up to the PluginManager when it iterates
over available plugins of a particular type.

The purpose of these commands is to provide more visibility into
registered plugins and allow users to disable plugins for experimental
perf reasons.

There are a few limitations to the current implementation

1. Only SystemRuntime and InstrumentationRuntime plugins are currently
supported. We can easily extend the existing implementation to support
more types. The scope was limited to these plugins to keep the PR size
manageable.

2. Only "statically" know plugin types are supported (i.e. those managed
by the PluginManager and not from `plugin load`). It is possibly we
could support dynamic plugins as well, but I have not looked into it
yet.
2025-06-09 13:30:13 -07:00

88 lines
4.1 KiB
Plaintext

# This test validates the plugin enable and disable commands.
# Currently it works only for system-runtime plugins and we only have one
# system runtime plugin so testing is a bit limited.
#
# Note that commands that return errors will stop running a script, so we
# have new RUN lines for any command that is expected to return an error.
# RUN: %lldb -s %s -o exit 2>&1 | FileCheck %s
# Test plugin list shows the default state which is expected to be enabled.
plugin list
# CHECK-LABEL: plugin list
# CHECK: system-runtime
# CHECK: [+] systemruntime-macosx System runtime plugin for Mac OS X native libraries
# Test plugin disable disables a plugin.
plugin disable system-runtime.systemruntime-macosx
# CHECK-LABEL: plugin disable system-runtime.systemruntime-macosx
# CHECK: system-runtime
# CHECK: [-] systemruntime-macosx System runtime plugin for Mac OS X native libraries
# Make sure plugin list shows it disabled as well.
plugin list
# CHECK: system-runtime
# CHECK: [-] systemruntime-macosx System runtime plugin for Mac OS X native libraries
# Test plugin enable re-enables a plugin.
plugin enable system-runtime.systemruntime-macosx
# CHECK-LABEL: plugin enable system-runtime.systemruntime-macosx
# CHECK: system-runtime
# CHECK: [+] systemruntime-macosx System runtime plugin for Mac OS X native libraries
# Make sure plugin list shows it enabled as well.
plugin list
# CHECK: system-runtime
# CHECK: [+] systemruntime-macosx System runtime plugin for Mac OS X native libraries
# Test plugin disable with namespace works.
plugin disable system-runtime
# CHECK-LABEL: plugin disable system-runtime
# CHECK: system-runtime
# CHECK: [-] systemruntime-macosx System runtime plugin for Mac OS X native libraries
# Test plugin enable with namespace works.
plugin enable system-runtime
# CHECK-LABEL: plugin enable system-runtime
# CHECK: system-runtime
# CHECK: [+] systemruntime-macosx System runtime plugin for Mac OS X native libraries
# Test plugin enable/disable for instrumentation plugin works.
plugin enable instrumentation-runtime
# CHECK-LABEL: plugin enable instrumentation-runtime
# CHECK: instrumentation-runtime
# CHECK: [+] AddressSanitizer
plugin disable instrumentation-runtime
# CHECK-LABEL: plugin disable instrumentation-runtime
# CHECK: instrumentation-runtime
# CHECK: [-] AddressSanitizer
# Test plugin enable with multiple arguments.
plugin enable system-runtime instrumentation-runtime
# CHECK-LABEL: plugin enable system-runtime instrumentation-runtime
# CHECK: system-runtime
# CHECK: [+] systemruntime-macosx System runtime plugin for Mac OS X native libraries.
# CHECK: instrumentation-runtime
# CHECK: [+] AddressSanitizer AddressSanitizer instrumentation runtime plugin.
# Test plugin disable with multiple arguments.
plugin disable system-runtime instrumentation-runtime
# CHECK-LABEL: plugin disable system-runtime instrumentation-runtime
# CHECK: system-runtime
# CHECK: [-] systemruntime-macosx System runtime plugin for Mac OS X native libraries.
# CHECK: instrumentation-runtime
# CHECK: [-] AddressSanitizer AddressSanitizer instrumentation runtime plugin.
# Test plugin enable/disable for unknown plugin returns an error.
# RUN: %lldb -o "plugin enable some-plugin-that-does-not-exist" 2>&1 | FileCheck %s --check-prefix=ERROR_PLUGIN_NOT_FOUND
# RUN: %lldb -o "plugin disable some-plugin-that-does-not-exist" 2>&1 | FileCheck %s --check-prefix=ERROR_PLUGIN_NOT_FOUND
# RUN: %lldb -o "plugin enable system-runtime some-plugin-that-does-not-exist" 2>&1 | FileCheck %s --check-prefix=ERROR_PLUGIN_NOT_FOUND
# ERROR_PLUGIN_NOT_FOUND: error: Found no matching plugins
# Test plugin enable/disable requires a plugin name.
# RUN: %lldb -o "plugin enable" 2>&1 | FileCheck %s --check-prefix=ERROR_ARGUMENTS_ENABLE
# ERROR_ARGUMENTS_ENABLE: error: 'plugin enable' requires one or more arguments
# RUN: %lldb -o "plugin disable" 2>&1 | FileCheck %s --check-prefix=ERROR_ARGUMENTS_DISABLE
# ERROR_ARGUMENTS_DISABLE: error: 'plugin disable' requires one or more arguments