Refactor the lit configuration files
authorZachary Turner <zturner@google.com>
Fri, 2 Nov 2018 17:49:01 +0000 (17:49 +0000)
committerZachary Turner <zturner@google.com>
Fri, 2 Nov 2018 17:49:01 +0000 (17:49 +0000)
A year or so ago, I re-wrote most of the lit infrastructure in LLVM so
that it wasn't so boilerplate-y. I added lots of common helper type
stuff, simplifed usage patterns, and made the code more elegant and
maintainable.

We migrated to this in LLVM, clang, and lld's lit files, but not in
LLDBs. This started to bite me recently, as the 4 most recent times I
tried to run the lit test suite in LLDB on a fresh checkout the first
thing that would happen is that python would just start crashing with
unhelpful backtraces and I would have to spend time investigating.

You can reproduce this today by doing a fresh cmake generation, doing
ninja lldb and then python bin/llvm-lit.py -sv ~/lldb/lit/SymbolFile at
which point you'll get a segfault that tells you nothing about what your
problem is.

I started trying to fix the issues with bandaids, but it became clear
that the proper solution was to just bring in the work I did in the rest
of the projects. The side benefit of this is that the lit configuration
files become much cleaner and more understandable as a result.

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

llvm-svn: 346008

40 files changed:
lldb/lit/Breakpoint/case-insensitive.test
lldb/lit/Breakpoint/lit.local.cfg [deleted file]
lldb/lit/CMakeLists.txt
lldb/lit/Expr/TestIRMemoryMapWindows.test
lldb/lit/Expr/lit.local.cfg [deleted file]
lldb/lit/Quit/lit.local.cfg [deleted file]
lldb/lit/Settings/lit.local.cfg [deleted file]
lldb/lit/SymbolFile/NativePDB/lit.local.cfg [deleted file]
lldb/lit/SymbolFile/PDB/ast-restore.test
lldb/lit/SymbolFile/PDB/calling-conventions.test
lldb/lit/SymbolFile/PDB/class-layout.test
lldb/lit/SymbolFile/PDB/compilands.test
lldb/lit/SymbolFile/PDB/enums-layout.test
lldb/lit/SymbolFile/PDB/func-symbols.test
lldb/lit/SymbolFile/PDB/function-level-linking.test
lldb/lit/SymbolFile/PDB/function-nested-block.test
lldb/lit/SymbolFile/PDB/lit.local.cfg [deleted file]
lldb/lit/SymbolFile/PDB/pointers.test
lldb/lit/SymbolFile/PDB/type-quals.test
lldb/lit/SymbolFile/PDB/typedefs.test
lldb/lit/SymbolFile/PDB/udt-layout.test
lldb/lit/SymbolFile/PDB/variables-locations.test
lldb/lit/SymbolFile/PDB/variables.test
lldb/lit/Unit/lit.cfg.py [moved from lldb/lit/Unit/lit.cfg with 56% similarity]
lldb/lit/Unit/lit.site.cfg.py.in [moved from lldb/lit/Unit/lit.site.cfg.in with 94% similarity]
lldb/lit/lit.cfg [deleted file]
lldb/lit/lit.cfg.py [new file with mode: 0644]
lldb/lit/lit.site.cfg.py.in [moved from lldb/lit/lit.site.cfg.in with 95% similarity]
lldb/lit/tools/lldb-mi/breakpoint/break-insert-enable-pending.test
lldb/lit/tools/lldb-mi/breakpoint/break-insert.test
lldb/lit/tools/lldb-mi/data/data-info-line.test
lldb/lit/tools/lldb-mi/exec/exec-continue.test
lldb/lit/tools/lldb-mi/exec/exec-finish.test
lldb/lit/tools/lldb-mi/exec/exec-interrupt.test
lldb/lit/tools/lldb-mi/exec/exec-next-instruction.test
lldb/lit/tools/lldb-mi/exec/exec-next.test
lldb/lit/tools/lldb-mi/exec/exec-step-instruction.test
lldb/lit/tools/lldb-mi/exec/exec-step.test
lldb/lit/tools/lldb-mi/symbol/symbol-list-lines.test
llvm/utils/lit/lit/llvm/config.py

