[debuginfo-tests] 52bc1c1 - [dexter] Force dexter tests to use the host triple

via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 24 03:17:20 PST 2021


Author: OCHyams
Date: 2021-02-24T11:11:17Z
New Revision: 52bc1c1bd5397ef6ff37214a0186a47aa3348b72

URL: https://github.com/llvm/llvm-project/commit/52bc1c1bd5397ef6ff37214a0186a47aa3348b72
DIFF: https://github.com/llvm/llvm-project/commit/52bc1c1bd5397ef6ff37214a0186a47aa3348b72.diff

LOG: [dexter] Force dexter tests to use the host triple

If the default target and host triple don't match then print the following
message when the lit test runs:

    Forcing dexter tests to use host triple {HOST_TRIPLE}.

If we can't target the host arch then, when lit runs, we mark
the dexter test directories as UNSUPPORTED and print the message:

    Host triple {HOST_TRIPLE} not supported. Skipping dexter tests in
    the debuginfo-tests project.

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D96494

Added: 
    debuginfo-tests/dexter-tests/lit.local.cfg

Modified: 
    debuginfo-tests/dexter/feature_tests/lit.local.cfg
    debuginfo-tests/lit.cfg.py
    debuginfo-tests/lit.site.cfg.py.in

Removed: 
    


################################################################################
diff  --git a/debuginfo-tests/dexter-tests/lit.local.cfg b/debuginfo-tests/dexter-tests/lit.local.cfg
new file mode 100644
index 000000000000..a081e8e87daf
--- /dev/null
+++ b/debuginfo-tests/dexter-tests/lit.local.cfg
@@ -0,0 +1,2 @@
+if 'dexter' not in config.available_features:
+    config.unsupported = True

diff  --git a/debuginfo-tests/dexter/feature_tests/lit.local.cfg b/debuginfo-tests/dexter/feature_tests/lit.local.cfg
index 5e9b7908f8b6..6eb9f0ada02a 100644
--- a/debuginfo-tests/dexter/feature_tests/lit.local.cfg
+++ b/debuginfo-tests/dexter/feature_tests/lit.local.cfg
@@ -1,2 +1,5 @@
+if 'dexter' not in config.available_features:
+    config.unsupported = True
+
 config.name = "DExTer feature tests"
 config.suffixes = ['.cpp', '.c', '.test']

diff  --git a/debuginfo-tests/lit.cfg.py b/debuginfo-tests/lit.cfg.py
index 1657f63c468d..2de528ad6346 100644
--- a/debuginfo-tests/lit.cfg.py
+++ b/debuginfo-tests/lit.cfg.py
@@ -81,9 +81,41 @@ def get_required_attr(config, attr_name):
     # Propagate path to symbolizer for ASan/MSan.
     llvm_config.with_system_environment(
         ['ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH'])
-llvm_config.with_environment('PATHTOCLANG', llvm_config.config.clang)
-llvm_config.with_environment('PATHTOCLANGPP', llvm_config.use_llvm_tool('clang++'))
-llvm_config.with_environment('PATHTOCLANGCL', llvm_config.use_llvm_tool('clang-cl'))
+
+def add_host_triple(clang):
+  return '{} --target={}'.format(clang, config.host_triple)
+
+# The set of arches we can build.
+targets = set(config.targets_to_build)
+# Add aliases to the target set.
+if 'AArch64' in targets:
+  targets.add('arm64')
+if 'ARM' in config.targets_to_build:
+  targets.add('thumbv7')
+
+def can_target_host():
+  # Check if the targets set contains anything that looks like our host arch.
+  # The arch name in the triple and targets set may be spelled 
diff erently
+  # (e.g. x86 vs X86).
+  return any(config.host_triple.lower().startswith(x.lower())
+             for x in targets)
+
+# Dexter tests run on the host machine. If the host arch is supported add
+# 'dexter' as an available feature and force the dexter tests to use the host
+# triple.
+if can_target_host():
+  config.available_features.add('dexter')
+  if config.host_triple != config.target_triple:
+    print('Forcing dexter tests to use host triple {}.'.format(config.host_triple))
+  llvm_config.with_environment('PATHTOCLANG',
+                               add_host_triple(llvm_config.config.clang))
+  llvm_config.with_environment('PATHTOCLANGPP',
+                               add_host_triple(llvm_config.use_llvm_tool('clang++')))
+  llvm_config.with_environment('PATHTOCLANGCL',
+                               add_host_triple(llvm_config.use_llvm_tool('clang-cl')))
+else:
+  print('Host triple {} not supported. Skipping dexter tests in the '
+        'debuginfo-tests project.'.format(config.host_triple))
 
 # Check which debuggers are available:
 built_lldb = llvm_config.use_llvm_tool('lldb', search_env='CLANG')

diff  --git a/debuginfo-tests/lit.site.cfg.py.in b/debuginfo-tests/lit.site.cfg.py.in
index 687f6f0a4b7a..bd2cadc71d06 100644
--- a/debuginfo-tests/lit.site.cfg.py.in
+++ b/debuginfo-tests/lit.site.cfg.py.in
@@ -3,6 +3,7 @@
 import sys
 import lit.util
 
+config.targets_to_build = "@TARGETS_TO_BUILD@".split()
 config.llvm_src_root = "@LLVM_SOURCE_DIR@"
 config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
 config.llvm_libs_dir = "@LLVM_LIBS_DIR@"


        


More information about the llvm-commits mailing list