From 87a000dae337789c364ddf03006eeaa6407a6393 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Mon, 26 Feb 2018 22:40:20 +0000 Subject: Add a sanity check for inline testcases. When writing an inline test, there is no way to make sure that any of the inline commands are actually executed, so this patch adds a sanity check that at least one breakpoint was hit. This avoids a test with no breakpoints being hit passing. Differential Revision: https://reviews.llvm.org/D43694 llvm-svn: 326140 --- lldb/packages/Python/lldbsuite/test/lang/c/inlines/main.c | 1 + lldb/packages/Python/lldbsuite/test/lldbinline.py | 9 +++++++++ 2 files changed, 10 insertions(+) (limited to 'lldb/packages/Python/lldbsuite/test') diff --git a/lldb/packages/Python/lldbsuite/test/lang/c/inlines/main.c b/lldb/packages/Python/lldbsuite/test/lang/c/inlines/main.c index 415f97aedbd..8fe49180800 100644 --- a/lldb/packages/Python/lldbsuite/test/lang/c/inlines/main.c +++ b/lldb/packages/Python/lldbsuite/test/lang/c/inlines/main.c @@ -21,4 +21,5 @@ void test1(int a) { int main() { test2(42); test1(23); + return 0; } diff --git a/lldb/packages/Python/lldbsuite/test/lldbinline.py b/lldb/packages/Python/lldbsuite/test/lldbinline.py index 0b8474906fe..036bb293952 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbinline.py +++ b/lldb/packages/Python/lldbsuite/test/lldbinline.py @@ -182,14 +182,23 @@ class InlineTest(TestBase): parser.set_breakpoints(target) process = target.LaunchSimple(None, None, self.getBuildDir()) + hit_breakpoints = 0 while lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint): + hit_breakpoints += 1 thread = lldbutil.get_stopped_thread( process, lldb.eStopReasonBreakpoint) breakpoint_id = thread.GetStopReasonDataAtIndex(0) parser.handle_breakpoint(self, breakpoint_id) process.Continue() + self.assertTrue(hit_breakpoints > 0, + "inline test did not hit a single breakpoint") + # Either the process exited or the stepping plan is complete. + self.assertTrue(process.GetState() in [lldb.eStateStopped, + lldb.eStateExited], + PROCESS_EXITED) + # Utilities for testcases def check_expression(self, expression, expected_result, use_summary=True): -- cgit v1.2.3