e81d4076574df13c95f568dbd61fce269e30214b
[openbsd] /
1 """
2 Test that plugins that load commands work correctly.
3 """
4
5 from __future__ import print_function
6
7
8 import lldb
9 from lldbsuite.test.decorators import *
10 from lldbsuite.test.lldbtest import *
11 from lldbsuite.test import lldbutil
12
13
14 class PluginCommandTestCase(TestBase):
15
16     mydir = TestBase.compute_mydir(__file__)
17
18     def setUp(self):
19         TestBase.setUp(self)
20         self.generateSource('plugin.cpp')
21
22     @skipIfNoSBHeaders
23     # Requires a compatible arch and platform to link against the host's built
24     # lldb lib.
25     @skipIfHostIncompatibleWithRemote
26     @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778")
27     @no_debug_info_test
28     def test_load_plugin(self):
29         """Test that plugins that load commands work correctly."""
30
31         plugin_name = "plugin"
32         if sys.platform.startswith("darwin"):
33             plugin_lib_name = "lib%s.dylib" % plugin_name
34         else:
35             plugin_lib_name = "lib%s.so" % plugin_name
36
37         # Invoke the library build rule.
38         self.buildLibrary("plugin.cpp", plugin_name)
39
40         debugger = lldb.SBDebugger.Create()
41
42         retobj = lldb.SBCommandReturnObject()
43
44         retval = debugger.GetCommandInterpreter().HandleCommand(
45             "plugin load %s" % self.getBuildArtifact(plugin_lib_name), retobj)
46
47         retobj.Clear()
48
49         retval = debugger.GetCommandInterpreter().HandleCommand(
50             "plugin_loaded_command child abc def ghi", retobj)
51
52         if self.TraceOn():
53             print(retobj.GetOutput())
54
55         self.expect(retobj, substrs=['abc def ghi'], exe=False)
56
57         retobj.Clear()
58
59         # check that abbreviations work correctly in plugin commands.
60         retval = debugger.GetCommandInterpreter().HandleCommand(
61             "plugin_loaded_ ch abc def ghi", retobj)
62
63         if self.TraceOn():
64             print(retobj.GetOutput())
65
66         self.expect(retobj, substrs=['abc def ghi'], exe=False)
67
68     @no_debug_info_test
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")
74
75     @no_debug_info_test
76     def test_invalid_plugin_target(self):
77         self.expect("plugin load ThisIsNotAValidPluginName",
78                     error=True, startstr="error: no such file")