From c432c8f856e0bd84de980a9d9bb2d31b06fa95b1 Mon Sep 17 00:00:00 2001 From: Zachary Turner Date: Wed, 28 Oct 2015 17:43:26 +0000 Subject: Move lldb/test to lldb/packages/Python/lldbsuite/test. This is the conclusion of an effort to get LLDB's Python code structured into a bona-fide Python package. This has a number of benefits, but most notably the ability to more easily share Python code between different but related pieces of LLDB's Python infrastructure (for example, `scripts` can now share code with `test`). llvm-svn: 251532 --- .../lldbsuite/test/python_api/breakpoint/Makefile | 5 +++ .../python_api/breakpoint/TestBreakpointAPI.py | 44 ++++++++++++++++++++++ .../lldbsuite/test/python_api/breakpoint/main.c | 14 +++++++ 3 files changed, 63 insertions(+) create mode 100644 lldb/packages/Python/lldbsuite/test/python_api/breakpoint/Makefile create mode 100644 lldb/packages/Python/lldbsuite/test/python_api/breakpoint/TestBreakpointAPI.py create mode 100644 lldb/packages/Python/lldbsuite/test/python_api/breakpoint/main.c (limited to 'lldb/packages/Python/lldbsuite/test/python_api/breakpoint') diff --git a/lldb/packages/Python/lldbsuite/test/python_api/breakpoint/Makefile b/lldb/packages/Python/lldbsuite/test/python_api/breakpoint/Makefile new file mode 100644 index 00000000000..0d70f259501 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/python_api/breakpoint/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../make + +C_SOURCES := main.c + +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/python_api/breakpoint/TestBreakpointAPI.py b/lldb/packages/Python/lldbsuite/test/python_api/breakpoint/TestBreakpointAPI.py new file mode 100644 index 00000000000..c70b485a93a --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/python_api/breakpoint/TestBreakpointAPI.py @@ -0,0 +1,44 @@ +""" +Test SBBreakpoint APIs. +""" + +from __future__ import print_function + +import use_lldb_suite + +import os, time +import re +import lldb, lldbutil +from lldbtest import * + +class BreakpointAPITestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + @add_test_categories(['pyapi']) + def test_breakpoint_is_valid(self): + """Make sure that if an SBBreakpoint gets deleted its IsValid returns false.""" + self.build() + exe = os.path.join(os.getcwd(), "a.out") + + # Create a target by the debugger. + target = self.dbg.CreateTarget(exe) + self.assertTrue(target, VALID_TARGET) + + # Now create a breakpoint on main.c by name 'AFunction'. + breakpoint = target.BreakpointCreateByName('AFunction', 'a.out') + #print("breakpoint:", breakpoint) + self.assertTrue(breakpoint and + breakpoint.GetNumLocations() == 1, + VALID_BREAKPOINT) + + # Now delete it: + did_delete = target.BreakpointDelete(breakpoint.GetID()) + self.assertTrue (did_delete, "Did delete the breakpoint we just created.") + + # Make sure we can't find it: + del_bkpt = target.FindBreakpointByID (breakpoint.GetID()) + self.assertTrue (not del_bkpt, "We did delete the breakpoint.") + + # Finally make sure the original breakpoint is no longer valid. + self.assertTrue (not breakpoint, "Breakpoint we deleted is no longer valid.") diff --git a/lldb/packages/Python/lldbsuite/test/python_api/breakpoint/main.c b/lldb/packages/Python/lldbsuite/test/python_api/breakpoint/main.c new file mode 100644 index 00000000000..2677594e622 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/python_api/breakpoint/main.c @@ -0,0 +1,14 @@ +#include + +void +AFunction() +{ + printf ("I am a function.\n"); +} + +int +main () +{ + AFunction(); + return 0; +} -- cgit v1.2.3