Index: compiler-rt/trunk/test/asan/CMakeLists.txt =================================================================== --- compiler-rt/trunk/test/asan/CMakeLists.txt +++ compiler-rt/trunk/test/asan/CMakeLists.txt @@ -58,8 +58,8 @@ string(TOUPPER ${arch} ARCH_UPPER_CASE) set(CONFIG_NAME ${ARCH_UPPER_CASE}${OS_NAME}Config) configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in + ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py ) list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}) @@ -68,8 +68,8 @@ set(ASAN_TEST_DYNAMIC True) set(CONFIG_NAME ${ARCH_UPPER_CASE}${OS_NAME}DynamicConfig) configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg) + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in + ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py) list(APPEND ASAN_DYNAMIC_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}) endif() @@ -95,8 +95,8 @@ string(TOUPPER ${arch} ARCH_UPPER_CASE) set(CONFIG_NAME "IOSSim${ARCH_UPPER_CASE}Config") configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in + ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py ) add_lit_testsuite(check-asan-iossim-${arch} "AddressSanitizer iOS Simulator ${arch} tests" ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/ @@ -112,8 +112,8 @@ string(TOUPPER ${arch} ARCH_UPPER_CASE) set(CONFIG_NAME "IOS${ARCH_UPPER_CASE}Config") configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in + ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py ) add_lit_testsuite(check-asan-ios-${arch} "AddressSanitizer iOS ${arch} tests" ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/ @@ -127,13 +127,13 @@ if(COMPILER_RT_INCLUDE_TESTS) set(ASAN_TEST_DYNAMIC False) 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) if(COMPILER_RT_ASAN_HAS_STATIC_RUNTIME) set(ASAN_TEST_DYNAMIC True) configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/Unit/dynamic/lit.site.cfg) + ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.py.in + ${CMAKE_CURRENT_BINARY_DIR}/Unit/dynamic/lit.site.cfg.py) endif() # FIXME: support unit test in the android test runner if (NOT ANDROID) Index: compiler-rt/trunk/test/asan/TestCases/Android/lit.local.cfg =================================================================== --- compiler-rt/trunk/test/asan/TestCases/Android/lit.local.cfg +++ compiler-rt/trunk/test/asan/TestCases/Android/lit.local.cfg @@ -1,11 +0,0 @@ -def getRoot(config): - if not config.parent: - return config - return getRoot(config.parent) - -root = getRoot(config) - -if root.android != "1": - config.unsupported = True - -config.substitutions.append( ("%device", "/data/local/tmp/Output") ) Index: compiler-rt/trunk/test/asan/TestCases/Android/lit.local.cfg.py =================================================================== --- compiler-rt/trunk/test/asan/TestCases/Android/lit.local.cfg.py +++ compiler-rt/trunk/test/asan/TestCases/Android/lit.local.cfg.py @@ -0,0 +1,11 @@ +def getRoot(config): + if not config.parent: + return config + return getRoot(config.parent) + +root = getRoot(config) + +if root.android != "1": + config.unsupported = True + +config.substitutions.append( ("%device", "/data/local/tmp/Output") ) Index: compiler-rt/trunk/test/asan/TestCases/Darwin/lit.local.cfg =================================================================== --- compiler-rt/trunk/test/asan/TestCases/Darwin/lit.local.cfg +++ compiler-rt/trunk/test/asan/TestCases/Darwin/lit.local.cfg @@ -1,9 +0,0 @@ -def getRoot(config): - if not config.parent: - return config - return getRoot(config.parent) - -root = getRoot(config) - -if root.host_os not in ['Darwin']: - config.unsupported = True Index: compiler-rt/trunk/test/asan/TestCases/Darwin/lit.local.cfg.py =================================================================== --- compiler-rt/trunk/test/asan/TestCases/Darwin/lit.local.cfg.py +++ compiler-rt/trunk/test/asan/TestCases/Darwin/lit.local.cfg.py @@ -0,0 +1,9 @@ +def getRoot(config): + if not config.parent: + return config + return getRoot(config.parent) + +root = getRoot(config) + +if root.host_os not in ['Darwin']: + config.unsupported = True Index: compiler-rt/trunk/test/asan/TestCases/Helpers/lit.local.cfg =================================================================== --- compiler-rt/trunk/test/asan/TestCases/Helpers/lit.local.cfg +++ compiler-rt/trunk/test/asan/TestCases/Helpers/lit.local.cfg @@ -1,3 +0,0 @@ -# Sources in this directory are helper files for tests which test functionality -# involving multiple translation units. -config.suffixes = [] Index: compiler-rt/trunk/test/asan/TestCases/Helpers/lit.local.cfg.py =================================================================== --- compiler-rt/trunk/test/asan/TestCases/Helpers/lit.local.cfg.py +++ compiler-rt/trunk/test/asan/TestCases/Helpers/lit.local.cfg.py @@ -0,0 +1,3 @@ +# Sources in this directory are helper files for tests which test functionality +# involving multiple translation units. +config.suffixes = [] Index: compiler-rt/trunk/test/asan/TestCases/Linux/lit.local.cfg =================================================================== --- compiler-rt/trunk/test/asan/TestCases/Linux/lit.local.cfg +++ compiler-rt/trunk/test/asan/TestCases/Linux/lit.local.cfg @@ -1,9 +0,0 @@ -def getRoot(config): - if not config.parent: - return config - return getRoot(config.parent) - -root = getRoot(config) - -if root.host_os not in ['Linux']: - config.unsupported = True Index: compiler-rt/trunk/test/asan/TestCases/Linux/lit.local.cfg.py =================================================================== --- compiler-rt/trunk/test/asan/TestCases/Linux/lit.local.cfg.py +++ compiler-rt/trunk/test/asan/TestCases/Linux/lit.local.cfg.py @@ -0,0 +1,9 @@ +def getRoot(config): + if not config.parent: + return config + return getRoot(config.parent) + +root = getRoot(config) + +if root.host_os not in ['Linux']: + config.unsupported = True Index: compiler-rt/trunk/test/asan/TestCases/Posix/lit.local.cfg =================================================================== --- compiler-rt/trunk/test/asan/TestCases/Posix/lit.local.cfg +++ compiler-rt/trunk/test/asan/TestCases/Posix/lit.local.cfg @@ -1,9 +0,0 @@ -def getRoot(config): - if not config.parent: - return config - return getRoot(config.parent) - -root = getRoot(config) - -if root.host_os in ['Windows']: - config.unsupported = True Index: compiler-rt/trunk/test/asan/TestCases/Posix/lit.local.cfg.py =================================================================== --- compiler-rt/trunk/test/asan/TestCases/Posix/lit.local.cfg.py +++ compiler-rt/trunk/test/asan/TestCases/Posix/lit.local.cfg.py @@ -0,0 +1,9 @@ +def getRoot(config): + if not config.parent: + return config + return getRoot(config.parent) + +root = getRoot(config) + +if root.host_os in ['Windows']: + config.unsupported = True Index: compiler-rt/trunk/test/asan/TestCases/Windows/lit.local.cfg =================================================================== --- compiler-rt/trunk/test/asan/TestCases/Windows/lit.local.cfg +++ compiler-rt/trunk/test/asan/TestCases/Windows/lit.local.cfg @@ -1,14 +0,0 @@ -def getRoot(config): - if not config.parent: - return config - return getRoot(config.parent) - -root = getRoot(config) - -# We only run a small set of tests on Windows for now. -# Override the parent directory's "unsupported" decision until we can handle -# all of its tests. -if root.host_os in ['Windows']: - config.unsupported = False -else: - config.unsupported = True Index: compiler-rt/trunk/test/asan/TestCases/Windows/lit.local.cfg.py =================================================================== --- compiler-rt/trunk/test/asan/TestCases/Windows/lit.local.cfg.py +++ compiler-rt/trunk/test/asan/TestCases/Windows/lit.local.cfg.py @@ -0,0 +1,14 @@ +def getRoot(config): + if not config.parent: + return config + return getRoot(config.parent) + +root = getRoot(config) + +# We only run a small set of tests on Windows for now. +# Override the parent directory's "unsupported" decision until we can handle +# all of its tests. +if root.host_os in ['Windows']: + config.unsupported = False +else: + config.unsupported = True Index: compiler-rt/trunk/test/asan/Unit/lit.site.cfg.in =================================================================== --- compiler-rt/trunk/test/asan/Unit/lit.site.cfg.in +++ compiler-rt/trunk/test/asan/Unit/lit.site.cfg.in @@ -1,32 +0,0 @@ -@LIT_SITE_CFG_IN_HEADER@ - -import os - -# Load common config for all compiler-rt unit tests. -lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/unittests/lit.common.unit.configured") - -def push_ld_library_path(config, new_path): - new_ld_library_path = os.path.pathsep.join( - (new_path, config.environment.get('LD_LIBRARY_PATH', ''))) - config.environment['LD_LIBRARY_PATH'] = new_ld_library_path - -# Setup config name. -config.name = 'AddressSanitizer-Unit' - -# Setup test source and exec root. For unit tests, we define -# it as build directory with ASan unit tests. -# FIXME: De-hardcode this path. -if @ASAN_TEST_DYNAMIC@: - test_dir = "dynamic" -else: - test_dir = "default" -config.test_exec_root = os.path.join("@COMPILER_RT_BINARY_DIR@", - "lib", "asan", "tests", test_dir) - -config.test_source_root = config.test_exec_root - -# Set LD_LIBRARY_PATH to pick dynamic runtime up properly. -push_ld_library_path(config, config.compiler_rt_libdir) - -if config.host_os == 'Darwin': - config.parallelism_group = config.darwin_sanitizer_parallelism_group_func Index: compiler-rt/trunk/test/asan/Unit/lit.site.cfg.py.in =================================================================== --- compiler-rt/trunk/test/asan/Unit/lit.site.cfg.py.in +++ compiler-rt/trunk/test/asan/Unit/lit.site.cfg.py.in @@ -0,0 +1,32 @@ +@LIT_SITE_CFG_IN_HEADER@ + +import os + +# Load common config for all compiler-rt unit tests. +lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/unittests/lit.common.unit.configured") + +def push_ld_library_path(config, new_path): + new_ld_library_path = os.path.pathsep.join( + (new_path, config.environment.get('LD_LIBRARY_PATH', ''))) + config.environment['LD_LIBRARY_PATH'] = new_ld_library_path + +# Setup config name. +config.name = 'AddressSanitizer-Unit' + +# Setup test source and exec root. For unit tests, we define +# it as build directory with ASan unit tests. +# FIXME: De-hardcode this path. +if @ASAN_TEST_DYNAMIC@: + test_dir = "dynamic" +else: + test_dir = "default" +config.test_exec_root = os.path.join("@COMPILER_RT_BINARY_DIR@", + "lib", "asan", "tests", test_dir) + +config.test_source_root = config.test_exec_root + +# Set LD_LIBRARY_PATH to pick dynamic runtime up properly. +push_ld_library_path(config, config.compiler_rt_libdir) + +if config.host_os == 'Darwin': + config.parallelism_group = config.darwin_sanitizer_parallelism_group_func Index: compiler-rt/trunk/test/asan/lit.cfg =================================================================== --- compiler-rt/trunk/test/asan/lit.cfg +++ compiler-rt/trunk/test/asan/lit.cfg @@ -1,232 +0,0 @@ -# -*- Python -*- - -import os -import platform -import re - -import lit.formats - -# Get shlex.quote if available (added in 3.3), and fall back to pipes.quote if -# it's not available. -try: - import shlex - sh_quote = shlex.quote -except: - import pipes - sh_quote = pipes.quote - -def get_required_attr(config, attr_name): - attr_value = getattr(config, attr_name, None) - if attr_value == None: - lit_config.fatal( - "No attribute %r in test configuration! You may need to run " - "tests from your build directory or add this attribute " - "to lit.site.cfg " % attr_name) - return attr_value - -def push_dynamic_library_lookup_path(config, new_path): - if platform.system() == 'Windows': - dynamic_library_lookup_var = 'PATH' - elif platform.system() == 'Darwin': - dynamic_library_lookup_var = 'DYLD_LIBRARY_PATH' - else: - dynamic_library_lookup_var = 'LD_LIBRARY_PATH' - - new_ld_library_path = os.path.pathsep.join( - (new_path, config.environment.get(dynamic_library_lookup_var, ''))) - config.environment[dynamic_library_lookup_var] = new_ld_library_path - -# Setup config name. -config.name = 'AddressSanitizer' + config.name_suffix - -# Platform-specific default ASAN_OPTIONS for lit tests. -default_asan_opts = list(config.default_sanitizer_opts) - -# On Darwin, leak checking is not enabled by default. Enable for x86_64 -# tests to prevent regressions -if config.host_os == 'Darwin' and config.target_arch == 'x86_64': - default_asan_opts += ['detect_leaks=1'] - -default_asan_opts_str = ':'.join(default_asan_opts) -if default_asan_opts_str: - config.environment['ASAN_OPTIONS'] = default_asan_opts_str - default_asan_opts_str += ':' -config.substitutions.append(('%env_asan_opts=', - 'env ASAN_OPTIONS=' + default_asan_opts_str)) - -# Setup source root. -config.test_source_root = os.path.dirname(__file__) - -if config.host_os not in ['FreeBSD', 'NetBSD']: - libdl_flag = "-ldl" -else: - libdl_flag = "" - -# GCC-ASan doesn't link in all the necessary libraries automatically, so -# we have to do it ourselves. -if config.compiler_id == 'GNU': - extra_link_flags = ["-pthread", "-lstdc++", libdl_flag] -else: - extra_link_flags = [] - -# Setup default compiler flags used with -fsanitize=address option. -# FIXME: Review the set of required flags and check if it can be reduced. -target_cflags = [get_required_attr(config, "target_cflags")] + extra_link_flags -target_cxxflags = config.cxx_mode_flags + target_cflags -clang_asan_static_cflags = (["-fsanitize=address", - "-mno-omit-leaf-frame-pointer", - "-fno-omit-frame-pointer", - "-fno-optimize-sibling-calls"] + - config.debug_info_flags + target_cflags) -if config.target_arch == 's390x': - clang_asan_static_cflags.append("-mbackchain") -clang_asan_static_cxxflags = config.cxx_mode_flags + clang_asan_static_cflags - -asan_dynamic_flags = [] -if config.asan_dynamic: - asan_dynamic_flags = ["-shared-libasan"] - # On Windows, we need to simulate "clang-cl /MD" on the clang driver side. - if platform.system() == 'Windows': - asan_dynamic_flags += ["-D_MT", "-D_DLL", "-Wl,-nodefaultlib:libcmt,-defaultlib:msvcrt,-defaultlib:oldnames"] - config.available_features.add("asan-dynamic-runtime") -else: - config.available_features.add("asan-static-runtime") -clang_asan_cflags = clang_asan_static_cflags + asan_dynamic_flags -clang_asan_cxxflags = clang_asan_static_cxxflags + asan_dynamic_flags - -# Add win32-(static|dynamic)-asan features to mark tests as passing or failing -# in those modes. lit doesn't support logical feature test combinations. -if platform.system() == 'Windows': - if config.asan_dynamic: - win_runtime_feature = "win32-dynamic-asan" - else: - win_runtime_feature = "win32-static-asan" - config.available_features.add(win_runtime_feature) - -def build_invocation(compile_flags): - return " " + " ".join([config.clang] + compile_flags) + " " - -config.substitutions.append( ("%clang ", build_invocation(target_cflags)) ) -config.substitutions.append( ("%clangxx ", build_invocation(target_cxxflags)) ) -config.substitutions.append( ("%clang_asan ", build_invocation(clang_asan_cflags)) ) -config.substitutions.append( ("%clangxx_asan ", build_invocation(clang_asan_cxxflags)) ) -if config.asan_dynamic: - if config.host_os in ['Linux', 'NetBSD', 'SunOS']: - shared_libasan_path = os.path.join(config.compiler_rt_libdir, "libclang_rt.asan{}.so".format(config.target_suffix)) - elif config.host_os == 'Darwin': - shared_libasan_path = os.path.join(config.compiler_rt_libdir, 'libclang_rt.asan_{}_dynamic.dylib'.format(config.apple_platform)) - else: - lit_config.warning('%shared_libasan substitution not set but dynamic ASan is available.') - shared_libasan_path = None - - if shared_libasan_path is not None: - config.substitutions.append( ("%shared_libasan", shared_libasan_path) ) - config.substitutions.append( ("%clang_asan_static ", build_invocation(clang_asan_static_cflags)) ) - config.substitutions.append( ("%clangxx_asan_static ", build_invocation(clang_asan_static_cxxflags)) ) - -# Windows-specific tests might also use the clang-cl.exe driver. -if platform.system() == 'Windows': - clang_cl_cxxflags = ["-Wno-deprecated-declarations", - "-WX", - "-D_HAS_EXCEPTIONS=0", - "-Zi"] + target_cflags - clang_cl_asan_cxxflags = ["-fsanitize=address"] + clang_cl_cxxflags - if config.asan_dynamic: - clang_cl_asan_cxxflags.append("-MD") - - clang_cl_invocation = build_invocation(clang_cl_cxxflags) - clang_cl_invocation = clang_cl_invocation.replace("clang.exe","clang-cl.exe") - config.substitutions.append( ("%clang_cl ", clang_cl_invocation) ) - - clang_cl_asan_invocation = build_invocation(clang_cl_asan_cxxflags) - clang_cl_asan_invocation = clang_cl_asan_invocation.replace("clang.exe","clang-cl.exe") - config.substitutions.append( ("%clang_cl_asan ", clang_cl_asan_invocation) ) - - base_lib = os.path.join(config.compiler_rt_libdir, "clang_rt.asan%%s%s.lib" % config.target_suffix) - config.substitutions.append( ("%asan_lib", base_lib % "") ) - config.substitutions.append( ("%asan_cxx_lib", base_lib % "_cxx") ) - config.substitutions.append( ("%asan_dll_thunk", base_lib % "_dll_thunk") ) - -if platform.system() == 'Windows': - # Don't use -std=c++11 on Windows, as the driver will detect the appropriate - # default needed to use with the STL. - config.substitutions.append(("%stdcxx11 ", "")) -else: - # Some tests uses C++11 features such as lambdas and need to pass -std=c++11. - config.substitutions.append(("%stdcxx11 ", "-std=c++11 ")) - -# FIXME: De-hardcode this path. -asan_source_dir = os.path.join( - get_required_attr(config, "compiler_rt_src_root"), "lib", "asan") -python_exec = sh_quote(get_required_attr(config, "python_executable")) -# Setup path to asan_symbolize.py script. -asan_symbolize = os.path.join(asan_source_dir, "scripts", "asan_symbolize.py") -if not os.path.exists(asan_symbolize): - lit_config.fatal("Can't find script on path %r" % asan_symbolize) -config.substitutions.append( ("%asan_symbolize", python_exec + " " + asan_symbolize + " ") ) -# Setup path to sancov.py script. -sanitizer_common_source_dir = os.path.join( - get_required_attr(config, "compiler_rt_src_root"), "lib", "sanitizer_common") -sancov = os.path.join(sanitizer_common_source_dir, "scripts", "sancov.py") -if not os.path.exists(sancov): - lit_config.fatal("Can't find script on path %r" % sancov) -config.substitutions.append( ("%sancov ", python_exec + " " + sancov + " ") ) - -# Determine kernel bitness -if config.host_arch.find('64') != -1 and not config.android: - kernel_bits = '64' -else: - kernel_bits = '32' - -config.substitutions.append( ('CHECK-%kernel_bits', ("CHECK-kernel-" + kernel_bits + "-bits"))) - -config.substitutions.append( ("%libdl", libdl_flag) ) - -config.available_features.add("asan-" + config.bits + "-bits") - -# Fast unwinder doesn't work with Thumb -if re.search('mthumb', config.target_cflags) is None: - config.available_features.add('fast-unwinder-works') - -# Turn on leak detection on 64-bit Linux. -leak_detection_linux = (config.host_os == 'Linux') and (not config.android) and (config.target_arch == 'x86_64' or config.target_arch == 'i386') -leak_detection_mac = (config.host_os == 'Darwin') and (config.target_arch == 'x86_64') -if leak_detection_linux or leak_detection_mac: - config.available_features.add('leak-detection') - -# Set LD_LIBRARY_PATH to pick dynamic runtime up properly. -push_dynamic_library_lookup_path(config, config.compiler_rt_libdir) - -# GCC-ASan uses dynamic runtime by default. -if config.compiler_id == 'GNU': - gcc_dir = os.path.dirname(config.clang) - libasan_dir = os.path.join(gcc_dir, "..", "lib" + config.bits) - push_dynamic_library_lookup_path(config, libasan_dir) - -# Add the RT libdir to PATH directly so that we can successfully run the gtest -# binary to list its tests. -if config.host_os == 'Windows' and config.asan_dynamic: - os.environ['PATH'] = os.path.pathsep.join([config.compiler_rt_libdir, - os.environ.get('PATH', '')]) - -# Default test suffixes. -config.suffixes = ['.c', '.cc', '.cpp'] - -if config.host_os == 'Darwin': - config.suffixes.append('.mm') - -if config.host_os == 'Windows': - config.substitutions.append(('%fPIC', '')) - config.substitutions.append(('%fPIE', '')) - config.substitutions.append(('%pie', '')) -else: - config.substitutions.append(('%fPIC', '-fPIC')) - config.substitutions.append(('%fPIE', '-fPIE')) - config.substitutions.append(('%pie', '-pie')) - -# Only run the tests on supported OSs. -if config.host_os not in ['Linux', 'Darwin', 'FreeBSD', 'SunOS', 'Windows', 'NetBSD']: - config.unsupported = True - -if not config.parallelism_group: - config.parallelism_group = 'shadow-memory' Index: compiler-rt/trunk/test/asan/lit.cfg.py =================================================================== --- compiler-rt/trunk/test/asan/lit.cfg.py +++ compiler-rt/trunk/test/asan/lit.cfg.py @@ -0,0 +1,232 @@ +# -*- Python -*- + +import os +import platform +import re + +import lit.formats + +# Get shlex.quote if available (added in 3.3), and fall back to pipes.quote if +# it's not available. +try: + import shlex + sh_quote = shlex.quote +except: + import pipes + sh_quote = pipes.quote + +def get_required_attr(config, attr_name): + attr_value = getattr(config, attr_name, None) + if attr_value == None: + lit_config.fatal( + "No attribute %r in test configuration! You may need to run " + "tests from your build directory or add this attribute " + "to lit.site.cfg.py " % attr_name) + return attr_value + +def push_dynamic_library_lookup_path(config, new_path): + if platform.system() == 'Windows': + dynamic_library_lookup_var = 'PATH' + elif platform.system() == 'Darwin': + dynamic_library_lookup_var = 'DYLD_LIBRARY_PATH' + else: + dynamic_library_lookup_var = 'LD_LIBRARY_PATH' + + new_ld_library_path = os.path.pathsep.join( + (new_path, config.environment.get(dynamic_library_lookup_var, ''))) + config.environment[dynamic_library_lookup_var] = new_ld_library_path + +# Setup config name. +config.name = 'AddressSanitizer' + config.name_suffix + +# Platform-specific default ASAN_OPTIONS for lit tests. +default_asan_opts = list(config.default_sanitizer_opts) + +# On Darwin, leak checking is not enabled by default. Enable for x86_64 +# tests to prevent regressions +if config.host_os == 'Darwin' and config.target_arch == 'x86_64': + default_asan_opts += ['detect_leaks=1'] + +default_asan_opts_str = ':'.join(default_asan_opts) +if default_asan_opts_str: + config.environment['ASAN_OPTIONS'] = default_asan_opts_str + default_asan_opts_str += ':' +config.substitutions.append(('%env_asan_opts=', + 'env ASAN_OPTIONS=' + default_asan_opts_str)) + +# Setup source root. +config.test_source_root = os.path.dirname(__file__) + +if config.host_os not in ['FreeBSD', 'NetBSD']: + libdl_flag = "-ldl" +else: + libdl_flag = "" + +# GCC-ASan doesn't link in all the necessary libraries automatically, so +# we have to do it ourselves. +if config.compiler_id == 'GNU': + extra_link_flags = ["-pthread", "-lstdc++", libdl_flag] +else: + extra_link_flags = [] + +# Setup default compiler flags used with -fsanitize=address option. +# FIXME: Review the set of required flags and check if it can be reduced. +target_cflags = [get_required_attr(config, "target_cflags")] + extra_link_flags +target_cxxflags = config.cxx_mode_flags + target_cflags +clang_asan_static_cflags = (["-fsanitize=address", + "-mno-omit-leaf-frame-pointer", + "-fno-omit-frame-pointer", + "-fno-optimize-sibling-calls"] + + config.debug_info_flags + target_cflags) +if config.target_arch == 's390x': + clang_asan_static_cflags.append("-mbackchain") +clang_asan_static_cxxflags = config.cxx_mode_flags + clang_asan_static_cflags + +asan_dynamic_flags = [] +if config.asan_dynamic: + asan_dynamic_flags = ["-shared-libasan"] + # On Windows, we need to simulate "clang-cl /MD" on the clang driver side. + if platform.system() == 'Windows': + asan_dynamic_flags += ["-D_MT", "-D_DLL", "-Wl,-nodefaultlib:libcmt,-defaultlib:msvcrt,-defaultlib:oldnames"] + config.available_features.add("asan-dynamic-runtime") +else: + config.available_features.add("asan-static-runtime") +clang_asan_cflags = clang_asan_static_cflags + asan_dynamic_flags +clang_asan_cxxflags = clang_asan_static_cxxflags + asan_dynamic_flags + +# Add win32-(static|dynamic)-asan features to mark tests as passing or failing +# in those modes. lit doesn't support logical feature test combinations. +if platform.system() == 'Windows': + if config.asan_dynamic: + win_runtime_feature = "win32-dynamic-asan" + else: + win_runtime_feature = "win32-static-asan" + config.available_features.add(win_runtime_feature) + +def build_invocation(compile_flags): + return " " + " ".join([config.clang] + compile_flags) + " " + +config.substitutions.append( ("%clang ", build_invocation(target_cflags)) ) +config.substitutions.append( ("%clangxx ", build_invocation(target_cxxflags)) ) +config.substitutions.append( ("%clang_asan ", build_invocation(clang_asan_cflags)) ) +config.substitutions.append( ("%clangxx_asan ", build_invocation(clang_asan_cxxflags)) ) +if config.asan_dynamic: + if config.host_os in ['Linux', 'NetBSD', 'SunOS']: + shared_libasan_path = os.path.join(config.compiler_rt_libdir, "libclang_rt.asan{}.so".format(config.target_suffix)) + elif config.host_os == 'Darwin': + shared_libasan_path = os.path.join(config.compiler_rt_libdir, 'libclang_rt.asan_{}_dynamic.dylib'.format(config.apple_platform)) + else: + lit_config.warning('%shared_libasan substitution not set but dynamic ASan is available.') + shared_libasan_path = None + + if shared_libasan_path is not None: + config.substitutions.append( ("%shared_libasan", shared_libasan_path) ) + config.substitutions.append( ("%clang_asan_static ", build_invocation(clang_asan_static_cflags)) ) + config.substitutions.append( ("%clangxx_asan_static ", build_invocation(clang_asan_static_cxxflags)) ) + +# Windows-specific tests might also use the clang-cl.exe driver. +if platform.system() == 'Windows': + clang_cl_cxxflags = ["-Wno-deprecated-declarations", + "-WX", + "-D_HAS_EXCEPTIONS=0", + "-Zi"] + target_cflags + clang_cl_asan_cxxflags = ["-fsanitize=address"] + clang_cl_cxxflags + if config.asan_dynamic: + clang_cl_asan_cxxflags.append("-MD") + + clang_cl_invocation = build_invocation(clang_cl_cxxflags) + clang_cl_invocation = clang_cl_invocation.replace("clang.exe","clang-cl.exe") + config.substitutions.append( ("%clang_cl ", clang_cl_invocation) ) + + clang_cl_asan_invocation = build_invocation(clang_cl_asan_cxxflags) + clang_cl_asan_invocation = clang_cl_asan_invocation.replace("clang.exe","clang-cl.exe") + config.substitutions.append( ("%clang_cl_asan ", clang_cl_asan_invocation) ) + + base_lib = os.path.join(config.compiler_rt_libdir, "clang_rt.asan%%s%s.lib" % config.target_suffix) + config.substitutions.append( ("%asan_lib", base_lib % "") ) + config.substitutions.append( ("%asan_cxx_lib", base_lib % "_cxx") ) + config.substitutions.append( ("%asan_dll_thunk", base_lib % "_dll_thunk") ) + +if platform.system() == 'Windows': + # Don't use -std=c++11 on Windows, as the driver will detect the appropriate + # default needed to use with the STL. + config.substitutions.append(("%stdcxx11 ", "")) +else: + # Some tests uses C++11 features such as lambdas and need to pass -std=c++11. + config.substitutions.append(("%stdcxx11 ", "-std=c++11 ")) + +# FIXME: De-hardcode this path. +asan_source_dir = os.path.join( + get_required_attr(config, "compiler_rt_src_root"), "lib", "asan") +python_exec = sh_quote(get_required_attr(config, "python_executable")) +# Setup path to asan_symbolize.py script. +asan_symbolize = os.path.join(asan_source_dir, "scripts", "asan_symbolize.py") +if not os.path.exists(asan_symbolize): + lit_config.fatal("Can't find script on path %r" % asan_symbolize) +config.substitutions.append( ("%asan_symbolize", python_exec + " " + asan_symbolize + " ") ) +# Setup path to sancov.py script. +sanitizer_common_source_dir = os.path.join( + get_required_attr(config, "compiler_rt_src_root"), "lib", "sanitizer_common") +sancov = os.path.join(sanitizer_common_source_dir, "scripts", "sancov.py") +if not os.path.exists(sancov): + lit_config.fatal("Can't find script on path %r" % sancov) +config.substitutions.append( ("%sancov ", python_exec + " " + sancov + " ") ) + +# Determine kernel bitness +if config.host_arch.find('64') != -1 and not config.android: + kernel_bits = '64' +else: + kernel_bits = '32' + +config.substitutions.append( ('CHECK-%kernel_bits', ("CHECK-kernel-" + kernel_bits + "-bits"))) + +config.substitutions.append( ("%libdl", libdl_flag) ) + +config.available_features.add("asan-" + config.bits + "-bits") + +# Fast unwinder doesn't work with Thumb +if re.search('mthumb', config.target_cflags) is None: + config.available_features.add('fast-unwinder-works') + +# Turn on leak detection on 64-bit Linux. +leak_detection_linux = (config.host_os == 'Linux') and (not config.android) and (config.target_arch == 'x86_64' or config.target_arch == 'i386') +leak_detection_mac = (config.host_os == 'Darwin') and (config.target_arch == 'x86_64') +if leak_detection_linux or leak_detection_mac: + config.available_features.add('leak-detection') + +# Set LD_LIBRARY_PATH to pick dynamic runtime up properly. +push_dynamic_library_lookup_path(config, config.compiler_rt_libdir) + +# GCC-ASan uses dynamic runtime by default. +if config.compiler_id == 'GNU': + gcc_dir = os.path.dirname(config.clang) + libasan_dir = os.path.join(gcc_dir, "..", "lib" + config.bits) + push_dynamic_library_lookup_path(config, libasan_dir) + +# Add the RT libdir to PATH directly so that we can successfully run the gtest +# binary to list its tests. +if config.host_os == 'Windows' and config.asan_dynamic: + os.environ['PATH'] = os.path.pathsep.join([config.compiler_rt_libdir, + os.environ.get('PATH', '')]) + +# Default test suffixes. +config.suffixes = ['.c', '.cc', '.cpp'] + +if config.host_os == 'Darwin': + config.suffixes.append('.mm') + +if config.host_os == 'Windows': + config.substitutions.append(('%fPIC', '')) + config.substitutions.append(('%fPIE', '')) + config.substitutions.append(('%pie', '')) +else: + config.substitutions.append(('%fPIC', '-fPIC')) + config.substitutions.append(('%fPIE', '-fPIE')) + config.substitutions.append(('%pie', '-pie')) + +# Only run the tests on supported OSs. +if config.host_os not in ['Linux', 'Darwin', 'FreeBSD', 'SunOS', 'Windows', 'NetBSD']: + config.unsupported = True + +if not config.parallelism_group: + config.parallelism_group = 'shadow-memory' Index: compiler-rt/trunk/test/asan/lit.site.cfg.in =================================================================== --- compiler-rt/trunk/test/asan/lit.site.cfg.in +++ compiler-rt/trunk/test/asan/lit.site.cfg.in @@ -1,16 +0,0 @@ -@LIT_SITE_CFG_IN_HEADER@ - -# Tool-specific config options. -config.name_suffix = "@ASAN_TEST_CONFIG_SUFFIX@" -config.target_cflags = "@ASAN_TEST_TARGET_CFLAGS@" -config.clang = "@ASAN_TEST_TARGET_CC@" -config.bits = "@ASAN_TEST_BITS@" -config.apple_platform = "@ASAN_TEST_APPLE_PLATFORM@" -config.asan_dynamic = @ASAN_TEST_DYNAMIC@ -config.target_arch = "@ASAN_TEST_TARGET_ARCH@" - -# Load common config for all compiler-rt lit tests. -lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") - -# Load tool-specific config that would do the real work. -lit_config.load_config(config, "@ASAN_LIT_SOURCE_DIR@/lit.cfg") Index: compiler-rt/trunk/test/asan/lit.site.cfg.py.in =================================================================== --- compiler-rt/trunk/test/asan/lit.site.cfg.py.in +++ compiler-rt/trunk/test/asan/lit.site.cfg.py.in @@ -0,0 +1,16 @@ +@LIT_SITE_CFG_IN_HEADER@ + +# Tool-specific config options. +config.name_suffix = "@ASAN_TEST_CONFIG_SUFFIX@" +config.target_cflags = "@ASAN_TEST_TARGET_CFLAGS@" +config.clang = "@ASAN_TEST_TARGET_CC@" +config.bits = "@ASAN_TEST_BITS@" +config.apple_platform = "@ASAN_TEST_APPLE_PLATFORM@" +config.asan_dynamic = @ASAN_TEST_DYNAMIC@ +config.target_arch = "@ASAN_TEST_TARGET_ARCH@" + +# Load common config for all compiler-rt lit tests. +lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") + +# Load tool-specific config that would do the real work. +lit_config.load_config(config, "@ASAN_LIT_SOURCE_DIR@/lit.cfg.py") Index: compiler-rt/trunk/test/builtins/CMakeLists.txt =================================================================== --- compiler-rt/trunk/test/builtins/CMakeLists.txt +++ compiler-rt/trunk/test/builtins/CMakeLists.txt @@ -5,8 +5,8 @@ # Test cases. 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 ) #Unit tests. @@ -44,8 +44,8 @@ string(TOUPPER ${arch} ARCH_UPPER_CASE) set(CONFIG_NAME ${ARCH_UPPER_CASE}${OS_NAME}Config) configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/Unit/${CONFIG_NAME}/lit.site.cfg + ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.py.in + ${CMAKE_CURRENT_BINARY_DIR}/Unit/${CONFIG_NAME}/lit.site.cfg.py ) list(APPEND BUILTINS_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/Unit/${CONFIG_NAME}) endforeach() Index: compiler-rt/trunk/test/builtins/TestCases/Darwin/lit.local.cfg =================================================================== --- compiler-rt/trunk/test/builtins/TestCases/Darwin/lit.local.cfg +++ compiler-rt/trunk/test/builtins/TestCases/Darwin/lit.local.cfg @@ -1,9 +0,0 @@ -def getRoot(config): - if not config.parent: - return config - return getRoot(config.parent) - -root = getRoot(config) - -if root.host_os not in ['Darwin']: - config.unsupported = True Index: compiler-rt/trunk/test/builtins/TestCases/Darwin/lit.local.cfg.py =================================================================== --- compiler-rt/trunk/test/builtins/TestCases/Darwin/lit.local.cfg.py +++ compiler-rt/trunk/test/builtins/TestCases/Darwin/lit.local.cfg.py @@ -0,0 +1,9 @@ +def getRoot(config): + if not config.parent: + return config + return getRoot(config.parent) + +root = getRoot(config) + +if root.host_os not in ['Darwin']: + config.unsupported = True Index: compiler-rt/trunk/test/builtins/Unit/lit.cfg =================================================================== --- compiler-rt/trunk/test/builtins/Unit/lit.cfg +++ compiler-rt/trunk/test/builtins/Unit/lit.cfg @@ -1,93 +0,0 @@ -# -*- Python -*- - -import os -import platform - -import lit.formats - -def get_required_attr(config, attr_name): - attr_value = getattr(config, attr_name, None) - if attr_value == None: - lit_config.fatal( - "No attribute %r in test configuration! You may need to run " - "tests from your build directory or add this attribute " - "to lit.site.cfg " % attr_name) - return attr_value - -# Setup config name. -config.name = 'Builtins' + config.name_suffix - -# Platform-specific default Builtins_OPTIONS for lit tests. -default_builtins_opts = '' - -# Setup source root. -config.test_source_root = os.path.dirname(__file__) - -# Path to the static library -is_msvc = get_required_attr(config, "is_msvc") -if is_msvc: - base_lib = os.path.join(config.compiler_rt_libdir, "clang_rt.builtins%s.lib " - % config.target_suffix) - config.substitutions.append( ("%librt ", base_lib) ) -else: - base_lib = os.path.join(config.compiler_rt_libdir, "libclang_rt.builtins%s.a" - % config.target_suffix) - config.substitutions.append( ("%librt ", base_lib + ' -lc -lm ') ) - -builtins_source_dir = os.path.join( - get_required_attr(config, "compiler_rt_src_root"), "lib", "builtins") -builtins_lit_source_dir = get_required_attr(config, "builtins_lit_source_dir") - -extra_link_flags = ["-nodefaultlibs"] - -target_cflags = [get_required_attr(config, "target_cflags")] -target_cflags += ['-fno-builtin', '-I', builtins_source_dir] -target_cflags += extra_link_flags -target_cxxflags = config.cxx_mode_flags + target_cflags -clang_builtins_static_cflags = ([""] + - config.debug_info_flags + target_cflags) -clang_builtins_static_cxxflags = config.cxx_mode_flags + \ - clang_builtins_static_cflags - -clang_builtins_cflags = clang_builtins_static_cflags -clang_builtins_cxxflags = clang_builtins_static_cxxflags - -# FIXME: Right now we don't compile the C99 complex builtins when using -# clang-cl. Fix that. -if not is_msvc: - config.available_features.add('c99-complex') - -builtins_is_msvc = get_required_attr(config, "builtins_is_msvc") -if not builtins_is_msvc: - config.available_features.add('int128') - -clang_wrapper = "" - -def build_invocation(compile_flags): - return " " + " ".join([clang_wrapper, config.clang] + compile_flags) + " " - - -target_arch = config.target_arch -if (target_arch == "arm"): - target_arch = "armv7" - -config.substitutions.append( ("%clang ", build_invocation(target_cflags)) ) -config.substitutions.append( ("%clangxx ", build_invocation(target_cxxflags)) ) -config.substitutions.append( ("%clang_builtins ", \ - build_invocation(clang_builtins_cflags))) -config.substitutions.append( ("%clangxx_builtins ", \ - build_invocation(clang_builtins_cxxflags))) - -# FIXME: move the call_apsr.s into call_apsr.h as inline-asm. -# some ARM tests needs call_apsr.s -call_apsr_source = os.path.join(builtins_lit_source_dir, 'arm', 'call_apsr.S') -march_flag = '-march=' + target_arch -call_apsr_flags = ['-c', march_flag, call_apsr_source] -config.substitutions.append( ("%arm_call_apsr ", \ - build_invocation(call_apsr_flags)) ) - -# Default test suffixes. -config.suffixes = ['.c', '.cc', '.cpp'] - -if not config.emulator: - config.available_features.add('native-run') Index: compiler-rt/trunk/test/builtins/Unit/lit.cfg.py =================================================================== --- compiler-rt/trunk/test/builtins/Unit/lit.cfg.py +++ compiler-rt/trunk/test/builtins/Unit/lit.cfg.py @@ -0,0 +1,93 @@ +# -*- Python -*- + +import os +import platform + +import lit.formats + +def get_required_attr(config, attr_name): + attr_value = getattr(config, attr_name, None) + if attr_value == None: + lit_config.fatal( + "No attribute %r in test configuration! You may need to run " + "tests from your build directory or add this attribute " + "to lit.site.cfg.py " % attr_name) + return attr_value + +# Setup config name. +config.name = 'Builtins' + config.name_suffix + +# Platform-specific default Builtins_OPTIONS for lit tests. +default_builtins_opts = '' + +# Setup source root. +config.test_source_root = os.path.dirname(__file__) + +# Path to the static library +is_msvc = get_required_attr(config, "is_msvc") +if is_msvc: + base_lib = os.path.join(config.compiler_rt_libdir, "clang_rt.builtins%s.lib " + % config.target_suffix) + config.substitutions.append( ("%librt ", base_lib) ) +else: + base_lib = os.path.join(config.compiler_rt_libdir, "libclang_rt.builtins%s.a" + % config.target_suffix) + config.substitutions.append( ("%librt ", base_lib + ' -lc -lm ') ) + +builtins_source_dir = os.path.join( + get_required_attr(config, "compiler_rt_src_root"), "lib", "builtins") +builtins_lit_source_dir = get_required_attr(config, "builtins_lit_source_dir") + +extra_link_flags = ["-nodefaultlibs"] + +target_cflags = [get_required_attr(config, "target_cflags")] +target_cflags += ['-fno-builtin', '-I', builtins_source_dir] +target_cflags += extra_link_flags +target_cxxflags = config.cxx_mode_flags + target_cflags +clang_builtins_static_cflags = ([""] + + config.debug_info_flags + target_cflags) +clang_builtins_static_cxxflags = config.cxx_mode_flags + \ + clang_builtins_static_cflags + +clang_builtins_cflags = clang_builtins_static_cflags +clang_builtins_cxxflags = clang_builtins_static_cxxflags + +# FIXME: Right now we don't compile the C99 complex builtins when using +# clang-cl. Fix that. +if not is_msvc: + config.available_features.add('c99-complex') + +builtins_is_msvc = get_required_attr(config, "builtins_is_msvc") +if not builtins_is_msvc: + config.available_features.add('int128') + +clang_wrapper = "" + +def build_invocation(compile_flags): + return " " + " ".join([clang_wrapper, config.clang] + compile_flags) + " " + + +target_arch = config.target_arch +if (target_arch == "arm"): + target_arch = "armv7" + +config.substitutions.append( ("%clang ", build_invocation(target_cflags)) ) +config.substitutions.append( ("%clangxx ", build_invocation(target_cxxflags)) ) +config.substitutions.append( ("%clang_builtins ", \ + build_invocation(clang_builtins_cflags))) +config.substitutions.append( ("%clangxx_builtins ", \ + build_invocation(clang_builtins_cxxflags))) + +# FIXME: move the call_apsr.s into call_apsr.h as inline-asm. +# some ARM tests needs call_apsr.s +call_apsr_source = os.path.join(builtins_lit_source_dir, 'arm', 'call_apsr.S') +march_flag = '-march=' + target_arch +call_apsr_flags = ['-c', march_flag, call_apsr_source] +config.substitutions.append( ("%arm_call_apsr ", \ + build_invocation(call_apsr_flags)) ) + +# Default test suffixes. +config.suffixes = ['.c', '.cc', '.cpp'] + +if not config.emulator: + config.available_features.add('native-run') Index: compiler-rt/trunk/test/builtins/Unit/lit.site.cfg.in =================================================================== --- compiler-rt/trunk/test/builtins/Unit/lit.site.cfg.in +++ compiler-rt/trunk/test/builtins/Unit/lit.site.cfg.in @@ -1,13 +0,0 @@ -@LIT_SITE_CFG_IN_HEADER@ - -config.name_suffix = "@BUILTINS_TEST_CONFIG_SUFFIX@" -config.builtins_lit_source_dir = "@BUILTINS_LIT_SOURCE_DIR@/Unit" -config.target_cflags = "@BUILTINS_TEST_TARGET_CFLAGS@" -config.target_arch = "@BUILTINS_TEST_TARGET_ARCH@" -config.is_msvc = @MSVC_PYBOOL@ -config.builtins_is_msvc = @BUILTINS_IS_MSVC_PYBOOL@ -# Load common config for all compiler-rt lit tests. -lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") - -# Load tool-specific config that would do the real work. -lit_config.load_config(config, "@BUILTINS_LIT_SOURCE_DIR@/Unit/lit.cfg") Index: compiler-rt/trunk/test/builtins/Unit/lit.site.cfg.py.in =================================================================== --- compiler-rt/trunk/test/builtins/Unit/lit.site.cfg.py.in +++ compiler-rt/trunk/test/builtins/Unit/lit.site.cfg.py.in @@ -0,0 +1,13 @@ +@LIT_SITE_CFG_IN_HEADER@ + +config.name_suffix = "@BUILTINS_TEST_CONFIG_SUFFIX@" +config.builtins_lit_source_dir = "@BUILTINS_LIT_SOURCE_DIR@/Unit" +config.target_cflags = "@BUILTINS_TEST_TARGET_CFLAGS@" +config.target_arch = "@BUILTINS_TEST_TARGET_ARCH@" +config.is_msvc = @MSVC_PYBOOL@ +config.builtins_is_msvc = @BUILTINS_IS_MSVC_PYBOOL@ +# Load common config for all compiler-rt lit tests. +lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") + +# Load tool-specific config that would do the real work. +lit_config.load_config(config, "@BUILTINS_LIT_SOURCE_DIR@/Unit/lit.cfg.py") Index: compiler-rt/trunk/test/builtins/lit.cfg =================================================================== --- compiler-rt/trunk/test/builtins/lit.cfg +++ compiler-rt/trunk/test/builtins/lit.cfg @@ -1,20 +0,0 @@ -# -*- Python -*- - -import os - -# Setup config name. -config.name = 'Builtins' - -# Setup source root. -config.test_source_root = os.path.dirname(__file__) - -# Test suffixes. -config.suffixes = ['.c', '.cc', '.cpp', '.m', '.mm'] - -# Define %clang and %clangxx substitutions to use in test RUN lines. -config.substitutions.append( ("%clang ", " " + config.clang + " ") ) - -if config.host_os == 'Darwin': - config.substitutions.append( ("%macos_version_major", str(config.darwin_osx_version[0])) ) - config.substitutions.append( ("%macos_version_minor", str(config.darwin_osx_version[1])) ) - config.substitutions.append( ("%macos_version_subminor", str(config.darwin_osx_version[2])) ) Index: compiler-rt/trunk/test/builtins/lit.cfg.py =================================================================== --- compiler-rt/trunk/test/builtins/lit.cfg.py +++ compiler-rt/trunk/test/builtins/lit.cfg.py @@ -0,0 +1,20 @@ +# -*- Python -*- + +import os + +# Setup config name. +config.name = 'Builtins' + +# Setup source root. +config.test_source_root = os.path.dirname(__file__) + +# Test suffixes. +config.suffixes = ['.c', '.cc', '.cpp', '.m', '.mm'] + +# Define %clang and %clangxx substitutions to use in test RUN lines. +config.substitutions.append( ("%clang ", " " + config.clang + " ") ) + +if config.host_os == 'Darwin': + config.substitutions.append( ("%macos_version_major", str(config.darwin_osx_version[0])) ) + config.substitutions.append( ("%macos_version_minor", str(config.darwin_osx_version[1])) ) + config.substitutions.append( ("%macos_version_subminor", str(config.darwin_osx_version[2])) ) Index: compiler-rt/trunk/test/builtins/lit.site.cfg.in =================================================================== --- compiler-rt/trunk/test/builtins/lit.site.cfg.in +++ compiler-rt/trunk/test/builtins/lit.site.cfg.in @@ -1,7 +0,0 @@ -@LIT_SITE_CFG_IN_HEADER@ - -# Load common config for all compiler-rt lit tests. -lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") - -# Load tool-specific config that would do the real work. -lit_config.load_config(config, "@BUILTINS_LIT_SOURCE_DIR@/lit.cfg") Index: compiler-rt/trunk/test/builtins/lit.site.cfg.py.in =================================================================== --- compiler-rt/trunk/test/builtins/lit.site.cfg.py.in +++ compiler-rt/trunk/test/builtins/lit.site.cfg.py.in @@ -0,0 +1,7 @@ +@LIT_SITE_CFG_IN_HEADER@ + +# Load common config for all compiler-rt lit tests. +lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") + +# Load tool-specific config that would do the real work. +lit_config.load_config(config, "@BUILTINS_LIT_SOURCE_DIR@/lit.cfg.py") Index: compiler-rt/trunk/test/cfi/CMakeLists.txt =================================================================== --- compiler-rt/trunk/test/cfi/CMakeLists.txt +++ compiler-rt/trunk/test/cfi/CMakeLists.txt @@ -20,16 +20,16 @@ set(CFI_LIT_TEST_MODE Standalone) set(CFI_TEST_CONFIG_SUFFIX -standalone${suffix}) configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/Standalone${suffix}/lit.site.cfg + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in + ${CMAKE_CURRENT_BINARY_DIR}/Standalone${suffix}/lit.site.cfg.py ) list(APPEND CFI_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/Standalone${suffix}) set(CFI_LIT_TEST_MODE Devirt) set(CFI_TEST_CONFIG_SUFFIX -devirt${suffix}) configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/Devirt${suffix}/lit.site.cfg + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in + ${CMAKE_CURRENT_BINARY_DIR}/Devirt${suffix}/lit.site.cfg.py ) list(APPEND CFI_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/Devirt${suffix}) endmacro() Index: compiler-rt/trunk/test/cfi/cross-dso/icall/lit.local.cfg =================================================================== --- compiler-rt/trunk/test/cfi/cross-dso/icall/lit.local.cfg +++ compiler-rt/trunk/test/cfi/cross-dso/icall/lit.local.cfg @@ -1,3 +0,0 @@ -# The cfi-icall checker is only supported on x86 and x86_64 for now. -if config.root.host_arch not in ['x86', 'x86_64']: - config.unsupported = True Index: compiler-rt/trunk/test/cfi/cross-dso/icall/lit.local.cfg.py =================================================================== --- compiler-rt/trunk/test/cfi/cross-dso/icall/lit.local.cfg.py +++ compiler-rt/trunk/test/cfi/cross-dso/icall/lit.local.cfg.py @@ -0,0 +1,3 @@ +# The cfi-icall checker is only supported on x86 and x86_64 for now. +if config.root.host_arch not in ['x86', 'x86_64']: + config.unsupported = True Index: compiler-rt/trunk/test/cfi/cross-dso/lit.local.cfg =================================================================== --- compiler-rt/trunk/test/cfi/cross-dso/lit.local.cfg +++ compiler-rt/trunk/test/cfi/cross-dso/lit.local.cfg @@ -1,13 +0,0 @@ -def getRoot(config): - if not config.parent: - return config - return getRoot(config.parent) - -root = getRoot(config) - -if root.host_os not in ['Linux', 'FreeBSD', 'NetBSD']: - config.unsupported = True - -# Android O (API level 26) has support for cross-dso cfi in libdl.so. -if config.android and 'android-26' not in config.available_features: - config.unsupported = True Index: compiler-rt/trunk/test/cfi/cross-dso/lit.local.cfg.py =================================================================== --- compiler-rt/trunk/test/cfi/cross-dso/lit.local.cfg.py +++ compiler-rt/trunk/test/cfi/cross-dso/lit.local.cfg.py @@ -0,0 +1,13 @@ +def getRoot(config): + if not config.parent: + return config + return getRoot(config.parent) + +root = getRoot(config) + +if root.host_os not in ['Linux', 'FreeBSD', 'NetBSD']: + config.unsupported = True + +# Android O (API level 26) has support for cross-dso cfi in libdl.so. +if config.android and 'android-26' not in config.available_features: + config.unsupported = True Index: compiler-rt/trunk/test/cfi/icall/lit.local.cfg =================================================================== --- compiler-rt/trunk/test/cfi/icall/lit.local.cfg +++ compiler-rt/trunk/test/cfi/icall/lit.local.cfg @@ -1,3 +0,0 @@ -# The cfi-icall checker is only supported on x86 and x86_64 for now. -if config.root.host_arch not in ['x86', 'x86_64']: - config.unsupported = True Index: compiler-rt/trunk/test/cfi/icall/lit.local.cfg.py =================================================================== --- compiler-rt/trunk/test/cfi/icall/lit.local.cfg.py +++ compiler-rt/trunk/test/cfi/icall/lit.local.cfg.py @@ -0,0 +1,3 @@ +# The cfi-icall checker is only supported on x86 and x86_64 for now. +if config.root.host_arch not in ['x86', 'x86_64']: + config.unsupported = True Index: compiler-rt/trunk/test/cfi/lit.cfg =================================================================== --- compiler-rt/trunk/test/cfi/lit.cfg +++ compiler-rt/trunk/test/cfi/lit.cfg @@ -1,46 +0,0 @@ -import lit.formats -import os - -config.name = 'cfi' + config.name_suffix -config.suffixes = ['.c', '.cpp', '.test'] -config.test_source_root = os.path.dirname(__file__) - -def build_invocation(compile_flags): - return " " + " ".join([config.clang] + compile_flags) + " " - -clang = build_invocation([config.target_cflags]) -clangxx = build_invocation([config.target_cflags] + config.cxx_mode_flags) - -config.substitutions.append((r"%clang ", clang + ' ')) -config.substitutions.append((r"%clangxx ", clangxx + ' ')) -if config.lto_supported: - clang_cfi = clang + '-fsanitize=cfi ' - - if config.cfi_lit_test_mode == "Devirt": - config.available_features.add('devirt') - clang_cfi += '-fwhole-program-vtables ' - config.substitutions.append((r"%expect_crash_unless_devirt ", "")) - else: - config.substitutions.append((r"%expect_crash_unless_devirt ", config.expect_crash)) - - cxx = ' '.join(config.cxx_mode_flags) + ' ' - diag = '-fno-sanitize-trap=cfi -fsanitize-recover=cfi ' - non_dso = '-fvisibility=hidden ' - dso = '-fsanitize-cfi-cross-dso -fvisibility=default ' - if config.android: - dso += '-include ' + config.test_source_root + '/cross-dso/util/cfi_stubs.h ' - config.substitutions.append((r"%clang_cfi ", clang_cfi + non_dso)) - config.substitutions.append((r"%clangxx_cfi ", clang_cfi + cxx + non_dso)) - config.substitutions.append((r"%clang_cfi_diag ", clang_cfi + non_dso + diag)) - config.substitutions.append((r"%clangxx_cfi_diag ", clang_cfi + cxx + non_dso + diag)) - config.substitutions.append((r"%clangxx_cfi_dso ", clang_cfi + cxx + dso)) - config.substitutions.append((r"%clangxx_cfi_dso_diag ", clang_cfi + cxx + dso + diag)) - config.substitutions.append((r"%debug_info_flags", ' '.join(config.debug_info_flags))) -else: - config.unsupported = True - -if config.default_sanitizer_opts: - config.environment['UBSAN_OPTIONS'] = ':'.join(config.default_sanitizer_opts) - -if lit_config.params.get('check_supported', None) and config.unsupported: - raise BaseException("Tests unsupported") Index: compiler-rt/trunk/test/cfi/lit.cfg.py =================================================================== --- compiler-rt/trunk/test/cfi/lit.cfg.py +++ compiler-rt/trunk/test/cfi/lit.cfg.py @@ -0,0 +1,46 @@ +import lit.formats +import os + +config.name = 'cfi' + config.name_suffix +config.suffixes = ['.c', '.cpp', '.test'] +config.test_source_root = os.path.dirname(__file__) + +def build_invocation(compile_flags): + return " " + " ".join([config.clang] + compile_flags) + " " + +clang = build_invocation([config.target_cflags]) +clangxx = build_invocation([config.target_cflags] + config.cxx_mode_flags) + +config.substitutions.append((r"%clang ", clang + ' ')) +config.substitutions.append((r"%clangxx ", clangxx + ' ')) +if config.lto_supported: + clang_cfi = clang + '-fsanitize=cfi ' + + if config.cfi_lit_test_mode == "Devirt": + config.available_features.add('devirt') + clang_cfi += '-fwhole-program-vtables ' + config.substitutions.append((r"%expect_crash_unless_devirt ", "")) + else: + config.substitutions.append((r"%expect_crash_unless_devirt ", config.expect_crash)) + + cxx = ' '.join(config.cxx_mode_flags) + ' ' + diag = '-fno-sanitize-trap=cfi -fsanitize-recover=cfi ' + non_dso = '-fvisibility=hidden ' + dso = '-fsanitize-cfi-cross-dso -fvisibility=default ' + if config.android: + dso += '-include ' + config.test_source_root + '/cross-dso/util/cfi_stubs.h ' + config.substitutions.append((r"%clang_cfi ", clang_cfi + non_dso)) + config.substitutions.append((r"%clangxx_cfi ", clang_cfi + cxx + non_dso)) + config.substitutions.append((r"%clang_cfi_diag ", clang_cfi + non_dso + diag)) + config.substitutions.append((r"%clangxx_cfi_diag ", clang_cfi + cxx + non_dso + diag)) + config.substitutions.append((r"%clangxx_cfi_dso ", clang_cfi + cxx + dso)) + config.substitutions.append((r"%clangxx_cfi_dso_diag ", clang_cfi + cxx + dso + diag)) + config.substitutions.append((r"%debug_info_flags", ' '.join(config.debug_info_flags))) +else: + config.unsupported = True + +if config.default_sanitizer_opts: + config.environment['UBSAN_OPTIONS'] = ':'.join(config.default_sanitizer_opts) + +if lit_config.params.get('check_supported', None) and config.unsupported: + raise BaseException("Tests unsupported") Index: compiler-rt/trunk/test/cfi/lit.site.cfg.in =================================================================== --- compiler-rt/trunk/test/cfi/lit.site.cfg.in +++ compiler-rt/trunk/test/cfi/lit.site.cfg.in @@ -1,13 +0,0 @@ -@LIT_SITE_CFG_IN_HEADER@ - -config.name_suffix = "@CFI_TEST_CONFIG_SUFFIX@" -config.cfi_lit_test_mode = "@CFI_LIT_TEST_MODE@" -config.target_arch = "@CFI_TEST_TARGET_ARCH@" -config.target_cflags = "@CFI_TEST_TARGET_CFLAGS@" -config.use_lld = @CFI_TEST_USE_LLD@ -config.use_lto = True # CFI *requires* LTO. -config.use_thinlto = @CFI_TEST_USE_THINLTO@ -config.use_newpm = @CFI_TEST_USE_NEWPM@ - -lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") -lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg") Index: compiler-rt/trunk/test/cfi/lit.site.cfg.py.in =================================================================== --- compiler-rt/trunk/test/cfi/lit.site.cfg.py.in +++ compiler-rt/trunk/test/cfi/lit.site.cfg.py.in @@ -0,0 +1,13 @@ +@LIT_SITE_CFG_IN_HEADER@ + +config.name_suffix = "@CFI_TEST_CONFIG_SUFFIX@" +config.cfi_lit_test_mode = "@CFI_LIT_TEST_MODE@" +config.target_arch = "@CFI_TEST_TARGET_ARCH@" +config.target_cflags = "@CFI_TEST_TARGET_CFLAGS@" +config.use_lld = @CFI_TEST_USE_LLD@ +config.use_lto = True # CFI *requires* LTO. +config.use_thinlto = @CFI_TEST_USE_THINLTO@ +config.use_newpm = @CFI_TEST_USE_NEWPM@ + +lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") +lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg.py") Index: compiler-rt/trunk/test/crt/CMakeLists.txt =================================================================== --- compiler-rt/trunk/test/crt/CMakeLists.txt +++ compiler-rt/trunk/test/crt/CMakeLists.txt @@ -22,8 +22,8 @@ set(CONFIG_NAME ${ARCH_UPPER_CASE}${OS_NAME}Config) configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg) + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in + ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py) list(APPEND CRT_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}) endforeach() endif() Index: compiler-rt/trunk/test/crt/lit.cfg =================================================================== --- compiler-rt/trunk/test/crt/lit.cfg +++ compiler-rt/trunk/test/crt/lit.cfg @@ -1,78 +0,0 @@ -# -*- Python -*- - -import os -import subprocess - -# Setup config name. -config.name = 'CRT' + config.name_suffix - -# Setup source root. -config.test_source_root = os.path.dirname(__file__) - - -def get_library_path(file): - cmd = subprocess.Popen([config.clang.strip(), - config.target_cflags.strip(), - '-print-file-name=%s' % file], - stdout=subprocess.PIPE, - env=config.environment) - if not cmd.stdout: - lit_config.fatal("Couldn't find the library path for '%s'" % file) - dir = cmd.stdout.read().strip() - if sys.platform in ['win32'] and execute_external: - # Don't pass dosish path separator to msys bash.exe. - dir = dir.replace('\\', '/') - # Ensure the result is an ascii string, across Python2.5+ - Python3. - return str(dir.decode('ascii')) - - -def get_libgcc_file_name(): - cmd = subprocess.Popen([config.clang.strip(), - config.target_cflags.strip(), - '-print-libgcc-file-name'], - stdout=subprocess.PIPE, - env=config.environment) - if not cmd.stdout: - lit_config.fatal("Couldn't find the library path for '%s'" % file) - dir = cmd.stdout.read().strip() - if sys.platform in ['win32'] and execute_external: - # Don't pass dosish path separator to msys bash.exe. - dir = dir.replace('\\', '/') - # Ensure the result is an ascii string, across Python2.5+ - Python3. - return str(dir.decode('ascii')) - - -def build_invocation(compile_flags): - return ' ' + ' '.join([config.clang] + compile_flags) + ' ' - - -# Setup substitutions. -config.substitutions.append( - ('%clang ', build_invocation([config.target_cflags]))) -config.substitutions.append( - ('%clangxx ', - build_invocation(config.cxx_mode_flags + [config.target_cflags]))) - -base_lib = os.path.join( - config.compiler_rt_libdir, "clang_rt.%%s%s.o" % config.target_suffix) -config.substitutions.append(('%crtbegin', base_lib % "crtbegin")) -config.substitutions.append(('%crtend', base_lib % "crtend")) - -config.substitutions.append( - ('%crt1', get_library_path('crt1.o'))) -config.substitutions.append( - ('%crti', get_library_path('crti.o'))) -config.substitutions.append( - ('%crtn', get_library_path('crtn.o'))) - -config.substitutions.append( - ('%libgcc', get_libgcc_file_name())) - -config.substitutions.append( - ('%libstdcxx', '-l' + config.sanitizer_cxx_lib.lstrip('lib'))) - -# Default test suffixes. -config.suffixes = ['.c', '.cc', '.cpp'] - -if config.host_os not in ['Linux']: - config.unsupported = True Index: compiler-rt/trunk/test/crt/lit.cfg.py =================================================================== --- compiler-rt/trunk/test/crt/lit.cfg.py +++ compiler-rt/trunk/test/crt/lit.cfg.py @@ -0,0 +1,78 @@ +# -*- Python -*- + +import os +import subprocess + +# Setup config name. +config.name = 'CRT' + config.name_suffix + +# Setup source root. +config.test_source_root = os.path.dirname(__file__) + + +def get_library_path(file): + cmd = subprocess.Popen([config.clang.strip(), + config.target_cflags.strip(), + '-print-file-name=%s' % file], + stdout=subprocess.PIPE, + env=config.environment) + if not cmd.stdout: + lit_config.fatal("Couldn't find the library path for '%s'" % file) + dir = cmd.stdout.read().strip() + if sys.platform in ['win32'] and execute_external: + # Don't pass dosish path separator to msys bash.exe. + dir = dir.replace('\\', '/') + # Ensure the result is an ascii string, across Python2.5+ - Python3. + return str(dir.decode('ascii')) + + +def get_libgcc_file_name(): + cmd = subprocess.Popen([config.clang.strip(), + config.target_cflags.strip(), + '-print-libgcc-file-name'], + stdout=subprocess.PIPE, + env=config.environment) + if not cmd.stdout: + lit_config.fatal("Couldn't find the library path for '%s'" % file) + dir = cmd.stdout.read().strip() + if sys.platform in ['win32'] and execute_external: + # Don't pass dosish path separator to msys bash.exe. + dir = dir.replace('\\', '/') + # Ensure the result is an ascii string, across Python2.5+ - Python3. + return str(dir.decode('ascii')) + + +def build_invocation(compile_flags): + return ' ' + ' '.join([config.clang] + compile_flags) + ' ' + + +# Setup substitutions. +config.substitutions.append( + ('%clang ', build_invocation([config.target_cflags]))) +config.substitutions.append( + ('%clangxx ', + build_invocation(config.cxx_mode_flags + [config.target_cflags]))) + +base_lib = os.path.join( + config.compiler_rt_libdir, "clang_rt.%%s%s.o" % config.target_suffix) +config.substitutions.append(('%crtbegin', base_lib % "crtbegin")) +config.substitutions.append(('%crtend', base_lib % "crtend")) + +config.substitutions.append( + ('%crt1', get_library_path('crt1.o'))) +config.substitutions.append( + ('%crti', get_library_path('crti.o'))) +config.substitutions.append( + ('%crtn', get_library_path('crtn.o'))) + +config.substitutions.append( + ('%libgcc', get_libgcc_file_name())) + +config.substitutions.append( + ('%libstdcxx', '-l' + config.sanitizer_cxx_lib.lstrip('lib'))) + +# Default test suffixes. +config.suffixes = ['.c', '.cc', '.cpp'] + +if config.host_os not in ['Linux']: + config.unsupported = True Index: compiler-rt/trunk/test/crt/lit.site.cfg.in =================================================================== --- compiler-rt/trunk/test/crt/lit.site.cfg.in +++ compiler-rt/trunk/test/crt/lit.site.cfg.in @@ -1,14 +0,0 @@ -@LIT_SITE_CFG_IN_HEADER@ - -# Tool-specific config options. -config.name_suffix = "@CRT_TEST_CONFIG_SUFFIX@" -config.crt_lit_source_dir = "@CRT_LIT_SOURCE_DIR@" -config.target_cflags = "@CRT_TEST_TARGET_CFLAGS@" -config.target_arch = "@CRT_TEST_TARGET_ARCH@" -config.sanitizer_cxx_lib = "@SANITIZER_TEST_CXX_LIBNAME@" - -# Load common config for all compiler-rt lit tests -lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") - -# Load tool-specific config that would do the real work. -lit_config.load_config(config, "@CRT_LIT_SOURCE_DIR@/lit.cfg") Index: compiler-rt/trunk/test/crt/lit.site.cfg.py.in =================================================================== --- compiler-rt/trunk/test/crt/lit.site.cfg.py.in +++ compiler-rt/trunk/test/crt/lit.site.cfg.py.in @@ -0,0 +1,14 @@ +@LIT_SITE_CFG_IN_HEADER@ + +# Tool-specific config options. +config.name_suffix = "@CRT_TEST_CONFIG_SUFFIX@" +config.crt_lit_source_dir = "@CRT_LIT_SOURCE_DIR@" +config.target_cflags = "@CRT_TEST_TARGET_CFLAGS@" +config.target_arch = "@CRT_TEST_TARGET_ARCH@" +config.sanitizer_cxx_lib = "@SANITIZER_TEST_CXX_LIBNAME@" + +# Load common config for all compiler-rt lit tests +lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") + +# Load tool-specific config that would do the real work. +lit_config.load_config(config, "@CRT_LIT_SOURCE_DIR@/lit.cfg.py") Index: compiler-rt/trunk/test/dfsan/CMakeLists.txt =================================================================== --- compiler-rt/trunk/test/dfsan/CMakeLists.txt +++ compiler-rt/trunk/test/dfsan/CMakeLists.txt @@ -15,8 +15,8 @@ set(CONFIG_NAME ${ARCH_UPPER_CASE}Config) configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg) + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in + ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py) list(APPEND DFSAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}) endforeach() Index: compiler-rt/trunk/test/dfsan/lit.cfg =================================================================== --- compiler-rt/trunk/test/dfsan/lit.cfg +++ compiler-rt/trunk/test/dfsan/lit.cfg @@ -1,26 +0,0 @@ -# -*- Python -*- - -import os - -# Setup config name. -config.name = 'DataFlowSanitizer' + config.name_suffix - -# Setup source root. -config.test_source_root = os.path.dirname(__file__) - -# Setup default compiler flags used with -fsanitize=dataflow option. -clang_dfsan_cflags = ["-fsanitize=dataflow", config.target_cflags] -clang_dfsan_cxxflags = config.cxx_mode_flags + clang_dfsan_cflags - -def build_invocation(compile_flags): - return " " + " ".join([config.clang] + compile_flags) + " " - -config.substitutions.append( ("%clang_dfsan ", build_invocation(clang_dfsan_cflags)) ) -config.substitutions.append( ("%clangxx_dfsan ", build_invocation(clang_dfsan_cxxflags)) ) - -# Default test suffixes. -config.suffixes = ['.c', '.cc', '.cpp'] - -# DataFlowSanitizer tests are currently supported on Linux only. -if config.host_os not in ['Linux']: - config.unsupported = True Index: compiler-rt/trunk/test/dfsan/lit.cfg.py =================================================================== --- compiler-rt/trunk/test/dfsan/lit.cfg.py +++ compiler-rt/trunk/test/dfsan/lit.cfg.py @@ -0,0 +1,26 @@ +# -*- Python -*- + +import os + +# Setup config name. +config.name = 'DataFlowSanitizer' + config.name_suffix + +# Setup source root. +config.test_source_root = os.path.dirname(__file__) + +# Setup default compiler flags used with -fsanitize=dataflow option. +clang_dfsan_cflags = ["-fsanitize=dataflow", config.target_cflags] +clang_dfsan_cxxflags = config.cxx_mode_flags + clang_dfsan_cflags + +def build_invocation(compile_flags): + return " " + " ".join([config.clang] + compile_flags) + " " + +config.substitutions.append( ("%clang_dfsan ", build_invocation(clang_dfsan_cflags)) ) +config.substitutions.append( ("%clangxx_dfsan ", build_invocation(clang_dfsan_cxxflags)) ) + +# Default test suffixes. +config.suffixes = ['.c', '.cc', '.cpp'] + +# DataFlowSanitizer tests are currently supported on Linux only. +if config.host_os not in ['Linux']: + config.unsupported = True Index: compiler-rt/trunk/test/dfsan/lit.site.cfg.in =================================================================== --- compiler-rt/trunk/test/dfsan/lit.site.cfg.in +++ compiler-rt/trunk/test/dfsan/lit.site.cfg.in @@ -1,12 +0,0 @@ -@LIT_SITE_CFG_IN_HEADER@ - -# Tool-specific config options. -config.name_suffix = "@DFSAN_TEST_CONFIG_SUFFIX@" -config.target_cflags = "@DFSAN_TEST_TARGET_CFLAGS@" -config.target_arch = "@DFSAN_TEST_TARGET_ARCH@" - -# Load common config for all compiler-rt lit tests. -lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") - -# Load tool-specific config that would do the real work. -lit_config.load_config(config, "@DFSAN_LIT_TESTS_DIR@/lit.cfg") Index: compiler-rt/trunk/test/dfsan/lit.site.cfg.py.in =================================================================== --- compiler-rt/trunk/test/dfsan/lit.site.cfg.py.in +++ compiler-rt/trunk/test/dfsan/lit.site.cfg.py.in @@ -0,0 +1,12 @@ +@LIT_SITE_CFG_IN_HEADER@ + +# Tool-specific config options. +config.name_suffix = "@DFSAN_TEST_CONFIG_SUFFIX@" +config.target_cflags = "@DFSAN_TEST_TARGET_CFLAGS@" +config.target_arch = "@DFSAN_TEST_TARGET_ARCH@" + +# Load common config for all compiler-rt lit tests. +lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") + +# Load tool-specific config that would do the real work. +lit_config.load_config(config, "@DFSAN_LIT_TESTS_DIR@/lit.cfg.py") Index: compiler-rt/trunk/test/fuzzer/CMakeLists.txt =================================================================== --- compiler-rt/trunk/test/fuzzer/CMakeLists.txt +++ compiler-rt/trunk/test/fuzzer/CMakeLists.txt @@ -27,8 +27,8 @@ if(COMPILER_RT_INCLUDE_TESTS) # libFuzzer unit tests. 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) add_lit_testsuite(check-fuzzer-unit "Running Fuzzer unit tests" ${CMAKE_CURRENT_BINARY_DIR}/unit DEPENDS ${LIBFUZZER_TEST_DEPS}) @@ -61,8 +61,8 @@ # LIT-based libFuzzer tests. configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in + ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py ) add_lit_testsuite(check-fuzzer-${stdlib_name}-${arch} @@ -99,8 +99,8 @@ string(TOUPPER ${arch} ARCH_UPPER_CASE) set(CONFIG_NAME "IOS${ARCH_UPPER_CASE}Config") configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in + ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py ) add_lit_testsuite(check-fuzzer-ios-${arch} "libFuzzer iOS ${arch} tests" ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/ Index: compiler-rt/trunk/test/fuzzer/lit.cfg =================================================================== --- compiler-rt/trunk/test/fuzzer/lit.cfg +++ compiler-rt/trunk/test/fuzzer/lit.cfg @@ -1,120 +0,0 @@ -import lit.formats -import sys -import os - -config.name = "libFuzzer" + config.name_suffix -config.test_format = lit.formats.ShTest(True) -config.suffixes = ['.test'] -config.test_source_root = os.path.dirname(__file__) -config.available_features.add(config.target_arch) - -# Choose between lit's internal shell pipeline runner and a real shell. If -# LIT_USE_INTERNAL_SHELL is in the environment, we use that as an override. -use_lit_shell = os.environ.get("LIT_USE_INTERNAL_SHELL") -if use_lit_shell: - # 0 is external, "" is default, and everything else is internal. - execute_external = (use_lit_shell == "0") -else: - # Otherwise we default to internal on Windows and external elsewhere, as - # bash on Windows is usually very slow. - execute_external = (not sys.platform in ['win32']) - -# 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. -config.test_format = lit.formats.ShTest(execute_external) - -# LeakSanitizer is not supported on OSX or Windows right now. -if (sys.platform.startswith('darwin') or - sys.platform.startswith('freebsd') or - sys.platform.startswith('netbsd') or - sys.platform.startswith('win')): - lit_config.note('lsan feature unavailable') -else: - lit_config.note('lsan feature available') - config.available_features.add('lsan') - -# MemorySanitizer is not supported on OSX or Windows right now -if (sys.platform.startswith('darwin') or sys.platform.startswith('win') or - config.target_arch == 'i386'): - lit_config.note('msan feature unavailable') - assert 'msan' not in config.available_features -else: - lit_config.note('msan feature available') - config.available_features.add('msan') - -if sys.platform.startswith('win') or sys.platform.startswith('cygwin'): - config.available_features.add('windows') - -if sys.platform.startswith('darwin'): - config.available_features.add('darwin') - -if sys.platform.startswith('linux'): - # Note the value of ``sys.platform`` is not consistent - # between python 2 and 3, hence the use of ``.startswith()``. - lit_config.note('linux feature available') - config.available_features.add('linux') -else: - lit_config.note('linux feature unavailable') - -config.substitutions.append(('%build_dir', config.cmake_binary_dir)) -libfuzzer_src_root = os.path.join(config.compiler_rt_src_root, "lib", "fuzzer") -config.substitutions.append(('%libfuzzer_src', libfuzzer_src_root)) - -def generate_compiler_cmd(is_cpp=True, fuzzer_enabled=True, msan_enabled=False): - compiler_cmd = config.clang - extra_cmd = config.target_flags - - if is_cpp and 'windows-msvc' in config.target_triple: - std_cmd = '--driver-mode=cl' - elif is_cpp: - std_cmd = '--driver-mode=g++ -std=c++11' - else: - std_cmd = '' - - if msan_enabled: - sanitizers = ['memory'] - else: - sanitizers = ['address'] - if fuzzer_enabled: - sanitizers.append('fuzzer') - sanitizers_cmd = ('-fsanitize=%s' % ','.join(sanitizers)) - return " ".join([ - compiler_cmd, - std_cmd, - "-O2 -gline-tables-only", - sanitizers_cmd, - "-I%s" % libfuzzer_src_root, - extra_cmd - ]) - -config.substitutions.append(('%cpp_compiler', - generate_compiler_cmd(is_cpp=True, fuzzer_enabled=True) - )) - -config.substitutions.append(('%c_compiler', - generate_compiler_cmd(is_cpp=False, fuzzer_enabled=True) - )) - -config.substitutions.append(('%no_fuzzer_cpp_compiler', - generate_compiler_cmd(is_cpp=True, fuzzer_enabled=False) - )) - -config.substitutions.append(('%no_fuzzer_c_compiler', - generate_compiler_cmd(is_cpp=False, fuzzer_enabled=False) - )) - -config.substitutions.append(('%msan_compiler', - generate_compiler_cmd(is_cpp=True, fuzzer_enabled=True, msan_enabled=True) - )) - -default_asan_opts_str = ':'.join(config.default_sanitizer_opts) -if default_asan_opts_str: - config.environment['ASAN_OPTIONS'] = default_asan_opts_str - default_asan_opts_str += ':' -config.substitutions.append(('%env_asan_opts=', - 'env ASAN_OPTIONS=' + default_asan_opts_str)) - -if not config.parallelism_group: - config.parallelism_group = 'shadow-memory' Index: compiler-rt/trunk/test/fuzzer/lit.cfg.py =================================================================== --- compiler-rt/trunk/test/fuzzer/lit.cfg.py +++ compiler-rt/trunk/test/fuzzer/lit.cfg.py @@ -0,0 +1,120 @@ +import lit.formats +import sys +import os + +config.name = "libFuzzer" + config.name_suffix +config.test_format = lit.formats.ShTest(True) +config.suffixes = ['.test'] +config.test_source_root = os.path.dirname(__file__) +config.available_features.add(config.target_arch) + +# Choose between lit's internal shell pipeline runner and a real shell. If +# LIT_USE_INTERNAL_SHELL is in the environment, we use that as an override. +use_lit_shell = os.environ.get("LIT_USE_INTERNAL_SHELL") +if use_lit_shell: + # 0 is external, "" is default, and everything else is internal. + execute_external = (use_lit_shell == "0") +else: + # Otherwise we default to internal on Windows and external elsewhere, as + # bash on Windows is usually very slow. + execute_external = (not sys.platform in ['win32']) + +# 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. +config.test_format = lit.formats.ShTest(execute_external) + +# LeakSanitizer is not supported on OSX or Windows right now. +if (sys.platform.startswith('darwin') or + sys.platform.startswith('freebsd') or + sys.platform.startswith('netbsd') or + sys.platform.startswith('win')): + lit_config.note('lsan feature unavailable') +else: + lit_config.note('lsan feature available') + config.available_features.add('lsan') + +# MemorySanitizer is not supported on OSX or Windows right now +if (sys.platform.startswith('darwin') or sys.platform.startswith('win') or + config.target_arch == 'i386'): + lit_config.note('msan feature unavailable') + assert 'msan' not in config.available_features +else: + lit_config.note('msan feature available') + config.available_features.add('msan') + +if sys.platform.startswith('win') or sys.platform.startswith('cygwin'): + config.available_features.add('windows') + +if sys.platform.startswith('darwin'): + config.available_features.add('darwin') + +if sys.platform.startswith('linux'): + # Note the value of ``sys.platform`` is not consistent + # between python 2 and 3, hence the use of ``.startswith()``. + lit_config.note('linux feature available') + config.available_features.add('linux') +else: + lit_config.note('linux feature unavailable') + +config.substitutions.append(('%build_dir', config.cmake_binary_dir)) +libfuzzer_src_root = os.path.join(config.compiler_rt_src_root, "lib", "fuzzer") +config.substitutions.append(('%libfuzzer_src', libfuzzer_src_root)) + +def generate_compiler_cmd(is_cpp=True, fuzzer_enabled=True, msan_enabled=False): + compiler_cmd = config.clang + extra_cmd = config.target_flags + + if is_cpp and 'windows-msvc' in config.target_triple: + std_cmd = '--driver-mode=cl' + elif is_cpp: + std_cmd = '--driver-mode=g++ -std=c++11' + else: + std_cmd = '' + + if msan_enabled: + sanitizers = ['memory'] + else: + sanitizers = ['address'] + if fuzzer_enabled: + sanitizers.append('fuzzer') + sanitizers_cmd = ('-fsanitize=%s' % ','.join(sanitizers)) + return " ".join([ + compiler_cmd, + std_cmd, + "-O2 -gline-tables-only", + sanitizers_cmd, + "-I%s" % libfuzzer_src_root, + extra_cmd + ]) + +config.substitutions.append(('%cpp_compiler', + generate_compiler_cmd(is_cpp=True, fuzzer_enabled=True) + )) + +config.substitutions.append(('%c_compiler', + generate_compiler_cmd(is_cpp=False, fuzzer_enabled=True) + )) + +config.substitutions.append(('%no_fuzzer_cpp_compiler', + generate_compiler_cmd(is_cpp=True, fuzzer_enabled=False) + )) + +config.substitutions.append(('%no_fuzzer_c_compiler', + generate_compiler_cmd(is_cpp=False, fuzzer_enabled=False) + )) + +config.substitutions.append(('%msan_compiler', + generate_compiler_cmd(is_cpp=True, fuzzer_enabled=True, msan_enabled=True) + )) + +default_asan_opts_str = ':'.join(config.default_sanitizer_opts) +if default_asan_opts_str: + config.environment['ASAN_OPTIONS'] = default_asan_opts_str + default_asan_opts_str += ':' +config.substitutions.append(('%env_asan_opts=', + 'env ASAN_OPTIONS=' + default_asan_opts_str)) + +if not config.parallelism_group: + config.parallelism_group = 'shadow-memory' Index: compiler-rt/trunk/test/fuzzer/lit.site.cfg.in =================================================================== --- compiler-rt/trunk/test/fuzzer/lit.site.cfg.in +++ compiler-rt/trunk/test/fuzzer/lit.site.cfg.in @@ -1,25 +0,0 @@ -@LIT_SITE_CFG_IN_HEADER@ - -config.cpp_compiler = "@LIBFUZZER_TEST_COMPILER@" -config.target_flags = "@LIBFUZZER_TEST_FLAGS@" -config.c_compiler = "@LIBFUZZER_TEST_COMPILER@" -config.stdlib = "@LIBFUZZER_TEST_STDLIB@" -config.apple_platform = "@LIBFUZZER_TEST_APPLE_PLATFORM@" -config.name_suffix = "@LIBFUZZER_TEST_CONFIG_SUFFIX@" - -config.osx_sysroot_flag = "@OSX_SYSROOT_FLAG@" -config.cmake_binary_dir = "@CMAKE_BINARY_DIR@" -config.llvm_library_dir = "@LLVM_LIBRARY_DIR@" -config.target_triple = "@TARGET_TRIPLE@" -config.target_arch = "@LIBFUZZER_TEST_TARGET_ARCH@" - -# Load common config for all compiler-rt lit tests. -lit_config.load_config(config, - "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") - -if config.enable_per_target_runtime_dir: - config.runtime_library_dir = config.compiler_rt_libdir -else: - config.runtime_library_dir = "@LLVM_LIBRARY_DIR@" - -lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg") Index: compiler-rt/trunk/test/fuzzer/lit.site.cfg.py.in =================================================================== --- compiler-rt/trunk/test/fuzzer/lit.site.cfg.py.in +++ compiler-rt/trunk/test/fuzzer/lit.site.cfg.py.in @@ -0,0 +1,25 @@ +@LIT_SITE_CFG_IN_HEADER@ + +config.cpp_compiler = "@LIBFUZZER_TEST_COMPILER@" +config.target_flags = "@LIBFUZZER_TEST_FLAGS@" +config.c_compiler = "@LIBFUZZER_TEST_COMPILER@" +config.stdlib = "@LIBFUZZER_TEST_STDLIB@" +config.apple_platform = "@LIBFUZZER_TEST_APPLE_PLATFORM@" +config.name_suffix = "@LIBFUZZER_TEST_CONFIG_SUFFIX@" + +config.osx_sysroot_flag = "@OSX_SYSROOT_FLAG@" +config.cmake_binary_dir = "@CMAKE_BINARY_DIR@" +config.llvm_library_dir = "@LLVM_LIBRARY_DIR@" +config.target_triple = "@TARGET_TRIPLE@" +config.target_arch = "@LIBFUZZER_TEST_TARGET_ARCH@" + +# Load common config for all compiler-rt lit tests. +lit_config.load_config(config, + "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") + +if config.enable_per_target_runtime_dir: + config.runtime_library_dir = config.compiler_rt_libdir +else: + config.runtime_library_dir = "@LLVM_LIBRARY_DIR@" + +lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg.py") Index: compiler-rt/trunk/test/fuzzer/unit/lit.site.cfg.in =================================================================== --- compiler-rt/trunk/test/fuzzer/unit/lit.site.cfg.in +++ compiler-rt/trunk/test/fuzzer/unit/lit.site.cfg.in @@ -1,9 +0,0 @@ -@LIT_SITE_CFG_IN_HEADER@ - -config.name = "LLVMFuzzer-Unittest" -# Load common config for all compiler-rt unit tests. -lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/unittests/lit.common.unit.configured") - -config.test_exec_root = os.path.join("@COMPILER_RT_BINARY_DIR@", - "lib", "fuzzer", "tests") -config.test_source_root = config.test_exec_root Index: compiler-rt/trunk/test/fuzzer/unit/lit.site.cfg.py.in =================================================================== --- compiler-rt/trunk/test/fuzzer/unit/lit.site.cfg.py.in +++ compiler-rt/trunk/test/fuzzer/unit/lit.site.cfg.py.in @@ -0,0 +1,9 @@ +@LIT_SITE_CFG_IN_HEADER@ + +config.name = "LLVMFuzzer-Unittest" +# Load common config for all compiler-rt unit tests. +lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/unittests/lit.common.unit.configured") + +config.test_exec_root = os.path.join("@COMPILER_RT_BINARY_DIR@", + "lib", "fuzzer", "tests") +config.test_source_root = config.test_exec_root Index: compiler-rt/trunk/test/gwp_asan/CMakeLists.txt =================================================================== --- compiler-rt/trunk/test/gwp_asan/CMakeLists.txt +++ compiler-rt/trunk/test/gwp_asan/CMakeLists.txt @@ -17,8 +17,8 @@ if (COMPILER_RT_INCLUDE_TESTS AND COMPILER_RT_HAS_GWP_ASAN AND NOT ANDROID) list(APPEND GWP_ASAN_TEST_DEPS GwpAsanUnitTests) 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) add_lit_testsuite(check-gwp_asan-unit "Running GWP-ASan unit tests" ${CMAKE_CURRENT_BINARY_DIR}/unit DEPENDS ${GWP_ASAN_TEST_DEPS}) @@ -28,8 +28,8 @@ endif() 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 ) foreach(arch ${GWP_ASAN_SUPPORTED_ARCH}) @@ -40,8 +40,8 @@ set(CONFIG_NAME ${ARCH_UPPER_CASE}${OS_NAME}Config) configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg) + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in + ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py) list(APPEND GWP_ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}) endforeach() Index: compiler-rt/trunk/test/gwp_asan/lit.cfg =================================================================== --- compiler-rt/trunk/test/gwp_asan/lit.cfg +++ compiler-rt/trunk/test/gwp_asan/lit.cfg @@ -1,44 +0,0 @@ -# -*- Python -*- - -import os - -# Setup config name. -config.name = 'GWP-ASan' + config.name_suffix - -# Setup source root. -config.test_source_root = os.path.dirname(__file__) - -# Test suffixes. -config.suffixes = ['.c', '.cc', '.cpp', '.test'] - -# C & CXX flags. -c_flags = ([config.target_cflags]) - -# Android doesn't want -lrt. -if not config.android: - c_flags += ["-lrt"] - -cxx_flags = (c_flags + config.cxx_mode_flags + ["-std=c++11"]) - -gwp_asan_flags = ["-fsanitize=scudo"] - -def build_invocation(compile_flags): - return " " + " ".join([config.clang] + compile_flags) + " " - -# Add substitutions. -config.substitutions.append(("%clang ", build_invocation(c_flags))) -config.substitutions.append(("%clang_gwp_asan ", build_invocation(c_flags + gwp_asan_flags))) -config.substitutions.append(("%clangxx_gwp_asan ", build_invocation(cxx_flags + gwp_asan_flags))) - -# Platform-specific default GWP_ASAN for lit tests. Ensure that GWP-ASan is -# enabled and that it samples every allocation. -default_gwp_asan_options = 'Enabled=1:SampleRate=1' - -config.environment['GWP_ASAN_OPTIONS'] = default_gwp_asan_options -default_gwp_asan_options += ':' -config.substitutions.append(('%env_gwp_asan_options=', - 'env GWP_ASAN_OPTIONS=' + default_gwp_asan_options)) - -# GWP-ASan tests are currently supported on Linux only. -if config.host_os not in ['Linux']: - config.unsupported = True Index: compiler-rt/trunk/test/gwp_asan/lit.cfg.py =================================================================== --- compiler-rt/trunk/test/gwp_asan/lit.cfg.py +++ compiler-rt/trunk/test/gwp_asan/lit.cfg.py @@ -0,0 +1,44 @@ +# -*- Python -*- + +import os + +# Setup config name. +config.name = 'GWP-ASan' + config.name_suffix + +# Setup source root. +config.test_source_root = os.path.dirname(__file__) + +# Test suffixes. +config.suffixes = ['.c', '.cc', '.cpp', '.test'] + +# C & CXX flags. +c_flags = ([config.target_cflags]) + +# Android doesn't want -lrt. +if not config.android: + c_flags += ["-lrt"] + +cxx_flags = (c_flags + config.cxx_mode_flags + ["-std=c++11"]) + +gwp_asan_flags = ["-fsanitize=scudo"] + +def build_invocation(compile_flags): + return " " + " ".join([config.clang] + compile_flags) + " " + +# Add substitutions. +config.substitutions.append(("%clang ", build_invocation(c_flags))) +config.substitutions.append(("%clang_gwp_asan ", build_invocation(c_flags + gwp_asan_flags))) +config.substitutions.append(("%clangxx_gwp_asan ", build_invocation(cxx_flags + gwp_asan_flags))) + +# Platform-specific default GWP_ASAN for lit tests. Ensure that GWP-ASan is +# enabled and that it samples every allocation. +default_gwp_asan_options = 'Enabled=1:SampleRate=1' + +config.environment['GWP_ASAN_OPTIONS'] = default_gwp_asan_options +default_gwp_asan_options += ':' +config.substitutions.append(('%env_gwp_asan_options=', + 'env GWP_ASAN_OPTIONS=' + default_gwp_asan_options)) + +# GWP-ASan tests are currently supported on Linux only. +if config.host_os not in ['Linux']: + config.unsupported = True Index: compiler-rt/trunk/test/gwp_asan/lit.site.cfg.in =================================================================== --- compiler-rt/trunk/test/gwp_asan/lit.site.cfg.in +++ compiler-rt/trunk/test/gwp_asan/lit.site.cfg.in @@ -1,11 +0,0 @@ -@LIT_SITE_CFG_IN_HEADER@ - -config.name_suffix = "@GWP_ASAN_TEST_CONFIG_SUFFIX@" -config.target_arch = "@GWP_ASAN_TEST_TARGET_ARCH@" -config.target_cflags = "@GWP_ASAN_TEST_TARGET_CFLAGS@" - -# Load common config for all compiler-rt lit tests. -lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") - -# Load tool-specific config that would do the real work. -lit_config.load_config(config, "@GWP_ASAN_LIT_SOURCE_DIR@/lit.cfg") Index: compiler-rt/trunk/test/gwp_asan/lit.site.cfg.py.in =================================================================== --- compiler-rt/trunk/test/gwp_asan/lit.site.cfg.py.in +++ compiler-rt/trunk/test/gwp_asan/lit.site.cfg.py.in @@ -0,0 +1,11 @@ +@LIT_SITE_CFG_IN_HEADER@ + +config.name_suffix = "@GWP_ASAN_TEST_CONFIG_SUFFIX@" +config.target_arch = "@GWP_ASAN_TEST_TARGET_ARCH@" +config.target_cflags = "@GWP_ASAN_TEST_TARGET_CFLAGS@" + +# Load common config for all compiler-rt lit tests. +lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") + +# Load tool-specific config that would do the real work. +lit_config.load_config(config, "@GWP_ASAN_LIT_SOURCE_DIR@/lit.cfg.py") Index: compiler-rt/trunk/test/gwp_asan/unit/lit.site.cfg.in =================================================================== --- compiler-rt/trunk/test/gwp_asan/unit/lit.site.cfg.in +++ compiler-rt/trunk/test/gwp_asan/unit/lit.site.cfg.in @@ -1,9 +0,0 @@ -@LIT_SITE_CFG_IN_HEADER@ - -config.name = "GwpAsan-Unittest" -# Load common config for all compiler-rt unit tests. -lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/unittests/lit.common.unit.configured") - -config.test_exec_root = os.path.join("@COMPILER_RT_BINARY_DIR@", - "lib", "gwp_asan", "tests") -config.test_source_root = config.test_exec_root Index: compiler-rt/trunk/test/gwp_asan/unit/lit.site.cfg.py.in =================================================================== --- compiler-rt/trunk/test/gwp_asan/unit/lit.site.cfg.py.in +++ compiler-rt/trunk/test/gwp_asan/unit/lit.site.cfg.py.in @@ -0,0 +1,9 @@ +@LIT_SITE_CFG_IN_HEADER@ + +config.name = "GwpAsan-Unittest" +# Load common config for all compiler-rt unit tests. +lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/unittests/lit.common.unit.configured") + +config.test_exec_root = os.path.join("@COMPILER_RT_BINARY_DIR@", + "lib", "gwp_asan", "tests") +config.test_source_root = config.test_exec_root Index: compiler-rt/trunk/test/hwasan/CMakeLists.txt =================================================================== --- compiler-rt/trunk/test/hwasan/CMakeLists.txt +++ compiler-rt/trunk/test/hwasan/CMakeLists.txt @@ -15,8 +15,8 @@ set(HWASAN_ANDROID_FILES_TO_PUSH []) configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg) + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in + ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py) list(APPEND HWASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}) endforeach() Index: compiler-rt/trunk/test/hwasan/TestCases/Linux/lit.local.cfg =================================================================== --- compiler-rt/trunk/test/hwasan/TestCases/Linux/lit.local.cfg +++ compiler-rt/trunk/test/hwasan/TestCases/Linux/lit.local.cfg @@ -1,9 +0,0 @@ -def getRoot(config): - if not config.parent: - return config - return getRoot(config.parent) - -root = getRoot(config) - -if root.host_os not in ['Linux']: - config.unsupported = True Index: compiler-rt/trunk/test/hwasan/TestCases/Linux/lit.local.cfg.py =================================================================== --- compiler-rt/trunk/test/hwasan/TestCases/Linux/lit.local.cfg.py +++ compiler-rt/trunk/test/hwasan/TestCases/Linux/lit.local.cfg.py @@ -0,0 +1,9 @@ +def getRoot(config): + if not config.parent: + return config + return getRoot(config.parent) + +root = getRoot(config) + +if root.host_os not in ['Linux']: + config.unsupported = True Index: compiler-rt/trunk/test/hwasan/TestCases/Posix/lit.local.cfg =================================================================== --- compiler-rt/trunk/test/hwasan/TestCases/Posix/lit.local.cfg +++ compiler-rt/trunk/test/hwasan/TestCases/Posix/lit.local.cfg @@ -1,9 +0,0 @@ -def getRoot(config): - if not config.parent: - return config - return getRoot(config.parent) - -root = getRoot(config) - -if root.host_os in ['Windows']: - config.unsupported = True Index: compiler-rt/trunk/test/hwasan/TestCases/Posix/lit.local.cfg.py =================================================================== --- compiler-rt/trunk/test/hwasan/TestCases/Posix/lit.local.cfg.py +++ compiler-rt/trunk/test/hwasan/TestCases/Posix/lit.local.cfg.py @@ -0,0 +1,9 @@ +def getRoot(config): + if not config.parent: + return config + return getRoot(config.parent) + +root = getRoot(config) + +if root.host_os in ['Windows']: + config.unsupported = True Index: compiler-rt/trunk/test/hwasan/lit.cfg =================================================================== --- compiler-rt/trunk/test/hwasan/lit.cfg +++ compiler-rt/trunk/test/hwasan/lit.cfg @@ -1,36 +0,0 @@ -# -*- Python -*- - -import os - -# Setup config name. -config.name = 'HWAddressSanitizer' + getattr(config, 'name_suffix', 'default') - -# Setup source root. -config.test_source_root = os.path.dirname(__file__) - -# Setup default compiler flags used with -fsanitize=memory option. -clang_cflags = [config.target_cflags] + config.debug_info_flags -clang_cxxflags = config.cxx_mode_flags + clang_cflags -clang_hwasan_cflags = ["-fsanitize=hwaddress"] + clang_cflags -clang_hwasan_cxxflags = config.cxx_mode_flags + clang_hwasan_cflags - -def build_invocation(compile_flags): - return " " + " ".join([config.clang] + compile_flags) + " " - -config.substitutions.append( ("%clangxx ", build_invocation(clang_cxxflags)) ) -config.substitutions.append( ("%clang_hwasan ", build_invocation(clang_hwasan_cflags)) ) -config.substitutions.append( ("%clangxx_hwasan ", build_invocation(clang_hwasan_cxxflags)) ) -config.substitutions.append( ("%compiler_rt_libdir", config.compiler_rt_libdir) ) - -default_hwasan_opts_str = ':'.join(['disable_allocator_tagging=1', 'random_tags=0'] + config.default_sanitizer_opts) -if default_hwasan_opts_str: - config.environment['HWASAN_OPTIONS'] = default_hwasan_opts_str - default_hwasan_opts_str += ':' -config.substitutions.append(('%env_hwasan_opts=', - 'env HWASAN_OPTIONS=' + default_hwasan_opts_str)) - -# Default test suffixes. -config.suffixes = ['.c', '.cc', '.cpp'] - -if config.host_os not in ['Linux', 'Android']: - config.unsupported = True Index: compiler-rt/trunk/test/hwasan/lit.cfg.py =================================================================== --- compiler-rt/trunk/test/hwasan/lit.cfg.py +++ compiler-rt/trunk/test/hwasan/lit.cfg.py @@ -0,0 +1,36 @@ +# -*- Python -*- + +import os + +# Setup config name. +config.name = 'HWAddressSanitizer' + getattr(config, 'name_suffix', 'default') + +# Setup source root. +config.test_source_root = os.path.dirname(__file__) + +# Setup default compiler flags used with -fsanitize=memory option. +clang_cflags = [config.target_cflags] + config.debug_info_flags +clang_cxxflags = config.cxx_mode_flags + clang_cflags +clang_hwasan_cflags = ["-fsanitize=hwaddress"] + clang_cflags +clang_hwasan_cxxflags = config.cxx_mode_flags + clang_hwasan_cflags + +def build_invocation(compile_flags): + return " " + " ".join([config.clang] + compile_flags) + " " + +config.substitutions.append( ("%clangxx ", build_invocation(clang_cxxflags)) ) +config.substitutions.append( ("%clang_hwasan ", build_invocation(clang_hwasan_cflags)) ) +config.substitutions.append( ("%clangxx_hwasan ", build_invocation(clang_hwasan_cxxflags)) ) +config.substitutions.append( ("%compiler_rt_libdir", config.compiler_rt_libdir) ) + +default_hwasan_opts_str = ':'.join(['disable_allocator_tagging=1', 'random_tags=0'] + config.default_sanitizer_opts) +if default_hwasan_opts_str: + config.environment['HWASAN_OPTIONS'] = default_hwasan_opts_str + default_hwasan_opts_str += ':' +config.substitutions.append(('%env_hwasan_opts=', + 'env HWASAN_OPTIONS=' + default_hwasan_opts_str)) + +# Default test suffixes. +config.suffixes = ['.c', '.cc', '.cpp'] + +if config.host_os not in ['Linux', 'Android']: + config.unsupported = True Index: compiler-rt/trunk/test/hwasan/lit.site.cfg.in =================================================================== --- compiler-rt/trunk/test/hwasan/lit.site.cfg.in +++ compiler-rt/trunk/test/hwasan/lit.site.cfg.in @@ -1,13 +0,0 @@ -@LIT_SITE_CFG_IN_HEADER@ - -# Tool-specific config options. -config.name_suffix = "@HWASAN_TEST_CONFIG_SUFFIX@" -config.target_cflags = "@HWASAN_TEST_TARGET_CFLAGS@" -config.target_arch = "@HWASAN_TEST_TARGET_ARCH@" -config.android_files_to_push = @HWASAN_ANDROID_FILES_TO_PUSH@ - -# Load common config for all compiler-rt lit tests. -lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") - -# Load tool-specific config that would do the real work. -lit_config.load_config(config, "@HWASAN_LIT_SOURCE_DIR@/lit.cfg") Index: compiler-rt/trunk/test/hwasan/lit.site.cfg.py.in =================================================================== --- compiler-rt/trunk/test/hwasan/lit.site.cfg.py.in +++ compiler-rt/trunk/test/hwasan/lit.site.cfg.py.in @@ -0,0 +1,13 @@ +@LIT_SITE_CFG_IN_HEADER@ + +# Tool-specific config options. +config.name_suffix = "@HWASAN_TEST_CONFIG_SUFFIX@" +config.target_cflags = "@HWASAN_TEST_TARGET_CFLAGS@" +config.target_arch = "@HWASAN_TEST_TARGET_ARCH@" +config.android_files_to_push = @HWASAN_ANDROID_FILES_TO_PUSH@ + +# Load common config for all compiler-rt lit tests. +lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") + +# Load tool-specific config that would do the real work. +lit_config.load_config(config, "@HWASAN_LIT_SOURCE_DIR@/lit.cfg.py") Index: compiler-rt/trunk/test/interception/CMakeLists.txt =================================================================== --- compiler-rt/trunk/test/interception/CMakeLists.txt +++ compiler-rt/trunk/test/interception/CMakeLists.txt @@ -5,8 +5,8 @@ # Android targets. if(COMPILER_RT_INCLUDE_TESTS AND NOT ANDROID AND NOT APPLE) 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) list(APPEND INTERCEPTION_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/Unit) list(APPEND INTERCEPTION_TEST_DEPS InterceptionUnitTests) endif() Index: compiler-rt/trunk/test/interception/Unit/lit.site.cfg.in =================================================================== --- compiler-rt/trunk/test/interception/Unit/lit.site.cfg.in +++ compiler-rt/trunk/test/interception/Unit/lit.site.cfg.in @@ -1,14 +0,0 @@ -@LIT_SITE_CFG_IN_HEADER@ - -# Load common config for all compiler-rt unit tests. -lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/unittests/lit.common.unit.configured") - -# Setup config name. -config.name = 'Interception-Unit' - -# Setup test source and exec root. For unit tests, we define -# it as build directory with interception tests. -# FIXME: De-hardcode this path. -config.test_exec_root = os.path.join("@COMPILER_RT_BINARY_DIR@", "lib", - "interception", "tests") -config.test_source_root = config.test_exec_root Index: compiler-rt/trunk/test/interception/Unit/lit.site.cfg.py.in =================================================================== --- compiler-rt/trunk/test/interception/Unit/lit.site.cfg.py.in +++ compiler-rt/trunk/test/interception/Unit/lit.site.cfg.py.in @@ -0,0 +1,14 @@ +@LIT_SITE_CFG_IN_HEADER@ + +# Load common config for all compiler-rt unit tests. +lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/unittests/lit.common.unit.configured") + +# Setup config name. +config.name = 'Interception-Unit' + +# Setup test source and exec root. For unit tests, we define +# it as build directory with interception tests. +# FIXME: De-hardcode this path. +config.test_exec_root = os.path.join("@COMPILER_RT_BINARY_DIR@", "lib", + "interception", "tests") +config.test_source_root = config.test_exec_root Index: compiler-rt/trunk/test/lit.common.cfg =================================================================== --- compiler-rt/trunk/test/lit.common.cfg +++ compiler-rt/trunk/test/lit.common.cfg @@ -1,497 +0,0 @@ -# -*- Python -*- - -# Configuration file for 'lit' test runner. -# This file contains common rules for various compiler-rt testsuites. -# It is mostly copied from lit.cfg used by Clang. -import os -import platform -import re -import subprocess -import json - -import lit.formats -import lit.util - -# Choose between lit's internal shell pipeline runner and a real shell. If -# LIT_USE_INTERNAL_SHELL is in the environment, we use that as an override. -use_lit_shell = os.environ.get("LIT_USE_INTERNAL_SHELL") -if use_lit_shell: - # 0 is external, "" is default, and everything else is internal. - execute_external = (use_lit_shell == "0") -else: - # Otherwise we default to internal on Windows and external elsewhere, as - # bash on Windows is usually very slow. - execute_external = (not sys.platform in ['win32']) - -# Setup test format. -config.test_format = lit.formats.ShTest(execute_external) -if execute_external: - config.available_features.add('shell') - -compiler_id = getattr(config, 'compiler_id', None) -if compiler_id == "Clang": - if platform.system() != 'Windows': - config.cxx_mode_flags = ["--driver-mode=g++"] - else: - config.cxx_mode_flags = [] - # We assume that sanitizers should provide good enough error - # reports and stack traces even with minimal debug info. - config.debug_info_flags = ["-gline-tables-only"] - if platform.system() == 'Windows': - # On Windows, use CodeView with column info instead of DWARF. Both VS and - # windbg do not behave well when column info is enabled, but users have - # requested it because it makes ASan reports more precise. - config.debug_info_flags.append("-gcodeview") - config.debug_info_flags.append("-gcolumn-info") -elif compiler_id == 'GNU': - config.cxx_mode_flags = ["-x c++"] - config.debug_info_flags = ["-g"] -else: - lit_config.fatal("Unsupported compiler id: %r" % compiler_id) -# Add compiler ID to the list of available features. -config.available_features.add(compiler_id) - -# If needed, add cflag for shadow scale. -if config.asan_shadow_scale != '': - config.target_cflags += " -mllvm -asan-mapping-scale=" + config.asan_shadow_scale - -# BFD linker in 64-bit android toolchains fails to find libc++_shared.so, which -# is a transitive shared library dependency (via asan runtime). -if config.android: - # Prepend the flag so that it can be overridden. - config.target_cflags = "-pie -fuse-ld=gold " + config.target_cflags - if config.android_ndk_version < 19: - # With a new compiler and NDK < r19 this flag ends up meaning "link against - # libc++", but NDK r19 makes this mean "link against the stub libstdc++ that - # just contains a handful of ABI functions", which makes most C++ code fail - # to link. In r19 and later we just use the default which is libc++. - config.cxx_mode_flags.append('-stdlib=libstdc++') - -# Clear some environment variables that might affect Clang. -possibly_dangerous_env_vars = ['ASAN_OPTIONS', 'DFSAN_OPTIONS', 'LSAN_OPTIONS', - 'MSAN_OPTIONS', 'UBSAN_OPTIONS', - 'COMPILER_PATH', 'RC_DEBUG_OPTIONS', - 'CINDEXTEST_PREAMBLE_FILE', 'LIBRARY_PATH', - 'CPATH', 'C_INCLUDE_PATH', 'CPLUS_INCLUDE_PATH', - 'OBJC_INCLUDE_PATH', 'OBJCPLUS_INCLUDE_PATH', - 'LIBCLANG_TIMING', 'LIBCLANG_OBJTRACKING', - 'LIBCLANG_LOGGING', 'LIBCLANG_BGPRIO_INDEX', - 'LIBCLANG_BGPRIO_EDIT', 'LIBCLANG_NOTHREADS', - 'LIBCLANG_RESOURCE_USAGE', - 'LIBCLANG_CODE_COMPLETION_LOGGING', - 'XRAY_OPTIONS'] -# Clang/Win32 may refer to %INCLUDE%. vsvarsall.bat sets it. -if platform.system() != 'Windows': - possibly_dangerous_env_vars.append('INCLUDE') -for name in possibly_dangerous_env_vars: - if name in config.environment: - del config.environment[name] - -# Tweak PATH to include llvm tools dir. -if (not config.llvm_tools_dir) or (not os.path.exists(config.llvm_tools_dir)): - lit_config.fatal("Invalid llvm_tools_dir config attribute: %r" % config.llvm_tools_dir) -path = os.path.pathsep.join((config.llvm_tools_dir, config.environment['PATH'])) -config.environment['PATH'] = path - -# Help MSVS link.exe find the standard libraries. -# Make sure we only try to use it when targetting Windows. -if platform.system() == 'Windows' and '-win' in config.target_triple: - config.environment['LIB'] = os.environ['LIB'] - -config.available_features.add(config.host_os.lower()) - -if re.match(r'^x86_64.*-linux', config.target_triple): - config.available_features.add("x86_64-linux") - -if config.have_zlib == "1": - config.available_features.add("zlib") - -# Use ugly construction to explicitly prohibit "clang", "clang++" etc. -# in RUN lines. -config.substitutions.append( - (' clang', """\n\n*** Do not use 'clangXXX' in tests, - instead define '%clangXXX' substitution in lit config. ***\n\n""") ) - -# Allow tests to be executed on a simulator or remotely. -if config.emulator: - config.substitutions.append( ('%run', config.emulator) ) - config.substitutions.append( ('%env ', "env ") ) - # TODO: Implement `%device_rm` to perform removal of files in the emulator. - # For now just make it a no-op. - lit_config.warning('%device_rm is not implemented') - config.substitutions.append( ('%device_rm', 'echo ') ) - config.compile_wrapper = "" -elif config.host_os == 'Darwin' and config.apple_platform != "osx": - # Darwin tests can be targetting macOS, a device or a simulator. All devices - # are declared as "ios", even for iOS derivatives (tvOS, watchOS). Similarly, - # all simulators are "iossim". See the table below. - # - # ========================================================================= - # Target | Feature set - # ========================================================================= - # macOS | darwin - # iOS device | darwin, ios - # iOS simulator | darwin, ios, iossim - # tvOS device | darwin, ios, tvos - # tvOS simulator | darwin, ios, iossim, tvos, tvossim - # watchOS device | darwin, ios, watchos - # watchOS simulator | darwin, ios, iossim, watchos, watchossim - # ========================================================================= - - ios_or_iossim = "iossim" if config.apple_platform.endswith("sim") else "ios" - - config.available_features.add('ios') - device_id_env = "SANITIZER_" + ios_or_iossim.upper() + "_TEST_DEVICE_IDENTIFIER" - if ios_or_iossim == "iossim": - config.available_features.add('iossim') - if device_id_env not in os.environ: - lit_config.fatal( - '{} must be set in the environment when running iossim tests'.format( - device_id_env)) - if config.apple_platform != "ios" and config.apple_platform != "iossim": - config.available_features.add(config.apple_platform) - - ios_commands_dir = os.path.join(config.compiler_rt_src_root, "test", "sanitizer_common", "ios_commands") - - run_wrapper = os.path.join(ios_commands_dir, ios_or_iossim + "_run.py") - env_wrapper = os.path.join(ios_commands_dir, ios_or_iossim + "_env.py") - compile_wrapper = os.path.join(ios_commands_dir, ios_or_iossim + "_compile.py") - prepare_script = os.path.join(ios_commands_dir, ios_or_iossim + "_prepare.py") - - if device_id_env in os.environ: - config.environment[device_id_env] = os.environ[device_id_env] - config.substitutions.append(('%run', run_wrapper)) - config.substitutions.append(('%env ', env_wrapper + " ")) - # Current implementation of %device_rm uses the run_wrapper to do - # the work. - config.substitutions.append(('%device_rm', '{} rm '.format(run_wrapper))) - config.compile_wrapper = compile_wrapper - - try: - prepare_output = subprocess.check_output([prepare_script, config.apple_platform, config.clang]).strip() - except subprocess.CalledProcessError as e: - print("Command failed:") - print(e.output) - raise e - if len(prepare_output) > 0: print(prepare_output) - prepare_output_json = prepare_output.split("\n")[-1] - prepare_output = json.loads(prepare_output_json) - config.environment.update(prepare_output["env"]) -elif config.android: - config.available_features.add('android') - compile_wrapper = os.path.join(config.compiler_rt_src_root, "test", "sanitizer_common", "android_commands", "android_compile.py") + " " - config.compile_wrapper = compile_wrapper - config.substitutions.append( ('%run', "") ) - config.substitutions.append( ('%env ', "env ") ) - # TODO: Implement `%device_rm` to perform removal of files on a device. For - # now just make it a no-op. - lit_config.warning('%device_rm is not implemented') - config.substitutions.append( ('%device_rm', 'echo ') ) -else: - config.substitutions.append( ('%run', "") ) - config.substitutions.append( ('%env ', "env ") ) - # When running locally %device_rm is a no-op. - config.substitutions.append( ('%device_rm', 'echo ') ) - config.compile_wrapper = "" - -# Define CHECK-%os to check for OS-dependent output. -config.substitutions.append( ('CHECK-%os', ("CHECK-" + config.host_os))) - -# Define %arch to check for architecture-dependent output. -config.substitutions.append( ('%arch', (config.host_arch))) - -if config.host_os == 'Windows': - # FIXME: This isn't quite right. Specifically, it will succeed if the program - # does not crash but exits with a non-zero exit code. We ought to merge - # KillTheDoctor and not --crash to make the latter more useful and remove the - # need for this substitution. - config.expect_crash = "not KillTheDoctor " -else: - config.expect_crash = "not --crash " - -config.substitutions.append( ("%expect_crash ", config.expect_crash) ) - -target_arch = getattr(config, 'target_arch', None) -if target_arch: - config.available_features.add(target_arch + '-target-arch') - if target_arch in ['x86_64', 'i386']: - config.available_features.add('x86-target-arch') - config.available_features.add(target_arch + '-' + config.host_os.lower()) - -compiler_rt_debug = getattr(config, 'compiler_rt_debug', False) -if not compiler_rt_debug: - config.available_features.add('compiler-rt-optimized') - -libdispatch = getattr(config, 'compiler_rt_intercept_libdispatch', False) -if libdispatch: - config.available_features.add('libdispatch') - -sanitizer_can_use_cxxabi = getattr(config, 'sanitizer_can_use_cxxabi', True) -if sanitizer_can_use_cxxabi: - config.available_features.add('cxxabi') - -if config.has_lld: - config.available_features.add('lld-available') - -if config.use_lld: - config.available_features.add('lld') - -if config.can_symbolize: - config.available_features.add('can-symbolize') - -if config.gwp_asan: - config.available_features.add('gwp_asan') - -lit.util.usePlatformSdkOnDarwin(config, lit_config) - -if config.host_os == 'Darwin': - osx_version = (10, 0, 0) - try: - osx_version = subprocess.check_output(["sw_vers", "-productVersion"]) - osx_version = tuple(int(x) for x in osx_version.split('.')) - if len(osx_version) == 2: osx_version = (osx_version[0], osx_version[1], 0) - if osx_version >= (10, 11): - config.available_features.add('osx-autointerception') - config.available_features.add('osx-ld64-live_support') - else: - # The ASAN initialization-bug.cc test should XFAIL on OS X systems - # older than El Capitan. By marking the test as being unsupported with - # this "feature", we can pass the test on newer OS X versions and other - # platforms. - config.available_features.add('osx-no-ld64-live_support') - except: - pass - - config.darwin_osx_version = osx_version - - # Detect x86_64h - try: - output = subprocess.check_output(["sysctl", "hw.cpusubtype"]) - output_re = re.match("^hw.cpusubtype: ([0-9]+)$", output) - if output_re: - cpu_subtype = int(output_re.group(1)) - if cpu_subtype == 8: # x86_64h - config.available_features.add('x86_64h') - except: - pass - - config.substitutions.append( ("%macos_min_target_10_11", "-mmacosx-version-min=10.11") ) - - isIOS = config.apple_platform != "osx" - # rdar://problem/22207160 - config.substitutions.append( ("%darwin_min_target_with_full_runtime_arc_support", - "-miphoneos-version-min=9.0" if isIOS else "-mmacosx-version-min=10.11") ) - - # 32-bit iOS simulator is deprecated and removed in latest Xcode. - if config.apple_platform == "iossim": - if config.target_arch == "i386": - config.unsupported = True -else: - config.substitutions.append( ("%macos_min_target_10_11", "") ) - config.substitutions.append( ("%darwin_min_target_with_full_runtime_arc_support", "") ) - -if config.android: - env = os.environ.copy() - if config.android_serial: - env['ANDROID_SERIAL'] = config.android_serial - config.environment['ANDROID_SERIAL'] = config.android_serial - - adb = os.environ.get('ADB', 'adb') - try: - android_api_level_str = subprocess.check_output([adb, "shell", "getprop", "ro.build.version.sdk"], env=env).rstrip() - except (subprocess.CalledProcessError, OSError): - lit_config.fatal("Failed to read ro.build.version.sdk (using '%s' as adb)" % adb) - try: - android_api_level = int(android_api_level_str) - except ValueError: - lit_config.fatal("Failed to read ro.build.version.sdk (using '%s' as adb): got '%s'" % (adb, android_api_level_str)) - if android_api_level >= 26: - config.available_features.add('android-26') - if android_api_level >= 28: - config.available_features.add('android-28') - - # Prepare the device. - android_tmpdir = '/data/local/tmp/Output' - subprocess.check_call([adb, "shell", "mkdir", "-p", android_tmpdir], env=env) - for file in config.android_files_to_push: - subprocess.check_call([adb, "push", file, android_tmpdir], env=env) - -if config.host_os == 'Linux': - # detect whether we are using glibc, and which version - # NB: 'ldd' is just one of the tools commonly installed as part of glibc - ldd_ver_cmd = subprocess.Popen(['ldd', '--version'], - stdout=subprocess.PIPE, - env={'LANG': 'C'}) - sout, _ = ldd_ver_cmd.communicate() - ver_line = sout.splitlines()[0] - if ver_line.startswith(b"ldd "): - from distutils.version import LooseVersion - ver = LooseVersion(ver_line.split()[-1].decode()) - # 2.27 introduced some incompatibilities - if ver >= LooseVersion("2.27"): - config.available_features.add("glibc-2.27") - -sancovcc_path = os.path.join(config.llvm_tools_dir, "sancov") -if os.path.exists(sancovcc_path): - config.available_features.add("has_sancovcc") - config.substitutions.append( ("%sancovcc ", sancovcc_path) ) - -def is_darwin_lto_supported(): - return os.path.exists(os.path.join(config.llvm_shlib_dir, 'libLTO.dylib')) - -def is_linux_lto_supported(): - if config.use_lld: - return True - - if not os.path.exists(os.path.join(config.llvm_shlib_dir, 'LLVMgold.so')): - return False - - ld_cmd = subprocess.Popen([config.gold_executable, '--help'], stdout = subprocess.PIPE, env={'LANG': 'C'}) - ld_out = ld_cmd.stdout.read().decode() - ld_cmd.wait() - - if not '-plugin' in ld_out: - return False - - return True - -def is_windows_lto_supported(): - return os.path.exists(os.path.join(config.llvm_tools_dir, 'lld-link.exe')) - -if config.host_os == 'Darwin' and is_darwin_lto_supported(): - config.lto_supported = True - config.lto_launch = ["env", "DYLD_LIBRARY_PATH=" + config.llvm_shlib_dir] - config.lto_flags = [] -elif config.host_os in ['Linux', 'FreeBSD', 'NetBSD'] and is_linux_lto_supported(): - config.lto_supported = True - config.lto_launch = [] - if config.use_lld: - config.lto_flags = ["-fuse-ld=lld"] - else: - config.lto_flags = ["-fuse-ld=gold"] -elif config.host_os == 'Windows' and is_windows_lto_supported(): - config.lto_supported = True - config.lto_launch = [] - config.lto_flags = ["-fuse-ld=lld"] -else: - config.lto_supported = False - -if config.lto_supported: - config.available_features.add('lto') - if config.use_thinlto: - config.available_features.add('thinlto') - config.lto_flags += ["-flto=thin"] - else: - config.lto_flags += ["-flto"] - if config.use_newpm: - config.lto_flags += ["-fexperimental-new-pass-manager"] - -if config.have_rpc_xdr_h: - config.available_features.add('sunrpc') - -# Ask llvm-config about assertion mode. -try: - llvm_config_cmd = subprocess.Popen( - [os.path.join(config.llvm_tools_dir, 'llvm-config'), '--assertion-mode'], - stdout = subprocess.PIPE, - env=config.environment) -except OSError as e: - print("Could not launch llvm-config in " + config.llvm_tools_dir) - print(" Failed with error #{0}: {1}".format(e.errno, e.strerror)) - exit(42) - -if re.search(r'ON', llvm_config_cmd.stdout.read().decode('ascii')): - config.available_features.add('asserts') -llvm_config_cmd.wait() - -# Sanitizer tests tend to be flaky on Windows due to PR24554, so add some -# retries. We don't do this on otther platforms because it's slower. -if platform.system() == 'Windows': - config.test_retry_attempts = 2 - -# No throttling on non-Darwin platforms. -lit_config.parallelism_groups['shadow-memory'] = None - -if platform.system() == 'Darwin': - ios_device = config.apple_platform != 'osx' and not config.apple_platform.endswith('sim') - # Force sequential execution when running tests on iOS devices. - if ios_device: - lit_config.warning('Forcing sequential execution for iOS device tests') - lit_config.parallelism_groups['ios-device'] = 1 - config.parallelism_group = 'ios-device' - - # Only run up to 3 processes that require shadow memory simultaneously on - # 64-bit Darwin. Using more scales badly and hogs the system due to - # inefficient handling of large mmap'd regions (terabytes) by the kernel. - elif config.target_arch in ['x86_64', 'x86_64h']: - lit_config.warning('Throttling sanitizer tests that require shadow memory on Darwin 64bit') - lit_config.parallelism_groups['shadow-memory'] = 3 - -# Multiple substitutions are necessary to support multiple shared objects used -# at once. -# Note that substitutions with numbers have to be defined first to avoid -# being subsumed by substitutions with smaller postfix. -for postfix in ["2", "1", ""]: - if config.host_os == 'Darwin': - config.substitutions.append( ("%ld_flags_rpath_exe" + postfix, '-Wl,-rpath,@executable_path/ %dynamiclib' + postfix) ) - config.substitutions.append( ("%ld_flags_rpath_so" + postfix, '-install_name @rpath/`basename %dynamiclib{}`'.format(postfix)) ) - elif config.host_os in ('FreeBSD', 'NetBSD', 'OpenBSD'): - config.substitutions.append( ("%ld_flags_rpath_exe" + postfix, "-Wl,-z,origin -Wl,-rpath,\$ORIGIN -L%T -l%xdynamiclib_namespec" + postfix) ) - config.substitutions.append( ("%ld_flags_rpath_so" + postfix, '') ) - elif config.host_os == 'Linux': - config.substitutions.append( ("%ld_flags_rpath_exe" + postfix, "-Wl,-rpath,\$ORIGIN -L%T -l%xdynamiclib_namespec" + postfix) ) - config.substitutions.append( ("%ld_flags_rpath_so" + postfix, '') ) - elif config.host_os == 'SunOS': - config.substitutions.append( ("%ld_flags_rpath_exe" + postfix, "-Wl,-R\$ORIGIN -L%T -l%xdynamiclib_namespec" + postfix) ) - config.substitutions.append( ("%ld_flags_rpath_so" + postfix, '') ) - - # Must be defined after the substitutions that use %dynamiclib. - config.substitutions.append( ("%dynamiclib" + postfix, '%T/%xdynamiclib_filename' + postfix) ) - config.substitutions.append( ("%xdynamiclib_filename" + postfix, 'lib%xdynamiclib_namespec{}.so'.format(postfix)) ) - config.substitutions.append( ("%xdynamiclib_namespec", '%basename_t.dynamic') ) - -# Provide a substituion that can be used to tell Clang to use a static libstdc++. -# The substitution expands to nothing on non Linux platforms. -# FIXME: This should check the target OS, not the host OS. -if config.host_os == 'Linux': - config.substitutions.append( ("%linux_static_libstdcplusplus", "-stdlib=libstdc++ -static-libstdc++") ) -else: - config.substitutions.append( ("%linux_static_libstdcplusplus", "") ) - -config.default_sanitizer_opts = [] -if config.host_os == 'Darwin': - # On Darwin, we default to `abort_on_error=1`, which would make tests run - # much slower. Let's override this and run lit tests with 'abort_on_error=0'. - config.default_sanitizer_opts += ['abort_on_error=0'] - config.default_sanitizer_opts += ['log_to_syslog=0'] -elif config.android: - config.default_sanitizer_opts += ['abort_on_error=0'] - -# Allow tests to use REQUIRES=stable-runtime. For use when you cannot use XFAIL -# because the test hangs or fails on one configuration and not the other. -if config.android or (config.target_arch not in ['arm', 'armhf', 'aarch64']): - config.available_features.add('stable-runtime') - -if config.asan_shadow_scale: - config.available_features.add("shadow-scale-%s" % config.asan_shadow_scale) -else: - config.available_features.add("shadow-scale-3") - -# Propagate the LLD/LTO into the clang config option, so nothing else is needed. -run_wrapper = [] -target_cflags = [getattr(config, 'target_cflags', None)] -extra_cflags = [] - -if config.use_lto and config.lto_supported: - run_wrapper += config.lto_launch - extra_cflags += config.lto_flags -elif config.use_lto and (not config.lto_supported): - config.unsupported = True - -if config.use_lld and config.has_lld and not config.use_lto: - extra_cflags += ["-fuse-ld=lld"] -elif config.use_lld and (not config.has_lld): - config.unsupported = True - -config.clang = " " + " ".join(run_wrapper + [config.compile_wrapper, config.clang]) + " " -config.target_cflags = " " + " ".join(target_cflags + extra_cflags) + " " Index: compiler-rt/trunk/test/lit.common.cfg.py =================================================================== --- compiler-rt/trunk/test/lit.common.cfg.py +++ compiler-rt/trunk/test/lit.common.cfg.py @@ -0,0 +1,497 @@ +# -*- Python -*- + +# Configuration file for 'lit' test runner. +# This file contains common rules for various compiler-rt testsuites. +# It is mostly copied from lit.cfg.py used by Clang. +import os +import platform +import re +import subprocess +import json + +import lit.formats +import lit.util + +# Choose between lit's internal shell pipeline runner and a real shell. If +# LIT_USE_INTERNAL_SHELL is in the environment, we use that as an override. +use_lit_shell = os.environ.get("LIT_USE_INTERNAL_SHELL") +if use_lit_shell: + # 0 is external, "" is default, and everything else is internal. + execute_external = (use_lit_shell == "0") +else: + # Otherwise we default to internal on Windows and external elsewhere, as + # bash on Windows is usually very slow. + execute_external = (not sys.platform in ['win32']) + +# Setup test format. +config.test_format = lit.formats.ShTest(execute_external) +if execute_external: + config.available_features.add('shell') + +compiler_id = getattr(config, 'compiler_id', None) +if compiler_id == "Clang": + if platform.system() != 'Windows': + config.cxx_mode_flags = ["--driver-mode=g++"] + else: + config.cxx_mode_flags = [] + # We assume that sanitizers should provide good enough error + # reports and stack traces even with minimal debug info. + config.debug_info_flags = ["-gline-tables-only"] + if platform.system() == 'Windows': + # On Windows, use CodeView with column info instead of DWARF. Both VS and + # windbg do not behave well when column info is enabled, but users have + # requested it because it makes ASan reports more precise. + config.debug_info_flags.append("-gcodeview") + config.debug_info_flags.append("-gcolumn-info") +elif compiler_id == 'GNU': + config.cxx_mode_flags = ["-x c++"] + config.debug_info_flags = ["-g"] +else: + lit_config.fatal("Unsupported compiler id: %r" % compiler_id) +# Add compiler ID to the list of available features. +config.available_features.add(compiler_id) + +# If needed, add cflag for shadow scale. +if config.asan_shadow_scale != '': + config.target_cflags += " -mllvm -asan-mapping-scale=" + config.asan_shadow_scale + +# BFD linker in 64-bit android toolchains fails to find libc++_shared.so, which +# is a transitive shared library dependency (via asan runtime). +if config.android: + # Prepend the flag so that it can be overridden. + config.target_cflags = "-pie -fuse-ld=gold " + config.target_cflags + if config.android_ndk_version < 19: + # With a new compiler and NDK < r19 this flag ends up meaning "link against + # libc++", but NDK r19 makes this mean "link against the stub libstdc++ that + # just contains a handful of ABI functions", which makes most C++ code fail + # to link. In r19 and later we just use the default which is libc++. + config.cxx_mode_flags.append('-stdlib=libstdc++') + +# Clear some environment variables that might affect Clang. +possibly_dangerous_env_vars = ['ASAN_OPTIONS', 'DFSAN_OPTIONS', 'LSAN_OPTIONS', + 'MSAN_OPTIONS', 'UBSAN_OPTIONS', + 'COMPILER_PATH', 'RC_DEBUG_OPTIONS', + 'CINDEXTEST_PREAMBLE_FILE', 'LIBRARY_PATH', + 'CPATH', 'C_INCLUDE_PATH', 'CPLUS_INCLUDE_PATH', + 'OBJC_INCLUDE_PATH', 'OBJCPLUS_INCLUDE_PATH', + 'LIBCLANG_TIMING', 'LIBCLANG_OBJTRACKING', + 'LIBCLANG_LOGGING', 'LIBCLANG_BGPRIO_INDEX', + 'LIBCLANG_BGPRIO_EDIT', 'LIBCLANG_NOTHREADS', + 'LIBCLANG_RESOURCE_USAGE', + 'LIBCLANG_CODE_COMPLETION_LOGGING', + 'XRAY_OPTIONS'] +# Clang/Win32 may refer to %INCLUDE%. vsvarsall.bat sets it. +if platform.system() != 'Windows': + possibly_dangerous_env_vars.append('INCLUDE') +for name in possibly_dangerous_env_vars: + if name in config.environment: + del config.environment[name] + +# Tweak PATH to include llvm tools dir. +if (not config.llvm_tools_dir) or (not os.path.exists(config.llvm_tools_dir)): + lit_config.fatal("Invalid llvm_tools_dir config attribute: %r" % config.llvm_tools_dir) +path = os.path.pathsep.join((config.llvm_tools_dir, config.environment['PATH'])) +config.environment['PATH'] = path + +# Help MSVS link.exe find the standard libraries. +# Make sure we only try to use it when targetting Windows. +if platform.system() == 'Windows' and '-win' in config.target_triple: + config.environment['LIB'] = os.environ['LIB'] + +config.available_features.add(config.host_os.lower()) + +if re.match(r'^x86_64.*-linux', config.target_triple): + config.available_features.add("x86_64-linux") + +if config.have_zlib == "1": + config.available_features.add("zlib") + +# Use ugly construction to explicitly prohibit "clang", "clang++" etc. +# in RUN lines. +config.substitutions.append( + (' clang', """\n\n*** Do not use 'clangXXX' in tests, + instead define '%clangXXX' substitution in lit config. ***\n\n""") ) + +# Allow tests to be executed on a simulator or remotely. +if config.emulator: + config.substitutions.append( ('%run', config.emulator) ) + config.substitutions.append( ('%env ', "env ") ) + # TODO: Implement `%device_rm` to perform removal of files in the emulator. + # For now just make it a no-op. + lit_config.warning('%device_rm is not implemented') + config.substitutions.append( ('%device_rm', 'echo ') ) + config.compile_wrapper = "" +elif config.host_os == 'Darwin' and config.apple_platform != "osx": + # Darwin tests can be targetting macOS, a device or a simulator. All devices + # are declared as "ios", even for iOS derivatives (tvOS, watchOS). Similarly, + # all simulators are "iossim". See the table below. + # + # ========================================================================= + # Target | Feature set + # ========================================================================= + # macOS | darwin + # iOS device | darwin, ios + # iOS simulator | darwin, ios, iossim + # tvOS device | darwin, ios, tvos + # tvOS simulator | darwin, ios, iossim, tvos, tvossim + # watchOS device | darwin, ios, watchos + # watchOS simulator | darwin, ios, iossim, watchos, watchossim + # ========================================================================= + + ios_or_iossim = "iossim" if config.apple_platform.endswith("sim") else "ios" + + config.available_features.add('ios') + device_id_env = "SANITIZER_" + ios_or_iossim.upper() + "_TEST_DEVICE_IDENTIFIER" + if ios_or_iossim == "iossim": + config.available_features.add('iossim') + if device_id_env not in os.environ: + lit_config.fatal( + '{} must be set in the environment when running iossim tests'.format( + device_id_env)) + if config.apple_platform != "ios" and config.apple_platform != "iossim": + config.available_features.add(config.apple_platform) + + ios_commands_dir = os.path.join(config.compiler_rt_src_root, "test", "sanitizer_common", "ios_commands") + + run_wrapper = os.path.join(ios_commands_dir, ios_or_iossim + "_run.py") + env_wrapper = os.path.join(ios_commands_dir, ios_or_iossim + "_env.py") + compile_wrapper = os.path.join(ios_commands_dir, ios_or_iossim + "_compile.py") + prepare_script = os.path.join(ios_commands_dir, ios_or_iossim + "_prepare.py") + + if device_id_env in os.environ: + config.environment[device_id_env] = os.environ[device_id_env] + config.substitutions.append(('%run', run_wrapper)) + config.substitutions.append(('%env ', env_wrapper + " ")) + # Current implementation of %device_rm uses the run_wrapper to do + # the work. + config.substitutions.append(('%device_rm', '{} rm '.format(run_wrapper))) + config.compile_wrapper = compile_wrapper + + try: + prepare_output = subprocess.check_output([prepare_script, config.apple_platform, config.clang]).strip() + except subprocess.CalledProcessError as e: + print("Command failed:") + print(e.output) + raise e + if len(prepare_output) > 0: print(prepare_output) + prepare_output_json = prepare_output.split("\n")[-1] + prepare_output = json.loads(prepare_output_json) + config.environment.update(prepare_output["env"]) +elif config.android: + config.available_features.add('android') + compile_wrapper = os.path.join(config.compiler_rt_src_root, "test", "sanitizer_common", "android_commands", "android_compile.py") + " " + config.compile_wrapper = compile_wrapper + config.substitutions.append( ('%run', "") ) + config.substitutions.append( ('%env ', "env ") ) + # TODO: Implement `%device_rm` to perform removal of files on a device. For + # now just make it a no-op. + lit_config.warning('%device_rm is not implemented') + config.substitutions.append( ('%device_rm', 'echo ') ) +else: + config.substitutions.append( ('%run', "") ) + config.substitutions.append( ('%env ', "env ") ) + # When running locally %device_rm is a no-op. + config.substitutions.append( ('%device_rm', 'echo ') ) + config.compile_wrapper = "" + +# Define CHECK-%os to check for OS-dependent output. +config.substitutions.append( ('CHECK-%os', ("CHECK-" + config.host_os))) + +# Define %arch to check for architecture-dependent output. +config.substitutions.append( ('%arch', (config.host_arch))) + +if config.host_os == 'Windows': + # FIXME: This isn't quite right. Specifically, it will succeed if the program + # does not crash but exits with a non-zero exit code. We ought to merge + # KillTheDoctor and not --crash to make the latter more useful and remove the + # need for this substitution. + config.expect_crash = "not KillTheDoctor " +else: + config.expect_crash = "not --crash " + +config.substitutions.append( ("%expect_crash ", config.expect_crash) ) + +target_arch = getattr(config, 'target_arch', None) +if target_arch: + config.available_features.add(target_arch + '-target-arch') + if target_arch in ['x86_64', 'i386']: + config.available_features.add('x86-target-arch') + config.available_features.add(target_arch + '-' + config.host_os.lower()) + +compiler_rt_debug = getattr(config, 'compiler_rt_debug', False) +if not compiler_rt_debug: + config.available_features.add('compiler-rt-optimized') + +libdispatch = getattr(config, 'compiler_rt_intercept_libdispatch', False) +if libdispatch: + config.available_features.add('libdispatch') + +sanitizer_can_use_cxxabi = getattr(config, 'sanitizer_can_use_cxxabi', True) +if sanitizer_can_use_cxxabi: + config.available_features.add('cxxabi') + +if config.has_lld: + config.available_features.add('lld-available') + +if config.use_lld: + config.available_features.add('lld') + +if config.can_symbolize: + config.available_features.add('can-symbolize') + +if config.gwp_asan: + config.available_features.add('gwp_asan') + +lit.util.usePlatformSdkOnDarwin(config, lit_config) + +if config.host_os == 'Darwin': + osx_version = (10, 0, 0) + try: + osx_version = subprocess.check_output(["sw_vers", "-productVersion"]) + osx_version = tuple(int(x) for x in osx_version.split('.')) + if len(osx_version) == 2: osx_version = (osx_version[0], osx_version[1], 0) + if osx_version >= (10, 11): + config.available_features.add('osx-autointerception') + config.available_features.add('osx-ld64-live_support') + else: + # The ASAN initialization-bug.cc test should XFAIL on OS X systems + # older than El Capitan. By marking the test as being unsupported with + # this "feature", we can pass the test on newer OS X versions and other + # platforms. + config.available_features.add('osx-no-ld64-live_support') + except: + pass + + config.darwin_osx_version = osx_version + + # Detect x86_64h + try: + output = subprocess.check_output(["sysctl", "hw.cpusubtype"]) + output_re = re.match("^hw.cpusubtype: ([0-9]+)$", output) + if output_re: + cpu_subtype = int(output_re.group(1)) + if cpu_subtype == 8: # x86_64h + config.available_features.add('x86_64h') + except: + pass + + config.substitutions.append( ("%macos_min_target_10_11", "-mmacosx-version-min=10.11") ) + + isIOS = config.apple_platform != "osx" + # rdar://problem/22207160 + config.substitutions.append( ("%darwin_min_target_with_full_runtime_arc_support", + "-miphoneos-version-min=9.0" if isIOS else "-mmacosx-version-min=10.11") ) + + # 32-bit iOS simulator is deprecated and removed in latest Xcode. + if config.apple_platform == "iossim": + if config.target_arch == "i386": + config.unsupported = True +else: + config.substitutions.append( ("%macos_min_target_10_11", "") ) + config.substitutions.append( ("%darwin_min_target_with_full_runtime_arc_support", "") ) + +if config.android: + env = os.environ.copy() + if config.android_serial: + env['ANDROID_SERIAL'] = config.android_serial + config.environment['ANDROID_SERIAL'] = config.android_serial + + adb = os.environ.get('ADB', 'adb') + try: + android_api_level_str = subprocess.check_output([adb, "shell", "getprop", "ro.build.version.sdk"], env=env).rstrip() + except (subprocess.CalledProcessError, OSError): + lit_config.fatal("Failed to read ro.build.version.sdk (using '%s' as adb)" % adb) + try: + android_api_level = int(android_api_level_str) + except ValueError: + lit_config.fatal("Failed to read ro.build.version.sdk (using '%s' as adb): got '%s'" % (adb, android_api_level_str)) + if android_api_level >= 26: + config.available_features.add('android-26') + if android_api_level >= 28: + config.available_features.add('android-28') + + # Prepare the device. + android_tmpdir = '/data/local/tmp/Output' + subprocess.check_call([adb, "shell", "mkdir", "-p", android_tmpdir], env=env) + for file in config.android_files_to_push: + subprocess.check_call([adb, "push", file, android_tmpdir], env=env) + +if config.host_os == 'Linux': + # detect whether we are using glibc, and which version + # NB: 'ldd' is just one of the tools commonly installed as part of glibc + ldd_ver_cmd = subprocess.Popen(['ldd', '--version'], + stdout=subprocess.PIPE, + env={'LANG': 'C'}) + sout, _ = ldd_ver_cmd.communicate() + ver_line = sout.splitlines()[0] + if ver_line.startswith(b"ldd "): + from distutils.version import LooseVersion + ver = LooseVersion(ver_line.split()[-1].decode()) + # 2.27 introduced some incompatibilities + if ver >= LooseVersion("2.27"): + config.available_features.add("glibc-2.27") + +sancovcc_path = os.path.join(config.llvm_tools_dir, "sancov") +if os.path.exists(sancovcc_path): + config.available_features.add("has_sancovcc") + config.substitutions.append( ("%sancovcc ", sancovcc_path) ) + +def is_darwin_lto_supported(): + return os.path.exists(os.path.join(config.llvm_shlib_dir, 'libLTO.dylib')) + +def is_linux_lto_supported(): + if config.use_lld: + return True + + if not os.path.exists(os.path.join(config.llvm_shlib_dir, 'LLVMgold.so')): + return False + + ld_cmd = subprocess.Popen([config.gold_executable, '--help'], stdout = subprocess.PIPE, env={'LANG': 'C'}) + ld_out = ld_cmd.stdout.read().decode() + ld_cmd.wait() + + if not '-plugin' in ld_out: + return False + + return True + +def is_windows_lto_supported(): + return os.path.exists(os.path.join(config.llvm_tools_dir, 'lld-link.exe')) + +if config.host_os == 'Darwin' and is_darwin_lto_supported(): + config.lto_supported = True + config.lto_launch = ["env", "DYLD_LIBRARY_PATH=" + config.llvm_shlib_dir] + config.lto_flags = [] +elif config.host_os in ['Linux', 'FreeBSD', 'NetBSD'] and is_linux_lto_supported(): + config.lto_supported = True + config.lto_launch = [] + if config.use_lld: + config.lto_flags = ["-fuse-ld=lld"] + else: + config.lto_flags = ["-fuse-ld=gold"] +elif config.host_os == 'Windows' and is_windows_lto_supported(): + config.lto_supported = True + config.lto_launch = [] + config.lto_flags = ["-fuse-ld=lld"] +else: + config.lto_supported = False + +if config.lto_supported: + config.available_features.add('lto') + if config.use_thinlto: + config.available_features.add('thinlto') + config.lto_flags += ["-flto=thin"] + else: + config.lto_flags += ["-flto"] + if config.use_newpm: + config.lto_flags += ["-fexperimental-new-pass-manager"] + +if config.have_rpc_xdr_h: + config.available_features.add('sunrpc') + +# Ask llvm-config about assertion mode. +try: + llvm_config_cmd = subprocess.Popen( + [os.path.join(config.llvm_tools_dir, 'llvm-config'), '--assertion-mode'], + stdout = subprocess.PIPE, + env=config.environment) +except OSError as e: + print("Could not launch llvm-config in " + config.llvm_tools_dir) + print(" Failed with error #{0}: {1}".format(e.errno, e.strerror)) + exit(42) + +if re.search(r'ON', llvm_config_cmd.stdout.read().decode('ascii')): + config.available_features.add('asserts') +llvm_config_cmd.wait() + +# Sanitizer tests tend to be flaky on Windows due to PR24554, so add some +# retries. We don't do this on otther platforms because it's slower. +if platform.system() == 'Windows': + config.test_retry_attempts = 2 + +# No throttling on non-Darwin platforms. +lit_config.parallelism_groups['shadow-memory'] = None + +if platform.system() == 'Darwin': + ios_device = config.apple_platform != 'osx' and not config.apple_platform.endswith('sim') + # Force sequential execution when running tests on iOS devices. + if ios_device: + lit_config.warning('Forcing sequential execution for iOS device tests') + lit_config.parallelism_groups['ios-device'] = 1 + config.parallelism_group = 'ios-device' + + # Only run up to 3 processes that require shadow memory simultaneously on + # 64-bit Darwin. Using more scales badly and hogs the system due to + # inefficient handling of large mmap'd regions (terabytes) by the kernel. + elif config.target_arch in ['x86_64', 'x86_64h']: + lit_config.warning('Throttling sanitizer tests that require shadow memory on Darwin 64bit') + lit_config.parallelism_groups['shadow-memory'] = 3 + +# Multiple substitutions are necessary to support multiple shared objects used +# at once. +# Note that substitutions with numbers have to be defined first to avoid +# being subsumed by substitutions with smaller postfix. +for postfix in ["2", "1", ""]: + if config.host_os == 'Darwin': + config.substitutions.append( ("%ld_flags_rpath_exe" + postfix, '-Wl,-rpath,@executable_path/ %dynamiclib' + postfix) ) + config.substitutions.append( ("%ld_flags_rpath_so" + postfix, '-install_name @rpath/`basename %dynamiclib{}`'.format(postfix)) ) + elif config.host_os in ('FreeBSD', 'NetBSD', 'OpenBSD'): + config.substitutions.append( ("%ld_flags_rpath_exe" + postfix, "-Wl,-z,origin -Wl,-rpath,\$ORIGIN -L%T -l%xdynamiclib_namespec" + postfix) ) + config.substitutions.append( ("%ld_flags_rpath_so" + postfix, '') ) + elif config.host_os == 'Linux': + config.substitutions.append( ("%ld_flags_rpath_exe" + postfix, "-Wl,-rpath,\$ORIGIN -L%T -l%xdynamiclib_namespec" + postfix) ) + config.substitutions.append( ("%ld_flags_rpath_so" + postfix, '') ) + elif config.host_os == 'SunOS': + config.substitutions.append( ("%ld_flags_rpath_exe" + postfix, "-Wl,-R\$ORIGIN -L%T -l%xdynamiclib_namespec" + postfix) ) + config.substitutions.append( ("%ld_flags_rpath_so" + postfix, '') ) + + # Must be defined after the substitutions that use %dynamiclib. + config.substitutions.append( ("%dynamiclib" + postfix, '%T/%xdynamiclib_filename' + postfix) ) + config.substitutions.append( ("%xdynamiclib_filename" + postfix, 'lib%xdynamiclib_namespec{}.so'.format(postfix)) ) + config.substitutions.append( ("%xdynamiclib_namespec", '%basename_t.dynamic') ) + +# Provide a substituion that can be used to tell Clang to use a static libstdc++. +# The substitution expands to nothing on non Linux platforms. +# FIXME: This should check the target OS, not the host OS. +if config.host_os == 'Linux': + config.substitutions.append( ("%linux_static_libstdcplusplus", "-stdlib=libstdc++ -static-libstdc++") ) +else: + config.substitutions.append( ("%linux_static_libstdcplusplus", "") ) + +config.default_sanitizer_opts = [] +if config.host_os == 'Darwin': + # On Darwin, we default to `abort_on_error=1`, which would make tests run + # much slower. Let's override this and run lit tests with 'abort_on_error=0'. + config.default_sanitizer_opts += ['abort_on_error=0'] + config.default_sanitizer_opts += ['log_to_syslog=0'] +elif config.android: + config.default_sanitizer_opts += ['abort_on_error=0'] + +# Allow tests to use REQUIRES=stable-runtime. For use when you cannot use XFAIL +# because the test hangs or fails on one configuration and not the other. +if config.android or (config.target_arch not in ['arm', 'armhf', 'aarch64']): + config.available_features.add('stable-runtime') + +if config.asan_shadow_scale: + config.available_features.add("shadow-scale-%s" % config.asan_shadow_scale) +else: + config.available_features.add("shadow-scale-3") + +# Propagate the LLD/LTO into the clang config option, so nothing else is needed. +run_wrapper = [] +target_cflags = [getattr(config, 'target_cflags', None)] +extra_cflags = [] + +if config.use_lto and config.lto_supported: + run_wrapper += config.lto_launch + extra_cflags += config.lto_flags +elif config.use_lto and (not config.lto_supported): + config.unsupported = True + +if config.use_lld and config.has_lld and not config.use_lto: + extra_cflags += ["-fuse-ld=lld"] +elif config.use_lld and (not config.has_lld): + config.unsupported = True + +config.clang = " " + " ".join(run_wrapper + [config.compile_wrapper, config.clang]) + " " +config.target_cflags = " " + " ".join(target_cflags + extra_cflags) + " " Index: compiler-rt/trunk/test/lit.common.configured.in =================================================================== --- compiler-rt/trunk/test/lit.common.configured.in +++ compiler-rt/trunk/test/lit.common.configured.in @@ -66,4 +66,4 @@ lit_config.fatal("Can't find compiler on path %r" % config.clang) # Setup attributes common for all compiler-rt projects. -lit_config.load_config(config, "@COMPILER_RT_SOURCE_DIR@/test/lit.common.cfg") +lit_config.load_config(config, "@COMPILER_RT_SOURCE_DIR@/test/lit.common.cfg.py") Index: compiler-rt/trunk/test/lsan/CMakeLists.txt =================================================================== --- compiler-rt/trunk/test/lsan/CMakeLists.txt +++ compiler-rt/trunk/test/lsan/CMakeLists.txt @@ -16,16 +16,16 @@ set(CONFIG_NAME ${ARCH_UPPER_CASE}LsanConfig) configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg) + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in + ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py) list(APPEND LSAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}) set(CONFIG_NAME ${ARCH_UPPER_CASE}AsanConfig) set(LSAN_LIT_TEST_MODE "AddressSanitizer") configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg) + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in + ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py) list(APPEND LSAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}) endforeach() Index: compiler-rt/trunk/test/lsan/TestCases/Darwin/lit.local.cfg =================================================================== --- compiler-rt/trunk/test/lsan/TestCases/Darwin/lit.local.cfg +++ compiler-rt/trunk/test/lsan/TestCases/Darwin/lit.local.cfg @@ -1,9 +0,0 @@ -def getRoot(config): - if not config.parent: - return config - return getRoot(config.parent) - -root = getRoot(config) - -if root.host_os not in ['Darwin']: - config.unsupported = True Index: compiler-rt/trunk/test/lsan/TestCases/Darwin/lit.local.cfg.py =================================================================== --- compiler-rt/trunk/test/lsan/TestCases/Darwin/lit.local.cfg.py +++ compiler-rt/trunk/test/lsan/TestCases/Darwin/lit.local.cfg.py @@ -0,0 +1,9 @@ +def getRoot(config): + if not config.parent: + return config + return getRoot(config.parent) + +root = getRoot(config) + +if root.host_os not in ['Darwin']: + config.unsupported = True Index: compiler-rt/trunk/test/lsan/TestCases/Linux/lit.local.cfg =================================================================== --- compiler-rt/trunk/test/lsan/TestCases/Linux/lit.local.cfg +++ compiler-rt/trunk/test/lsan/TestCases/Linux/lit.local.cfg @@ -1,9 +0,0 @@ -def getRoot(config): - if not config.parent: - return config - return getRoot(config.parent) - -root = getRoot(config) - -if root.host_os not in ['Linux']: - config.unsupported = True Index: compiler-rt/trunk/test/lsan/TestCases/Linux/lit.local.cfg.py =================================================================== --- compiler-rt/trunk/test/lsan/TestCases/Linux/lit.local.cfg.py +++ compiler-rt/trunk/test/lsan/TestCases/Linux/lit.local.cfg.py @@ -0,0 +1,9 @@ +def getRoot(config): + if not config.parent: + return config + return getRoot(config.parent) + +root = getRoot(config) + +if root.host_os not in ['Linux']: + config.unsupported = True Index: compiler-rt/trunk/test/lsan/TestCases/Posix/lit.local.cfg =================================================================== --- compiler-rt/trunk/test/lsan/TestCases/Posix/lit.local.cfg +++ compiler-rt/trunk/test/lsan/TestCases/Posix/lit.local.cfg @@ -1,9 +0,0 @@ -def getRoot(config): - if not config.parent: - return config - return getRoot(config.parent) - -root = getRoot(config) - -if root.host_os in ['Windows']: - config.unsupported = True Index: compiler-rt/trunk/test/lsan/TestCases/Posix/lit.local.cfg.py =================================================================== --- compiler-rt/trunk/test/lsan/TestCases/Posix/lit.local.cfg.py +++ compiler-rt/trunk/test/lsan/TestCases/Posix/lit.local.cfg.py @@ -0,0 +1,9 @@ +def getRoot(config): + if not config.parent: + return config + return getRoot(config.parent) + +root = getRoot(config) + +if root.host_os in ['Windows']: + config.unsupported = True Index: compiler-rt/trunk/test/lsan/lit.common.cfg =================================================================== --- compiler-rt/trunk/test/lsan/lit.common.cfg +++ compiler-rt/trunk/test/lsan/lit.common.cfg @@ -1,80 +0,0 @@ -# -*- Python -*- - -# Common configuration for running leak detection tests under LSan/ASan. - -import os -import re - -import lit.util - -def get_required_attr(config, attr_name): - attr_value = getattr(config, attr_name, None) - if attr_value == None: - lit_config.fatal( - "No attribute %r in test configuration! You may need to run " - "tests from your build directory or add this attribute " - "to lit.site.cfg " % attr_name) - return attr_value - -# Setup source root. -config.test_source_root = os.path.dirname(__file__) - -# Choose between standalone and LSan+ASan modes. -lsan_lit_test_mode = get_required_attr(config, 'lsan_lit_test_mode') -if lsan_lit_test_mode == "Standalone": - config.name = "LeakSanitizer-Standalone" - lsan_cflags = ["-fsanitize=leak"] -elif lsan_lit_test_mode == "AddressSanitizer": - config.name = "LeakSanitizer-AddressSanitizer" - lsan_cflags = ["-fsanitize=address"] - config.available_features.add('asan') -else: - lit_config.fatal("Unknown LSan test mode: %r" % lsan_lit_test_mode) -config.name += config.name_suffix - -# Platform-specific default LSAN_OPTIONS for lit tests. -default_lsan_opts = 'detect_leaks=1' -if config.host_os == 'Darwin': - # On Darwin, we default to `abort_on_error=1`, which would make tests run - # much slower. Let's override this and run lit tests with 'abort_on_error=0'. - # Also, make sure we do not overwhelm the syslog while testing. - default_lsan_opts += ':abort_on_error=0' - default_lsan_opts += ':log_to_syslog=0' - -if default_lsan_opts: - config.environment['LSAN_OPTIONS'] = default_lsan_opts - default_lsan_opts += ':' -config.substitutions.append(('%env_lsan_opts=', - 'env LSAN_OPTIONS=' + default_lsan_opts)) - -if lit.util.which('strace'): - config.available_features.add('strace') - -clang_cflags = ["-O0", config.target_cflags] + config.debug_info_flags -clang_cxxflags = config.cxx_mode_flags + clang_cflags -lsan_incdir = config.test_source_root + "/../" -clang_lsan_cflags = clang_cflags + lsan_cflags + ["-I%s" % lsan_incdir] -clang_lsan_cxxflags = clang_cxxflags + lsan_cflags + ["-I%s" % lsan_incdir] - -config.clang_cflags = clang_cflags -config.clang_cxxflags = clang_cxxflags - -def build_invocation(compile_flags): - return " " + " ".join([config.clang] + compile_flags) + " " - -config.substitutions.append( ("%clang ", build_invocation(clang_cflags)) ) -config.substitutions.append( ("%clangxx ", build_invocation(clang_cxxflags)) ) -config.substitutions.append( ("%clang_lsan ", build_invocation(clang_lsan_cflags)) ) -config.substitutions.append( ("%clangxx_lsan ", build_invocation(clang_lsan_cxxflags)) ) - -# LeakSanitizer tests are currently supported on x86-64 Linux, PowerPC64 Linux, arm Linux, mips64 Linux, and x86_64 Darwin. -supported_linux = config.host_os is 'Linux' and config.host_arch in ['x86_64', 'ppc64', 'ppc64le', 'mips64', 'arm', 'armhf', 'armv7l'] -supported_darwin = config.host_os is 'Darwin' and config.target_arch is 'x86_64' -if not (supported_linux or supported_darwin): - config.unsupported = True - -# Don't support Thumb due to broken fast unwinder -if re.search('mthumb', config.target_cflags) is not None: - config.unsupported = True - -config.suffixes = ['.c', '.cc', '.cpp', '.mm'] Index: compiler-rt/trunk/test/lsan/lit.common.cfg.py =================================================================== --- compiler-rt/trunk/test/lsan/lit.common.cfg.py +++ compiler-rt/trunk/test/lsan/lit.common.cfg.py @@ -0,0 +1,80 @@ +# -*- Python -*- + +# Common configuration for running leak detection tests under LSan/ASan. + +import os +import re + +import lit.util + +def get_required_attr(config, attr_name): + attr_value = getattr(config, attr_name, None) + if attr_value == None: + lit_config.fatal( + "No attribute %r in test configuration! You may need to run " + "tests from your build directory or add this attribute " + "to lit.site.cfg.py " % attr_name) + return attr_value + +# Setup source root. +config.test_source_root = os.path.dirname(__file__) + +# Choose between standalone and LSan+ASan modes. +lsan_lit_test_mode = get_required_attr(config, 'lsan_lit_test_mode') +if lsan_lit_test_mode == "Standalone": + config.name = "LeakSanitizer-Standalone" + lsan_cflags = ["-fsanitize=leak"] +elif lsan_lit_test_mode == "AddressSanitizer": + config.name = "LeakSanitizer-AddressSanitizer" + lsan_cflags = ["-fsanitize=address"] + config.available_features.add('asan') +else: + lit_config.fatal("Unknown LSan test mode: %r" % lsan_lit_test_mode) +config.name += config.name_suffix + +# Platform-specific default LSAN_OPTIONS for lit tests. +default_lsan_opts = 'detect_leaks=1' +if config.host_os == 'Darwin': + # On Darwin, we default to `abort_on_error=1`, which would make tests run + # much slower. Let's override this and run lit tests with 'abort_on_error=0'. + # Also, make sure we do not overwhelm the syslog while testing. + default_lsan_opts += ':abort_on_error=0' + default_lsan_opts += ':log_to_syslog=0' + +if default_lsan_opts: + config.environment['LSAN_OPTIONS'] = default_lsan_opts + default_lsan_opts += ':' +config.substitutions.append(('%env_lsan_opts=', + 'env LSAN_OPTIONS=' + default_lsan_opts)) + +if lit.util.which('strace'): + config.available_features.add('strace') + +clang_cflags = ["-O0", config.target_cflags] + config.debug_info_flags +clang_cxxflags = config.cxx_mode_flags + clang_cflags +lsan_incdir = config.test_source_root + "/../" +clang_lsan_cflags = clang_cflags + lsan_cflags + ["-I%s" % lsan_incdir] +clang_lsan_cxxflags = clang_cxxflags + lsan_cflags + ["-I%s" % lsan_incdir] + +config.clang_cflags = clang_cflags +config.clang_cxxflags = clang_cxxflags + +def build_invocation(compile_flags): + return " " + " ".join([config.clang] + compile_flags) + " " + +config.substitutions.append( ("%clang ", build_invocation(clang_cflags)) ) +config.substitutions.append( ("%clangxx ", build_invocation(clang_cxxflags)) ) +config.substitutions.append( ("%clang_lsan ", build_invocation(clang_lsan_cflags)) ) +config.substitutions.append( ("%clangxx_lsan ", build_invocation(clang_lsan_cxxflags)) ) + +# LeakSanitizer tests are currently supported on x86-64 Linux, PowerPC64 Linux, arm Linux, mips64 Linux, and x86_64 Darwin. +supported_linux = config.host_os is 'Linux' and config.host_arch in ['x86_64', 'ppc64', 'ppc64le', 'mips64', 'arm', 'armhf', 'armv7l'] +supported_darwin = config.host_os is 'Darwin' and config.target_arch is 'x86_64' +if not (supported_linux or supported_darwin): + config.unsupported = True + +# Don't support Thumb due to broken fast unwinder +if re.search('mthumb', config.target_cflags) is not None: + config.unsupported = True + +config.suffixes = ['.c', '.cc', '.cpp', '.mm'] Index: compiler-rt/trunk/test/lsan/lit.site.cfg.in =================================================================== --- compiler-rt/trunk/test/lsan/lit.site.cfg.in +++ compiler-rt/trunk/test/lsan/lit.site.cfg.in @@ -1,13 +0,0 @@ -@LIT_SITE_CFG_IN_HEADER@ - -# Tool-specific config options. -config.name_suffix = "@LSAN_TEST_CONFIG_SUFFIX@" -config.target_cflags = "@LSAN_TEST_TARGET_CFLAGS@" -config.lsan_lit_test_mode = "@LSAN_LIT_TEST_MODE@" -config.target_arch = "@LSAN_TEST_TARGET_ARCH@" - -# Load common config for all compiler-rt lit tests. -lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") - -# Load tool-specific config that would do the real work. -lit_config.load_config(config, "@LSAN_LIT_SOURCE_DIR@/lit.common.cfg") Index: compiler-rt/trunk/test/lsan/lit.site.cfg.py.in =================================================================== --- compiler-rt/trunk/test/lsan/lit.site.cfg.py.in +++ compiler-rt/trunk/test/lsan/lit.site.cfg.py.in @@ -0,0 +1,13 @@ +@LIT_SITE_CFG_IN_HEADER@ + +# Tool-specific config options. +config.name_suffix = "@LSAN_TEST_CONFIG_SUFFIX@" +config.target_cflags = "@LSAN_TEST_TARGET_CFLAGS@" +config.lsan_lit_test_mode = "@LSAN_LIT_TEST_MODE@" +config.target_arch = "@LSAN_TEST_TARGET_ARCH@" + +# Load common config for all compiler-rt lit tests. +lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") + +# Load tool-specific config that would do the real work. +lit_config.load_config(config, "@LSAN_LIT_SOURCE_DIR@/lit.common.cfg.py") Index: compiler-rt/trunk/test/msan/CMakeLists.txt =================================================================== --- compiler-rt/trunk/test/msan/CMakeLists.txt +++ compiler-rt/trunk/test/msan/CMakeLists.txt @@ -26,8 +26,8 @@ set(MSAN_TEST_USE_LLD ${lld}) configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg) + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in + ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py) list(APPEND MSAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}) endmacro() @@ -47,8 +47,8 @@ COMPILER_RT_LIBCXX_PATH AND COMPILER_RT_LIBCXXABI_PATH) 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) list(APPEND MSAN_TEST_DEPS MsanUnitTests) list(APPEND MSAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/Unit) endif() Index: compiler-rt/trunk/test/msan/Linux/lit.local.cfg =================================================================== --- compiler-rt/trunk/test/msan/Linux/lit.local.cfg +++ compiler-rt/trunk/test/msan/Linux/lit.local.cfg @@ -1,9 +0,0 @@ -def getRoot(config): - if not config.parent: - return config - return getRoot(config.parent) - -root = getRoot(config) - -if root.host_os not in ['Linux']: - config.unsupported = True Index: compiler-rt/trunk/test/msan/Linux/lit.local.cfg.py =================================================================== --- compiler-rt/trunk/test/msan/Linux/lit.local.cfg.py +++ compiler-rt/trunk/test/msan/Linux/lit.local.cfg.py @@ -0,0 +1,9 @@ +def getRoot(config): + if not config.parent: + return config + return getRoot(config.parent) + +root = getRoot(config) + +if root.host_os not in ['Linux']: + config.unsupported = True Index: compiler-rt/trunk/test/msan/Unit/lit.site.cfg.in =================================================================== --- compiler-rt/trunk/test/msan/Unit/lit.site.cfg.in +++ compiler-rt/trunk/test/msan/Unit/lit.site.cfg.in @@ -1,13 +0,0 @@ -@LIT_SITE_CFG_IN_HEADER@ - -# Load common config for all compiler-rt unit tests. -lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/unittests/lit.common.unit.configured") - -# Setup config name. -config.name = 'MemorySanitizer-Unit' - -# Setup test source and exec root. For unit tests, we define -# it as build directory with MSan unit tests. -# FIXME: Don't use hardcoded path to MSan unit tests. -config.test_exec_root = "@COMPILER_RT_BINARY_DIR@/lib/msan/tests" -config.test_source_root = config.test_exec_root Index: compiler-rt/trunk/test/msan/Unit/lit.site.cfg.py.in =================================================================== --- compiler-rt/trunk/test/msan/Unit/lit.site.cfg.py.in +++ compiler-rt/trunk/test/msan/Unit/lit.site.cfg.py.in @@ -0,0 +1,13 @@ +@LIT_SITE_CFG_IN_HEADER@ + +# Load common config for all compiler-rt unit tests. +lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/unittests/lit.common.unit.configured") + +# Setup config name. +config.name = 'MemorySanitizer-Unit' + +# Setup test source and exec root. For unit tests, we define +# it as build directory with MSan unit tests. +# FIXME: Don't use hardcoded path to MSan unit tests. +config.test_exec_root = "@COMPILER_RT_BINARY_DIR@/lib/msan/tests" +config.test_source_root = config.test_exec_root Index: compiler-rt/trunk/test/msan/lit.cfg =================================================================== --- compiler-rt/trunk/test/msan/lit.cfg +++ compiler-rt/trunk/test/msan/lit.cfg @@ -1,47 +0,0 @@ -# -*- Python -*- - -import os - -# Setup config name. -config.name = 'MemorySanitizer' + getattr(config, 'name_suffix', 'default') - -# Setup source root. -config.test_source_root = os.path.dirname(__file__) - -# Setup default compiler flags used with -fsanitize=memory option. -clang_msan_cflags = (["-fsanitize=memory", - "-mno-omit-leaf-frame-pointer", - "-fno-omit-frame-pointer", - "-fno-optimize-sibling-calls"] + - [config.target_cflags] + - config.debug_info_flags) -# Some Msan tests leverage backtrace() which requires libexecinfo on FreeBSD. -if config.host_os == 'FreeBSD': - clang_msan_cflags += ["-lexecinfo", "-fPIC"] -clang_msan_cxxflags = config.cxx_mode_flags + clang_msan_cflags - -# Flags for KMSAN invocation. This is C-only, we're not interested in C++. -clang_kmsan_cflags = (["-fsanitize=kernel-memory"] + - [config.target_cflags] + - config.debug_info_flags) - -def build_invocation(compile_flags): - return " " + " ".join([config.clang] + compile_flags) + " " - -config.substitutions.append( ("%clang_msan ", build_invocation(clang_msan_cflags)) ) -config.substitutions.append( ("%clangxx_msan ", build_invocation(clang_msan_cxxflags)) ) -config.substitutions.append( ("%clang_kmsan ", build_invocation(clang_kmsan_cflags)) ) - -# Default test suffixes. -config.suffixes = ['.c', '.cc', '.cpp'] - -if config.host_os not in ['Linux', 'NetBSD', 'FreeBSD']: - config.unsupported = True - -# For mips64, mips64el we have forced store_context_size to 1 because these -# archs use slow unwinder which is not async signal safe. Therefore we only -# check the first frame since store_context size is 1. -if config.host_arch in ['mips64', 'mips64el']: - config.substitutions.append( ('CHECK-%short-stack', 'CHECK-SHORT-STACK')) -else: - config.substitutions.append( ('CHECK-%short-stack', 'CHECK-FULL-STACK')) Index: compiler-rt/trunk/test/msan/lit.cfg.py =================================================================== --- compiler-rt/trunk/test/msan/lit.cfg.py +++ compiler-rt/trunk/test/msan/lit.cfg.py @@ -0,0 +1,47 @@ +# -*- Python -*- + +import os + +# Setup config name. +config.name = 'MemorySanitizer' + getattr(config, 'name_suffix', 'default') + +# Setup source root. +config.test_source_root = os.path.dirname(__file__) + +# Setup default compiler flags used with -fsanitize=memory option. +clang_msan_cflags = (["-fsanitize=memory", + "-mno-omit-leaf-frame-pointer", + "-fno-omit-frame-pointer", + "-fno-optimize-sibling-calls"] + + [config.target_cflags] + + config.debug_info_flags) +# Some Msan tests leverage backtrace() which requires libexecinfo on FreeBSD. +if config.host_os == 'FreeBSD': + clang_msan_cflags += ["-lexecinfo", "-fPIC"] +clang_msan_cxxflags = config.cxx_mode_flags + clang_msan_cflags + +# Flags for KMSAN invocation. This is C-only, we're not interested in C++. +clang_kmsan_cflags = (["-fsanitize=kernel-memory"] + + [config.target_cflags] + + config.debug_info_flags) + +def build_invocation(compile_flags): + return " " + " ".join([config.clang] + compile_flags) + " " + +config.substitutions.append( ("%clang_msan ", build_invocation(clang_msan_cflags)) ) +config.substitutions.append( ("%clangxx_msan ", build_invocation(clang_msan_cxxflags)) ) +config.substitutions.append( ("%clang_kmsan ", build_invocation(clang_kmsan_cflags)) ) + +# Default test suffixes. +config.suffixes = ['.c', '.cc', '.cpp'] + +if config.host_os not in ['Linux', 'NetBSD', 'FreeBSD']: + config.unsupported = True + +# For mips64, mips64el we have forced store_context_size to 1 because these +# archs use slow unwinder which is not async signal safe. Therefore we only +# check the first frame since store_context size is 1. +if config.host_arch in ['mips64', 'mips64el']: + config.substitutions.append( ('CHECK-%short-stack', 'CHECK-SHORT-STACK')) +else: + config.substitutions.append( ('CHECK-%short-stack', 'CHECK-FULL-STACK')) Index: compiler-rt/trunk/test/msan/lit.site.cfg.in =================================================================== --- compiler-rt/trunk/test/msan/lit.site.cfg.in +++ compiler-rt/trunk/test/msan/lit.site.cfg.in @@ -1,14 +0,0 @@ -@LIT_SITE_CFG_IN_HEADER@ - -# Tool-specific config options. -config.name_suffix = "-@CONFIG_NAME@" -config.target_cflags = "@MSAN_TEST_TARGET_CFLAGS@" -config.target_arch = "@MSAN_TEST_TARGET_ARCH@" -config.use_lld = @MSAN_TEST_USE_LLD@ -config.use_thinlto = @MSAN_TEST_USE_THINLTO@ - -# Load common config for all compiler-rt lit tests. -lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") - -# Load tool-specific config that would do the real work. -lit_config.load_config(config, "@MSAN_LIT_SOURCE_DIR@/lit.cfg") Index: compiler-rt/trunk/test/msan/lit.site.cfg.py.in =================================================================== --- compiler-rt/trunk/test/msan/lit.site.cfg.py.in +++ compiler-rt/trunk/test/msan/lit.site.cfg.py.in @@ -0,0 +1,14 @@ +@LIT_SITE_CFG_IN_HEADER@ + +# Tool-specific config options. +config.name_suffix = "-@CONFIG_NAME@" +config.target_cflags = "@MSAN_TEST_TARGET_CFLAGS@" +config.target_arch = "@MSAN_TEST_TARGET_ARCH@" +config.use_lld = @MSAN_TEST_USE_LLD@ +config.use_thinlto = @MSAN_TEST_USE_THINLTO@ + +# Load common config for all compiler-rt lit tests. +lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") + +# Load tool-specific config that would do the real work. +lit_config.load_config(config, "@MSAN_LIT_SOURCE_DIR@/lit.cfg.py") Index: compiler-rt/trunk/test/profile/CMakeLists.txt =================================================================== --- compiler-rt/trunk/test/profile/CMakeLists.txt +++ compiler-rt/trunk/test/profile/CMakeLists.txt @@ -17,8 +17,8 @@ get_test_cc_for_arch(${arch} PROFILE_TEST_TARGET_CC PROFILE_TEST_TARGET_CFLAGS) set(CONFIG_NAME Profile-${arch}) configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in + ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py ) list(APPEND PROFILE_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}) endforeach() Index: compiler-rt/trunk/test/profile/Linux/lit.local.cfg =================================================================== --- compiler-rt/trunk/test/profile/Linux/lit.local.cfg +++ compiler-rt/trunk/test/profile/Linux/lit.local.cfg @@ -1,40 +0,0 @@ -import subprocess - -def getRoot(config): - if not config.parent: - return config - return getRoot(config.parent) - - -def is_gold_linker_available(): - - if not config.gold_executable: - return False - try: - ld_cmd = subprocess.Popen([config.gold_executable, '--help'], stdout = subprocess.PIPE) - ld_out = ld_cmd.stdout.read().decode() - ld_cmd.wait() - except: - return False - - if not '-plugin' in ld_out: - return False - - # config.clang is not guaranteed to be just the executable! - clang_cmd = subprocess.Popen(" ".join([config.clang, '-fuse-ld=gold', '-xc', '-']), - shell=True, - universal_newlines = True, - stdin = subprocess.PIPE, - stdout = subprocess.PIPE, - stderr = subprocess.PIPE) - clang_err = clang_cmd.communicate('int main() { return 0; }')[1] - - if not 'invalid linker' in clang_err: - return True - - return False - -root = getRoot(config) - -if root.host_os not in ['Linux'] or not is_gold_linker_available(): - config.unsupported = True Index: compiler-rt/trunk/test/profile/Linux/lit.local.cfg.py =================================================================== --- compiler-rt/trunk/test/profile/Linux/lit.local.cfg.py +++ compiler-rt/trunk/test/profile/Linux/lit.local.cfg.py @@ -0,0 +1,40 @@ +import subprocess + +def getRoot(config): + if not config.parent: + return config + return getRoot(config.parent) + + +def is_gold_linker_available(): + + if not config.gold_executable: + return False + try: + ld_cmd = subprocess.Popen([config.gold_executable, '--help'], stdout = subprocess.PIPE) + ld_out = ld_cmd.stdout.read().decode() + ld_cmd.wait() + except: + return False + + if not '-plugin' in ld_out: + return False + + # config.clang is not guaranteed to be just the executable! + clang_cmd = subprocess.Popen(" ".join([config.clang, '-fuse-ld=gold', '-xc', '-']), + shell=True, + universal_newlines = True, + stdin = subprocess.PIPE, + stdout = subprocess.PIPE, + stderr = subprocess.PIPE) + clang_err = clang_cmd.communicate('int main() { return 0; }')[1] + + if not 'invalid linker' in clang_err: + return True + + return False + +root = getRoot(config) + +if root.host_os not in ['Linux'] or not is_gold_linker_available(): + config.unsupported = True Index: compiler-rt/trunk/test/profile/Posix/lit.local.cfg =================================================================== --- compiler-rt/trunk/test/profile/Posix/lit.local.cfg +++ compiler-rt/trunk/test/profile/Posix/lit.local.cfg @@ -1,9 +0,0 @@ -def getRoot(config): - if not config.parent: - return config - return getRoot(config.parent) - -root = getRoot(config) - -if root.host_os in ['Windows']: - config.unsupported = True Index: compiler-rt/trunk/test/profile/Posix/lit.local.cfg.py =================================================================== --- compiler-rt/trunk/test/profile/Posix/lit.local.cfg.py +++ compiler-rt/trunk/test/profile/Posix/lit.local.cfg.py @@ -0,0 +1,9 @@ +def getRoot(config): + if not config.parent: + return config + return getRoot(config.parent) + +root = getRoot(config) + +if root.host_os in ['Windows']: + config.unsupported = True Index: compiler-rt/trunk/test/profile/lit.cfg =================================================================== --- compiler-rt/trunk/test/profile/lit.cfg +++ compiler-rt/trunk/test/profile/lit.cfg @@ -1,81 +0,0 @@ -# -*- Python -*- - -import os - -def get_required_attr(config, attr_name): - attr_value = getattr(config, attr_name, None) - if attr_value == None: - lit_config.fatal( - "No attribute %r in test configuration! You may need to run " - "tests from your build directory or add this attribute " - "to lit.site.cfg " % attr_name) - return attr_value - -# Setup config name. -config.name = 'Profile-' + config.target_arch - -# Setup source root. -config.test_source_root = os.path.dirname(__file__) - -# Setup executable root. -if hasattr(config, 'profile_lit_binary_dir') and \ - config.profile_lit_binary_dir is not None: - config.test_exec_root = os.path.join(config.profile_lit_binary_dir, config.name) - -if config.host_os in ['Linux']: - extra_link_flags = ["-ldl"] -elif config.host_os in ['Windows']: - # InstrProf is incompatible with incremental linking. Disable it as a - # workaround. - extra_link_flags = ["-Wl,-incremental:no"] -else: - extra_link_flags = [] - -# Test suffixes. -config.suffixes = ['.c', '.cc', '.cpp', '.m', '.mm', '.ll', '.test'] - -# What to exclude. -config.excludes = ['Inputs'] - -# Clang flags. -target_cflags=[get_required_attr(config, "target_cflags")] -clang_cflags = target_cflags + extra_link_flags -clang_cxxflags = config.cxx_mode_flags + clang_cflags - -def build_invocation(compile_flags, with_lto = False): - lto_flags = [] - lto_prefix = [] - if with_lto and config.lto_supported: - lto_flags += config.lto_flags - lto_prefix += config.lto_launch - return " " + " ".join(lto_prefix + [config.clang] + lto_flags + compile_flags) + " " - -# Add clang substitutions. -config.substitutions.append( ("%clang ", build_invocation(clang_cflags)) ) -config.substitutions.append( ("%clangxx ", build_invocation(clang_cxxflags)) ) -config.substitutions.append( ("%clang_profgen ", build_invocation(clang_cflags) + " -fprofile-instr-generate ") ) -config.substitutions.append( ("%clang_profgen=", build_invocation(clang_cflags) + " -fprofile-instr-generate=") ) -config.substitutions.append( ("%clang_pgogen ", build_invocation(clang_cflags) + " -fprofile-generate ") ) -config.substitutions.append( ("%clang_pgogen=", build_invocation(clang_cflags) + " -fprofile-generate=") ) - -config.substitutions.append( ("%clangxx_profgen ", build_invocation(clang_cxxflags) + " -fprofile-instr-generate ") ) -config.substitutions.append( ("%clangxx_profgen=", build_invocation(clang_cxxflags) + " -fprofile-instr-generate=") ) -config.substitutions.append( ("%clangxx_pgogen ", build_invocation(clang_cxxflags) + " -fprofile-generate ") ) -config.substitutions.append( ("%clangxx_pgogen=", build_invocation(clang_cxxflags) + " -fprofile-generate=") ) - -config.substitutions.append( ("%clang_profgen_gcc=", build_invocation(clang_cflags) + " -fprofile-generate=") ) -config.substitutions.append( ("%clang_profuse_gcc=", build_invocation(clang_cflags) + " -fprofile-use=") ) - -config.substitutions.append( ("%clang_profuse=", build_invocation(clang_cflags) + " -fprofile-instr-use=") ) -config.substitutions.append( ("%clangxx_profuse=", build_invocation(clang_cxxflags) + " -fprofile-instr-use=") ) - -config.substitutions.append( ("%clang_lto_profgen=", build_invocation(clang_cflags, True) + " -fprofile-instr-generate=") ) - -if config.host_os not in ['Windows', 'Darwin', 'FreeBSD', 'Linux', 'NetBSD', 'SunOS']: - config.unsupported = True - -if config.target_arch in ['armv7l']: - config.unsupported = True - -if config.android: - config.unsupported = True Index: compiler-rt/trunk/test/profile/lit.cfg.py =================================================================== --- compiler-rt/trunk/test/profile/lit.cfg.py +++ compiler-rt/trunk/test/profile/lit.cfg.py @@ -0,0 +1,81 @@ +# -*- Python -*- + +import os + +def get_required_attr(config, attr_name): + attr_value = getattr(config, attr_name, None) + if attr_value == None: + lit_config.fatal( + "No attribute %r in test configuration! You may need to run " + "tests from your build directory or add this attribute " + "to lit.site.cfg.py " % attr_name) + return attr_value + +# Setup config name. +config.name = 'Profile-' + config.target_arch + +# Setup source root. +config.test_source_root = os.path.dirname(__file__) + +# Setup executable root. +if hasattr(config, 'profile_lit_binary_dir') and \ + config.profile_lit_binary_dir is not None: + config.test_exec_root = os.path.join(config.profile_lit_binary_dir, config.name) + +if config.host_os in ['Linux']: + extra_link_flags = ["-ldl"] +elif config.host_os in ['Windows']: + # InstrProf is incompatible with incremental linking. Disable it as a + # workaround. + extra_link_flags = ["-Wl,-incremental:no"] +else: + extra_link_flags = [] + +# Test suffixes. +config.suffixes = ['.c', '.cc', '.cpp', '.m', '.mm', '.ll', '.test'] + +# What to exclude. +config.excludes = ['Inputs'] + +# Clang flags. +target_cflags=[get_required_attr(config, "target_cflags")] +clang_cflags = target_cflags + extra_link_flags +clang_cxxflags = config.cxx_mode_flags + clang_cflags + +def build_invocation(compile_flags, with_lto = False): + lto_flags = [] + lto_prefix = [] + if with_lto and config.lto_supported: + lto_flags += config.lto_flags + lto_prefix += config.lto_launch + return " " + " ".join(lto_prefix + [config.clang] + lto_flags + compile_flags) + " " + +# Add clang substitutions. +config.substitutions.append( ("%clang ", build_invocation(clang_cflags)) ) +config.substitutions.append( ("%clangxx ", build_invocation(clang_cxxflags)) ) +config.substitutions.append( ("%clang_profgen ", build_invocation(clang_cflags) + " -fprofile-instr-generate ") ) +config.substitutions.append( ("%clang_profgen=", build_invocation(clang_cflags) + " -fprofile-instr-generate=") ) +config.substitutions.append( ("%clang_pgogen ", build_invocation(clang_cflags) + " -fprofile-generate ") ) +config.substitutions.append( ("%clang_pgogen=", build_invocation(clang_cflags) + " -fprofile-generate=") ) + +config.substitutions.append( ("%clangxx_profgen ", build_invocation(clang_cxxflags) + " -fprofile-instr-generate ") ) +config.substitutions.append( ("%clangxx_profgen=", build_invocation(clang_cxxflags) + " -fprofile-instr-generate=") ) +config.substitutions.append( ("%clangxx_pgogen ", build_invocation(clang_cxxflags) + " -fprofile-generate ") ) +config.substitutions.append( ("%clangxx_pgogen=", build_invocation(clang_cxxflags) + " -fprofile-generate=") ) + +config.substitutions.append( ("%clang_profgen_gcc=", build_invocation(clang_cflags) + " -fprofile-generate=") ) +config.substitutions.append( ("%clang_profuse_gcc=", build_invocation(clang_cflags) + " -fprofile-use=") ) + +config.substitutions.append( ("%clang_profuse=", build_invocation(clang_cflags) + " -fprofile-instr-use=") ) +config.substitutions.append( ("%clangxx_profuse=", build_invocation(clang_cxxflags) + " -fprofile-instr-use=") ) + +config.substitutions.append( ("%clang_lto_profgen=", build_invocation(clang_cflags, True) + " -fprofile-instr-generate=") ) + +if config.host_os not in ['Windows', 'Darwin', 'FreeBSD', 'Linux', 'NetBSD', 'SunOS']: + config.unsupported = True + +if config.target_arch in ['armv7l']: + config.unsupported = True + +if config.android: + config.unsupported = True Index: compiler-rt/trunk/test/profile/lit.site.cfg.in =================================================================== --- compiler-rt/trunk/test/profile/lit.site.cfg.in +++ compiler-rt/trunk/test/profile/lit.site.cfg.in @@ -1,12 +0,0 @@ -@LIT_SITE_CFG_IN_HEADER@ - -# Tool-specific config options. -config.profile_lit_binary_dir = "@PROFILE_LIT_BINARY_DIR@" -config.target_cflags = "@PROFILE_TEST_TARGET_CFLAGS@" -config.target_arch = "@PROFILE_TEST_TARGET_ARCH@" - -# Load common config for all compiler-rt lit tests. -lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") - -# Load tool-specific config that would do the real work. -lit_config.load_config(config, "@PROFILE_LIT_SOURCE_DIR@/lit.cfg") Index: compiler-rt/trunk/test/profile/lit.site.cfg.py.in =================================================================== --- compiler-rt/trunk/test/profile/lit.site.cfg.py.in +++ compiler-rt/trunk/test/profile/lit.site.cfg.py.in @@ -0,0 +1,12 @@ +@LIT_SITE_CFG_IN_HEADER@ + +# Tool-specific config options. +config.profile_lit_binary_dir = "@PROFILE_LIT_BINARY_DIR@" +config.target_cflags = "@PROFILE_TEST_TARGET_CFLAGS@" +config.target_arch = "@PROFILE_TEST_TARGET_ARCH@" + +# Load common config for all compiler-rt lit tests. +lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") + +# Load tool-specific config that would do the real work. +lit_config.load_config(config, "@PROFILE_LIT_SOURCE_DIR@/lit.cfg.py") Index: compiler-rt/trunk/test/safestack/CMakeLists.txt =================================================================== --- compiler-rt/trunk/test/safestack/CMakeLists.txt +++ compiler-rt/trunk/test/safestack/CMakeLists.txt @@ -21,8 +21,8 @@ endif() 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 ) add_lit_testsuite(check-safestack "Running the SafeStack tests" Index: compiler-rt/trunk/test/safestack/lit.cfg =================================================================== --- compiler-rt/trunk/test/safestack/lit.cfg +++ compiler-rt/trunk/test/safestack/lit.cfg @@ -1,22 +0,0 @@ -# -*- Python -*- - -import os - -# Setup config name. -config.name = 'SafeStack' - -# Setup source root. -config.test_source_root = os.path.dirname(__file__) - -# Test suffixes. -config.suffixes = ['.c', '.cc', '.cpp', '.m', '.mm', '.ll', '.test'] - -# Add clang substitutions. -config.substitutions.append( ("%clang_nosafestack ", config.clang + " -O0 -fno-sanitize=safe-stack ") ) -config.substitutions.append( ("%clang_safestack ", config.clang + " -O0 -fsanitize=safe-stack ") ) - -if config.lto_supported: - config.substitutions.append((r"%clang_lto_safestack ", ' '.join(config.lto_launch + [config.clang] + config.lto_flags + ['-fsanitize=safe-stack ']))) - -if config.host_os not in ['Linux', 'FreeBSD', 'NetBSD']: - config.unsupported = True Index: compiler-rt/trunk/test/safestack/lit.cfg.py =================================================================== --- compiler-rt/trunk/test/safestack/lit.cfg.py +++ compiler-rt/trunk/test/safestack/lit.cfg.py @@ -0,0 +1,22 @@ +# -*- Python -*- + +import os + +# Setup config name. +config.name = 'SafeStack' + +# Setup source root. +config.test_source_root = os.path.dirname(__file__) + +# Test suffixes. +config.suffixes = ['.c', '.cc', '.cpp', '.m', '.mm', '.ll', '.test'] + +# Add clang substitutions. +config.substitutions.append( ("%clang_nosafestack ", config.clang + " -O0 -fno-sanitize=safe-stack ") ) +config.substitutions.append( ("%clang_safestack ", config.clang + " -O0 -fsanitize=safe-stack ") ) + +if config.lto_supported: + config.substitutions.append((r"%clang_lto_safestack ", ' '.join(config.lto_launch + [config.clang] + config.lto_flags + ['-fsanitize=safe-stack ']))) + +if config.host_os not in ['Linux', 'FreeBSD', 'NetBSD']: + config.unsupported = True Index: compiler-rt/trunk/test/safestack/lit.site.cfg.in =================================================================== --- compiler-rt/trunk/test/safestack/lit.site.cfg.in +++ compiler-rt/trunk/test/safestack/lit.site.cfg.in @@ -1,7 +0,0 @@ -@LIT_SITE_CFG_IN_HEADER@ - -# Load common config for all compiler-rt lit tests. -lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") - -# Load tool-specific config that would do the real work. -lit_config.load_config(config, "@SAFESTACK_LIT_SOURCE_DIR@/lit.cfg") Index: compiler-rt/trunk/test/safestack/lit.site.cfg.py.in =================================================================== --- compiler-rt/trunk/test/safestack/lit.site.cfg.py.in +++ compiler-rt/trunk/test/safestack/lit.site.cfg.py.in @@ -0,0 +1,7 @@ +@LIT_SITE_CFG_IN_HEADER@ + +# Load common config for all compiler-rt lit tests. +lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") + +# Load tool-specific config that would do the real work. +lit_config.load_config(config, "@SAFESTACK_LIT_SOURCE_DIR@/lit.cfg.py") Index: compiler-rt/trunk/test/sanitizer_common/CMakeLists.txt =================================================================== --- compiler-rt/trunk/test/sanitizer_common/CMakeLists.txt +++ compiler-rt/trunk/test/sanitizer_common/CMakeLists.txt @@ -66,8 +66,8 @@ get_test_cc_for_arch(${arch} SANITIZER_COMMON_TEST_TARGET_CC SANITIZER_COMMON_TEST_TARGET_CFLAGS) set(CONFIG_NAME ${tool}-${arch}-${OS_NAME}) configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg) + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in + ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py) # FIXME(dliew): LSan i386 on Darwin is completly broken right now. # so don't run the tests by default. if (NOT (CMAKE_SYSTEM_NAME MATCHES "Darwin" AND @@ -82,8 +82,8 @@ # Unit tests. if(COMPILER_RT_INCLUDE_TESTS) 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) # FIXME: support unit test in the android test runner if (NOT ANDROID) list(APPEND SANITIZER_COMMON_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/Unit) Index: compiler-rt/trunk/test/sanitizer_common/TestCases/Darwin/lit.local.cfg =================================================================== --- compiler-rt/trunk/test/sanitizer_common/TestCases/Darwin/lit.local.cfg +++ compiler-rt/trunk/test/sanitizer_common/TestCases/Darwin/lit.local.cfg @@ -1,9 +0,0 @@ -def getRoot(config): - if not config.parent: - return config - return getRoot(config.parent) - -root = getRoot(config) - -if root.host_os not in ['Darwin']: - config.unsupported = True Index: compiler-rt/trunk/test/sanitizer_common/TestCases/Darwin/lit.local.cfg.py =================================================================== --- compiler-rt/trunk/test/sanitizer_common/TestCases/Darwin/lit.local.cfg.py +++ compiler-rt/trunk/test/sanitizer_common/TestCases/Darwin/lit.local.cfg.py @@ -0,0 +1,9 @@ +def getRoot(config): + if not config.parent: + return config + return getRoot(config.parent) + +root = getRoot(config) + +if root.host_os not in ['Darwin']: + config.unsupported = True Index: compiler-rt/trunk/test/sanitizer_common/TestCases/FreeBSD/lit.local.cfg =================================================================== --- compiler-rt/trunk/test/sanitizer_common/TestCases/FreeBSD/lit.local.cfg +++ compiler-rt/trunk/test/sanitizer_common/TestCases/FreeBSD/lit.local.cfg @@ -1,9 +0,0 @@ -def getRoot(config): - if not config.parent: - return config - return getRoot(config.parent) - -root = getRoot(config) - -if root.host_os not in ['FreeBSD']: - config.unsupported = True Index: compiler-rt/trunk/test/sanitizer_common/TestCases/FreeBSD/lit.local.cfg.py =================================================================== --- compiler-rt/trunk/test/sanitizer_common/TestCases/FreeBSD/lit.local.cfg.py +++ compiler-rt/trunk/test/sanitizer_common/TestCases/FreeBSD/lit.local.cfg.py @@ -0,0 +1,9 @@ +def getRoot(config): + if not config.parent: + return config + return getRoot(config.parent) + +root = getRoot(config) + +if root.host_os not in ['FreeBSD']: + config.unsupported = True Index: compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/lit.local.cfg =================================================================== --- compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/lit.local.cfg +++ compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/lit.local.cfg @@ -1,9 +0,0 @@ -def getRoot(config): - if not config.parent: - return config - return getRoot(config.parent) - -root = getRoot(config) - -if root.host_os not in ['Linux']: - config.unsupported = True Index: compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/lit.local.cfg.py =================================================================== --- compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/lit.local.cfg.py +++ compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/lit.local.cfg.py @@ -0,0 +1,9 @@ +def getRoot(config): + if not config.parent: + return config + return getRoot(config.parent) + +root = getRoot(config) + +if root.host_os not in ['Linux']: + config.unsupported = True Index: compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/lit.local.cfg =================================================================== --- compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/lit.local.cfg +++ compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/lit.local.cfg @@ -1,9 +0,0 @@ -def getRoot(config): - if not config.parent: - return config - return getRoot(config.parent) - -root = getRoot(config) - -if root.host_os not in ['NetBSD']: - config.unsupported = True Index: compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/lit.local.cfg.py =================================================================== --- compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/lit.local.cfg.py +++ compiler-rt/trunk/test/sanitizer_common/TestCases/NetBSD/lit.local.cfg.py @@ -0,0 +1,9 @@ +def getRoot(config): + if not config.parent: + return config + return getRoot(config.parent) + +root = getRoot(config) + +if root.host_os not in ['NetBSD']: + config.unsupported = True Index: compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/lit.local.cfg =================================================================== --- compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/lit.local.cfg +++ compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/lit.local.cfg @@ -1,9 +0,0 @@ -def getRoot(config): - if not config.parent: - return config - return getRoot(config.parent) - -root = getRoot(config) - -if root.host_os in ['Windows']: - config.unsupported = True Index: compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/lit.local.cfg.py =================================================================== --- compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/lit.local.cfg.py +++ compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/lit.local.cfg.py @@ -0,0 +1,9 @@ +def getRoot(config): + if not config.parent: + return config + return getRoot(config.parent) + +root = getRoot(config) + +if root.host_os in ['Windows']: + config.unsupported = True Index: compiler-rt/trunk/test/sanitizer_common/Unit/lit.site.cfg.in =================================================================== --- compiler-rt/trunk/test/sanitizer_common/Unit/lit.site.cfg.in +++ compiler-rt/trunk/test/sanitizer_common/Unit/lit.site.cfg.in @@ -1,17 +0,0 @@ -@LIT_SITE_CFG_IN_HEADER@ - -# Load common config for all compiler-rt unit tests. -lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/unittests/lit.common.unit.configured") - -# Setup config name. -config.name = 'SanitizerCommon-Unit' - -# Setup test source and exec root. For unit tests, we define -# it as build directory with sanitizer_common tests. -# FIXME: De-hardcode this path. -config.test_exec_root = os.path.join("@COMPILER_RT_BINARY_DIR@", "lib", - "sanitizer_common", "tests") -config.test_source_root = config.test_exec_root - -if config.host_os == 'Darwin': - config.parallelism_group = config.darwin_sanitizer_parallelism_group_func Index: compiler-rt/trunk/test/sanitizer_common/Unit/lit.site.cfg.py.in =================================================================== --- compiler-rt/trunk/test/sanitizer_common/Unit/lit.site.cfg.py.in +++ compiler-rt/trunk/test/sanitizer_common/Unit/lit.site.cfg.py.in @@ -0,0 +1,17 @@ +@LIT_SITE_CFG_IN_HEADER@ + +# Load common config for all compiler-rt unit tests. +lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/unittests/lit.common.unit.configured") + +# Setup config name. +config.name = 'SanitizerCommon-Unit' + +# Setup test source and exec root. For unit tests, we define +# it as build directory with sanitizer_common tests. +# FIXME: De-hardcode this path. +config.test_exec_root = os.path.join("@COMPILER_RT_BINARY_DIR@", "lib", + "sanitizer_common", "tests") +config.test_source_root = config.test_exec_root + +if config.host_os == 'Darwin': + config.parallelism_group = config.darwin_sanitizer_parallelism_group_func Index: compiler-rt/trunk/test/sanitizer_common/lit.common.cfg =================================================================== --- compiler-rt/trunk/test/sanitizer_common/lit.common.cfg +++ compiler-rt/trunk/test/sanitizer_common/lit.common.cfg @@ -1,75 +0,0 @@ -# -*- Python -*- - -# Setup source root. -config.test_source_root = os.path.join(os.path.dirname(__file__), "TestCases") - -config.name = "SanitizerCommon-" + config.name_suffix - -default_tool_options = [] -collect_stack_traces = "" -if config.tool_name == "asan": - tool_cflags = ["-fsanitize=address"] - tool_options = "ASAN_OPTIONS" -elif config.tool_name == "tsan": - tool_cflags = ["-fsanitize=thread"] - tool_options = "TSAN_OPTIONS" -elif config.tool_name == "msan": - tool_cflags = ["-fsanitize=memory"] - tool_options = "MSAN_OPTIONS" - collect_stack_traces = "-fsanitize-memory-track-origins" -elif config.tool_name == "lsan": - tool_cflags = ["-fsanitize=leak"] - tool_options = "LSAN_OPTIONS" -elif config.tool_name == "ubsan": - tool_cflags = ["-fsanitize=undefined"] - tool_options = "UBSAN_OPTIONS" -else: - lit_config.fatal("Unknown tool for sanitizer_common tests: %r" % config.tool_name) - -config.available_features.add(config.tool_name) - -if config.host_os == 'Linux' and config.tool_name == "lsan" and config.target_arch == 'i386': - config.available_features.add("lsan-x86") - -if config.host_os == 'Darwin': - # On Darwin, we default to `abort_on_error=1`, which would make tests run - # much slower. Let's override this and run lit tests with 'abort_on_error=0'. - default_tool_options += ['abort_on_error=0'] -elif config.android: - # The same as on Darwin, we default to "abort_on_error=1" which slows down - # testing. Also, all existing tests are using "not" instead of "not --crash" - # which does not work for abort()-terminated programs. - default_tool_options += ['abort_on_error=0'] - -default_tool_options_str = ':'.join(default_tool_options) -if default_tool_options_str: - config.environment[tool_options] = default_tool_options_str - default_tool_options_str += ':' - -if config.host_os in ['Linux']: - extra_link_flags = ["-ldl"] -else: - extra_link_flags = [] - -clang_cflags = config.debug_info_flags + tool_cflags + [config.target_cflags] -clang_cflags += extra_link_flags -clang_cxxflags = config.cxx_mode_flags + clang_cflags - -def build_invocation(compile_flags): - return " " + " ".join([config.clang] + compile_flags) + " " - -config.substitutions.append( ("%clang ", build_invocation(clang_cflags)) ) -config.substitutions.append( ("%clangxx ", build_invocation(clang_cxxflags)) ) -config.substitutions.append( ("%collect_stack_traces", collect_stack_traces) ) -config.substitutions.append( ("%tool_name", config.tool_name) ) -config.substitutions.append( ("%tool_options", tool_options) ) -config.substitutions.append( ('%env_tool_opts=', - 'env ' + tool_options + '=' + default_tool_options_str)) - -config.suffixes = ['.c', '.cc', '.cpp'] - -if config.host_os not in ['Linux', 'Darwin', 'NetBSD', 'FreeBSD']: - config.unsupported = True - -if not config.parallelism_group: - config.parallelism_group = 'shadow-memory' Index: compiler-rt/trunk/test/sanitizer_common/lit.common.cfg.py =================================================================== --- compiler-rt/trunk/test/sanitizer_common/lit.common.cfg.py +++ compiler-rt/trunk/test/sanitizer_common/lit.common.cfg.py @@ -0,0 +1,75 @@ +# -*- Python -*- + +# Setup source root. +config.test_source_root = os.path.join(os.path.dirname(__file__), "TestCases") + +config.name = "SanitizerCommon-" + config.name_suffix + +default_tool_options = [] +collect_stack_traces = "" +if config.tool_name == "asan": + tool_cflags = ["-fsanitize=address"] + tool_options = "ASAN_OPTIONS" +elif config.tool_name == "tsan": + tool_cflags = ["-fsanitize=thread"] + tool_options = "TSAN_OPTIONS" +elif config.tool_name == "msan": + tool_cflags = ["-fsanitize=memory"] + tool_options = "MSAN_OPTIONS" + collect_stack_traces = "-fsanitize-memory-track-origins" +elif config.tool_name == "lsan": + tool_cflags = ["-fsanitize=leak"] + tool_options = "LSAN_OPTIONS" +elif config.tool_name == "ubsan": + tool_cflags = ["-fsanitize=undefined"] + tool_options = "UBSAN_OPTIONS" +else: + lit_config.fatal("Unknown tool for sanitizer_common tests: %r" % config.tool_name) + +config.available_features.add(config.tool_name) + +if config.host_os == 'Linux' and config.tool_name == "lsan" and config.target_arch == 'i386': + config.available_features.add("lsan-x86") + +if config.host_os == 'Darwin': + # On Darwin, we default to `abort_on_error=1`, which would make tests run + # much slower. Let's override this and run lit tests with 'abort_on_error=0'. + default_tool_options += ['abort_on_error=0'] +elif config.android: + # The same as on Darwin, we default to "abort_on_error=1" which slows down + # testing. Also, all existing tests are using "not" instead of "not --crash" + # which does not work for abort()-terminated programs. + default_tool_options += ['abort_on_error=0'] + +default_tool_options_str = ':'.join(default_tool_options) +if default_tool_options_str: + config.environment[tool_options] = default_tool_options_str + default_tool_options_str += ':' + +if config.host_os in ['Linux']: + extra_link_flags = ["-ldl"] +else: + extra_link_flags = [] + +clang_cflags = config.debug_info_flags + tool_cflags + [config.target_cflags] +clang_cflags += extra_link_flags +clang_cxxflags = config.cxx_mode_flags + clang_cflags + +def build_invocation(compile_flags): + return " " + " ".join([config.clang] + compile_flags) + " " + +config.substitutions.append( ("%clang ", build_invocation(clang_cflags)) ) +config.substitutions.append( ("%clangxx ", build_invocation(clang_cxxflags)) ) +config.substitutions.append( ("%collect_stack_traces", collect_stack_traces) ) +config.substitutions.append( ("%tool_name", config.tool_name) ) +config.substitutions.append( ("%tool_options", tool_options) ) +config.substitutions.append( ('%env_tool_opts=', + 'env ' + tool_options + '=' + default_tool_options_str)) + +config.suffixes = ['.c', '.cc', '.cpp'] + +if config.host_os not in ['Linux', 'Darwin', 'NetBSD', 'FreeBSD']: + config.unsupported = True + +if not config.parallelism_group: + config.parallelism_group = 'shadow-memory' Index: compiler-rt/trunk/test/sanitizer_common/lit.site.cfg.in =================================================================== --- compiler-rt/trunk/test/sanitizer_common/lit.site.cfg.in +++ compiler-rt/trunk/test/sanitizer_common/lit.site.cfg.in @@ -1,14 +0,0 @@ -@LIT_SITE_CFG_IN_HEADER@ - -# Tool-specific config options. -config.name_suffix = "@CONFIG_NAME@" -config.tool_name = "@SANITIZER_COMMON_LIT_TEST_MODE@" -config.target_cflags = "@SANITIZER_COMMON_TEST_TARGET_CFLAGS@" -config.target_arch = "@SANITIZER_COMMON_TEST_TARGET_ARCH@" - -# Load common config for all compiler-rt lit tests. -lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") - -# Load tool-specific config that would do the real work. -lit_config.load_config(config, "@SANITIZER_COMMON_LIT_SOURCE_DIR@/lit.common.cfg") - Index: compiler-rt/trunk/test/sanitizer_common/lit.site.cfg.py.in =================================================================== --- compiler-rt/trunk/test/sanitizer_common/lit.site.cfg.py.in +++ compiler-rt/trunk/test/sanitizer_common/lit.site.cfg.py.in @@ -0,0 +1,14 @@ +@LIT_SITE_CFG_IN_HEADER@ + +# Tool-specific config options. +config.name_suffix = "@CONFIG_NAME@" +config.tool_name = "@SANITIZER_COMMON_LIT_TEST_MODE@" +config.target_cflags = "@SANITIZER_COMMON_TEST_TARGET_CFLAGS@" +config.target_arch = "@SANITIZER_COMMON_TEST_TARGET_ARCH@" + +# Load common config for all compiler-rt lit tests. +lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") + +# Load tool-specific config that would do the real work. +lit_config.load_config(config, "@SANITIZER_COMMON_LIT_SOURCE_DIR@/lit.common.cfg.py") + Index: compiler-rt/trunk/test/scudo/CMakeLists.txt =================================================================== --- compiler-rt/trunk/test/scudo/CMakeLists.txt +++ compiler-rt/trunk/test/scudo/CMakeLists.txt @@ -9,8 +9,8 @@ endif() 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 ) set(SCUDO_TEST_ARCH ${SCUDO_SUPPORTED_ARCH}) @@ -22,8 +22,8 @@ set(CONFIG_NAME ${ARCH_UPPER_CASE}${OS_NAME}Config) configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg) + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in + ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py) list(APPEND SCUDO_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}) endforeach() Index: compiler-rt/trunk/test/scudo/lit.cfg =================================================================== --- compiler-rt/trunk/test/scudo/lit.cfg +++ compiler-rt/trunk/test/scudo/lit.cfg @@ -1,64 +0,0 @@ -# -*- Python -*- - -import os - -# Setup config name. -config.name = 'Scudo' + config.name_suffix - -# Setup source root. -config.test_source_root = os.path.dirname(__file__) - -# Path to the shared library -shared_libscudo = os.path.join(config.compiler_rt_libdir, "libclang_rt.scudo%s.so" % config.target_suffix) -shared_minlibscudo = os.path.join(config.compiler_rt_libdir, "libclang_rt.scudo_minimal-%s.so" % config.target_arch) - -# Test suffixes. -config.suffixes = ['.c', '.cc', '.cpp', '.test'] - -# C & CXX flags. -c_flags = ([config.target_cflags] + - ["-pthread", - "-fPIE", - "-pie", - "-O0", - "-UNDEBUG", - "-ldl", - "-Wl,--gc-sections"]) - -# Android doesn't want -lrt. -if not config.android: - c_flags += ["-lrt"] - -cxx_flags = (c_flags + config.cxx_mode_flags + ["-std=c++11"]) - -scudo_flags = ["-fsanitize=scudo"] - -def build_invocation(compile_flags): - return " " + " ".join([config.clang] + compile_flags) + " " - -# Add substitutions. -config.substitutions.append(("%clang ", build_invocation(c_flags))) -config.substitutions.append(("%clang_scudo ", build_invocation(c_flags + scudo_flags))) -config.substitutions.append(("%clangxx_scudo ", build_invocation(cxx_flags + scudo_flags))) -config.substitutions.append(("%shared_libscudo", shared_libscudo)) -config.substitutions.append(("%shared_minlibscudo", shared_minlibscudo)) - -# Platform-specific default SCUDO_OPTIONS for lit tests. -default_scudo_opts = '' -if config.android: - # Android defaults to abort_on_error=1, which doesn't work for us. - default_scudo_opts = 'abort_on_error=0' - -# Disable GWP-ASan for scudo internal tests. -if config.gwp_asan: - config.environment['GWP_ASAN_OPTIONS'] = 'Enabled=0' - -if default_scudo_opts: - config.environment['SCUDO_OPTIONS'] = default_scudo_opts - default_scudo_opts += ':' -config.substitutions.append(('%env_scudo_opts=', - 'env SCUDO_OPTIONS=' + default_scudo_opts)) - -# Hardened Allocator tests are currently supported on Linux only. -if config.host_os not in ['Linux']: - config.unsupported = True Index: compiler-rt/trunk/test/scudo/lit.cfg.py =================================================================== --- compiler-rt/trunk/test/scudo/lit.cfg.py +++ compiler-rt/trunk/test/scudo/lit.cfg.py @@ -0,0 +1,64 @@ +# -*- Python -*- + +import os + +# Setup config name. +config.name = 'Scudo' + config.name_suffix + +# Setup source root. +config.test_source_root = os.path.dirname(__file__) + +# Path to the shared library +shared_libscudo = os.path.join(config.compiler_rt_libdir, "libclang_rt.scudo%s.so" % config.target_suffix) +shared_minlibscudo = os.path.join(config.compiler_rt_libdir, "libclang_rt.scudo_minimal-%s.so" % config.target_arch) + +# Test suffixes. +config.suffixes = ['.c', '.cc', '.cpp', '.test'] + +# C & CXX flags. +c_flags = ([config.target_cflags] + + ["-pthread", + "-fPIE", + "-pie", + "-O0", + "-UNDEBUG", + "-ldl", + "-Wl,--gc-sections"]) + +# Android doesn't want -lrt. +if not config.android: + c_flags += ["-lrt"] + +cxx_flags = (c_flags + config.cxx_mode_flags + ["-std=c++11"]) + +scudo_flags = ["-fsanitize=scudo"] + +def build_invocation(compile_flags): + return " " + " ".join([config.clang] + compile_flags) + " " + +# Add substitutions. +config.substitutions.append(("%clang ", build_invocation(c_flags))) +config.substitutions.append(("%clang_scudo ", build_invocation(c_flags + scudo_flags))) +config.substitutions.append(("%clangxx_scudo ", build_invocation(cxx_flags + scudo_flags))) +config.substitutions.append(("%shared_libscudo", shared_libscudo)) +config.substitutions.append(("%shared_minlibscudo", shared_minlibscudo)) + +# Platform-specific default SCUDO_OPTIONS for lit tests. +default_scudo_opts = '' +if config.android: + # Android defaults to abort_on_error=1, which doesn't work for us. + default_scudo_opts = 'abort_on_error=0' + +# Disable GWP-ASan for scudo internal tests. +if config.gwp_asan: + config.environment['GWP_ASAN_OPTIONS'] = 'Enabled=0' + +if default_scudo_opts: + config.environment['SCUDO_OPTIONS'] = default_scudo_opts + default_scudo_opts += ':' +config.substitutions.append(('%env_scudo_opts=', + 'env SCUDO_OPTIONS=' + default_scudo_opts)) + +# Hardened Allocator tests are currently supported on Linux only. +if config.host_os not in ['Linux']: + config.unsupported = True Index: compiler-rt/trunk/test/scudo/lit.site.cfg.in =================================================================== --- compiler-rt/trunk/test/scudo/lit.site.cfg.in +++ compiler-rt/trunk/test/scudo/lit.site.cfg.in @@ -1,11 +0,0 @@ -@LIT_SITE_CFG_IN_HEADER@ - -config.name_suffix = "@SCUDO_TEST_CONFIG_SUFFIX@" -config.target_arch = "@SCUDO_TEST_TARGET_ARCH@" -config.target_cflags = "@SCUDO_TEST_TARGET_CFLAGS@" - -# Load common config for all compiler-rt lit tests. -lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") - -# Load tool-specific config that would do the real work. -lit_config.load_config(config, "@SCUDO_LIT_SOURCE_DIR@/lit.cfg") Index: compiler-rt/trunk/test/scudo/lit.site.cfg.py.in =================================================================== --- compiler-rt/trunk/test/scudo/lit.site.cfg.py.in +++ compiler-rt/trunk/test/scudo/lit.site.cfg.py.in @@ -0,0 +1,11 @@ +@LIT_SITE_CFG_IN_HEADER@ + +config.name_suffix = "@SCUDO_TEST_CONFIG_SUFFIX@" +config.target_arch = "@SCUDO_TEST_TARGET_ARCH@" +config.target_cflags = "@SCUDO_TEST_TARGET_CFLAGS@" + +# Load common config for all compiler-rt lit tests. +lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") + +# Load tool-specific config that would do the real work. +lit_config.load_config(config, "@SCUDO_LIT_SOURCE_DIR@/lit.cfg.py") Index: compiler-rt/trunk/test/scudo/standalone/CMakeLists.txt =================================================================== --- compiler-rt/trunk/test/scudo/standalone/CMakeLists.txt +++ compiler-rt/trunk/test/scudo/standalone/CMakeLists.txt @@ -1,7 +1,7 @@ if(COMPILER_RT_INCLUDE_TESTS AND COMPILER_RT_HAS_SCUDO_STANDALONE) 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) list(APPEND SCUDO_STANDALONE_TEST_DEPS ScudoUnitTests) list(APPEND SCUDO_STANDALONE_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/unit) endif() Index: compiler-rt/trunk/test/scudo/standalone/unit/lit.site.cfg.in =================================================================== --- compiler-rt/trunk/test/scudo/standalone/unit/lit.site.cfg.in +++ compiler-rt/trunk/test/scudo/standalone/unit/lit.site.cfg.in @@ -1,12 +0,0 @@ -@LIT_SITE_CFG_IN_HEADER@ - -# Load common config for all compiler-rt unit tests. -lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/unittests/lit.common.unit.configured") - -# Setup config name. -config.name = 'ScudoStandalone-Unit' - -# Setup test source and exec root. -# For unit tests, we define it as build directory with unit tests. -config.test_exec_root = "@COMPILER_RT_BINARY_DIR@/lib/scudo/standalone/tests" -config.test_source_root = config.test_exec_root Index: compiler-rt/trunk/test/scudo/standalone/unit/lit.site.cfg.py.in =================================================================== --- compiler-rt/trunk/test/scudo/standalone/unit/lit.site.cfg.py.in +++ compiler-rt/trunk/test/scudo/standalone/unit/lit.site.cfg.py.in @@ -0,0 +1,12 @@ +@LIT_SITE_CFG_IN_HEADER@ + +# Load common config for all compiler-rt unit tests. +lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/unittests/lit.common.unit.configured") + +# Setup config name. +config.name = 'ScudoStandalone-Unit' + +# Setup test source and exec root. +# For unit tests, we define it as build directory with unit tests. +config.test_exec_root = "@COMPILER_RT_BINARY_DIR@/lib/scudo/standalone/tests" +config.test_source_root = config.test_exec_root Index: compiler-rt/trunk/test/shadowcallstack/CMakeLists.txt =================================================================== --- compiler-rt/trunk/test/shadowcallstack/CMakeLists.txt +++ compiler-rt/trunk/test/shadowcallstack/CMakeLists.txt @@ -10,8 +10,8 @@ get_test_cc_for_arch(${arch} SHADOWSTACK_TEST_TARGET_CC SHADOWSTACK_TEST_TARGET_CFLAGS) configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/${arch}/lit.site.cfg) + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in + ${CMAKE_CURRENT_BINARY_DIR}/${arch}/lit.site.cfg.py) list(APPEND SHADOWCALLSTACK_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${arch}) endforeach() Index: compiler-rt/trunk/test/shadowcallstack/lit.cfg =================================================================== --- compiler-rt/trunk/test/shadowcallstack/lit.cfg +++ compiler-rt/trunk/test/shadowcallstack/lit.cfg @@ -1,23 +0,0 @@ -# -*- Python -*- - -import os - -# Setup config name. -config.name = 'ShadowCallStack' - -# Setup source root. -config.test_source_root = os.path.dirname(__file__) - -# Test suffixes. -config.suffixes = ['.c', '.cc', '.cpp', '.m', '.mm', '.ll', '.test'] - -# Add clang substitutions. -config.substitutions.append( ("%clang_noscs ", config.clang + ' -O0 -fno-sanitize=shadow-call-stack ' + config.target_cflags + ' ') ) - -scs_arch_cflags = config.target_cflags -if config.target_arch == 'aarch64': - scs_arch_cflags += ' -ffixed-x18 ' -config.substitutions.append( ("%clang_scs ", config.clang + ' -O0 -fsanitize=shadow-call-stack ' + scs_arch_cflags + ' ') ) - -if config.host_os not in ['Linux'] or config.target_arch not in ['aarch64']: - config.unsupported = True Index: compiler-rt/trunk/test/shadowcallstack/lit.cfg.py =================================================================== --- compiler-rt/trunk/test/shadowcallstack/lit.cfg.py +++ compiler-rt/trunk/test/shadowcallstack/lit.cfg.py @@ -0,0 +1,23 @@ +# -*- Python -*- + +import os + +# Setup config name. +config.name = 'ShadowCallStack' + +# Setup source root. +config.test_source_root = os.path.dirname(__file__) + +# Test suffixes. +config.suffixes = ['.c', '.cc', '.cpp', '.m', '.mm', '.ll', '.test'] + +# Add clang substitutions. +config.substitutions.append( ("%clang_noscs ", config.clang + ' -O0 -fno-sanitize=shadow-call-stack ' + config.target_cflags + ' ') ) + +scs_arch_cflags = config.target_cflags +if config.target_arch == 'aarch64': + scs_arch_cflags += ' -ffixed-x18 ' +config.substitutions.append( ("%clang_scs ", config.clang + ' -O0 -fsanitize=shadow-call-stack ' + scs_arch_cflags + ' ') ) + +if config.host_os not in ['Linux'] or config.target_arch not in ['aarch64']: + config.unsupported = True Index: compiler-rt/trunk/test/shadowcallstack/lit.site.cfg.in =================================================================== --- compiler-rt/trunk/test/shadowcallstack/lit.site.cfg.in +++ compiler-rt/trunk/test/shadowcallstack/lit.site.cfg.in @@ -1,12 +0,0 @@ -@LIT_SITE_CFG_IN_HEADER@ - -# Tool-specific config options. -config.name_suffix = "@SHADOWCALLSTACK_TEST_CONFIG_SUFFIX@" -config.target_cflags = "@SHADOWCALLSTACK_TEST_TARGET_CFLAGS@" -config.target_arch = "@SHADOWCALLSTACK_TEST_TARGET_ARCH@" - -# Load common config for all compiler-rt lit tests. -lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") - -# Load tool-specific config that would do the real work. -lit_config.load_config(config, "@SHADOWCALLSTACK_LIT_SOURCE_DIR@/lit.cfg") Index: compiler-rt/trunk/test/shadowcallstack/lit.site.cfg.py.in =================================================================== --- compiler-rt/trunk/test/shadowcallstack/lit.site.cfg.py.in +++ compiler-rt/trunk/test/shadowcallstack/lit.site.cfg.py.in @@ -0,0 +1,12 @@ +@LIT_SITE_CFG_IN_HEADER@ + +# Tool-specific config options. +config.name_suffix = "@SHADOWCALLSTACK_TEST_CONFIG_SUFFIX@" +config.target_cflags = "@SHADOWCALLSTACK_TEST_TARGET_CFLAGS@" +config.target_arch = "@SHADOWCALLSTACK_TEST_TARGET_ARCH@" + +# Load common config for all compiler-rt lit tests. +lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") + +# Load tool-specific config that would do the real work. +lit_config.load_config(config, "@SHADOWCALLSTACK_LIT_SOURCE_DIR@/lit.cfg.py") Index: compiler-rt/trunk/test/tsan/CMakeLists.txt =================================================================== --- compiler-rt/trunk/test/tsan/CMakeLists.txt +++ compiler-rt/trunk/test/tsan/CMakeLists.txt @@ -38,8 +38,8 @@ set(CONFIG_NAME ${ARCH_UPPER_CASE}Config) configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg) + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in + ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py) list(APPEND TSAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}) endforeach() @@ -61,8 +61,8 @@ string(TOUPPER ${arch} ARCH_UPPER_CASE) set(CONFIG_NAME "IOSSim${ARCH_UPPER_CASE}Config") configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in + ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py ) add_lit_testsuite(check-tsan-iossim-${arch} "ThreadSanitizer iOS Simulator ${arch} tests" ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/ @@ -76,8 +76,8 @@ string(TOUPPER ${arch} ARCH_UPPER_CASE) set(CONFIG_NAME "IOS${ARCH_UPPER_CASE}Config") configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in + ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py ) add_lit_testsuite(check-tsan-ios-${arch} "ThreadSanitizer iOS Simulator ${arch} tests" ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/ @@ -88,8 +88,8 @@ if(COMPILER_RT_INCLUDE_TESTS) 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) list(APPEND TSAN_TEST_DEPS TsanUnitTests) list(APPEND TSAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/Unit) endif() Index: compiler-rt/trunk/test/tsan/Darwin/lit.local.cfg =================================================================== --- compiler-rt/trunk/test/tsan/Darwin/lit.local.cfg +++ compiler-rt/trunk/test/tsan/Darwin/lit.local.cfg @@ -1,11 +0,0 @@ -def getRoot(config): - if not config.parent: - return config - return getRoot(config.parent) - -root = getRoot(config) - -if root.host_os not in ['Darwin']: - config.unsupported = True - -config.environment['TSAN_OPTIONS'] += ':ignore_noninstrumented_modules=1' Index: compiler-rt/trunk/test/tsan/Darwin/lit.local.cfg.py =================================================================== --- compiler-rt/trunk/test/tsan/Darwin/lit.local.cfg.py +++ compiler-rt/trunk/test/tsan/Darwin/lit.local.cfg.py @@ -0,0 +1,11 @@ +def getRoot(config): + if not config.parent: + return config + return getRoot(config.parent) + +root = getRoot(config) + +if root.host_os not in ['Darwin']: + config.unsupported = True + +config.environment['TSAN_OPTIONS'] += ':ignore_noninstrumented_modules=1' Index: compiler-rt/trunk/test/tsan/Linux/lit.local.cfg =================================================================== --- compiler-rt/trunk/test/tsan/Linux/lit.local.cfg +++ compiler-rt/trunk/test/tsan/Linux/lit.local.cfg @@ -1,9 +0,0 @@ -def getRoot(config): - if not config.parent: - return config - return getRoot(config.parent) - -root = getRoot(config) - -if root.host_os not in ['Linux']: - config.unsupported = True Index: compiler-rt/trunk/test/tsan/Linux/lit.local.cfg.py =================================================================== --- compiler-rt/trunk/test/tsan/Linux/lit.local.cfg.py +++ compiler-rt/trunk/test/tsan/Linux/lit.local.cfg.py @@ -0,0 +1,9 @@ +def getRoot(config): + if not config.parent: + return config + return getRoot(config.parent) + +root = getRoot(config) + +if root.host_os not in ['Linux']: + config.unsupported = True Index: compiler-rt/trunk/test/tsan/Unit/lit.site.cfg.in =================================================================== --- compiler-rt/trunk/test/tsan/Unit/lit.site.cfg.in +++ compiler-rt/trunk/test/tsan/Unit/lit.site.cfg.in @@ -1,23 +0,0 @@ -@LIT_SITE_CFG_IN_HEADER@ - -# Load common config for all compiler-rt unit tests. -lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/unittests/lit.common.unit.configured") - -# Setup config name. -config.name = 'ThreadSanitizer-Unit' - -# Setup test source and exec root. For unit tests, we define -# it as build directory with ASan unit tests. -# FIXME: De-hardcode this path. -config.test_exec_root = "@COMPILER_RT_BINARY_DIR@/lib/tsan/tests" -config.test_source_root = config.test_exec_root - -if config.host_os == 'Darwin': - config.parallelism_group = config.darwin_sanitizer_parallelism_group_func - - # On Darwin, we default to ignore_noninstrumented_modules=1, which also - # suppresses some races the tests are supposed to find. See tsan/lit.cfg. - if 'TSAN_OPTIONS' in config.environment: - config.environment['TSAN_OPTIONS'] += ':ignore_noninstrumented_modules=0' - else: - config.environment['TSAN_OPTIONS'] = 'ignore_noninstrumented_modules=0' Index: compiler-rt/trunk/test/tsan/Unit/lit.site.cfg.py.in =================================================================== --- compiler-rt/trunk/test/tsan/Unit/lit.site.cfg.py.in +++ compiler-rt/trunk/test/tsan/Unit/lit.site.cfg.py.in @@ -0,0 +1,23 @@ +@LIT_SITE_CFG_IN_HEADER@ + +# Load common config for all compiler-rt unit tests. +lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/unittests/lit.common.unit.configured") + +# Setup config name. +config.name = 'ThreadSanitizer-Unit' + +# Setup test source and exec root. For unit tests, we define +# it as build directory with ASan unit tests. +# FIXME: De-hardcode this path. +config.test_exec_root = "@COMPILER_RT_BINARY_DIR@/lib/tsan/tests" +config.test_source_root = config.test_exec_root + +if config.host_os == 'Darwin': + config.parallelism_group = config.darwin_sanitizer_parallelism_group_func + + # On Darwin, we default to ignore_noninstrumented_modules=1, which also + # suppresses some races the tests are supposed to find. See tsan/lit.cfg.py. + if 'TSAN_OPTIONS' in config.environment: + config.environment['TSAN_OPTIONS'] += ':ignore_noninstrumented_modules=0' + else: + config.environment['TSAN_OPTIONS'] = 'ignore_noninstrumented_modules=0' Index: compiler-rt/trunk/test/tsan/libcxx/lit.local.cfg =================================================================== --- compiler-rt/trunk/test/tsan/libcxx/lit.local.cfg +++ compiler-rt/trunk/test/tsan/libcxx/lit.local.cfg @@ -1,12 +0,0 @@ -def getRoot(config): - if not config.parent: - return config - return getRoot(config.parent) - -root = getRoot(config) - -# Only run if we have an instrumented libcxx. On Darwin, run always (we have -# interceptors to support the system-provided libcxx). -if not root.has_libcxx and root.host_os != 'Darwin': - config.unsupported = True - Index: compiler-rt/trunk/test/tsan/libcxx/lit.local.cfg.py =================================================================== --- compiler-rt/trunk/test/tsan/libcxx/lit.local.cfg.py +++ compiler-rt/trunk/test/tsan/libcxx/lit.local.cfg.py @@ -0,0 +1,12 @@ +def getRoot(config): + if not config.parent: + return config + return getRoot(config.parent) + +root = getRoot(config) + +# Only run if we have an instrumented libcxx. On Darwin, run always (we have +# interceptors to support the system-provided libcxx). +if not root.has_libcxx and root.host_os != 'Darwin': + config.unsupported = True + Index: compiler-rt/trunk/test/tsan/libdispatch/lit.local.cfg =================================================================== --- compiler-rt/trunk/test/tsan/libdispatch/lit.local.cfg +++ compiler-rt/trunk/test/tsan/libdispatch/lit.local.cfg @@ -1,17 +0,0 @@ -def getRoot(config): - if not config.parent: - return config - return getRoot(config.parent) - -root = getRoot(config) - -if 'libdispatch' in root.available_features: - additional_cflags = ' -fblocks ' - for index, (template, replacement) in enumerate(config.substitutions): - if template in ['%clang_tsan ', '%clangxx_tsan ']: - config.substitutions[index] = (template, replacement + additional_cflags) -else: - config.unsupported = True - -if config.host_os == 'Darwin': - config.environment['TSAN_OPTIONS'] += ':ignore_noninstrumented_modules=1' Index: compiler-rt/trunk/test/tsan/libdispatch/lit.local.cfg.py =================================================================== --- compiler-rt/trunk/test/tsan/libdispatch/lit.local.cfg.py +++ compiler-rt/trunk/test/tsan/libdispatch/lit.local.cfg.py @@ -0,0 +1,17 @@ +def getRoot(config): + if not config.parent: + return config + return getRoot(config.parent) + +root = getRoot(config) + +if 'libdispatch' in root.available_features: + additional_cflags = ' -fblocks ' + for index, (template, replacement) in enumerate(config.substitutions): + if template in ['%clang_tsan ', '%clangxx_tsan ']: + config.substitutions[index] = (template, replacement + additional_cflags) +else: + config.unsupported = True + +if config.host_os == 'Darwin': + config.environment['TSAN_OPTIONS'] += ':ignore_noninstrumented_modules=1' Index: compiler-rt/trunk/test/tsan/lit.cfg =================================================================== --- compiler-rt/trunk/test/tsan/lit.cfg +++ compiler-rt/trunk/test/tsan/lit.cfg @@ -1,90 +0,0 @@ -# -*- Python -*- - -import os - -def get_required_attr(config, attr_name): - attr_value = getattr(config, attr_name, None) - if not attr_value: - lit_config.fatal( - "No attribute %r in test configuration! You may need to run " - "tests from your build directory or add this attribute " - "to lit.site.cfg " % attr_name) - return attr_value - -# Setup config name. -config.name = 'ThreadSanitizer' + config.name_suffix - -# Setup source root. -config.test_source_root = os.path.dirname(__file__) - -# Setup environment variables for running ThreadSanitizer. -default_tsan_opts = "atexit_sleep_ms=0" - -if config.host_os == 'Darwin': - # On Darwin, we default to `abort_on_error=1`, which would make tests run - # much slower. Let's override this and run lit tests with 'abort_on_error=0'. - default_tsan_opts += ':abort_on_error=0' - # On Darwin, we default to ignore_noninstrumented_modules=1, which also - # suppresses some races the tests are supposed to find. Let's run without this - # setting, but turn it back on for Darwin tests (see Darwin/lit.local.cfg). - default_tsan_opts += ':ignore_noninstrumented_modules=0' - -# Platform-specific default TSAN_OPTIONS for lit tests. -if default_tsan_opts: - config.environment['TSAN_OPTIONS'] = default_tsan_opts - default_tsan_opts += ':' -config.substitutions.append(('%env_tsan_opts=', - 'env TSAN_OPTIONS=' + default_tsan_opts)) - -# GCC driver doesn't add necessary compile/link flags with -fsanitize=thread. -if config.compiler_id == 'GNU': - extra_cflags = ["-fPIE", "-pthread", "-ldl", "-lrt", "-pie"] -else: - extra_cflags = [] - -tsan_incdir = config.test_source_root + "/../" -# Setup default compiler flags used with -fsanitize=thread option. -clang_tsan_cflags = (["-fsanitize=thread", - "-Wall"] + - [config.target_cflags] + - config.debug_info_flags + - extra_cflags + - ["-I%s" % tsan_incdir]) -clang_tsan_cxxflags = config.cxx_mode_flags + clang_tsan_cflags + ["-std=c++11"] + ["-I%s" % tsan_incdir] -# Add additional flags if we're using instrumented libc++. -# Instrumented libcxx currently not supported on Darwin. -if config.has_libcxx and config.host_os != 'Darwin': - # FIXME: Dehardcode this path somehow. - libcxx_path = os.path.join(config.compiler_rt_obj_root, "lib", - "tsan", "libcxx_tsan_%s" % config.target_arch) - libcxx_incdir = os.path.join(libcxx_path, "include", "c++", "v1") - libcxx_libdir = os.path.join(libcxx_path, "lib") - libcxx_a = os.path.join(libcxx_libdir, "libc++.a") - clang_tsan_cxxflags += ["-nostdinc++", - "-I%s" % libcxx_incdir] - config.substitutions.append( ("%link_libcxx_tsan", libcxx_a) ) -else: - config.substitutions.append( ("%link_libcxx_tsan", "") ) - -def build_invocation(compile_flags): - return " " + " ".join([config.clang] + compile_flags) + " " - -config.substitutions.append( ("%clang_tsan ", build_invocation(clang_tsan_cflags)) ) -config.substitutions.append( ("%clangxx_tsan ", build_invocation(clang_tsan_cxxflags)) ) - -# Define CHECK-%os to check for OS-dependent output. -config.substitutions.append( ('CHECK-%os', ("CHECK-" + config.host_os))) - -config.substitutions.append( ("%deflake ", os.path.join(os.path.dirname(__file__), "deflake.bash") + " ")) - -# Default test suffixes. -config.suffixes = ['.c', '.cc', '.cpp', '.m', '.mm'] - -if config.host_os not in ['FreeBSD', 'Linux', 'Darwin', 'NetBSD']: - config.unsupported = True - -if config.android: - config.unsupported = True - -if not config.parallelism_group: - config.parallelism_group = 'shadow-memory' Index: compiler-rt/trunk/test/tsan/lit.cfg.py =================================================================== --- compiler-rt/trunk/test/tsan/lit.cfg.py +++ compiler-rt/trunk/test/tsan/lit.cfg.py @@ -0,0 +1,90 @@ +# -*- Python -*- + +import os + +def get_required_attr(config, attr_name): + attr_value = getattr(config, attr_name, None) + if not attr_value: + lit_config.fatal( + "No attribute %r in test configuration! You may need to run " + "tests from your build directory or add this attribute " + "to lit.site.cfg.py " % attr_name) + return attr_value + +# Setup config name. +config.name = 'ThreadSanitizer' + config.name_suffix + +# Setup source root. +config.test_source_root = os.path.dirname(__file__) + +# Setup environment variables for running ThreadSanitizer. +default_tsan_opts = "atexit_sleep_ms=0" + +if config.host_os == 'Darwin': + # On Darwin, we default to `abort_on_error=1`, which would make tests run + # much slower. Let's override this and run lit tests with 'abort_on_error=0'. + default_tsan_opts += ':abort_on_error=0' + # On Darwin, we default to ignore_noninstrumented_modules=1, which also + # suppresses some races the tests are supposed to find. Let's run without this + # setting, but turn it back on for Darwin tests (see Darwin/lit.local.cfg.py). + default_tsan_opts += ':ignore_noninstrumented_modules=0' + +# Platform-specific default TSAN_OPTIONS for lit tests. +if default_tsan_opts: + config.environment['TSAN_OPTIONS'] = default_tsan_opts + default_tsan_opts += ':' +config.substitutions.append(('%env_tsan_opts=', + 'env TSAN_OPTIONS=' + default_tsan_opts)) + +# GCC driver doesn't add necessary compile/link flags with -fsanitize=thread. +if config.compiler_id == 'GNU': + extra_cflags = ["-fPIE", "-pthread", "-ldl", "-lrt", "-pie"] +else: + extra_cflags = [] + +tsan_incdir = config.test_source_root + "/../" +# Setup default compiler flags used with -fsanitize=thread option. +clang_tsan_cflags = (["-fsanitize=thread", + "-Wall"] + + [config.target_cflags] + + config.debug_info_flags + + extra_cflags + + ["-I%s" % tsan_incdir]) +clang_tsan_cxxflags = config.cxx_mode_flags + clang_tsan_cflags + ["-std=c++11"] + ["-I%s" % tsan_incdir] +# Add additional flags if we're using instrumented libc++. +# Instrumented libcxx currently not supported on Darwin. +if config.has_libcxx and config.host_os != 'Darwin': + # FIXME: Dehardcode this path somehow. + libcxx_path = os.path.join(config.compiler_rt_obj_root, "lib", + "tsan", "libcxx_tsan_%s" % config.target_arch) + libcxx_incdir = os.path.join(libcxx_path, "include", "c++", "v1") + libcxx_libdir = os.path.join(libcxx_path, "lib") + libcxx_a = os.path.join(libcxx_libdir, "libc++.a") + clang_tsan_cxxflags += ["-nostdinc++", + "-I%s" % libcxx_incdir] + config.substitutions.append( ("%link_libcxx_tsan", libcxx_a) ) +else: + config.substitutions.append( ("%link_libcxx_tsan", "") ) + +def build_invocation(compile_flags): + return " " + " ".join([config.clang] + compile_flags) + " " + +config.substitutions.append( ("%clang_tsan ", build_invocation(clang_tsan_cflags)) ) +config.substitutions.append( ("%clangxx_tsan ", build_invocation(clang_tsan_cxxflags)) ) + +# Define CHECK-%os to check for OS-dependent output. +config.substitutions.append( ('CHECK-%os', ("CHECK-" + config.host_os))) + +config.substitutions.append( ("%deflake ", os.path.join(os.path.dirname(__file__), "deflake.bash") + " ")) + +# Default test suffixes. +config.suffixes = ['.c', '.cc', '.cpp', '.m', '.mm'] + +if config.host_os not in ['FreeBSD', 'Linux', 'Darwin', 'NetBSD']: + config.unsupported = True + +if config.android: + config.unsupported = True + +if not config.parallelism_group: + config.parallelism_group = 'shadow-memory' Index: compiler-rt/trunk/test/tsan/lit.site.cfg.in =================================================================== --- compiler-rt/trunk/test/tsan/lit.site.cfg.in +++ compiler-rt/trunk/test/tsan/lit.site.cfg.in @@ -1,14 +0,0 @@ -@LIT_SITE_CFG_IN_HEADER@ - -config.name_suffix = "@TSAN_TEST_CONFIG_SUFFIX@" -config.tsan_lit_source_dir = "@TSAN_LIT_SOURCE_DIR@" -config.has_libcxx = @TSAN_HAS_LIBCXX@ -config.apple_platform = "@TSAN_TEST_APPLE_PLATFORM@" -config.target_cflags = "@TSAN_TEST_TARGET_CFLAGS@" -config.target_arch = "@TSAN_TEST_TARGET_ARCH@" - -# Load common config for all compiler-rt lit tests. -lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") - -# Load tool-specific config that would do the real work. -lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg") Index: compiler-rt/trunk/test/tsan/lit.site.cfg.py.in =================================================================== --- compiler-rt/trunk/test/tsan/lit.site.cfg.py.in +++ compiler-rt/trunk/test/tsan/lit.site.cfg.py.in @@ -0,0 +1,14 @@ +@LIT_SITE_CFG_IN_HEADER@ + +config.name_suffix = "@TSAN_TEST_CONFIG_SUFFIX@" +config.tsan_lit_source_dir = "@TSAN_LIT_SOURCE_DIR@" +config.has_libcxx = @TSAN_HAS_LIBCXX@ +config.apple_platform = "@TSAN_TEST_APPLE_PLATFORM@" +config.target_cflags = "@TSAN_TEST_TARGET_CFLAGS@" +config.target_arch = "@TSAN_TEST_TARGET_ARCH@" + +# Load common config for all compiler-rt lit tests. +lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") + +# Load tool-specific config that would do the real work. +lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg.py") Index: compiler-rt/trunk/test/ubsan/CMakeLists.txt =================================================================== --- compiler-rt/trunk/test/ubsan/CMakeLists.txt +++ compiler-rt/trunk/test/ubsan/CMakeLists.txt @@ -18,8 +18,8 @@ set(UBSAN_TEST_USE_THINLTO ${thinlto}) set(CONFIG_NAME ${CONFIG_NAME}-${arch}) configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg) + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in + ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py) list(APPEND UBSAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}) if(NOT COMPILER_RT_STANDALONE_BUILD) list(APPEND UBSAN_TEST_DEPS ${sanitizer}) @@ -75,8 +75,8 @@ unset(UBSAN_TEST_APPLE_PLATFORM) endif() configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg) + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in + ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py) #list(APPEND UBSAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}) if(NOT COMPILER_RT_STANDALONE_BUILD) list(APPEND UBSAN_TEST_DEPS ${sanitizer}) Index: compiler-rt/trunk/test/ubsan/TestCases/Misc/Linux/lit.local.cfg =================================================================== --- compiler-rt/trunk/test/ubsan/TestCases/Misc/Linux/lit.local.cfg +++ compiler-rt/trunk/test/ubsan/TestCases/Misc/Linux/lit.local.cfg @@ -1,9 +0,0 @@ -def getRoot(config): - if not config.parent: - return config - return getRoot(config.parent) - -root = getRoot(config) - -if root.host_os not in ['Linux']: - config.unsupported = True Index: compiler-rt/trunk/test/ubsan/TestCases/Misc/Linux/lit.local.cfg.py =================================================================== --- compiler-rt/trunk/test/ubsan/TestCases/Misc/Linux/lit.local.cfg.py +++ compiler-rt/trunk/test/ubsan/TestCases/Misc/Linux/lit.local.cfg.py @@ -0,0 +1,9 @@ +def getRoot(config): + if not config.parent: + return config + return getRoot(config.parent) + +root = getRoot(config) + +if root.host_os not in ['Linux']: + config.unsupported = True Index: compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/Function/lit.local.cfg =================================================================== --- compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/Function/lit.local.cfg +++ compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/Function/lit.local.cfg @@ -1,3 +0,0 @@ -# The function type checker is only supported on x86 and x86_64 for now. -if config.target_arch not in ['x86', 'x86_64']: - config.unsupported = True Index: compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/Function/lit.local.cfg.py =================================================================== --- compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/Function/lit.local.cfg.py +++ compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/Function/lit.local.cfg.py @@ -0,0 +1,3 @@ +# The function type checker is only supported on x86 and x86_64 for now. +if config.target_arch not in ['x86', 'x86_64']: + config.unsupported = True Index: compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/Linux/lit.local.cfg =================================================================== --- compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/Linux/lit.local.cfg +++ compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/Linux/lit.local.cfg @@ -1,9 +0,0 @@ -def getRoot(config): - if not config.parent: - return config - return getRoot(config.parent) - -root = getRoot(config) - -if root.host_os not in ['Linux']: - config.unsupported = True Index: compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/Linux/lit.local.cfg.py =================================================================== --- compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/Linux/lit.local.cfg.py +++ compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/Linux/lit.local.cfg.py @@ -0,0 +1,9 @@ +def getRoot(config): + if not config.parent: + return config + return getRoot(config.parent) + +root = getRoot(config) + +if root.host_os not in ['Linux']: + config.unsupported = True Index: compiler-rt/trunk/test/ubsan/lit.common.cfg =================================================================== --- compiler-rt/trunk/test/ubsan/lit.common.cfg +++ compiler-rt/trunk/test/ubsan/lit.common.cfg @@ -1,80 +0,0 @@ -# -*- Python -*- - -import os - -def get_required_attr(config, attr_name): - attr_value = getattr(config, attr_name, None) - if attr_value == None: - lit_config.fatal( - "No attribute %r in test configuration! You may need to run " - "tests from your build directory or add this attribute " - "to lit.site.cfg " % attr_name) - return attr_value - -# Setup config name. -config.name = 'UBSan-' + config.name_suffix - -# Setup source root. -config.test_source_root = os.path.dirname(__file__) - -default_ubsan_opts = list(config.default_sanitizer_opts) -# Choose between standalone and UBSan+ASan modes. -ubsan_lit_test_mode = get_required_attr(config, 'ubsan_lit_test_mode') -if ubsan_lit_test_mode == "Standalone": - config.available_features.add("ubsan-standalone") - clang_ubsan_cflags = [] -elif ubsan_lit_test_mode == "StandaloneStatic": - config.available_features.add("ubsan-standalone-static") - clang_ubsan_cflags = ['-static-libsan'] -elif ubsan_lit_test_mode == "AddressSanitizer": - config.available_features.add("ubsan-asan") - clang_ubsan_cflags = ["-fsanitize=address"] - default_ubsan_opts += ['detect_leaks=0'] -elif ubsan_lit_test_mode == "MemorySanitizer": - config.available_features.add("ubsan-msan") - clang_ubsan_cflags = ["-fsanitize=memory"] -elif ubsan_lit_test_mode == "ThreadSanitizer": - config.available_features.add("ubsan-tsan") - clang_ubsan_cflags = ["-fsanitize=thread"] -else: - lit_config.fatal("Unknown UBSan test mode: %r" % ubsan_lit_test_mode) - -# Platform-specific default for lit tests. -if config.target_arch == 's390x': - # On SystemZ we need -mbackchain to make the fast unwinder work. - clang_ubsan_cflags.append("-mbackchain") - -default_ubsan_opts_str = ':'.join(default_ubsan_opts) -if default_ubsan_opts_str: - config.environment['UBSAN_OPTIONS'] = default_ubsan_opts_str - default_ubsan_opts_str += ':' -# Substitution to setup UBSAN_OPTIONS in portable way. -config.substitutions.append(('%env_ubsan_opts=', - 'env UBSAN_OPTIONS=' + default_ubsan_opts_str)) - -def build_invocation(compile_flags): - return " " + " ".join([config.clang] + compile_flags) + " " - -target_cflags = [get_required_attr(config, "target_cflags")] -clang_ubsan_cflags += target_cflags -clang_ubsan_cxxflags = config.cxx_mode_flags + clang_ubsan_cflags - -# Define %clang and %clangxx substitutions to use in test RUN lines. -config.substitutions.append( ("%clang ", build_invocation(clang_ubsan_cflags)) ) -config.substitutions.append( ("%clangxx ", build_invocation(clang_ubsan_cxxflags)) ) -config.substitutions.append( ("%gmlt ", " ".join(config.debug_info_flags) + " ") ) - -# Default test suffixes. -config.suffixes = ['.c', '.cc', '.cpp'] - -# Check that the host supports UndefinedBehaviorSanitizer tests -if config.host_os not in ['Linux', 'Darwin', 'FreeBSD', 'Windows', 'NetBSD', 'SunOS', 'OpenBSD']: - config.unsupported = True - -config.available_features.add('arch=' + config.target_arch) - -config.excludes = ['Inputs'] - -if ubsan_lit_test_mode in ['AddressSanitizer', 'MemorySanitizer', 'ThreadSanitizer']: - if not config.parallelism_group: - config.parallelism_group = 'shadow-memory' Index: compiler-rt/trunk/test/ubsan/lit.common.cfg.py =================================================================== --- compiler-rt/trunk/test/ubsan/lit.common.cfg.py +++ compiler-rt/trunk/test/ubsan/lit.common.cfg.py @@ -0,0 +1,80 @@ +# -*- Python -*- + +import os + +def get_required_attr(config, attr_name): + attr_value = getattr(config, attr_name, None) + if attr_value == None: + lit_config.fatal( + "No attribute %r in test configuration! You may need to run " + "tests from your build directory or add this attribute " + "to lit.site.cfg.py " % attr_name) + return attr_value + +# Setup config name. +config.name = 'UBSan-' + config.name_suffix + +# Setup source root. +config.test_source_root = os.path.dirname(__file__) + +default_ubsan_opts = list(config.default_sanitizer_opts) +# Choose between standalone and UBSan+ASan modes. +ubsan_lit_test_mode = get_required_attr(config, 'ubsan_lit_test_mode') +if ubsan_lit_test_mode == "Standalone": + config.available_features.add("ubsan-standalone") + clang_ubsan_cflags = [] +elif ubsan_lit_test_mode == "StandaloneStatic": + config.available_features.add("ubsan-standalone-static") + clang_ubsan_cflags = ['-static-libsan'] +elif ubsan_lit_test_mode == "AddressSanitizer": + config.available_features.add("ubsan-asan") + clang_ubsan_cflags = ["-fsanitize=address"] + default_ubsan_opts += ['detect_leaks=0'] +elif ubsan_lit_test_mode == "MemorySanitizer": + config.available_features.add("ubsan-msan") + clang_ubsan_cflags = ["-fsanitize=memory"] +elif ubsan_lit_test_mode == "ThreadSanitizer": + config.available_features.add("ubsan-tsan") + clang_ubsan_cflags = ["-fsanitize=thread"] +else: + lit_config.fatal("Unknown UBSan test mode: %r" % ubsan_lit_test_mode) + +# Platform-specific default for lit tests. +if config.target_arch == 's390x': + # On SystemZ we need -mbackchain to make the fast unwinder work. + clang_ubsan_cflags.append("-mbackchain") + +default_ubsan_opts_str = ':'.join(default_ubsan_opts) +if default_ubsan_opts_str: + config.environment['UBSAN_OPTIONS'] = default_ubsan_opts_str + default_ubsan_opts_str += ':' +# Substitution to setup UBSAN_OPTIONS in portable way. +config.substitutions.append(('%env_ubsan_opts=', + 'env UBSAN_OPTIONS=' + default_ubsan_opts_str)) + +def build_invocation(compile_flags): + return " " + " ".join([config.clang] + compile_flags) + " " + +target_cflags = [get_required_attr(config, "target_cflags")] +clang_ubsan_cflags += target_cflags +clang_ubsan_cxxflags = config.cxx_mode_flags + clang_ubsan_cflags + +# Define %clang and %clangxx substitutions to use in test RUN lines. +config.substitutions.append( ("%clang ", build_invocation(clang_ubsan_cflags)) ) +config.substitutions.append( ("%clangxx ", build_invocation(clang_ubsan_cxxflags)) ) +config.substitutions.append( ("%gmlt ", " ".join(config.debug_info_flags) + " ") ) + +# Default test suffixes. +config.suffixes = ['.c', '.cc', '.cpp'] + +# Check that the host supports UndefinedBehaviorSanitizer tests +if config.host_os not in ['Linux', 'Darwin', 'FreeBSD', 'Windows', 'NetBSD', 'SunOS', 'OpenBSD']: + config.unsupported = True + +config.available_features.add('arch=' + config.target_arch) + +config.excludes = ['Inputs'] + +if ubsan_lit_test_mode in ['AddressSanitizer', 'MemorySanitizer', 'ThreadSanitizer']: + if not config.parallelism_group: + config.parallelism_group = 'shadow-memory' Index: compiler-rt/trunk/test/ubsan/lit.site.cfg.in =================================================================== --- compiler-rt/trunk/test/ubsan/lit.site.cfg.in +++ compiler-rt/trunk/test/ubsan/lit.site.cfg.in @@ -1,16 +0,0 @@ -@LIT_SITE_CFG_IN_HEADER@ - -# Tool-specific config options. -config.name_suffix = "@CONFIG_NAME@" -config.ubsan_lit_test_mode = "@UBSAN_LIT_TEST_MODE@" -config.target_cflags = "@UBSAN_TEST_TARGET_CFLAGS@" -config.target_arch = "@UBSAN_TEST_TARGET_ARCH@" -config.use_lld = @UBSAN_TEST_USE_LLD@ -config.use_thinlto = @UBSAN_TEST_USE_THINLTO@ -config.apple_platform = "@UBSAN_TEST_APPLE_PLATFORM@" - -# Load common config for all compiler-rt lit tests. -lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") - -# Load tool-specific config that would do the real work. -lit_config.load_config(config, "@UBSAN_LIT_TESTS_DIR@/lit.common.cfg") Index: compiler-rt/trunk/test/ubsan/lit.site.cfg.py.in =================================================================== --- compiler-rt/trunk/test/ubsan/lit.site.cfg.py.in +++ compiler-rt/trunk/test/ubsan/lit.site.cfg.py.in @@ -0,0 +1,16 @@ +@LIT_SITE_CFG_IN_HEADER@ + +# Tool-specific config options. +config.name_suffix = "@CONFIG_NAME@" +config.ubsan_lit_test_mode = "@UBSAN_LIT_TEST_MODE@" +config.target_cflags = "@UBSAN_TEST_TARGET_CFLAGS@" +config.target_arch = "@UBSAN_TEST_TARGET_ARCH@" +config.use_lld = @UBSAN_TEST_USE_LLD@ +config.use_thinlto = @UBSAN_TEST_USE_THINLTO@ +config.apple_platform = "@UBSAN_TEST_APPLE_PLATFORM@" + +# Load common config for all compiler-rt lit tests. +lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") + +# Load tool-specific config that would do the real work. +lit_config.load_config(config, "@UBSAN_LIT_TESTS_DIR@/lit.common.cfg.py") Index: compiler-rt/trunk/test/ubsan_minimal/CMakeLists.txt =================================================================== --- compiler-rt/trunk/test/ubsan_minimal/CMakeLists.txt +++ compiler-rt/trunk/test/ubsan_minimal/CMakeLists.txt @@ -18,8 +18,8 @@ get_test_cc_for_arch(${arch} UBSAN_TEST_TARGET_CC UBSAN_TEST_TARGET_CFLAGS) set(CONFIG_NAME ${arch}) configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg) + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in + ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py) list(APPEND UBSAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}) endforeach() Index: compiler-rt/trunk/test/ubsan_minimal/lit.common.cfg =================================================================== --- compiler-rt/trunk/test/ubsan_minimal/lit.common.cfg +++ compiler-rt/trunk/test/ubsan_minimal/lit.common.cfg @@ -1,40 +0,0 @@ -# -*- Python -*- - -import os - -def get_required_attr(config, attr_name): - attr_value = getattr(config, attr_name, None) - if attr_value == None: - lit_config.fatal( - "No attribute %r in test configuration! You may need to run " - "tests from your build directory or add this attribute " - "to lit.site.cfg " % attr_name) - return attr_value - -# Setup source root. -config.test_source_root = os.path.dirname(__file__) -config.name = 'UBSan-Minimal-' + config.target_arch - -def build_invocation(compile_flags): - return " " + " ".join([config.clang] + compile_flags) + " " - -target_cflags = [get_required_attr(config, "target_cflags")] -clang_ubsan_cflags = ["-fsanitize-minimal-runtime"] + target_cflags -clang_ubsan_cxxflags = config.cxx_mode_flags + clang_ubsan_cflags - -# Define %clang and %clangxx substitutions to use in test RUN lines. -config.substitutions.append( ("%clang ", build_invocation(clang_ubsan_cflags)) ) -config.substitutions.append( ("%clangxx ", build_invocation(clang_ubsan_cxxflags)) ) - -# Default test suffixes. -config.suffixes = ['.c', '.cc', '.cpp'] - -# Check that the host supports UndefinedBehaviorSanitizerMinimal tests -if config.host_os not in ['Linux', 'FreeBSD', 'NetBSD', 'Darwin', 'OpenBSD']: # TODO: Windows - config.unsupported = True - -# Don't target x86_64h if the test machine can't execute x86_64h binaries. -if '-arch x86_64h' in target_cflags and 'x86_64h' not in config.available_features: - config.unsupported = True - -config.available_features.add('arch=' + config.target_arch) Index: compiler-rt/trunk/test/ubsan_minimal/lit.common.cfg.py =================================================================== --- compiler-rt/trunk/test/ubsan_minimal/lit.common.cfg.py +++ compiler-rt/trunk/test/ubsan_minimal/lit.common.cfg.py @@ -0,0 +1,40 @@ +# -*- Python -*- + +import os + +def get_required_attr(config, attr_name): + attr_value = getattr(config, attr_name, None) + if attr_value == None: + lit_config.fatal( + "No attribute %r in test configuration! You may need to run " + "tests from your build directory or add this attribute " + "to lit.site.cfg.py " % attr_name) + return attr_value + +# Setup source root. +config.test_source_root = os.path.dirname(__file__) +config.name = 'UBSan-Minimal-' + config.target_arch + +def build_invocation(compile_flags): + return " " + " ".join([config.clang] + compile_flags) + " " + +target_cflags = [get_required_attr(config, "target_cflags")] +clang_ubsan_cflags = ["-fsanitize-minimal-runtime"] + target_cflags +clang_ubsan_cxxflags = config.cxx_mode_flags + clang_ubsan_cflags + +# Define %clang and %clangxx substitutions to use in test RUN lines. +config.substitutions.append( ("%clang ", build_invocation(clang_ubsan_cflags)) ) +config.substitutions.append( ("%clangxx ", build_invocation(clang_ubsan_cxxflags)) ) + +# Default test suffixes. +config.suffixes = ['.c', '.cc', '.cpp'] + +# Check that the host supports UndefinedBehaviorSanitizerMinimal tests +if config.host_os not in ['Linux', 'FreeBSD', 'NetBSD', 'Darwin', 'OpenBSD']: # TODO: Windows + config.unsupported = True + +# Don't target x86_64h if the test machine can't execute x86_64h binaries. +if '-arch x86_64h' in target_cflags and 'x86_64h' not in config.available_features: + config.unsupported = True + +config.available_features.add('arch=' + config.target_arch) Index: compiler-rt/trunk/test/ubsan_minimal/lit.site.cfg.in =================================================================== --- compiler-rt/trunk/test/ubsan_minimal/lit.site.cfg.in +++ compiler-rt/trunk/test/ubsan_minimal/lit.site.cfg.in @@ -1,11 +0,0 @@ -@LIT_SITE_CFG_IN_HEADER@ - -# Tool-specific config options. -config.target_cflags = "@UBSAN_TEST_TARGET_CFLAGS@" -config.target_arch = "@UBSAN_TEST_TARGET_ARCH@" - -# Load common config for all compiler-rt lit tests. -lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") - -# Load tool-specific config that would do the real work. -lit_config.load_config(config, "@UBSAN_LIT_TESTS_DIR@/lit.common.cfg") Index: compiler-rt/trunk/test/ubsan_minimal/lit.site.cfg.py.in =================================================================== --- compiler-rt/trunk/test/ubsan_minimal/lit.site.cfg.py.in +++ compiler-rt/trunk/test/ubsan_minimal/lit.site.cfg.py.in @@ -0,0 +1,11 @@ +@LIT_SITE_CFG_IN_HEADER@ + +# Tool-specific config options. +config.target_cflags = "@UBSAN_TEST_TARGET_CFLAGS@" +config.target_arch = "@UBSAN_TEST_TARGET_ARCH@" + +# Load common config for all compiler-rt lit tests. +lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") + +# Load tool-specific config that would do the real work. +lit_config.load_config(config, "@UBSAN_LIT_TESTS_DIR@/lit.common.cfg.py") Index: compiler-rt/trunk/test/xray/CMakeLists.txt =================================================================== --- compiler-rt/trunk/test/xray/CMakeLists.txt +++ compiler-rt/trunk/test/xray/CMakeLists.txt @@ -21,8 +21,8 @@ set(CONFIG_NAME ${ARCH_UPPER_CASE}${OS_NAME}Config) configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg) + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in + ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py) list(APPEND XRAY_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}) endforeach() @@ -30,8 +30,8 @@ if(COMPILER_RT_INCLUDE_TESTS) if(UNIX AND NOT APPLE) 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) list(APPEND XRAY_TEST_DEPS XRayUnitTests) list(APPEND XRAY_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/Unit) endif() Index: compiler-rt/trunk/test/xray/Unit/lit.site.cfg.in =================================================================== --- compiler-rt/trunk/test/xray/Unit/lit.site.cfg.in +++ compiler-rt/trunk/test/xray/Unit/lit.site.cfg.in @@ -1,24 +0,0 @@ -@LIT_SITE_CFG_IN_HEADER@ - -import os - -# Load common config for all compiler-rt unit tests. -lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/unittests/lit.common.unit.configured") - -# Setup config name. -config.name = 'XRay-Unit' - -config.test_exec_root = "@COMPILER_RT_BINARY_DIR@/lib/xray/tests" -config.test_source_root = config.test_exec_root - -# Do not patch the XRay unit tests pre-main, and also make the error logging -# verbose to get a more accurate error logging mechanism. -config.environment['XRAY_OPTIONS'] = 'patch_premain=false' - -# Add the LLVM Library directory to the LD_LIBRARY_PATH to allow tests to look -# up the shared libraries. -if 'LD_LIBRARY_PATH' in os.environ: - libdirs = os.path.pathsep.join((config.llvm_lib_dir, os.environ['LD_LIBRARY_PATH'])) - config.environment['LD_LIBRARY_PATH'] = libdirs -else: - config.environment['LD_LIBRARY_PATH'] = config.llvm_lib_dir Index: compiler-rt/trunk/test/xray/Unit/lit.site.cfg.py.in =================================================================== --- compiler-rt/trunk/test/xray/Unit/lit.site.cfg.py.in +++ compiler-rt/trunk/test/xray/Unit/lit.site.cfg.py.in @@ -0,0 +1,24 @@ +@LIT_SITE_CFG_IN_HEADER@ + +import os + +# Load common config for all compiler-rt unit tests. +lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/unittests/lit.common.unit.configured") + +# Setup config name. +config.name = 'XRay-Unit' + +config.test_exec_root = "@COMPILER_RT_BINARY_DIR@/lib/xray/tests" +config.test_source_root = config.test_exec_root + +# Do not patch the XRay unit tests pre-main, and also make the error logging +# verbose to get a more accurate error logging mechanism. +config.environment['XRAY_OPTIONS'] = 'patch_premain=false' + +# Add the LLVM Library directory to the LD_LIBRARY_PATH to allow tests to look +# up the shared libraries. +if 'LD_LIBRARY_PATH' in os.environ: + libdirs = os.path.pathsep.join((config.llvm_lib_dir, os.environ['LD_LIBRARY_PATH'])) + config.environment['LD_LIBRARY_PATH'] = libdirs +else: + config.environment['LD_LIBRARY_PATH'] = config.llvm_lib_dir Index: compiler-rt/trunk/test/xray/lit.cfg =================================================================== --- compiler-rt/trunk/test/xray/lit.cfg +++ compiler-rt/trunk/test/xray/lit.cfg @@ -1,63 +0,0 @@ -# -*- Python -*- - -import os - -# Setup config name. -config.name = 'XRay' + config.name_suffix - -# Setup source root. -config.test_source_root = os.path.dirname(__file__) - -# Setup default compiler flags use with -fxray-instrument option. -clang_xray_cflags = (['-fxray-instrument', config.target_cflags]) - -# If libc++ was used to build XRAY libraries, libc++ is needed. Fix applied -# to Linux only since -rpath may not be portable. This can be extended to -# other platforms. -if config.libcxx_used == "1" and config.host_os == "Linux": - clang_xray_cflags = clang_xray_cflags + (['-L%s -lc++ -Wl,-rpath=%s' - % (config.llvm_shlib_dir, - config.llvm_shlib_dir)]) - -clang_xray_cxxflags = config.cxx_mode_flags + clang_xray_cflags - -def build_invocation(compile_flags): - return ' ' + ' '.join([config.clang] + compile_flags) + ' ' - -# Assume that llvm-xray is in the config.llvm_tools_dir. -llvm_xray = os.path.join(config.llvm_tools_dir, 'llvm-xray') - -# Setup substitutions. -if config.host_os == "Linux": - libdl_flag = "-ldl" -else: - libdl_flag = "" - -config.substitutions.append( - ('%clang ', build_invocation([config.target_cflags]))) -config.substitutions.append( - ('%clangxx ', - build_invocation(config.cxx_mode_flags + [config.target_cflags]))) -config.substitutions.append( - ('%clang_xray ', build_invocation(clang_xray_cflags))) -config.substitutions.append( - ('%clangxx_xray', build_invocation(clang_xray_cxxflags))) -config.substitutions.append( - ('%llvm_xray', llvm_xray)) -config.substitutions.append( - ('%xraylib', - ('-lm -lpthread %s -lrt -L%s ' - '-Wl,-whole-archive -lclang_rt.xray%s -Wl,-no-whole-archive') - % (libdl_flag, config.compiler_rt_libdir, config.target_suffix))) - -# Default test suffixes. -config.suffixes = ['.c', '.cc', '.cpp'] - -if config.host_os not in ['FreeBSD', 'Linux', 'NetBSD', 'OpenBSD']: - config.unsupported = True -elif '64' not in config.host_arch: - if 'arm' in config.host_arch: - if '-mthumb' in config.target_cflags: - config.unsupported = True - else: - config.unsupported = True Index: compiler-rt/trunk/test/xray/lit.cfg.py =================================================================== --- compiler-rt/trunk/test/xray/lit.cfg.py +++ compiler-rt/trunk/test/xray/lit.cfg.py @@ -0,0 +1,63 @@ +# -*- Python -*- + +import os + +# Setup config name. +config.name = 'XRay' + config.name_suffix + +# Setup source root. +config.test_source_root = os.path.dirname(__file__) + +# Setup default compiler flags use with -fxray-instrument option. +clang_xray_cflags = (['-fxray-instrument', config.target_cflags]) + +# If libc++ was used to build XRAY libraries, libc++ is needed. Fix applied +# to Linux only since -rpath may not be portable. This can be extended to +# other platforms. +if config.libcxx_used == "1" and config.host_os == "Linux": + clang_xray_cflags = clang_xray_cflags + (['-L%s -lc++ -Wl,-rpath=%s' + % (config.llvm_shlib_dir, + config.llvm_shlib_dir)]) + +clang_xray_cxxflags = config.cxx_mode_flags + clang_xray_cflags + +def build_invocation(compile_flags): + return ' ' + ' '.join([config.clang] + compile_flags) + ' ' + +# Assume that llvm-xray is in the config.llvm_tools_dir. +llvm_xray = os.path.join(config.llvm_tools_dir, 'llvm-xray') + +# Setup substitutions. +if config.host_os == "Linux": + libdl_flag = "-ldl" +else: + libdl_flag = "" + +config.substitutions.append( + ('%clang ', build_invocation([config.target_cflags]))) +config.substitutions.append( + ('%clangxx ', + build_invocation(config.cxx_mode_flags + [config.target_cflags]))) +config.substitutions.append( + ('%clang_xray ', build_invocation(clang_xray_cflags))) +config.substitutions.append( + ('%clangxx_xray', build_invocation(clang_xray_cxxflags))) +config.substitutions.append( + ('%llvm_xray', llvm_xray)) +config.substitutions.append( + ('%xraylib', + ('-lm -lpthread %s -lrt -L%s ' + '-Wl,-whole-archive -lclang_rt.xray%s -Wl,-no-whole-archive') + % (libdl_flag, config.compiler_rt_libdir, config.target_suffix))) + +# Default test suffixes. +config.suffixes = ['.c', '.cc', '.cpp'] + +if config.host_os not in ['FreeBSD', 'Linux', 'NetBSD', 'OpenBSD']: + config.unsupported = True +elif '64' not in config.host_arch: + if 'arm' in config.host_arch: + if '-mthumb' in config.target_cflags: + config.unsupported = True + else: + config.unsupported = True Index: compiler-rt/trunk/test/xray/lit.site.cfg.in =================================================================== --- compiler-rt/trunk/test/xray/lit.site.cfg.in +++ compiler-rt/trunk/test/xray/lit.site.cfg.in @@ -1,20 +0,0 @@ -@LIT_SITE_CFG_IN_HEADER@ - -# Tool-specific config options. -config.name_suffix = "@XRAY_TEST_CONFIG_SUFFIX@" -config.xray_lit_source_dir = "@XRAY_LIT_SOURCE_DIR@" -config.target_cflags = "@XRAY_TEST_TARGET_CFLAGS@" -config.target_arch = "@XRAY_TEST_TARGET_ARCH@" -config.built_with_llvm = ("@COMPILER_RT_STANDALONE_BUILD@" != "TRUE") - -# TODO: Look into whether we can run a capability test on the standalone build to -# see whether it can run 'llvm-xray convert' instead of turning off tests for a -# standalone build. -if config.built_with_llvm: - config.available_features.add('built-in-llvm-tree') - -# Load common config for all compiler-rt lit tests -lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") - -# Load tool-specific config that would do the real work. -lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg") Index: compiler-rt/trunk/test/xray/lit.site.cfg.py.in =================================================================== --- compiler-rt/trunk/test/xray/lit.site.cfg.py.in +++ compiler-rt/trunk/test/xray/lit.site.cfg.py.in @@ -0,0 +1,20 @@ +@LIT_SITE_CFG_IN_HEADER@ + +# Tool-specific config options. +config.name_suffix = "@XRAY_TEST_CONFIG_SUFFIX@" +config.xray_lit_source_dir = "@XRAY_LIT_SOURCE_DIR@" +config.target_cflags = "@XRAY_TEST_TARGET_CFLAGS@" +config.target_arch = "@XRAY_TEST_TARGET_ARCH@" +config.built_with_llvm = ("@COMPILER_RT_STANDALONE_BUILD@" != "TRUE") + +# TODO: Look into whether we can run a capability test on the standalone build to +# see whether it can run 'llvm-xray convert' instead of turning off tests for a +# standalone build. +if config.built_with_llvm: + config.available_features.add('built-in-llvm-tree') + +# Load common config for all compiler-rt lit tests +lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") + +# Load tool-specific config that would do the real work. +lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg.py") Index: compiler-rt/trunk/unittests/lit.common.unit.cfg =================================================================== --- compiler-rt/trunk/unittests/lit.common.unit.cfg +++ compiler-rt/trunk/unittests/lit.common.unit.cfg @@ -1,46 +0,0 @@ -# -*- Python -*- - -# Configuration file for 'lit' test runner. -# This file contains common config setup rules for unit tests in various -# compiler-rt testsuites. - -import os - -import lit.formats - -# Setup test format -llvm_build_mode = getattr(config, "llvm_build_mode", "Debug") -config.test_format = lit.formats.GoogleTest(llvm_build_mode, "Test") - -# Setup test suffixes. -config.suffixes = [] - -# Tweak PATH to include llvm tools dir. -llvm_tools_dir = config.llvm_tools_dir -if (not llvm_tools_dir) or (not os.path.exists(llvm_tools_dir)): - lit_config.fatal("Invalid llvm_tools_dir config attribute: %r" % llvm_tools_dir) -path = os.path.pathsep.join((llvm_tools_dir, config.environment['PATH'])) -config.environment['PATH'] = path - -# Propagate the temp directory. Windows requires this because it uses \Windows\ -# if none of these are present. -if 'TMP' in os.environ: - config.environment['TMP'] = os.environ['TMP'] -if 'TEMP' in os.environ: - config.environment['TEMP'] = os.environ['TEMP'] - -if config.host_os == 'Darwin': - # Only run up to 3 processes that require shadow memory simultaneously on - # 64-bit Darwin. Using more scales badly and hogs the system due to - # inefficient handling of large mmap'd regions (terabytes) by the kernel. - lit_config.parallelism_groups["shadow-memory"] = 3 - - # The test config gets pickled and sent to multiprocessing workers, and that - # only works for code if it is stored at the top level of some module. - # Therefore, we have to put the code in a .py file, add it to path, and import - # it to store it in the config. - import site - site.addsitedir(os.path.dirname(__file__)) - import lit_unittest_cfg_utils - config.darwin_sanitizer_parallelism_group_func = \ - lit_unittest_cfg_utils.darwin_sanitizer_parallelism_group_func Index: compiler-rt/trunk/unittests/lit.common.unit.cfg.py =================================================================== --- compiler-rt/trunk/unittests/lit.common.unit.cfg.py +++ compiler-rt/trunk/unittests/lit.common.unit.cfg.py @@ -0,0 +1,46 @@ +# -*- Python -*- + +# Configuration file for 'lit' test runner. +# This file contains common config setup rules for unit tests in various +# compiler-rt testsuites. + +import os + +import lit.formats + +# Setup test format +llvm_build_mode = getattr(config, "llvm_build_mode", "Debug") +config.test_format = lit.formats.GoogleTest(llvm_build_mode, "Test") + +# Setup test suffixes. +config.suffixes = [] + +# Tweak PATH to include llvm tools dir. +llvm_tools_dir = config.llvm_tools_dir +if (not llvm_tools_dir) or (not os.path.exists(llvm_tools_dir)): + lit_config.fatal("Invalid llvm_tools_dir config attribute: %r" % llvm_tools_dir) +path = os.path.pathsep.join((llvm_tools_dir, config.environment['PATH'])) +config.environment['PATH'] = path + +# Propagate the temp directory. Windows requires this because it uses \Windows\ +# if none of these are present. +if 'TMP' in os.environ: + config.environment['TMP'] = os.environ['TMP'] +if 'TEMP' in os.environ: + config.environment['TEMP'] = os.environ['TEMP'] + +if config.host_os == 'Darwin': + # Only run up to 3 processes that require shadow memory simultaneously on + # 64-bit Darwin. Using more scales badly and hogs the system due to + # inefficient handling of large mmap'd regions (terabytes) by the kernel. + lit_config.parallelism_groups["shadow-memory"] = 3 + + # The test config gets pickled and sent to multiprocessing workers, and that + # only works for code if it is stored at the top level of some module. + # Therefore, we have to put the code in a .py file, add it to path, and import + # it to store it in the config. + import site + site.addsitedir(os.path.dirname(__file__)) + import lit_unittest_cfg_utils + config.darwin_sanitizer_parallelism_group_func = \ + lit_unittest_cfg_utils.darwin_sanitizer_parallelism_group_func Index: compiler-rt/trunk/unittests/lit.common.unit.configured.in =================================================================== --- compiler-rt/trunk/unittests/lit.common.unit.configured.in +++ compiler-rt/trunk/unittests/lit.common.unit.configured.in @@ -23,4 +23,4 @@ lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key, key)) # Setup attributes common for all compiler-rt unit tests. -lit_config.load_config(config, "@COMPILER_RT_SOURCE_DIR@/unittests/lit.common.unit.cfg") +lit_config.load_config(config, "@COMPILER_RT_SOURCE_DIR@/unittests/lit.common.unit.cfg.py") Index: compiler-rt/trunk/unittests/lit_unittest_cfg_utils.py =================================================================== --- compiler-rt/trunk/unittests/lit_unittest_cfg_utils.py +++ compiler-rt/trunk/unittests/lit_unittest_cfg_utils.py @@ -1,4 +1,4 @@ # Put all 64-bit tests in the shadow-memory parallelism group. We throttle those -# in our common lit config (lit.common.unit.cfg). +# in our common lit config (lit.common.unit.cfg.py). def darwin_sanitizer_parallelism_group_func(test): return "shadow-memory" if "x86_64" in test.file_path else None Index: llvm/trunk/utils/gn/secondary/compiler-rt/test/hwasan/BUILD.gn =================================================================== --- llvm/trunk/utils/gn/secondary/compiler-rt/test/hwasan/BUILD.gn +++ llvm/trunk/utils/gn/secondary/compiler-rt/test/hwasan/BUILD.gn @@ -5,8 +5,8 @@ import("//llvm/version.gni") write_cmake_config("lit_site_cfg") { - input = "lit.site.cfg.in" - output = "$target_gen_dir/lit.site.cfg" + input = "lit.site.cfg.py.in" + output = "$target_gen_dir/lit.site.cfg.py" values = [ "LIT_SITE_CFG_IN_HEADER=## Autogenerated from $input, do not edit",