labath created this revision.
labath added reviewers: zturner, jingham, davide.
Herald added a subscriber: mgorny.

Some lldb features depend on xml support. Tests exercising that
functionality can only succeed if lldb was built with xml support. Right
now we have one such test, and another waiting in a patch that's blocked
on this.

This patch implements that functionality by exporting the build
configuration from cmake via configure_file (for the XCode build, I add
a hard-coded configuration file). Then, in dotest we parse this file and
use it to initialize a "feature" configuration variable. I chose a
fairly generic name as other as I anticipate adding other things here,
for example, the list of configured llvm targets. Lastly, I add a
new "features" option to the skipIf decorator enable skipping based on
configured features

The TestTargetXMLArch is updated to match on the xml feature instead of
incorrectly matching on the host platform.


https://reviews.llvm.org/D43292

Files:
  lldb.xcodeproj/lldb_build_config.py
  packages/Python/lldbsuite/test/configuration.py
  packages/Python/lldbsuite/test/decorators.py
  packages/Python/lldbsuite/test/dotest.py
  
packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestTargetXMLArch.py
  test/CMakeLists.txt
  test/lldb_build_config.py.in

Index: test/lldb_build_config.py.in
===================================================================
--- /dev/null
+++ test/lldb_build_config.py.in
@@ -0,0 +1 @@
+have_libxml2 = @LIBXML2_FOUND@
Index: test/CMakeLists.txt
===================================================================
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -148,3 +148,6 @@
 # This will add LLDB's test dependencies to the depenednecies for check-all and
 # include them in the test-depends target.
 set_property(GLOBAL APPEND PROPERTY LLVM_LIT_DEPENDS ${ARG_DEPENDS})
+
+llvm_canonicalize_cmake_booleans(LIBXML2_FOUND)
+configure_file(lldb_build_config.py.in lldb_build_config.py @ONLY)
Index: packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestTargetXMLArch.py
===================================================================
--- packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestTargetXMLArch.py
+++ packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestTargetXMLArch.py
@@ -6,7 +6,7 @@
 
 class TestTargetXMLArch(GDBRemoteTestBase):
 