index 841448c..3e7cfce 100644 (file)
@@ -1,5 +1,5 @@
-# REQUIRES: windows
-# XFAIL: windows
+# REQUIRES: system-windows
+# XFAIL: system-windows
 # -> llvm.org/pr24528
 #
 # RUN: %cc %p/Inputs/case-sensitive.c -g -o %t
diff --git a/lldb/lit/Breakpoint/lit.local.cfg b/lldb/lit/Breakpoint/lit.local.cfg
deleted file mode 100644 (file)
index df9b335..0000000
+++ /dev/null
@@ -1 +0,0 @@
-config.suffixes = ['.test']
index 640875f..c91535b 100644 (file)
@@ -51,11 +51,13 @@ llvm_canonicalize_cmake_booleans(
   LLVM_ENABLE_ZLIB)
 
 configure_lit_site_cfg(
-  ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
-  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg)
+  ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
+  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
+  MAIN_CONFIG
+  ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py)
 configure_lit_site_cfg(
-  ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in
-  ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg)
+  ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.py.in
+  ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg.py)
 configure_lit_site_cfg(
   ${CMAKE_CURRENT_SOURCE_DIR}/Suite/lit.site.cfg.in
   ${CMAKE_CURRENT_BINARY_DIR}/Suite/lit.site.cfg)
@@ -67,14 +69,8 @@ if(NOT LLDB_BUILT_STANDALONE)
     )
 endif()
 
-set(LLDB_TEST_PARAMS
-  lldb_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
-  )
-
 add_lit_testsuite(check-lldb-lit "Running lldb lit test suite"
   ${CMAKE_CURRENT_BINARY_DIR}
-  PARAMS lldb_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
-         lldb_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg
   DEPENDS ${LLDB_TEST_DEPS}
   )
 
@@ -88,7 +84,5 @@ endif()
 
 add_lit_testsuites(LLDB
   ${CMAKE_CURRENT_BINARY_DIR}
-  PARAMS lldb_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
-         lldb_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg
   DEPENDS ${LLDB_TEST_DEPS}
   )
index 2562ac1..9648309 100644 (file)
@@ -1,4 +1,4 @@
-# REQUIRES: windows
+# REQUIRES: system-windows
 
 # RUN: clang-cl /Zi %p/Inputs/call-function.cpp -o %t
 
diff --git a/lldb/lit/Expr/lit.local.cfg b/lldb/lit/Expr/lit.local.cfg
deleted file mode 100644 (file)
index df9b335..0000000
+++ /dev/null
@@ -1 +0,0 @@
-config.suffixes = ['.test']
diff --git a/lldb/lit/Quit/lit.local.cfg b/lldb/lit/Quit/lit.local.cfg
deleted file mode 100644 (file)
index df9b335..0000000
+++ /dev/null
@@ -1 +0,0 @@
-config.suffixes = ['.test']
diff --git a/lldb/lit/Settings/lit.local.cfg b/lldb/lit/Settings/lit.local.cfg
deleted file mode 100644 (file)
index df9b335..0000000
+++ /dev/null
@@ -1 +0,0 @@
-config.suffixes = ['.test']
diff --git a/lldb/lit/SymbolFile/NativePDB/lit.local.cfg b/lldb/lit/SymbolFile/NativePDB/lit.local.cfg
deleted file mode 100644 (file)
index fe74441..0000000
+++ /dev/null
@@ -1 +0,0 @@
-config.suffixes = ['.test', '.cpp']
index a770e2b..95e1301 100644 (file)
@@ -1,4 +1,4 @@
-REQUIRES: windows
+REQUIRES: system-windows
 RUN: cl /Zi /GS- /c %S/Inputs/AstRestoreTest.cpp /Fo%t.obj
 RUN: link /debug:full /nodefaultlib /entry:main %t.obj /out:%t.exe
 RUN: lldb-test symbols -dump-ast %t.exe | FileCheck --check-prefix=ENUM %s
index cc14749..b22d652 100644 (file)
@@ -1,4 +1,4 @@
-REQUIRES: windows, lld
+REQUIRES: system-windows, lld
 RUN: clang-cl -m32 /Zi /GS- /c %S/Inputs/CallingConventionsTest.cpp /o %t.obj
 RUN: lld-link /debug:full /nodefaultlib /entry:main %t.obj /out:%t.exe
 RUN: lldb-test symbols -dump-ast %t.exe | FileCheck %s
