diff options
Diffstat (limited to 'lld/test')
-rw-r--r-- | lld/test/CMakeLists.txt | 55 | ||||
-rw-r--r-- | lld/test/lit.cfg | 110 | ||||
-rw-r--r-- | lld/test/lit.site.cfg.in | 21 | ||||
-rw-r--r-- | lld/test/tent-merge.objtxt | 24 |
4 files changed, 210 insertions, 0 deletions
diff --git a/lld/test/CMakeLists.txt b/lld/test/CMakeLists.txt new file mode 100644 index 00000000000..32e86b7367d --- /dev/null +++ b/lld/test/CMakeLists.txt @@ -0,0 +1,55 @@ +set(LLVM_SOURCE_DIR "${LLVM_MAIN_SRC_DIR}") +set(LLVM_BINARY_DIR "${LLVM_BINARY_DIR}") +set(LLVM_BUILD_MODE "%(build_mode)s") +set(LLVM_TOOLS_DIR "${LLVM_TOOLS_BINARY_DIR}/%(build_config)s") +set(LLVM_LIBS_DIR "${LLVM_BINARY_DIR}/lib/%(build_config)s") +set(CLANG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..") +set(CLANG_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/..") +if(BUILD_SHARED_LIBS) + set(ENABLE_SHARED 1) +else() + set(ENABLE_SHARED 0) +endif(BUILD_SHARED_LIBS) + +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in + ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg) + +include(FindPythonInterp) +if (PYTHONINTERP_FOUND) + if (LLVM_MAIN_SRC_DIR) + set(LIT "${LLVM_SOURCE_DIR}/utils/lit/lit.py") + else() + set(LIT "${PATH_TO_LLVM_BUILD}/bin/${CMAKE_CFG_INTDIR}/llvm-lit") + # Installed LLVM does not contain ${CMAKE_CFG_INTDIR} in paths. + if (NOT EXISTS ${LIT}) + set(LIT "${PATH_TO_LLVM_BUILD}/bin/llvm-lit") + endif() + endif() + + if (PATH_TO_LLVM_BUILD) + set(LLD_TEST_EXTRA_ARGS "--path=${LLD_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}") + endif() + + set(LIT_ARGS "${LLD_TEST_EXTRA_ARGS} ${LLVM_LIT_ARGS}") + separate_arguments(LIT_ARGS) + + add_custom_target(lld-test.deps) + set_target_properties(lld-test.deps PROPERTIES FOLDER "lld tests") + + add_custom_target(lld-test + COMMAND ${PYTHON_EXECUTABLE} + ${LIT} + --param lld_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg + --param build_config=${CMAKE_CFG_INTDIR} + --param build_mode=${RUNTIME_BUILD_MODE} + ${LIT_ARGS} + ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "Running lld regression tests") + set_target_properties(lld-test PROPERTIES FOLDER "lld tests") + + add_dependencies(lld-test lld-test.deps) + add_dependencies(lld-test.deps + lld-core + ) +endif() diff --git a/lld/test/lit.cfg b/lld/test/lit.cfg new file mode 100644 index 00000000000..8870d71179f --- /dev/null +++ b/lld/test/lit.cfg @@ -0,0 +1,110 @@ +# -*- Python -*- + +import os +import platform +import re +import subprocess + + +# Configuration file for the 'lit' test runner. + +# name: The name of this test suite. +config.name = 'lld' + +# 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.getBashPath() not in [None, ""]) +config.test_format = lit.formats.ShTest(execute_external) + +# suffixes: A list of file extensions to treat as test files. +config.suffixes = ['.objtxt'] + +# 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. +lld_obj_root = getattr(config, 'lld_obj_root', None) +if lld_obj_root is not None: + config.test_exec_root = os.path.join(lld_obj_root, 'test') + +# 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) + +# Tweak the PATH to include the tools dir and the scripts dir. +if lld_obj_root is not None: + llvm_tools_dir = getattr(config, 'llvm_tools_dir', None) + if not llvm_tools_dir: + lit.fatal('No LLVM tools dir set!') + path = os.path.pathsep.join((llvm_tools_dir, config.environment['PATH'])) + config.environment['PATH'] = path + + llvm_libs_dir = getattr(config, 'llvm_libs_dir', None) + if not llvm_libs_dir: + lit.fatal('No LLVM libs dir set!') + path = os.path.pathsep.join((llvm_libs_dir, + config.environment.get('LD_LIBRARY_PATH',''))) + config.environment['LD_LIBRARY_PATH'] = path + +### + +# 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 'lld_site_config' user parameter, and use that if available. + site_cfg = lit.params.get('lld_site_config', None) + if site_cfg and os.path.exists(site_cfg): + lit.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.fatal('No site specific configuration available!') + + # Get the source and object roots. + llvm_src_root = lit.util.capture(['llvm-config', '--src-root']).strip() + llvm_obj_root = lit.util.capture(['llvm-config', '--obj-root']).strip() + lld_src_root = os.path.join(llvm_src_root, "tools", "lld") + lld_obj_root = os.path.join(llvm_obj_root, "tools", "lld") + + # Validate that we got a tree which points to here, using the standard + # tools/lld layout. + this_src_root = os.path.dirname(config.test_source_root) + if os.path.realpath(lld_src_root) != os.path.realpath(this_src_root): + lit.fatal('No site specific configuration available!') + + # Check that the site specific configuration exists. + site_cfg = os.path.join(lld_obj_root, 'test', 'lit.site.cfg') + if not os.path.exists(site_cfg): + lit.fatal('No site specific configuration available! You may need to ' + 'run "make test" in your lld build directory.') + + # Okay, that worked. Notify the user of the automagic, and reconfigure. + lit.note('using out-of-tree build at %r' % lld_obj_root) + lit.load_config(config, site_cfg) + raise SystemExit + +# When running under valgrind, we mangle '-vg' onto the end of the triple so we +# can check it with XFAIL and XTARGET. +if lit.useValgrind: + config.target_triple += '-vg' + +# Shell execution +if platform.system() not in ['Windows'] or lit.getBashPath() != '': + config.available_features.add('shell') diff --git a/lld/test/lit.site.cfg.in b/lld/test/lit.site.cfg.in new file mode 100644 index 00000000000..43ee120d2b0 --- /dev/null +++ b/lld/test/lit.site.cfg.in @@ -0,0 +1,21 @@ +## Autogenerated by LLVM/lld configuration. +# Do not edit! +config.llvm_src_root = "@LLVM_SOURCE_DIR@" +config.llvm_obj_root = "@LLVM_BINARY_DIR@" +config.llvm_tools_dir = "@LLVM_TOOLS_DIR@" +config.llvm_libs_dir = "@LLVM_LIBS_DIR@" +config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@" +config.lld_obj_root = "@LLD_BINARY_DIR@" +config.target_triple = "@TARGET_TRIPLE@" + +# 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. +try: + config.llvm_tools_dir = config.llvm_tools_dir % lit.params + config.llvm_libs_dir = config.llvm_libs_dir % lit.params +except KeyError,e: + key, = e.args + lit.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key)) + +# Let the main config do the real work. +lit.load_config(config, "@LLD_SOURCE_DIR@/test/lit.cfg") diff --git a/lld/test/tent-merge.objtxt b/lld/test/tent-merge.objtxt new file mode 100644 index 00000000000..d2a698f318a --- /dev/null +++ b/lld/test/tent-merge.objtxt @@ -0,0 +1,24 @@ +# RUN: lld-core %s | FileCheck %s + +# +# Test that a tentative definition and a regular global are merged into +# one regular global +# + +--- +atoms: + - name: _foo + definition: tentative + type: zero-fill + size: 4 +--- +atoms: + - name: _foo + definition: regular + type: data + content: [ 00, 00, 00, 00 ] +... + + +# CHECK: name: _foo +# CHECK-NEXT: definition: regular |