diff options
Diffstat (limited to 'packages/Python/lldbsuite/test/functionalities/command_script')
17 files changed, 145 insertions, 111 deletions
diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/TestCommandScript.py b/packages/Python/lldbsuite/test/functionalities/command_script/TestCommandScript.py index 97e52231e818..d562cb1511ac 100644 --- a/packages/Python/lldbsuite/test/functionalities/command_script/TestCommandScript.py +++ b/packages/Python/lldbsuite/test/functionalities/command_script/TestCommandScript.py @@ -5,33 +5,34 @@ Test lldb Python commands. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.lldbtest import * + class CmdPythonTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - def test (self): - self.build () - self.pycmd_tests () + def test(self): + self.build() + self.pycmd_tests() - def pycmd_tests (self): + def pycmd_tests(self): self.runCmd("command source py_import") # Verify command that specifies eCommandRequiresTarget returns failure # without a target. self.expect('targetname', - substrs = ['a.out'], matching=False, error=True) + substrs=['a.out'], matching=False, error=True) - exe = os.path.join (os.getcwd(), "a.out") + exe = os.path.join(os.getcwd(), "a.out") self.expect("file " + exe, - patterns = [ "Current executable set to .*a.out" ]) + patterns=["Current executable set to .*a.out"]) self.expect('targetname', - substrs = ['a.out'], matching=True, error=False) + substrs=['a.out'], matching=True, error=False) # This is the function to remove the custom commands in order to have a # clean slate for the next test case. @@ -57,86 +58,89 @@ class CmdPythonTestCase(TestBase): self.HideStdout() self.expect('welcome Enrico', - substrs = ['Hello Enrico, welcome to LLDB']); - + substrs=['Hello Enrico, welcome to LLDB']) + self.expect("help welcome", - substrs = ['Just a docstring for welcome_impl', - 'A command that says hello to LLDB users']) + substrs=['Just a docstring for welcome_impl', + 'A command that says hello to LLDB users']) self.expect("help", - substrs = ['For more information run', - 'welcome']) + substrs=['For more information run', + 'welcome']) self.expect("help -a", - substrs = ['For more information run', - 'welcome']) + substrs=['For more information run', + 'welcome']) self.expect("help -u", matching=False, - substrs = ['For more information run']) + substrs=['For more information run']) - self.runCmd("command script delete welcome"); + self.runCmd("command script delete welcome") self.expect('welcome Enrico', matching=False, error=True, - substrs = ['Hello Enrico, welcome to LLDB']); + substrs=['Hello Enrico, welcome to LLDB']) self.expect('targetname fail', error=True, - substrs = ['a test for error in command']) + substrs=['a test for error in command']) self.expect('command script list', - substrs = ['targetname', - 'For more information run']) + substrs=['targetname', + 'For more information run']) self.expect("help targetname", - substrs = ['Expects', '\'raw\'', 'input', - 'help', 'raw-input']) + substrs=['Expects', '\'raw\'', 'input', + 'help', 'raw-input']) self.expect("longwait", - substrs = ['Done; if you saw the delays I am doing OK']) + substrs=['Done; if you saw the delays I am doing OK']) self.runCmd("b main") self.runCmd("run") self.runCmd("mysto 3") self.expect("frame variable array", - substrs = ['[0] = 79630','[1] = 388785018','[2] = 0']) + substrs=['[0] = 79630', '[1] = 388785018', '[2] = 0']) self.runCmd("mysto 3") self.expect("frame variable array", - substrs = ['[0] = 79630','[4] = 388785018','[5] = 0']) + substrs=['[0] = 79630', '[4] = 388785018', '[5] = 0']) # we cannot use the stepover command to check for async execution mode since LLDB # seems to get confused when events start to queue up self.expect("tell_sync", - substrs = ['running sync']) + substrs=['running sync']) self.expect("tell_async", - substrs = ['running async']) + substrs=['running async']) self.expect("tell_curr", - substrs = ['I am running sync']) - + substrs=['I am running sync']) + # check that the execution context is passed in to commands that ask for it - self.expect("takes_exe_ctx", substrs = ["a.out"]) + self.expect("takes_exe_ctx", substrs=["a.out"]) # Test that a python command can redefine itself self.expect('command script add -f foobar welcome -h "just some help"') - + self.runCmd("command script clear") # Test that re-defining an existing command works - self.runCmd('command script add my_command --class welcome.WelcomeCommand') - self.expect('my_command Blah', substrs = ['Hello Blah, welcome to LLDB']) + self.runCmd( + 'command script add my_command --class welcome.WelcomeCommand') + self.expect('my_command Blah', substrs=['Hello Blah, welcome to LLDB']) - self.runCmd('command script add my_command --class welcome.TargetnameCommand') - self.expect('my_command', substrs = ['a.out']) + self.runCmd( + 'command script add my_command --class welcome.TargetnameCommand') + self.expect('my_command', substrs=['a.out']) self.runCmd("command script clear") - + self.expect('command script list', matching=False, - substrs = ['targetname', - 'longwait']) + substrs=['targetname', + 'longwait']) self.expect('command script add -f foobar frame', error=True, - substrs = ['cannot add command']) + substrs=['cannot add command']) # http://llvm.org/bugs/show_bug.cgi?id=11569 - # LLDBSwigPythonCallCommand crashes when a command script returns an object + # LLDBSwigPythonCallCommand crashes when a command script returns an + # object self.runCmd('command script add -f bug11569 bug11569') # This should not crash. self.runCmd('bug11569', check=False) diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/bug11569.py b/packages/Python/lldbsuite/test/functionalities/command_script/bug11569.py index 93897d88098f..3c124de79bf3 100644 --- a/packages/Python/lldbsuite/test/functionalities/command_script/bug11569.py +++ b/packages/Python/lldbsuite/test/functionalities/command_script/bug11569.py @@ -3,5 +3,4 @@ def bug11569(debugger, args, result, dict): http://llvm.org/bugs/show_bug.cgi?id=11569 LLDBSwigPythonCallCommand crashes when a command script returns an object. """ - return ["return", "a", "non-string", "should", "not", "crash", "LLDB"]; - + return ["return", "a", "non-string", "should", "not", "crash", "LLDB"] diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/import/TestImport.py b/packages/Python/lldbsuite/test/functionalities/command_script/import/TestImport.py index 01c3f35bf300..01e7902b0f32 100644 --- a/packages/Python/lldbsuite/test/functionalities/command_script/import/TestImport.py +++ b/packages/Python/lldbsuite/test/functionalities/command_script/import/TestImport.py @@ -3,13 +3,15 @@ from __future__ import print_function - -import os, sys, time +import os +import sys +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class ImportTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -47,29 +49,31 @@ class ImportTestCase(TestBase): self.runCmd("command script import ./bar/bar.py --allow-reload") self.expect("command script import ./nosuchfile.py", - error=True, startstr='error: module importing failed') + error=True, startstr='error: module importing failed') self.expect("command script import ./nosuchfolder/", - error=True, startstr='error: module importing failed') + error=True, startstr='error: module importing failed') self.expect("command script import ./foo/foo.py", error=False) self.runCmd("command script import --allow-reload ./thepackage") - self.expect("TPcommandA",substrs=["hello world A"]) - self.expect("TPcommandB",substrs=["hello world B"]) + self.expect("TPcommandA", substrs=["hello world A"]) + self.expect("TPcommandB", substrs=["hello world B"]) self.runCmd("script import dummymodule") self.expect("command script import ./dummymodule.py", error=False) - self.expect("command script import --allow-reload ./dummymodule.py", error=False) + self.expect( + "command script import --allow-reload ./dummymodule.py", + error=False) self.runCmd("command script add -f foo.foo_function foocmd") self.runCmd("command script add -f foobar.foo_function foobarcmd") self.runCmd("command script add -f bar.bar_function barcmd") self.expect("foocmd hello", - substrs = ['foo says', 'hello']) + substrs=['foo says', 'hello']) self.expect("foo2cmd hello", - substrs = ['foo2 says', 'hello']) + substrs=['foo2 says', 'hello']) self.expect("barcmd hello", - substrs = ['barutil says', 'bar told me', 'hello']) + substrs=['barutil says', 'bar told me', 'hello']) self.expect("barothercmd hello", - substrs = ['barutil says', 'bar told me', 'hello']) + substrs=['barutil says', 'bar told me', 'hello']) self.expect("foobarcmd hello", - substrs = ['foobar says', 'hello']) + substrs=['foobar says', 'hello']) diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/import/bar/bar.py b/packages/Python/lldbsuite/test/functionalities/command_script/import/bar/bar.py index bbc41f3b217d..444e00976ad9 100644 --- a/packages/Python/lldbsuite/test/functionalities/command_script/import/bar/bar.py +++ b/packages/Python/lldbsuite/test/functionalities/command_script/import/bar/bar.py @@ -1,12 +1,15 @@ from __future__ import print_function + def bar_function(debugger, args, result, dict): - global UtilityModule - print(UtilityModule.barutil_function("bar told me " + args), file=result) - return None + global UtilityModule + print(UtilityModule.barutil_function("bar told me " + args), file=result) + return None + def __lldb_init_module(debugger, session_dict): - global UtilityModule - UtilityModule = __import__("barutil") - debugger.HandleCommand("command script add -f bar.bar_function barothercmd") - return None
\ No newline at end of file + global UtilityModule + UtilityModule = __import__("barutil") + debugger.HandleCommand( + "command script add -f bar.bar_function barothercmd") + return None diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/import/bar/barutil.py b/packages/Python/lldbsuite/test/functionalities/command_script/import/bar/barutil.py index 0d3d2eb1b2d7..70ecea300578 100644 --- a/packages/Python/lldbsuite/test/functionalities/command_script/import/bar/barutil.py +++ b/packages/Python/lldbsuite/test/functionalities/command_script/import/bar/barutil.py @@ -1,2 +1,2 @@ def barutil_function(x): - return "barutil says: " + x + return "barutil says: " + x diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/import/dummymodule.py b/packages/Python/lldbsuite/test/functionalities/command_script/import/dummymodule.py index dcc724ec9c23..668a5b90ea4f 100644 --- a/packages/Python/lldbsuite/test/functionalities/command_script/import/dummymodule.py +++ b/packages/Python/lldbsuite/test/functionalities/command_script/import/dummymodule.py @@ -1,2 +1,2 @@ def no_useful_code(foo): - return foo + return foo diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/import/foo/bar/foobar.py b/packages/Python/lldbsuite/test/functionalities/command_script/import/foo/bar/foobar.py index 659ded22c901..6ef71064c9a9 100644 --- a/packages/Python/lldbsuite/test/functionalities/command_script/import/foo/bar/foobar.py +++ b/packages/Python/lldbsuite/test/functionalities/command_script/import/foo/bar/foobar.py @@ -1,5 +1,6 @@ from __future__ import print_function + def foo_function(debugger, args, result, dict): - print("foobar says " + args, file=result) - return None + print("foobar says " + args, file=result) + return None diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/import/foo/foo.py b/packages/Python/lldbsuite/test/functionalities/command_script/import/foo/foo.py index 51cc0c3bab19..1ccc38929396 100644 --- a/packages/Python/lldbsuite/test/functionalities/command_script/import/foo/foo.py +++ b/packages/Python/lldbsuite/test/functionalities/command_script/import/foo/foo.py @@ -1,5 +1,6 @@ from __future__ import print_function + def foo_function(debugger, args, result, dict): - print("foo says " + args, file=result) - return None + print("foo says " + args, file=result) + return None diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/import/foo/foo2.py b/packages/Python/lldbsuite/test/functionalities/command_script/import/foo/foo2.py index 6863454ca6ef..71657c299c21 100644 --- a/packages/Python/lldbsuite/test/functionalities/command_script/import/foo/foo2.py +++ b/packages/Python/lldbsuite/test/functionalities/command_script/import/foo/foo2.py @@ -1,9 +1,11 @@ from __future__ import print_function + def foo2_function(debugger, args, result, dict): - print("foo2 says " + args, file=result) - return None + print("foo2 says " + args, file=result) + return None + def __lldb_init_module(debugger, session_dict): - debugger.HandleCommand("command script add -f foo2.foo2_function foo2cmd") - return None
\ No newline at end of file + debugger.HandleCommand("command script add -f foo2.foo2_function foo2cmd") + return None diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/import/rdar-12586188/TestRdar12586188.py b/packages/Python/lldbsuite/test/functionalities/command_script/import/rdar-12586188/TestRdar12586188.py index 4f7ebebd4dd2..01fd51385836 100644 --- a/packages/Python/lldbsuite/test/functionalities/command_script/import/rdar-12586188/TestRdar12586188.py +++ b/packages/Python/lldbsuite/test/functionalities/command_script/import/rdar-12586188/TestRdar12586188.py @@ -3,13 +3,15 @@ from __future__ import print_function - -import os, sys, time +import os +import sys +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class Rdar12586188TestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -27,7 +29,11 @@ class Rdar12586188TestCase(TestBase): def run_test(self): """Check that we handle an ImportError in a special way when command script importing files.""" - self.expect("command script import ./fail12586188.py --allow-reload", - error=True, substrs = ['raise ImportError("I do not want to be imported")']) - self.expect("command script import ./fail212586188.py --allow-reload", - error=True, substrs = ['raise ValueError("I do not want to be imported")']) + self.expect( + "command script import ./fail12586188.py --allow-reload", + error=True, + substrs=['raise ImportError("I do not want to be imported")']) + self.expect( + "command script import ./fail212586188.py --allow-reload", + error=True, + substrs=['raise ValueError("I do not want to be imported")']) diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/import/rdar-12586188/fail12586188.py b/packages/Python/lldbsuite/test/functionalities/command_script/import/rdar-12586188/fail12586188.py index add85a73f853..ea385e03e046 100644 --- a/packages/Python/lldbsuite/test/functionalities/command_script/import/rdar-12586188/fail12586188.py +++ b/packages/Python/lldbsuite/test/functionalities/command_script/import/rdar-12586188/fail12586188.py @@ -1,4 +1,4 @@ def f(x): - return x + 1 + return x + 1 raise ImportError("I do not want to be imported") diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/import/rdar-12586188/fail212586188.py b/packages/Python/lldbsuite/test/functionalities/command_script/import/rdar-12586188/fail212586188.py index 1549a036590f..8dbc0e67ba19 100644 --- a/packages/Python/lldbsuite/test/functionalities/command_script/import/rdar-12586188/fail212586188.py +++ b/packages/Python/lldbsuite/test/functionalities/command_script/import/rdar-12586188/fail212586188.py @@ -1,4 +1,4 @@ def f(x): - return x + 1 + return x + 1 raise ValueError("I do not want to be imported") diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/import/thepackage/TPunitA.py b/packages/Python/lldbsuite/test/functionalities/command_script/import/thepackage/TPunitA.py index fb65305d205c..9694b084295f 100644 --- a/packages/Python/lldbsuite/test/functionalities/command_script/import/thepackage/TPunitA.py +++ b/packages/Python/lldbsuite/test/functionalities/command_script/import/thepackage/TPunitA.py @@ -1,6 +1,7 @@ import six + def command(debugger, command, result, internal_dict): - result.PutCString(six.u("hello world A")) - return None + result.PutCString(six.u("hello world A")) + return None diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/import/thepackage/TPunitB.py b/packages/Python/lldbsuite/test/functionalities/command_script/import/thepackage/TPunitB.py index 60b31b89f6da..94a333bc696b 100644 --- a/packages/Python/lldbsuite/test/functionalities/command_script/import/thepackage/TPunitB.py +++ b/packages/Python/lldbsuite/test/functionalities/command_script/import/thepackage/TPunitB.py @@ -1,6 +1,7 @@ import six + def command(debugger, command, result, internal_dict): - result.PutCString(six.u("hello world B")) - return None + result.PutCString(six.u("hello world B")) + return None diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/import/thepackage/__init__.py b/packages/Python/lldbsuite/test/functionalities/command_script/import/thepackage/__init__.py index 1181462af868..24cdea60f2c4 100644 --- a/packages/Python/lldbsuite/test/functionalities/command_script/import/thepackage/__init__.py +++ b/packages/Python/lldbsuite/test/functionalities/command_script/import/thepackage/__init__.py @@ -3,6 +3,9 @@ from __future__ import absolute_import from . import TPunitA from . import TPunitB -def __lldb_init_module(debugger,*args): - debugger.HandleCommand("command script add -f thepackage.TPunitA.command TPcommandA") - debugger.HandleCommand("command script add -f thepackage.TPunitB.command TPcommandB") + +def __lldb_init_module(debugger, *args): + debugger.HandleCommand( + "command script add -f thepackage.TPunitA.command TPcommandA") + debugger.HandleCommand( + "command script add -f thepackage.TPunitB.command TPcommandB") diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/mysto.py b/packages/Python/lldbsuite/test/functionalities/command_script/mysto.py index 656cd1502930..88a20cb4567f 100644 --- a/packages/Python/lldbsuite/test/functionalities/command_script/mysto.py +++ b/packages/Python/lldbsuite/test/functionalities/command_script/mysto.py @@ -5,19 +5,21 @@ import sys import os import time + def StepOver(debugger, args, result, dict): - """ - Step over a given number of times instead of only just once - """ - arg_split = args.split(" ") - print(type(arg_split)) - count = int(arg_split[0]) - for i in range(0,count): - debugger.GetSelectedTarget().GetProcess().GetSelectedThread().StepOver(lldb.eOnlyThisThread) - print("step<%d>"%i) + """ + Step over a given number of times instead of only just once + """ + arg_split = args.split(" ") + print(type(arg_split)) + count = int(arg_split[0]) + for i in range(0, count): + debugger.GetSelectedTarget().GetProcess( + ).GetSelectedThread().StepOver(lldb.eOnlyThisThread) + print("step<%d>" % i) -def __lldb_init_module(debugger, session_dict): - # by default, --synchronicity is set to synchronous - debugger.HandleCommand("command script add -f mysto.StepOver mysto") - return None +def __lldb_init_module(debugger, session_dict): + # by default, --synchronicity is set to synchronous + debugger.HandleCommand("command script add -f mysto.StepOver mysto") + return None diff --git a/packages/Python/lldbsuite/test/functionalities/command_script/welcome.py b/packages/Python/lldbsuite/test/functionalities/command_script/welcome.py index 5dbf09fbbec2..0539d7c17211 100644 --- a/packages/Python/lldbsuite/test/functionalities/command_script/welcome.py +++ b/packages/Python/lldbsuite/test/functionalities/command_script/welcome.py @@ -1,18 +1,23 @@ from __future__ import print_function -import lldb, sys +import lldb +import sys + class WelcomeCommand(object): + def __init__(self, debugger, session_dict): pass - + def get_short_help(self): return "Just a docstring for welcome_impl\nA command that says hello to LLDB users" - + def __call__(self, debugger, args, exe_ctx, result): - print('Hello ' + args + ', welcome to LLDB', file=result); - return None; + print('Hello ' + args + ', welcome to LLDB', file=result) + return None + class TargetnameCommand(object): + def __init__(self, debugger, session_dict): pass @@ -22,10 +27,11 @@ class TargetnameCommand(object): print('Current target ' + file.GetFilename(), file=result) if args == 'fail': result.SetError('a test for error in command') - + def get_flags(self): return lldb.eCommandRequiresTarget + def print_wait_impl(debugger, args, result, dict): result.SetImmediateOutputFile(sys.stdout) print('Trying to do long task..', file=result) @@ -35,12 +41,13 @@ def print_wait_impl(debugger, args, result, dict): time.sleep(1) print('Done; if you saw the delays I am doing OK', file=result) + def check_for_synchro(debugger, args, result, dict): - if debugger.GetAsync() == True: + if debugger.GetAsync(): print('I am running async', file=result) if debugger.GetAsync() == False: print('I am running sync', file=result) + def takes_exe_ctx(debugger, args, exe_ctx, result, dict): print(str(exe_ctx.GetTarget()), file=result) - |