index 732961a..942433b 100644 (file)
@@ -1,4 +1,4 @@
-REQUIRES: windows
+REQUIRES: system-windows
 RUN: clang-cl -m32 /Z7 /c /GS- %S/Inputs/ClassLayoutTest.cpp /o %T/ClassLayoutTest.cpp.obj
 RUN: link %T/ClassLayoutTest.cpp.obj /DEBUG /nodefaultlib /ENTRY:main /OUT:%T/ClassLayoutTest.cpp.exe
 RUN: lldb-test symbols %T/ClassLayoutTest.cpp.exe | FileCheck %s
index 2e7b014..b0c9572 100644 (file)
@@ -1,4 +1,4 @@
-REQUIRES: windows
+REQUIRES: system-windows
 RUN: clang-cl /Z7 %S/Inputs/CompilandsTest.cpp /o %T/CompilandsTest.cpp.exe
 RUN: lldb-test symbols %T/CompilandsTest.cpp.exe | FileCheck %s
 
index ce0b23f..3a3d9b2 100644 (file)
@@ -1,4 +1,4 @@
-REQUIRES: windows
+REQUIRES: system-windows
 RUN: clang-cl -m32 /Z7 /c /GS- %S/Inputs/SimpleTypesTest.cpp /o %T/SimpleTypesTest.cpp.enums.obj
 RUN: link %T/SimpleTypesTest.cpp.enums.obj /DEBUG /nodefaultlib /ENTRY:main /OUT:%T/SimpleTypesTest.cpp.enums.exe
 RUN: lldb-test symbols %T/SimpleTypesTest.cpp.enums.exe | FileCheck %s
index 4340b33..20eabd3 100644 (file)
@@ -1,4 +1,4 @@
-REQUIRES: windows
+REQUIRES: system-windows
 RUN: clang-cl -m32 /Z7 /c /GS- %S/Inputs/FuncSymbolsTestMain.cpp /o %T/FuncSymbolsTestMain.cpp.obj
 RUN: clang-cl -m32 /Z7 /c /GS- %S/Inputs/FuncSymbols.cpp /o %T/FuncSymbols.cpp.obj
 RUN: link %T/FuncSymbolsTestMain.cpp.obj %T/FuncSymbols.cpp.obj /DEBUG /nodefaultlib /Entry:main /OUT:%T/FuncSymbolsTest.exe
index 9b28ec1..06605d8 100644 (file)
@@ -1,4 +1,4 @@
-REQUIRES: windows, lld
+REQUIRES: system-windows, lld
 RUN: clang-cl /c /Zi /Gy %S/Inputs/FunctionLevelLinkingTest.cpp /o %t.obj
 RUN: lld-link /debug:full /nodefaultlib /entry:main /order:@%S/Inputs/FunctionLevelLinkingTest.ord %t.obj /out:%t.exe
 RUN: lldb-test symbols -verify %t.exe
index fcf42ac..ef714c4 100644 (file)
@@ -1,4 +1,4 @@
-REQUIRES: windows, lld
+REQUIRES: system-windows, lld
 RUN: clang-cl /c /Zi %S/Inputs/FunctionNestedBlockTest.cpp /o %t.obj
 RUN: lld-link /debug:full /nodefaultlib /entry:main %t.obj /out:%t.exe
 RUN: lldb-test symbols -find=function -file FunctionNestedBlockTest.cpp -line 4 %t.exe | FileCheck --check-prefix=CHECK-FUNCTION %s
diff --git a/lldb/lit/SymbolFile/PDB/lit.local.cfg b/lldb/lit/SymbolFile/PDB/lit.local.cfg
deleted file mode 100644 (file)
index df9b335..0000000
+++ /dev/null
@@ -1 +0,0 @@
-config.suffixes = ['.test']
index 03e31c4..9a5e72e 100644 (file)
@@ -1,4 +1,4 @@
-REQUIRES: windows
+REQUIRES: system-windows
 RUN: clang-cl -m32 /Z7 /c /GS- %S/Inputs/PointerTypeTest.cpp /o %T/PointerTypeTest.cpp.obj
 RUN: link %T/PointerTypeTest.cpp.obj /DEBUG /nodefaultlib /ENTRY:main /OUT:%T/PointerTypeTest.cpp.exe
 RUN: lldb-test symbols %T/PointerTypeTest.cpp.exe | FileCheck %s
