From 7ce92dc0b4bcc1044052a06df3f07a94eb890823 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Fri, 10 Jan 2020 14:38:19 -0800 Subject: [PATCH] [lldb/Test] Bypass LLDB_TEST_COMMON_ARGS for certain dotest args (NFC) Rather than serializing every argument through LLDB_TEST_COMMON_ARGS, we can pass some of them directly using their CMake variable. Although this does introduce some code duplication between lit's site config and the lldb-dotest utility, it also means that it becomes easier to override these values (WIP). --- lldb/test/API/CMakeLists.txt | 8 -------- lldb/test/API/lit.cfg.py | 31 ++++++++++++++++++++++++------- lldb/test/API/lit.site.cfg.py.in | 5 +++++ lldb/utils/lldb-dotest/lldb-dotest.in | 10 ++++++++++ 4 files changed, 39 insertions(+), 15 deletions(-) diff --git a/lldb/test/API/CMakeLists.txt b/lldb/test/API/CMakeLists.txt index 45f6227..16daa1e0 100644 --- a/lldb/test/API/CMakeLists.txt +++ b/lldb/test/API/CMakeLists.txt @@ -36,7 +36,6 @@ set(LLDB_TEST_USER_ARGS # hash of filename and .text section, there *will* be conflicts inside # the build directory. set(LLDB_TEST_COMMON_ARGS - --arch=${LLDB_TEST_ARCH} -s ${CMAKE_BINARY_DIR}/lldb-test-traces -S nm @@ -66,13 +65,6 @@ if ("${LLDB_TEST_COMPILER}" STREQUAL "") message(FATAL_ERROR "LLDB test compiler not specified. Tests will not run.") endif() -list(APPEND LLDB_TEST_COMMON_ARGS - --executable ${LLDB_TEST_EXECUTABLE} - --compiler ${LLDB_TEST_COMPILER} - --dsymutil ${LLDB_TEST_DSYMUTIL} - --filecheck ${LLDB_TEST_FILECHECK} - ) - if ( CMAKE_SYSTEM_NAME MATCHES "Windows" ) # All tests are currently flaky on Windows, so rerun them all once when they fail. set(LLDB_TEST_COMMON_ARGS ${LLDB_TEST_COMMON_ARGS} --rerun-all-issues) diff --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py index 9b1c3c1..aca13b9 100644 --- a/lldb/test/API/lit.cfg.py +++ b/lldb/test/API/lit.cfg.py @@ -33,6 +33,7 @@ if 'Address' in config.llvm_use_sanitizer: 'libclang_rt.asan_osx_dynamic.dylib') config.environment['DYLD_INSERT_LIBRARIES'] = runtime + def find_shlibpath_var(): if platform.system() in ['Linux', 'FreeBSD', 'NetBSD', 'SunOS']: yield 'LD_LIBRARY_PATH' @@ -41,6 +42,7 @@ def find_shlibpath_var(): elif platform.system() == 'Windows': yield 'PATH' + # Shared library build of LLVM may require LD_LIBRARY_PATH or equivalent. if config.shared_libs: for shlibpath_var in find_shlibpath_var(): @@ -64,7 +66,7 @@ if 'LLDB_CAPTURE_REPRODUCER' in os.environ: # lit.py invocation is close enough. for cachedir in [config.clang_module_cache, config.lldb_module_cache]: if os.path.isdir(cachedir): - print("Deleting module cache at %s."%cachedir) + print("Deleting module cache at %s." % cachedir) shutil.rmtree(cachedir) # Set a default per-test timeout of 10 minutes. Setting a timeout per test @@ -78,14 +80,9 @@ else: # Build dotest command. dotest_cmd = [config.dotest_path] +dotest_cmd += ['--arch', config.test_arch] dotest_cmd.extend(config.dotest_args_str.split(';')) -# We don't want to force users passing arguments to lit to use `;` as a -# separator. We use Python's simple lexical analyzer to turn the args into a -# list. -if config.dotest_lit_args_str: - dotest_cmd.extend(shlex.split(config.dotest_lit_args_str)) - # Library path may be needed to locate just-built clang. if config.llvm_libs_dir: dotest_cmd += ['--env', 'LLVM_LIBS_DIR=' + config.llvm_libs_dir] @@ -99,6 +96,26 @@ if config.lldb_module_cache: if config.clang_module_cache: dotest_cmd += ['--clang-module-cache-dir', config.clang_module_cache] +if config.lldb_executable: + dotest_cmd += ['--executable', config.lldb_executable] + +if config.test_compiler: + dotest_cmd += ['--compiler', config.test_compiler] + +if config.dsymutil: + dotest_cmd += ['--dsymutil', config.dsymutil] + +if config.filecheck: + dotest_cmd += ['--filecheck', config.filecheck] + +# We don't want to force users passing arguments to lit to use `;` as a +# separator. We use Python's simple lexical analyzer to turn the args into a +# list. Pass there arguments last so they can override anything that was +# already configured. +if config.dotest_lit_args_str: + dotest_cmd.extend(shlex.split(config.dotest_lit_args_str)) + + # Load LLDB test format. sys.path.append(os.path.join(config.lldb_src_root, "test", "API")) import lldbtest diff --git a/lldb/test/API/lit.site.cfg.py.in b/lldb/test/API/lit.site.cfg.py.in index 374ca92..d7e2764 100644 --- a/lldb/test/API/lit.site.cfg.py.in +++ b/lldb/test/API/lit.site.cfg.py.in @@ -22,6 +22,11 @@ config.dotest_path = "@LLDB_SOURCE_DIR@/test/API/dotest.py" config.dotest_args_str = "@LLDB_DOTEST_ARGS@" config.lldb_enable_python = @LLDB_ENABLE_PYTHON@ config.dotest_lit_args_str = None +config.lldb_executable = '@LLDB_TEST_EXECUTABLE@' +config.test_arch = '@LLDB_TEST_ARCH@' +config.test_compiler = '@LLDB_TEST_COMPILER@' +config.dsymutil = '@LLDB_TEST_DSYMUTIL@' +config.filecheck = '@LLDB_TEST_FILECHECK@' # The API tests use their own module caches. config.lldb_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_LLDB@", "lldb-api") config.clang_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_CLANG@", "lldb-api") diff --git a/lldb/utils/lldb-dotest/lldb-dotest.in b/lldb/utils/lldb-dotest/lldb-dotest.in index 2032e21..bab3f8b 100755 --- a/lldb/utils/lldb-dotest/lldb-dotest.in +++ b/lldb/utils/lldb-dotest/lldb-dotest.in @@ -5,14 +5,24 @@ import sys dotest_path = '@LLDB_SOURCE_DIR@/test/API/dotest.py' build_dir = '@LLDB_TEST_BUILD_DIRECTORY@' dotest_args_str = '@LLDB_DOTEST_ARGS@' +arch = '@LLDB_TEST_ARCH@' +executable = '@LLDB_TEST_EXECUTABLE@' +compiler = '@LLDB_TEST_COMPILER@' +dsymutil = '@LLDB_TEST_DSYMUTIL@' +filecheck = '@LLDB_TEST_FILECHECK@' if __name__ == '__main__': wrapper_args = sys.argv[1:] dotest_args = dotest_args_str.split(';') # Build dotest.py command. cmd = [sys.executable, dotest_path] + cmd.extend(['--arch', arch]) cmd.extend(dotest_args) cmd.extend(['--build-dir', build_dir]) + cmd.extend(['--executable', executable]) + cmd.extend(['--compiler', compiler]) + cmd.extend(['--dsymutil', dsymutil]) + cmd.extend(['--filecheck', filecheck]) cmd.extend(wrapper_args) # Invoke dotest.py and return exit code. print(' '.join(cmd)) -- 2.7.4