1""" 2Test that plugins that load commands work correctly. 3""" 4 5import os, time 6import re 7import unittest2 8import lldb 9from lldbtest import * 10import lldbutil 11 12class PluginCommandTestCase(TestBase): 13 14 mydir = os.path.join("functionalities", "plugins", "commands") 15 16 def setUp(self): 17 # Call super's setUp(). 18 TestBase.setUp(self) 19 20 @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") 21 def test_load_plugin(self): 22 """Test that plugins that load commands work correctly.""" 23 24 # Invoke the default build rule. 25 self.buildDefault() 26 27 debugger = lldb.SBDebugger.Create() 28 29 retobj = lldb.SBCommandReturnObject() 30 31 retval = debugger.GetCommandInterpreter().HandleCommand("plugin load plugin.dylib",retobj) 32 33 retobj.Clear() 34 35 retval = debugger.GetCommandInterpreter().HandleCommand("plugin_loaded_command child abc def ghi",retobj) 36 37 if self.TraceOn(): 38 print retobj.GetOutput() 39 40 self.expect(retobj,substrs = ['abc def ghi'], exe=False) 41 42 retobj.Clear() 43 44 # check that abbreviations work correctly in plugin commands. 45 retval = debugger.GetCommandInterpreter().HandleCommand("plugin_loaded_ ch abc def ghi",retobj) 46 47 if self.TraceOn(): 48 print retobj.GetOutput() 49 50 self.expect(retobj,substrs = ['abc def ghi'], exe=False) 51 52 53if __name__ == '__main__': 54 import atexit 55 lldb.SBDebugger.Initialize() 56 atexit.register(lambda: lldb.SBDebugger.Terminate()) 57 unittest2.main() 58