index fbe10c0..b4b66b6 100644 (file)
@@ -1,4 +1,4 @@
-REQUIRES: windows
+REQUIRES: system-windows
 RUN: clang-cl -m32 /Z7 /c /GS- %S/Inputs/TypeQualsTest.cpp /o %T/TypeQualsTest.cpp.obj
 RUN: link %T/TypeQualsTest.cpp.obj /DEBUG /nodefaultlib /ENTRY:main /OUT:%T/TypeQualsTest.cpp.exe
 RUN: lldb-test symbols %T/TypeQualsTest.cpp.exe | FileCheck %s
index 39514af..f69d3ec 100644 (file)
@@ -1,4 +1,4 @@
-REQUIRES: windows
+REQUIRES: system-windows
 RUN: clang-cl -m32 /Z7 /c /GS- %S/Inputs/SimpleTypesTest.cpp /o %T/SimpleTypesTest.cpp.typedefs.obj
 RUN: link %T/SimpleTypesTest.cpp.typedefs.obj /DEBUG /nodefaultlib /ENTRY:main /OUT:%T/SimpleTypesTest.cpp.typedefs.exe
 RUN: lldb-test symbols %T/SimpleTypesTest.cpp.typedefs.exe | FileCheck %s
index 3bca687..95533ae 100644 (file)
@@ -1,4 +1,4 @@
-REQUIRES: windows
+REQUIRES: system-windows
 RUN: clang-cl /Zi %S/Inputs/UdtLayoutTest.cpp /o %t.exe
 RUN: %lldb -b -s %S/Inputs/UdtLayoutTest.script -- %t.exe | FileCheck %s
 
index b70339f..19d3b4a 100644 (file)
@@ -1,4 +1,4 @@
-REQUIRES: windows
+REQUIRES: system-windows
 RUN: clang-cl /Zi %S/Inputs/VariablesLocationsTest.cpp /o %t.exe
 RUN: %lldb -b -s %S/Inputs/VariablesLocationsTest.script -- %t.exe | FileCheck %s
 
index 50202fe..81b888b 100644 (file)
@@ -1,4 +1,4 @@
-REQUIRES: windows
+REQUIRES: system-windows
 RUN: clang-cl -m64 /Z7 /c /GS- %S/Inputs/VariablesTest.cpp /o %T/VariablesTest.cpp.obj
 RUN: link %T/VariablesTest.cpp.obj /DEBUG /nodefaultlib /ENTRY:main /OUT:%T/VariablesTest.cpp.exe
 RUN: lldb-test symbols %T/VariablesTest.cpp.exe | FileCheck %s
similarity index 56%
rename from lldb/lit/Unit/lit.cfg
rename to lldb/lit/Unit/lit.cfg.py
index 338adfd..3633c73 100644 (file)
@@ -3,8 +3,10 @@
 # Configuration file for the 'lit' test runner.
 
 import os
+import sys
 
 import lit.formats
+from lit.llvm import llvm_config
 
 # name: The name of this test suite.
 config.name = 'lldb-Unit'
@@ -17,5 +19,12 @@ config.suffixes =  []
 config.test_source_root = os.path.join(config.lldb_obj_root, 'unittests')
 config.test_exec_root = config.test_source_root
 
+# One of our unit tests dynamically links against python.dll, and on Windows
+# it needs to be able to find it at runtime.  This is fine if Python is on your
+# system PATH, but if it's not, then this unit test executable will fail to run.
+# We can solve this by forcing the Python directory onto the system path here.
+llvm_config.with_system_environment('PATH')
+llvm_config.with_environment('PATH', os.path.dirname(sys.executable), append_path=True)
+
 # testFormat: The test format to use to interpret tests.
 config.test_format = lit.formats.GoogleTest(config.llvm_build_mode, 'Tests')
similarity index 94%
rename from lldb/lit/Unit/lit.site.cfg.in
rename to lldb/lit/Unit/lit.site.cfg.py.in
index 9c43172..a2d22a6 100644 (file)
@@ -22,5 +22,8 @@ except KeyError as e:
     key, = e.args
     lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key))
 
