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