-    @skipIf(hostoslist=no_match(lldbplatformutil.getDarwinOSTriples()))
+    @skipIf(features=no_match(["xml"]))
     @expectedFailureAll(archs=["i386"])
     def test(self):
         """
Index: packages/Python/lldbsuite/test/dotest.py
===================================================================
--- packages/Python/lldbsuite/test/dotest.py
+++ packages/Python/lldbsuite/test/dotest.py
@@ -816,6 +816,28 @@
         # sys.path[0].
         sys.path[1:1] = [lldbPythonDir]
 
+    # Import our build configuration
+    build_config_file = None
+    candidates = [
+            os.path.join(lldbLibDir, '..'), # Standalone build
+            os.path.join(lldbLibDir, '..', 'tools', 'lldb'), # Built as a part of llvm
+        ]
+    for c in candidates:
+        c = os.path.join(c, 'test', 'lldb_build_config.py')
+        if os.path.exists(c):
+            build_config_file = c
+            break
+
+    if build_config_file is None:
+        print("Could not find lldb_build_config.py")
+        print("Assuming an XCode build and loading defaults")
+        build_config_file = os.path.join(lldbRootDirectory, 'lldb.xcodeproj',
+                'lldb_build_config.py')
+
+    sys.path.append(os.path.dirname(build_config_file))
+    configuration.import_build_config(__import__("lldb_build_config"))
+    sys.path.pop()
+
 
 def visit_file(dir, name):
     # Try to match the regexp pattern, if specified.
Index: packages/Python/lldbsuite/test/decorators.py
===================================================================
--- packages/Python/lldbsuite/test/decorators.py
+++ packages/Python/lldbsuite/test/decorators.py
@@ -86,6 +86,15 @@
     else:
         return expected == actual
 
+def _match_features(features):
+    if features is None:
+        return True
+
+    if isinstance(features, no_match):
+        return not _match_features(features.item)
+
+    return any([f in configuration.features for f in features])
+
 
 def expectedFailure(expected_fn, bugnumber=None):
     def expectedFailure_impl(func):
@@ -159,7 +168,7 @@
                   debug_info=None,
                   swig_version=None, py_version=None,
                   macos_version=None,
-                  remote=None):
+                  remote=None, features=None):
     def fn(self):
         skip_for_os = _match_decorator_property(
             lldbplatform.translate(oslist), self.getPlatform())
@@ -176,6 +185,7 @@
             triple, lldb.DBG.GetSelectedPlatform().GetTriple())
         skip_for_remote = _match_decorator_property(
             remote, lldb.remote_platform is not None)
+        skip_for_features = _match_features(features)
 
         skip_for_swig_version = (
             swig_version is None) or (
@@ -207,7 +217,9 @@
                       (swig_version, skip_for_swig_version, "swig version"),
                       (py_version, skip_for_py_version, "python version"),
                       (macos_version, skip_for_macos_version, "macOS version"),
-                      (remote, skip_for_remote, "platform locality (remote/local)")]
+                      (remote, skip_for_remote, "platform locality (remote/local)"),
+                      (features, skip_for_features, "features"),
+                    ]
         reasons = []
         final_skip_result = True
         for this_condition in conditions:
@@ -244,48 +256,18 @@
 # @expectedFailureAll(bugnumber, ["linux"], "gcc", ['>=', '4.9'], ['i386']), xfail for gcc>=4.9 on linux with i386
 
 
-def expectedFailureAll(bugnumber=None,
-                       oslist=None, hostoslist=None,
-                       compiler=None, compiler_version=None,
-                       archs=None, triple=None,
-                       debug_info=None,
-                       swig_version=None, py_version=None,
-                       macos_version=None,
-                       remote=None):
-    return _decorateTest(DecorateMode.Xfail,
-                         bugnumber=bugnumber,
-                         oslist=oslist, hostoslist=hostoslist,
-                         compiler=compiler, compiler_version=compiler_version,
-                         archs=archs, triple=triple,
-                         debug_info=debug_info,
-                         swig_version=swig_version, py_version=py_version,
-                         macos_version=None,
-                         remote=remote)
+def expectedFailureAll(*args, **kwargs):
+    return _decorateTest(DecorateMode.Xfail, *args, **kwargs)
 
 
 # provide a function to skip on defined oslist, compiler version, and archs
 # if none is specified for any argument, that argument won't be checked and thus means for all
 # for example,
 # @skipIf, skip for all platform/compiler/arch,
 # @skipIf(compiler='gcc'), skip for gcc on all platform/architecture
 # @skipIf(bugnumber, ["linux"], "gcc", ['>=', '4.9'], ['i386']), skip for gcc>=4.9 on linux with i386
-def skipIf(bugnumber=None,
-           oslist=None, hostoslist=None,
-           compiler=None, compiler_version=None,
-           archs=None, triple=None,
-           debug_info=None,
-           swig_version=None, py_version=None,
-           macos_version=None,
-           remote=None):
-    return _decorateTest(DecorateMode.Skip,
-                         bugnumber=bugnumber,
-                         oslist=oslist, hostoslist=hostoslist,
-                         compiler=compiler, compiler_version=compiler_version,
-                         archs=archs, triple=triple,
-                         debug_info=debug_info,
-                         swig_version=swig_version, py_version=py_version,
-                         macos_version=macos_version,
-                         remote=remote)
+def skipIf(*args, **kwargs):
+    return _decorateTest(DecorateMode.Skip, *args, **kwargs)
 
 
 def _skip_for_android(reason, api_levels, archs):
Index: packages/Python/lldbsuite/test/configuration.py
===================================================================
--- packages/Python/lldbsuite/test/configuration.py
+++ packages/Python/lldbsuite/test/configuration.py
@@ -133,6 +133,9 @@
 # same base name.
 all_tests = set()
 
+# The set of features
+features = set()
+
 def shouldSkipBecauseOfCategories(test_categories):
     if useCategories:
         if len(test_categories) == 0 or len(
@@ -144,3 +147,6 @@
             return True
 
     return False
+
+def import_build_config(config):
+    if config.have_libxml2: features.add("xml")
Index: lldb.xcodeproj/lldb_build_config.py
===================================================================
--- /dev/null
+++ lldb.xcodeproj/lldb_build_config.py
@@ -0,0 +1 @@
+have_libxml2 = 1
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to