diff options
Diffstat (limited to 'lit')
| -rw-r--r-- | lit/CMakeLists.txt | 18 | ||||
| -rw-r--r-- | lit/Modules/compressed-sections.yaml | 30 | ||||
| -rw-r--r-- | lit/Modules/lit.local.cfg | 1 | ||||
| -rw-r--r-- | lit/Unit/lit.cfg | 15 | ||||
| -rw-r--r-- | lit/lit.cfg | 109 | ||||
| -rw-r--r-- | lit/lit.site.cfg.in | 19 | 
6 files changed, 66 insertions, 126 deletions
| diff --git a/lit/CMakeLists.txt b/lit/CMakeLists.txt index 07d490619649..5488154318a9 100644 --- a/lit/CMakeLists.txt +++ b/lit/CMakeLists.txt @@ -11,10 +11,6 @@ else()    set(ENABLE_SHARED 0)  endif(BUILD_SHARED_LIBS) -option(LLDB_TEST_CLANG "Use in-tree clang when testing lldb" Off) -set(LLDB_TEST_C_COMPILER "" CACHE STRING "C compiler to use when testing LLDB") -set(LLDB_TEST_CXX_COMPILER "" CACHE STRING "C++ compiler to use when testing LLDB") -  configure_lit_site_cfg(    ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in    ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg) @@ -26,10 +22,11 @@ configure_lit_site_cfg(  set(LLDB_TEST_DEPS    LLDBUnitTests    lldb +  lldb-test    )  if(NOT LLDB_BUILT_STANDALONE) -  list(APPEND LLDB_TEST_DEPS FileCheck not) +  list(APPEND LLDB_TEST_DEPS FileCheck not yaml2obj)  endif()  # lldb-server is not built on every platform. @@ -41,10 +38,7 @@ if(APPLE)    list(APPEND LLDB_TEST_DEPS debugserver)  endif() -if(LLDB_TEST_CLANG) -  if(LLDB_TEST_C_COMPILER OR LLDB_TEST_CXX_COMPILER) -    message(SEND_ERROR "Cannot override LLDB_TEST_<LANG>_COMPILER and set LLDB_TEST_CLANG.") -  endif() +if(TARGET clang)    list(APPEND LLDB_TEST_DEPS clang)  endif() @@ -61,6 +55,12 @@ add_lit_testsuite(check-lldb-lit "Running lldb lit test suite"  set_target_properties(check-lldb-lit PROPERTIES FOLDER "LLDB tests") +# If we're building with an in-tree clang, then list clang as a dependency +# to run tests. +if (TARGET clang) +  add_dependencies(check-lldb-lit clang) +endif() +  add_lit_testsuites(LLDB ${CMAKE_CURRENT_SOURCE_DIR}    PARAMS lldb_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg           lldb_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg diff --git a/lit/Modules/compressed-sections.yaml b/lit/Modules/compressed-sections.yaml new file mode 100644 index 000000000000..0eabd99f2d6d --- /dev/null +++ b/lit/Modules/compressed-sections.yaml @@ -0,0 +1,30 @@ +# REQUIRES: zlib +# RUN: yaml2obj %s > %t +# RUN: lldb-test module-sections --contents %t | FileCheck %s +--- !ELF +FileHeader: +  Class:           ELFCLASS32 +  Data:            ELFDATA2LSB +  Type:            ET_REL +  Machine:         EM_386 +Sections: +  - Name:            .hello_elf +    Type:            SHT_PROGBITS +    Flags:           [ SHF_COMPRESSED ] +    Content:         010000000800000001000000789c5330700848286898000009c802c1 +  - Name:            .bogus +    Type:            SHT_PROGBITS +    Flags:           [ SHF_COMPRESSED ] +    Content:         deadbeefbaadf00d + +# CHECK: Name: .hello_elf +# CHECK-NEXT: VM size: 0 +# CHECK-NEXT: File size: 28 +# CHECK-NEXT: Data: +# CHECK-NEXT: 20304050 60708090 + +# CHECK: Name: .bogus +# CHECK-NEXT: VM size: 0 +# CHECK-NEXT: File size: 8 +# CHECK-NEXT: Data: +# CHECK-NEXT: DEADBEEF BAADF00D diff --git a/lit/Modules/lit.local.cfg b/lit/Modules/lit.local.cfg new file mode 100644 index 000000000000..8169b9f95e11 --- /dev/null +++ b/lit/Modules/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.yaml'] diff --git a/lit/Unit/lit.cfg b/lit/Unit/lit.cfg index 7dfb344e6fae..338adfd7bd9a 100644 --- a/lit/Unit/lit.cfg +++ b/lit/Unit/lit.cfg @@ -6,19 +6,6 @@ import os  import lit.formats -# Check that the object root is known. -if config.test_exec_root is None: -    # Otherwise, we haven't loaded the site specific configuration (the user is -    # probably trying to run on a test file directly, and either the site -    # configuration hasn't been created by the build system, or we are in an -    # out-of-tree build situation). - -    # Check for 'llvm_unit_site_config' user parameter, and use that if available. -    site_cfg = lit_config.params.get('lldb_unit_site_config', None) -    if site_cfg and os.path.exists(site_cfg): -        lit_config.load_config(config, site_cfg) -        raise SystemExit -  # name: The name of this test suite.  config.name = 'lldb-Unit' @@ -31,6 +18,4 @@ config.test_source_root = os.path.join(config.lldb_obj_root, 'unittests')  config.test_exec_root = config.test_source_root  # testFormat: The test format to use to interpret tests. -if not hasattr(config, 'llvm_build_mode'): -    lit_config.fatal("unable to find llvm_build_mode value on config")  config.test_format = lit.formats.GoogleTest(config.llvm_build_mode, 'Tests') diff --git a/lit/lit.cfg b/lit/lit.cfg index 8dea61b27169..402d03947ca8 100644 --- a/lit/lit.cfg +++ b/lit/lit.cfg @@ -9,6 +9,9 @@ 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. @@ -29,94 +32,24 @@ config.suffixes = []  config.test_source_root = os.path.dirname(__file__)  # test_exec_root: The root path where tests should be run. -lldb_obj_root = getattr(config, 'lldb_obj_root', None) -if lldb_obj_root is not None: -    config.test_exec_root = os.path.join(lldb_obj_root, 'lit') - -# Set llvm_{src,obj}_root for use by others. -config.llvm_src_root = getattr(config, 'llvm_src_root', None) -config.llvm_obj_root = getattr(config, 'llvm_obj_root', None) +config.test_exec_root = os.path.join(config.lldb_obj_root, 'lit')  # Tweak the PATH to include the tools dir and the scripts dir. -if lldb_obj_root is not None: -    lldb_tools_dir = getattr(config, 'lldb_tools_dir', None) -    if not lldb_tools_dir: -        lit_config.fatal('No LLDB tools dir set!') -    llvm_tools_dir = getattr(config, 'llvm_tools_dir', None) -    if not llvm_tools_dir: -        lit_config.fatal('No LLVM tools dir set!') -    path = os.path.pathsep.join((lldb_tools_dir, llvm_tools_dir, config.environment['PATH'])) -    path = os.path.pathsep.join((os.path.join(getattr(config, 'llvm_src_root', None),'test','Scripts'),path)) - -    config.environment['PATH'] = path - -    lldb_libs_dir = getattr(config, 'lldb_libs_dir', None) -    if not lldb_libs_dir: -        lit_config.fatal('No LLDB libs dir set!') -    llvm_libs_dir = getattr(config, 'llvm_libs_dir', None) -    if not llvm_libs_dir: -        lit_config.fatal('No LLVM libs dir set!') -    path = os.path.pathsep.join((lldb_libs_dir, 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', -                                                      '') -### - -# Check that the object root is known. -if config.test_exec_root is None: -    # Otherwise, we haven't loaded the site specific configuration (the user is -    # probably trying to run on a test file directly, and either the site -    # configuration hasn't been created by the build system, or we are in an -    # out-of-tree build situation). - -    # Check for 'lldb_site_config' user parameter, and use that if available. -    site_cfg = lit_config.params.get('lldb_site_config', None) -    if site_cfg and os.path.exists(site_cfg): -        lit_config.load_config(config, site_cfg) -        raise SystemExit - -    # Try to detect the situation where we are using an out-of-tree build by -    # looking for 'llvm-config'. -    # -    # FIXME: I debated (i.e., wrote and threw away) adding logic to -    # automagically generate the lit.site.cfg if we are in some kind of fresh -    # build situation. This means knowing how to invoke the build system though, -    # and I decided it was too much magic. We should solve this by just having -    # the .cfg files generated during the configuration step. - -    llvm_config = lit.util.which('llvm-config', config.environment['PATH']) -    if not llvm_config: -        lit_config.fatal('No site specific configuration available!') - -    # Get the source and object roots. -    llvm_src_root = subprocess.check_output(['llvm-config', '--src-root']).strip() -    llvm_obj_root = subprocess.check_output(['llvm-config', '--obj-root']).strip() -    lldb_src_root = os.path.join(llvm_src_root, "tools", "lldb") -    lldb_obj_root = os.path.join(llvm_obj_root, "tools", "lldb") - -    # Validate that we got a tree which points to here, using the standard -    # tools/lldb layout. -    this_src_root = os.path.dirname(config.test_source_root) -    if os.path.realpath(lldb_src_root) != os.path.realpath(this_src_root): -        lit_config.fatal('No site specific configuration available!') - -    # Check that the site specific configuration exists. -    site_cfg = os.path.join(lldb_obj_root, 'test', 'lit.site.cfg') -    if not os.path.exists(site_cfg): -        lit_config.fatal( -            'No site specific configuration available! You may need to ' -            'run "make test" in your lldb build directory.') - -    # Okay, that worked. Notify the user of the automagic, and reconfigure. -    lit_config.note('using out-of-tree build at %r' % lldb_obj_root) -    lit_config.load_config(config, site_cfg) -    raise SystemExit +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', config.python_executable)) @@ -151,6 +84,8 @@ if debugserver is not None:      config.substitutions.append(('%debugserver', debugserver))  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) @@ -195,6 +130,8 @@ elif re.match(r'gcc', config.cc):  elif re.match(r'cl', config.cc):      config.available_features.add("compiler-msvc") +config.available_features.add(binary_feature(config.have_zlib, "zlib", "no")) +  # llvm-config knows whether it is compiled with asserts (and)  # whether we are operating in release/debug mode.  import subprocess diff --git a/lit/lit.site.cfg.in b/lit/lit.site.cfg.in index 03aa3df9ac55..2cfa677651a1 100644 --- a/lit/lit.site.cfg.in +++ b/lit/lit.site.cfg.in @@ -10,22 +10,9 @@ config.lldb_libs_dir = "@LLVM_LIBRARY_OUTPUT_INTDIR@"  config.lldb_tools_dir = "@LLVM_RUNTIME_OUTPUT_INTDIR@"  config.target_triple = "@TARGET_TRIPLE@"  config.python_executable = "@PYTHON_EXECUTABLE@" -config.cc = "@CMAKE_C_COMPILER@" -config.cxx = "@CMAKE_CXX_COMPILER@" - -test_c_compiler = "@LLDB_TEST_C_COMPILER@" -test_cxx_compiler = "@LLDB_TEST_CXX_COMPILER@" -test_clang = "@LLDB_TEST_CLANG@".lower() -test_clang = test_clang == "on" or test_clang == "true" or test_clang == "1" - -if len(test_c_compiler) > 0: -  config.cc = test_c_compiler -if len(test_c_compiler) > 0: -  config.cxx = test_cxx_compiler - -if test_clang: -  config.cc = 'clang' -  config.cxx = 'clang++' +config.cc = "@LLDB_TEST_C_COMPILER@" +config.cxx = "@LLDB_TEST_CXX_COMPILER@" +config.have_zlib = @HAVE_LIBZ@  # Support substitution of the tools and libs dirs with user parameters. This is  # used when we can't determine the tool dir at configuration time. | 