+import lit.llvm
+lit.llvm.initialize(lit_config, config)
+
 # Let the main config do the real work.
-lit_config.load_config(config, "@LLDB_SOURCE_DIR@/lit/Unit/lit.cfg")
+lit_config.load_config(config, "@LLDB_SOURCE_DIR@/lit/Unit/lit.cfg.py")
diff --git a/lldb/lit/lit.cfg b/lldb/lit/lit.cfg
deleted file mode 100644 (file)
index 38c819e..0000000
+++ /dev/null
@@ -1,183 +0,0 @@
-# -*- Python -*-
-
-import os
-import platform
-import re
-import subprocess
-import locale
-
-import lit.formats
-import lit.util
-
-def binary_feature(on, feature, off_prefix):
-  return feature if on else off_prefix + feature
-
-# Configuration file for the 'lit' test runner.
-
-# name: The name of this test suite.
-config.name = 'lldb'
-
-# testFormat: The test format to use to interpret tests.
-#
-# For now we require '&&' between commands, until they get globally killed and
-# the test runner updated.
-execute_external = (platform.system() != 'Windows'
-                    or lit_config.getBashPath() not in [None, ""])
-config.test_format = lit.formats.ShTest(execute_external)
-
-# suffixes: We only support unit tests
-config.suffixes = []
-
-config.excludes = ['Inputs']
-
-# test_source_root: The root path where tests are located.
-config.test_source_root = os.path.dirname(__file__)
-
-# test_exec_root: The root path where tests should be run.
-config.test_exec_root = os.path.join(config.lldb_obj_root, 'lit')
-
-# Tweak the PATH to include the tools dir and the scripts dir.
-lldb_tools_dir = config.lldb_tools_dir
-llvm_tools_dir = config.llvm_tools_dir
-path = os.path.pathsep.join((config.lldb_tools_dir, config.llvm_tools_dir, config.environment['PATH']))
-
-config.environment['PATH'] = path
-
-path = os.path.pathsep.join((config.lldb_libs_dir, config.llvm_libs_dir,
-                              config.environment.get('LD_LIBRARY_PATH','')))
-config.environment['LD_LIBRARY_PATH'] = path
-
-# Propagate LLVM_SRC_ROOT into the environment.
-config.environment['LLVM_SRC_ROOT'] = getattr(config, 'llvm_src_root', '')
-
-# Propagate PYTHON_EXECUTABLE into the environment
-config.environment['PYTHON_EXECUTABLE'] = getattr(config, 'python_executable', '')
-
-# Register substitutions
-config.substitutions.append(('%python', '"%s"' % (config.python_executable)))
-
-if platform.system() in ['Darwin']:
-    debugserver = lit.util.which('debugserver', lldb_tools_dir)
-else:
-    debugserver = lit.util.which('lldb-server', lldb_tools_dir)
-lldb = "%s -S %s/lit-lldb-init" % (lit.util.which('lldb', lldb_tools_dir),
-                               config.test_source_root)
-
-lldbmi = lit.util.which('lldb-mi', lldb_tools_dir)
-if lldbmi:
-    config.available_features.add('lldb-mi')
-
-if not os.path.exists(config.cc):
-    config.cc = lit.util.which(config.cc, config.environment['PATH'])
-
-if not os.path.exists(config.cxx):
-    config.cxx = lit.util.which(config.cxx, config.environment['PATH'])
-
-if platform.system() in ['Darwin']:
-    try:
-        out = subprocess.check_output(['xcrun', '--show-sdk-path']).strip()
-        res = 0
-    except OSError:
-        res = -1
-    if res == 0 and out:
-        sdk_path = lit.util.to_string(out)
-        lit_config.note('using SDKROOT: %r' % sdk_path)
-        config.cc += " -isysroot %s" % sdk_path
-        config.cxx += " -isysroot %s" % sdk_path
-
-if platform.system() in ['OpenBSD']:
-    config.cc += " -pthread"
-    config.cxx += " -pthread"
-
-config.substitutions.append(('%cc', config.cc))
-config.substitutions.append(('%cxx', config.cxx))
-
-if lldbmi:
-  config.substitutions.append(('%lldbmi', lldbmi + " --synchronous"))
-config.substitutions.append(('%lldb', lldb))
-
-if debugserver is not None:
-    if platform.system() in ['Darwin']:
-        config.substitutions.append(('%debugserver', debugserver))
-    else:
-        config.substitutions.append(('%debugserver', debugserver + ' gdbserver'))
-
-for pattern in [r"\bFileCheck\b",
-                r"\blldb-test\b",
-                r"\byaml2obj\b",
-                r"\| \bnot\b"]:
-    tool_match = re.match(r"^(\\)?((\| )?)\W+b([0-9A-Za-z-_]+)\\b\W*$",
-                          pattern)
-    tool_pipe = tool_match.group(2)
-    tool_name = tool_match.group(4)
-    tool_path = lit.util.which(tool_name, config.environment['PATH'])
-    if not tool_path:
-        # Warn, but still provide a substitution.
-        lit_config.note(
-            'Did not find ' + tool_name + ' in ' + config.environment['PATH'])
-    config.substitutions.append((pattern, tool_pipe + tool_path))
-
-# Shell execution
-if platform.system() not in ['Windows'] or lit_config.getBashPath() != '':
-    config.available_features.add('shell')
-
-# Running on Darwin OS
-if platform.system() in ['Darwin']:
-    config.available_features.add('darwin')
-    config.available_features.add('system-linker-mach-o')
-
-# Running on ELF based *nix
-if platform.system() in ['FreeBSD', 'Linux']:
-    config.available_features.add('system-linker-elf')
-    if platform.system() in ['FreeBSD']:
-        config.available_features.add('freebsd')
-    else:
-        config.available_features.add('linux')
-
-config.available_features.add(
-    binary_feature(platform.system() in ['Windows'], 'windows', 'no'))
-
-if re.match(r'^arm(hf.*-linux)|(.*-linux-gnuabihf)', config.target_triple):
-    config.available_features.add("armhf-linux")
-
-if re.match(r'icc', config.cc):
-    config.available_features.add("compiler-icc")
-elif re.match(r'clang', config.cc):
-    config.available_features.add("compiler-clang")
-elif re.match(r'gcc', config.cc):
-    config.available_features.add("compiler-gcc")
-elif re.match(r'cl', config.cc):
-    config.available_features.add("compiler-msvc")
-
-config.available_features.add(binary_feature(config.have_zlib, "zlib", "no"))
-if config.have_lld:
-  config.available_features.add("lld")
-
-# llvm-config knows whether it is compiled with asserts (and)
-# whether we are operating in release/debug mode.
-import subprocess
-try:
-    llvm_config_cmd = \
-     subprocess.Popen([os.path.join(llvm_tools_dir, 'llvm-config'),
-                     '--build-mode', '--assertion-mode', '--targets-built'],
-                      stdout = subprocess.PIPE)
-except OSError as why:
-    print("Could not find llvm-config in " + llvm_tools_dir)
-    exit(42)
-
-llvm_config_output = llvm_config_cmd.stdout.read().decode('utf_8')
-llvm_config_output_list = llvm_config_output.split("\n")
-
-if re.search(r'DEBUG', llvm_config_output_list[0]):
-    config.available_features.add('debug')
-if re.search(r'ON', llvm_config_output_list[1]):
-    config.available_features.add('asserts')
-if re.search(r'ARM', llvm_config_output_list[2]):
-    config.available_features.add('arm')
-if re.search(r'Mips', llvm_config_output_list[2]):
-    config.available_features.add('mips')
-if re.search(r'PowerPC', llvm_config_output_list[2]):
-    config.available_features.add('powerpc')
-if re.search(r'X86', llvm_config_output_list[2]):
-    config.available_features.add('x86')
-llvm_config_cmd.wait()
diff --git a/lldb/lit/lit.cfg.py b/lldb/lit/lit.cfg.py
new file mode 100644 (file)
index 0000000..9b78ba3
--- /dev/null
@@ -0,0 +1,126 @@
+# -*- Python -*-
+
+import os
+import sys
+import re
+import platform
+import subprocess
+
+
+import lit.util
+import lit.formats
+from lit.llvm import llvm_config
+from lit.llvm.subst import FindTool
+from lit.llvm.subst import ToolSubst
+
+# name: The name of this test suite.
+config.name = 'LLDB'
+
+# testFormat: The test format to use to interpret tests.
+config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
+
+# suffixes: A list of file extensions to treat as test files. This is overriden
+# by individual lit.local.cfg files in the test subdirectories.
+config.suffixes = ['.test', '.cpp', '.s']
+
+# excludes: A list of directories to exclude from the testsuite. The 'Inputs'
+# subdirectories contain auxiliary inputs for various tests in their parent
+# directories.
+config.excludes = ['Inputs', 'CMakeLists.txt', 'README.txt', 'LICENSE.txt']
+
+# test_source_root: The root path where tests are located.
+config.test_source_root = os.path.dirname(__file__)
+
+# test_exec_root: The root path where tests should be run.
+config.test_exec_root = os.path.join(config.lldb_obj_root, 'lit')
+
+# Tweak the PATH to include the tools dir.
+llvm_config.with_system_environment('PATH')
+llvm_config.with_environment('PATH', config.lldb_tools_dir, append_path=True)
+llvm_config.with_environment('PATH', config.llvm_tools_dir, append_path=True)
+
+llvm_config.with_environment('LD_LIBRARY_PATH', config.lldb_libs_dir, append_path=True)
+llvm_config.with_environment('LD_LIBRARY_PATH', config.llvm_libs_dir, append_path=True)
+llvm_config.with_system_environment('LD_LIBRARY_PATH', append_path=True)
+
+
+llvm_config.use_default_substitutions()
+
+if platform.system() in ['Darwin']:
+    debugserver = lit.util.which('debugserver', config.lldb_tools_dir)
+else:
+    debugserver = lit.util.which('lldb-server', config.lldb_tools_dir)
+lldb = "%s -S %s/lit-lldb-init" % (lit.util.which('lldb', config.lldb_tools_dir),
+                               config.test_source_root)
+
+lldbmi = lit.util.which('lldb-mi', config.lldb_tools_dir)
+if lldbmi:
+    config.available_features.add('lldb-mi')
+
+config.cc = llvm_config.use_llvm_tool(config.cc, required=True)
+config.cxx = llvm_config.use_llvm_tool(config.cxx, required=True)
+
+if platform.system() in ['Darwin']:
+    try:
+        out = subprocess.check_output(['xcrun', '--show-sdk-path']).strip()
+        res = 0
+    except OSError:
+        res = -1
+    if res == 0 and out:
+        sdk_path = lit.util.to_string(out)
+        lit_config.note('using SDKROOT: %r' % sdk_path)
+        config.cc += " -isysroot %s" % sdk_path
+        config.cxx += " -isysroot %s" % sdk_path
+
+if platform.system() in ['OpenBSD']:
+    config.cc += " -pthread"
+    config.cxx += " -pthread"
+
+config.substitutions.append(('%cc', config.cc))
+config.substitutions.append(('%cxx', config.cxx))
+
+if lldbmi:
+  config.substitutions.append(('%lldbmi', lldbmi + " --synchronous"))
+config.substitutions.append(('%lldb', lldb))
+
+if debugserver is not None:
+    if platform.system() in ['Darwin']:
+        config.substitutions.append(('%debugserver', debugserver))
+    else:
+        config.substitutions.append(('%debugserver', debugserver + ' gdbserver'))
+
+tools = ['lldb-test', 'yaml2obj', 'obj2yaml', 'llvm-pdbutil']
+llvm_config.add_tool_substitutions(tools, [config.llvm_tools_dir, config.lldb_tools_dir])
+
+if re.match(r'^arm(hf.*-linux)|(.*-linux-gnuabihf)', config.target_triple):
+    config.available_features.add("armhf-linux")
+
+print("config.cc = {}".format(config.cc))
+if re.match(r'icc', config.cc):
+    config.available_features.add("compiler-icc")
+elif re.match(r'clang', config.cc):
+    config.available_features.add("compiler-clang")
+elif re.match(r'gcc', config.cc):
+    config.available_features.add("compiler-gcc")
+elif re.match(r'cl', config.cc):
+    config.available_features.add("compiler-msvc")
+
+if config.have_lld:
+  config.available_features.add("lld")
+
+def calculate_arch_features(arch_string):
+    # This will add a feature such as x86, arm, mips, etc for each built
+    # target
+    features = []
+    for arch in arch_string.split():
+        features.append(arch.lower())
+    return features
+
+# Run llvm-config and add automatically add features for whether we have
+# assertions enabled, whether we are in debug mode, and what targets we
+# are built for.
+llvm_config.feature_config(
+    [('--assertion-mode', {'ON': 'asserts'}),
+     ('--build-mode', {'DEBUG': 'debug'}),
+     ('--targets-built', calculate_arch_features)
+     ])
similarity index 95%
rename from lldb/lit/lit.site.cfg.in
rename to lldb/lit/lit.site.cfg.py.in
index 55942db..8d5ebfa 100644 (file)
@@ -29,4 +29,4 @@ except KeyError as e:
     lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key))
 
 # Let the main config do the real work.
