[Lldb-commits] [PATCH] D81516: [lldb/Test] Ensure inline tests have a unique build directory

Jonas Devlieghere via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Jun 9 16:37:11 PDT 2020


JDevlieghere created this revision.
JDevlieghere added reviewers: labath, vsk.
Herald added a subscriber: aprantl.
JDevlieghere added a comment.

I discovered this because `TestBasicEntryValues.py` was failing with the reproducers. Because the paths to the binaries were the same, we'd end up with only the GNU variant of the binary in the VFS.


Inline tests have one method named 'test' which means that multiple inline tests in the same file end up sharing the same build directory per variant.

The output bellow illustrates that even though `BasicEntryValues_GNU` and `BasicEntryValues_V5` have unique names, the test method for the dwarf variant is called `test_dwarf` in both cases.

  PASS: LLDB (/Users/jonas/llvm/build-ra/bin/clang-11-x86_64) :: test_dwarf (lldbsuite.test.lldbtest.BasicEntryValues_GNU)
  PASS: LLDB (/Users/jonas/llvm/build-ra/bin/clang-11-x86_64) :: test_gmodules (lldbsuite.test.lldbtest.BasicEntryValues_GNU)
  PASS: LLDB (/Users/jonas/llvm/build-ra/bin/clang-11-x86_64) :: test_dsym (lldbsuite.test.lldbtest.BasicEntryValues_V5)
  PASS: LLDB (/Users/jonas/llvm/build-ra/bin/clang-11-x86_64) :: test_dwarf (lldbsuite.test.lldbtest.BasicEntryValues_V5)
  PASS: LLDB (/Users/jonas/llvm/build-ra/bin/clang-11-x86_64) :: test_gmodules (lldbsuite.test.lldbtest.BasicEntryValues_V5)

The '__inline_name__' attribute ensures that the (unique) test name is used instead.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D81516

Files:
  lldb/packages/Python/lldbsuite/test/lldbinline.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py


Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1743,6 +1743,15 @@
         if original_testcase.NO_DEBUG_INFO_TESTCASE:
             return original_testcase
 
+        # Inline tests have one method named 'test' which means that multiple
+        # inline tests in the same file end up sharing the same build directory
+        # per variant. The '__inline_name__' attribute ensures that the
+        # (unique) test name is used instead.
+        inline_name = None
+        for attrname, attrvalue in attrs.items():
+            if attrname == "__inline_name__":
+                inline_name = "test_" + attrvalue
+
         newattrs = {}
         for attrname, attrvalue in attrs.items():
             if attrname.startswith("test") and not getattr(
@@ -1766,7 +1775,8 @@
                     def test_method(self, attrvalue=attrvalue):
                         return attrvalue(self)
 
-                    method_name = attrname + "_" + cat
+                    test_name = inline_name if inline_name else attrname
+                    method_name = test_name + "_" + cat
                     test_method.__name__ = method_name
                     test_method.debug_info = cat
                     newattrs[method_name] = test_method
Index: lldb/packages/Python/lldbsuite/test/lldbinline.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/lldbinline.py
+++ lldb/packages/Python/lldbsuite/test/lldbinline.py
@@ -206,7 +206,7 @@
     test_func = ApplyDecoratorsToFunction(InlineTest._test, decorators)
     # Build the test case
     test_class = type(name, (InlineTest,), dict(test=test_func,
-        name=name, _build_dict=build_dict))
+        name=name, __inline_name__=name, _build_dict=build_dict))
 
     # Add the test case to the globals, and hide InlineTest
     __globals.update({name: test_class})


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81516.269695.patch
Type: text/x-patch
Size: 2060 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200609/4585df49/attachment.bin>


More information about the lldb-commits mailing list