[Lldb-commits] [lldb] r326140 - Add a sanity check for inline testcases.

Adrian Prantl via lldb-commits lldb-commits at lists.llvm.org
Mon Feb 26 14:40:20 PST 2018


Author: adrian
Date: Mon Feb 26 14:40:20 2018
New Revision: 326140

URL: http://llvm.org/viewvc/llvm-project?rev=326140&view=rev
Log:
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

Modified:
    lldb/trunk/packages/Python/lldbsuite/test/lang/c/inlines/main.c
    lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py

Modified: lldb/trunk/packages/Python/lldbsuite/test/lang/c/inlines/main.c
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/c/inlines/main.c?rev=326140&r1=326139&r2=326140&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/lang/c/inlines/main.c (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/c/inlines/main.c Mon Feb 26 14:40:20 2018
@@ -21,4 +21,5 @@ void test1(int a) {
 int main() {
     test2(42);
     test1(23);
+    return 0;
 }

Modified: lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py?rev=326140&r1=326139&r2=326140&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/lldbinline.py Mon Feb 26 14:40:20 2018
@@ -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):




More information about the lldb-commits mailing list