-lit_config.load_config(config, "@LLDB_SOURCE_DIR@/lit/lit.cfg")
+lit_config.load_config(config, "@LLDB_SOURCE_DIR@/lit/lit.cfg.py")
index bae224b..2a65068 100644 (file)
@@ -1,4 +1,4 @@
-# XFAIL: windows
+# XFAIL: system-windows
 # -> llvm.org/pr24452
 #
 # RUN: %cc -o %t %p/inputs/break-insert-pending.c -g
index cecf9e2..e6e230f 100644 (file)
@@ -1,4 +1,4 @@
-# XFAIL: windows
+# XFAIL: system-windows
 # -> llvm.org/pr24452
 #
 # RUN: %cc -o a.exe %p/inputs/break-insert.c -g
index c224efa..a38ae6e 100644 (file)
@@ -1,4 +1,4 @@
-# XFAIL: windows
+# XFAIL: system-windows
 # -> llvm.org/pr24452
 #
 # RUN: %cc -o %t %p/inputs/data-info-line.c -g
index c363422..162900e 100644 (file)
@@ -1,4 +1,4 @@
-# XFAIL: windows
+# XFAIL: system-windows
 # -> llvm.org/pr24452
 #
 # RUN: %cc -o %t %p/inputs/main.c -g
index 03c6b15..87ce75b 100644 (file)
@@ -1,4 +1,4 @@
-# XFAIL: windows
+# XFAIL: system-windows
 # -> llvm.org/pr24452
 #
 # RUN: %cc -o %t %p/inputs/main.c -g
