From 8ebed74e6e7aba431b07aa1f082f41948d9eafd7 Mon Sep 17 00:00:00 2001 From: Johnny Chen Date: Wed, 29 Jun 2011 00:05:40 +0000 Subject: Add fuzz calls for SBTarget and SBThread. llvm-svn: 134046 --- .../TestDefaultConstructorForAPIObjects.py | 6 ++++ .../python_api/default-constructor/sb_target.py | 42 ++++++++++++++++++++++ .../python_api/default-constructor/sb_thread.py | 35 ++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 lldb/test/python_api/default-constructor/sb_target.py create mode 100644 lldb/test/python_api/default-constructor/sb_thread.py (limited to 'lldb/test/python_api/default-constructor') diff --git a/lldb/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py b/lldb/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py index 9d068438250..f46ce835abf 100644 --- a/lldb/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py +++ b/lldb/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py @@ -277,6 +277,9 @@ class APIDefaultConstructorTestCase(TestBase): if self.TraceOn(): print obj self.assertFalse(obj) + # Do fuzz testing on the invalid obj, it should not crash lldb. + import sb_target + sb_target.fuzz_obj(obj) @python_api_test def test_SBThread(self): @@ -284,6 +287,9 @@ class APIDefaultConstructorTestCase(TestBase): if self.TraceOn(): print obj self.assertFalse(obj) + # Do fuzz testing on the invalid obj, it should not crash lldb. + import sb_thread + sb_thread.fuzz_obj(obj) @python_api_test def test_SBType(self): diff --git a/lldb/test/python_api/default-constructor/sb_target.py b/lldb/test/python_api/default-constructor/sb_target.py new file mode 100644 index 00000000000..0f94d2fc998 --- /dev/null +++ b/lldb/test/python_api/default-constructor/sb_target.py @@ -0,0 +1,42 @@ +""" +Fuzz tests an object after the default construction to make sure it does not crash lldb. +""" + +import sys +import lldb + +def fuzz_obj(obj): + obj.GetProcess() + listener = lldb.SBListener() + error = lldb.SBError() + obj.Launch(listener, None, None, None, None, None, None, 0, True, error) + obj.LaunchSimple(None, None, None) + obj.AttachToProcessWithID(listener, 123, error) + obj.AttachToProcessWithName(listener, 'lldb', False, error) + obj.ConnectRemote(listener, "connect://to/here", None, error) + obj.GetExecutable() + obj.GetNumModules() + obj.GetModuleAtIndex(0xffffffff) + obj.GetDebugger() + filespec = lldb.SBFileSpec() + obj.FindModule(filespec) + contextlist = lldb.SBSymbolContextList() + obj.FindFunctions("the_func", 0xff, True, contextlist) + address = lldb.SBAddress() + obj.ResolveLoadAddress(0xffff, address) + obj.ResolveSymbolContextForAddress(address, 0) + obj.BreakpointCreateByLocation("filename", 20) + obj.BreakpointCreateByLocation(filespec, 20) + obj.BreakpointCreateByName("func", None) + obj.BreakpointCreateByRegex("func.", None) + obj.BreakpointCreateByAddress(0xf0f0) + obj.GetNumBreakpoints() + obj.GetBreakpointAtIndex(0) + obj.BreakpointDelete(0) + obj.FindBreakpointByID(0) + obj.EnableAllBreakpoints() + obj.DisableAllBreakpoints() + obj.DeleteAllBreakpoints() + obj.GetBroadcaster() + obj.GetDescription(lldb.SBStream(), lldb.eDescriptionLevelBrief) + obj.Clear() diff --git a/lldb/test/python_api/default-constructor/sb_thread.py b/lldb/test/python_api/default-constructor/sb_thread.py new file mode 100644 index 00000000000..c4fb4838350 --- /dev/null +++ b/lldb/test/python_api/default-constructor/sb_thread.py @@ -0,0 +1,35 @@ +""" +Fuzz tests an object after the default construction to make sure it does not crash lldb. +""" + +import sys +import lldb + +def fuzz_obj(obj): + obj.GetStopReason() + obj.GetStopReasonDataCount() + obj.GetStopReasonDataAtIndex(100) + obj.GetStopDescription(256) + obj.GetThreadID() + obj.GetIndexID() + obj.GetName() + obj.GetQueueName() + obj.StepOver(lldb.eOnlyDuringStepping) + obj.StepInto(lldb.eOnlyDuringStepping) + obj.StepOut() + frame = lldb.SBFrame() + obj.StepOutOfFrame(frame) + obj.StepInstruction(True) + filespec = lldb.SBFileSpec() + obj.StepOverUntil(frame, filespec, 1234) + obj.RunToAddress(0xabcd) + obj.Suspend() + obj.Resume() + obj.IsSuspended() + obj.GetNumFrames() + obj.GetFrameAtIndex(200) + obj.GetSelectedFrame() + obj.SetSelectedFrame(999) + obj.GetProcess() + obj.GetDescription(lldb.SBStream()) + obj.Clear() -- cgit v1.2.3