2 Test that plugins that load commands work correctly.
5 from __future__ import print_function
9 from lldbsuite.test.decorators import *
10 from lldbsuite.test.lldbtest import *
11 from lldbsuite.test import lldbutil
14 class PluginCommandTestCase(TestBase):
16 mydir = TestBase.compute_mydir(__file__)
20 self.generateSource('plugin.cpp')
23 # Requires a compatible arch and platform to link against the host's built
25 @skipIfHostIncompatibleWithRemote
26 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778")
28 def test_load_plugin(self):
29 """Test that plugins that load commands work correctly."""
31 plugin_name = "plugin"
32 if sys.platform.startswith("darwin"):
33 plugin_lib_name = "lib%s.dylib" % plugin_name
35 plugin_lib_name = "lib%s.so" % plugin_name
37 # Invoke the library build rule.
38 self.buildLibrary("plugin.cpp", plugin_name)
40 debugger = lldb.SBDebugger.Create()
42 retobj = lldb.SBCommandReturnObject()
44 retval = debugger.GetCommandInterpreter().HandleCommand(
45 "plugin load %s" % self.getBuildArtifact(plugin_lib_name), retobj)
49 retval = debugger.GetCommandInterpreter().HandleCommand(
50 "plugin_loaded_command child abc def ghi", retobj)
53 print(retobj.GetOutput())
55 self.expect(retobj, substrs=['abc def ghi'], exe=False)
59 # check that abbreviations work correctly in plugin commands.
60 retval = debugger.GetCommandInterpreter().HandleCommand(
61 "plugin_loaded_ ch abc def ghi", retobj)
64 print(retobj.GetOutput())
66 self.expect(retobj, substrs=['abc def ghi'], exe=False)
69 def test_invalid_plugin_invocation(self):
70 self.expect("plugin load a b",
71 error=True, startstr="error: 'plugin load' requires one argument")
72 self.expect("plugin load",
73 error=True, startstr="error: 'plugin load' requires one argument")
76 def test_invalid_plugin_target(self):
77 self.expect("plugin load ThisIsNotAValidPluginName",
78 error=True, startstr="error: no such file")