index 81a3e72..3e855e1 100644 (file)
@@ -1,4 +1,4 @@
-# XFAIL: windows
+# XFAIL: system-windows
 # -> llvm.org/pr24452
 #
 # RUN: %cc -o %t %p/inputs/main.c -g
index 1dcca04..dae78e6 100644 (file)
@@ -1,4 +1,4 @@
-# XFAIL: windows
+# XFAIL: system-windows
 # -> llvm.org/pr24452
 #
 # RUN: %cc -o %t %p/inputs/main.c -g
index a4dd737..4583d53 100644 (file)
@@ -1,4 +1,4 @@
-# XFAIL: windows
+# XFAIL: system-windows
 # -> llvm.org/pr24452
 #
 # RUN: %cc -o %t %p/inputs/main.c -g
index a02bc01..37edc77 100644 (file)
@@ -1,4 +1,4 @@
-# XFAIL: windows
+# XFAIL: system-windows
 # -> llvm.org/pr24452
 #
 # RUN: %cc -o %t %p/inputs/main.c -g
index 095bba7..2187a00 100644 (file)
@@ -1,4 +1,4 @@
-# XFAIL: windows
+# XFAIL: system-windows
 # -> llvm.org/pr24452
 #
 # RUN: %cc -o %t %p/inputs/main.c -g
index 564280c..b949939 100644 (file)
@@ -1,4 +1,4 @@
-# XFAIL: windows
+# XFAIL: system-windows
 # -> llvm.org/pr24452
 #
 # RUN: %cc -o %t %p/inputs/main.c %p/inputs/symbol-list-lines.c %p/inputs/list-lines-helper.c -g
index 0e446da..6bb7135 100644 (file)
@@ -55,6 +55,8 @@ class LLVMConfig(object):
             features.add('system-windows')
         elif platform.system() == "Linux":
             features.add('system-linux')
+        elif platform.system() in ['FreeBSD']:
+            config.available_features.add('system-freebsd')
 
         # Native compilation: host arch == default triple arch
         # Both of these values should probably be in every site config (e.g. as