test infra: fix lldbinline tests to work with rerun
authorTodd Fiala <todd.fiala@gmail.com>
Tue, 22 Dec 2015 17:14:47 +0000 (17:14 +0000)
committerTodd Fiala <todd.fiala@gmail.com>
Tue, 22 Dec 2015 17:14:47 +0000 (17:14 +0000)
Fixes:
https://llvm.org/bugs/show_bug.cgi?id=25922

llvm-svn: 256255

lldb/packages/Python/lldbsuite/test/issue_verification/Makefile [new file with mode: 0644]
lldb/packages/Python/lldbsuite/test/issue_verification/TestRerunInline.py.park [new file with mode: 0644]
lldb/packages/Python/lldbsuite/test/issue_verification/inline_rerun_inferior.cpp [new file with mode: 0644]
lldb/packages/Python/lldbsuite/test/lldbinline.py
lldb/packages/Python/lldbsuite/test/result_formatter.py

diff --git a/lldb/packages/Python/lldbsuite/test/issue_verification/Makefile b/lldb/packages/Python/lldbsuite/test/issue_verification/Makefile
new file mode 100644 (file)
index 0000000..e7bd3f4
--- /dev/null
@@ -0,0 +1,4 @@
+LEVEL = ../make
+CXX_SOURCES := inline_rerun_inferior.cpp
+CXXFLAGS += -std=c++11
+include $(LEVEL)/Makefile.rules
diff --git a/lldb/packages/Python/lldbsuite/test/issue_verification/TestRerunInline.py.park b/lldb/packages/Python/lldbsuite/test/issue_verification/TestRerunInline.py.park
new file mode 100644 (file)
index 0000000..4c50495
--- /dev/null
@@ -0,0 +1,13 @@
+"""Tests that the rerun mechanism respects lldbinline-created tests.
+
+The current implementation of this test is expected to fail both on
+the initial run and on the rerun, assuming --rerun-all-issues is provided
+to the dotest.py run.
+
+This test could be improved by doing something in the test inferior
+C++ program that could look for the "should an issue be raised" marker
+file, and then really pass on the rerun.
+"""
+import lldbsuite.test.lldbinline as lldbinline
+
+lldbinline.MakeInlineTest(__file__, globals())
diff --git a/lldb/packages/Python/lldbsuite/test/issue_verification/inline_rerun_inferior.cpp b/lldb/packages/Python/lldbsuite/test/issue_verification/inline_rerun_inferior.cpp
new file mode 100644 (file)
index 0000000..933911f
--- /dev/null
@@ -0,0 +1,14 @@
+//===-- main.cpp --------------------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+typedef int Foo;
+
+int main() {
+    Foo array[3] = {1,2,3};
+    return 0; //% self.expect("frame variable array --show-types --", substrs = ['(Foo [3]) wrong_type_here = {','(Foo) [0] = 1','(Foo) [1] = 2','(Foo) [2] = 3'])
+}
index 67a5e81..691a3fb 100644 (file)
@@ -203,6 +203,8 @@ def MakeInlineTest(__file, __globals, decorators=None):
 
     # Add the test case to the globals, and hide InlineTest
     __globals.update({test_name : test})
-    
+
+    # Store the name of the originating file.o
+    test.test_filename = __file
     return test
 
index 35b3617..4447491 100644 (file)
@@ -242,11 +242,18 @@ class EventBuilder(object):
         """
         test_class_name, test_name = EventBuilder._get_test_name_info(test)
 
+        # Determine the filename for the test case.  If there is an attribute
+        # for it, use it.  Otherwise, determine from the TestCase class path.
+        if hasattr(test, "test_filename"):
+            test_filename = test.test_filename
+        else:
+            test_filename = inspect.getfile(test.__class__)
+
         event = EventBuilder.bare_event(event_type)
         event.update({
             "test_class": test_class_name,
             "test_name": test_name,
-            "test_filename": inspect.getfile(test.__class__)
+            "test_filename": test_filename
         })
 
         return event