199451b44SJordan Rupprecht""" 299451b44SJordan RupprechtTest that plugins that load commands work correctly. 399451b44SJordan Rupprecht""" 499451b44SJordan Rupprecht 599451b44SJordan Rupprechtimport lldb 699451b44SJordan Rupprechtfrom lldbsuite.test.decorators import * 799451b44SJordan Rupprechtfrom lldbsuite.test.lldbtest import * 899451b44SJordan Rupprechtfrom lldbsuite.test import lldbutil 999451b44SJordan Rupprecht 1099451b44SJordan Rupprecht 1199451b44SJordan Rupprechtclass PluginCommandTestCase(TestBase): 1299451b44SJordan Rupprecht def setUp(self): 1399451b44SJordan Rupprecht TestBase.setUp(self) 1499451b44SJordan Rupprecht 1599451b44SJordan Rupprecht @skipIfNoSBHeaders 16*bf93f4b8SJonas Devlieghere @skipIfHostIncompatibleWithTarget 1799451b44SJordan Rupprecht @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778") 1899451b44SJordan Rupprecht @no_debug_info_test 1999451b44SJordan Rupprecht def test_load_plugin(self): 2099451b44SJordan Rupprecht """Test that plugins that load commands work correctly.""" 212238dcc3SJonas Devlieghere self.generateSource("plugin.cpp") 2299451b44SJordan Rupprecht 2399451b44SJordan Rupprecht plugin_name = "plugin" 2499451b44SJordan Rupprecht if sys.platform.startswith("darwin"): 2599451b44SJordan Rupprecht plugin_lib_name = "lib%s.dylib" % plugin_name 2699451b44SJordan Rupprecht else: 2799451b44SJordan Rupprecht plugin_lib_name = "lib%s.so" % plugin_name 2899451b44SJordan Rupprecht 2999451b44SJordan Rupprecht # Invoke the library build rule. 3099451b44SJordan Rupprecht self.buildLibrary("plugin.cpp", plugin_name) 3199451b44SJordan Rupprecht 3299451b44SJordan Rupprecht retobj = lldb.SBCommandReturnObject() 3399451b44SJordan Rupprecht 34a31130f6STatyana Krasnukha retval = self.dbg.GetCommandInterpreter().HandleCommand( 352238dcc3SJonas Devlieghere "plugin load %s" % self.getBuildArtifact(plugin_lib_name), retobj 362238dcc3SJonas Devlieghere ) 3799451b44SJordan Rupprecht 3899451b44SJordan Rupprecht retobj.Clear() 3999451b44SJordan Rupprecht 40a31130f6STatyana Krasnukha retval = self.dbg.GetCommandInterpreter().HandleCommand( 412238dcc3SJonas Devlieghere "plugin_loaded_command child abc def ghi", retobj 422238dcc3SJonas Devlieghere ) 4399451b44SJordan Rupprecht 4499451b44SJordan Rupprecht if self.TraceOn(): 4599451b44SJordan Rupprecht print(retobj.GetOutput()) 4699451b44SJordan Rupprecht 472238dcc3SJonas Devlieghere self.expect(retobj, substrs=["abc def ghi"], exe=False) 4899451b44SJordan Rupprecht 4999451b44SJordan Rupprecht retobj.Clear() 5099451b44SJordan Rupprecht 5199451b44SJordan Rupprecht # check that abbreviations work correctly in plugin commands. 52a31130f6STatyana Krasnukha retval = self.dbg.GetCommandInterpreter().HandleCommand( 532238dcc3SJonas Devlieghere "plugin_loaded_ ch abc def ghi", retobj 542238dcc3SJonas Devlieghere ) 5599451b44SJordan Rupprecht 5699451b44SJordan Rupprecht if self.TraceOn(): 5799451b44SJordan Rupprecht print(retobj.GetOutput()) 5899451b44SJordan Rupprecht 592238dcc3SJonas Devlieghere self.expect(retobj, substrs=["abc def ghi"], exe=False) 6099451b44SJordan Rupprecht 6199451b44SJordan Rupprecht @no_debug_info_test 6299451b44SJordan Rupprecht def test_invalid_plugin_invocation(self): 632238dcc3SJonas Devlieghere self.expect( 642238dcc3SJonas Devlieghere "plugin load a b", 652238dcc3SJonas Devlieghere error=True, 662238dcc3SJonas Devlieghere startstr="error: 'plugin load' requires one argument", 672238dcc3SJonas Devlieghere ) 682238dcc3SJonas Devlieghere self.expect( 692238dcc3SJonas Devlieghere "plugin load", 702238dcc3SJonas Devlieghere error=True, 712238dcc3SJonas Devlieghere startstr="error: 'plugin load' requires one argument", 722238dcc3SJonas Devlieghere ) 7399451b44SJordan Rupprecht 7499451b44SJordan Rupprecht @no_debug_info_test 7599451b44SJordan Rupprecht def test_invalid_plugin_target(self): 762238dcc3SJonas Devlieghere self.expect( 772238dcc3SJonas Devlieghere "plugin load ThisIsNotAValidPluginName", 782238dcc3SJonas Devlieghere error=True, 792238dcc3SJonas Devlieghere startstr="error: no such file", 802238dcc3SJonas Devlieghere ) 81