From 16bae2463f98c0e3988b3bd94fce5012ae6a68ba Mon Sep 17 00:00:00 2001 From: Greg Fitzgerald Date: Wed, 30 Apr 2014 21:32:30 +0000 Subject: Allow any test to be executed via a %run command. Configure %run with COMPILER_RT_EMULATOR: $ cmake -DCOMPILER_RT_EMULATOR="qemu-arm -L $SYSROOT" git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@207707 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/asan/CMakeLists.txt | 20 +++++++++++++++++--- test/asan/lit.cfg | 2 +- test/asan/lit.site.cfg.in | 1 - test/lit.common.cfg | 3 +++ test/lit.common.configured.in | 2 ++ test/lsan/lit.common.cfg | 2 +- test/profile/instrprof-basic.c | 2 +- test/profile/lit.cfg | 12 +++++++++--- test/ubsan/lit.common.cfg | 2 +- 9 files changed, 35 insertions(+), 11 deletions(-) (limited to 'test') diff --git a/test/asan/CMakeLists.txt b/test/asan/CMakeLists.txt index 0dd6f816a..2080a72cc 100644 --- a/test/asan/CMakeLists.txt +++ b/test/asan/CMakeLists.txt @@ -9,7 +9,7 @@ if(CAN_TARGET_arm_android) get_filename_component(ASAN_TEST_LLVM_TOOLS_DIR ${CMAKE_C_COMPILER} PATH) set(ASAN_TEST_CONFIG_SUFFIX "-arm-android") set(ASAN_TEST_BITS "32") - get_target_flags_for_arch(arm_android ASAN_TEST_TARGET_CFLAGS) + get_target_flags_for_arch(arm_android COMPILER_RT_TEST_COMPILER_CFLAGS) configure_lit_site_cfg( ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in ${CMAKE_CURRENT_BINARY_DIR}/ARMAndroidConfig/lit.site.cfg @@ -17,10 +17,24 @@ if(CAN_TARGET_arm_android) list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/ARMAndroidConfig) endif() +if(CAN_TARGET_arm) + # This is only true if we are cross-compiling. + # Build all tests with host compiler and use host tools. + set(ASAN_TEST_TARGET_CC ${COMPILER_RT_TEST_COMPILER}) + set(ASAN_TEST_CONFIG_SUFFIX "-arm-linux") + set(ASAN_TEST_BITS "32") + set(ASAN_TEST_DYNAMIC False) + configure_lit_site_cfg( + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in + ${CMAKE_CURRENT_BINARY_DIR}/ARMLinuxConfig/lit.site.cfg + ) + list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/ARMLinuxConfig) +endif() + if(CAN_TARGET_x86_64 OR CAN_TARGET_powerpc64) set(ASAN_TEST_CONFIG_SUFFIX "64") set(ASAN_TEST_BITS "64") - set(ASAN_TEST_TARGET_CFLAGS ${TARGET_64_BIT_CFLAGS}) + set(COMPILER_RT_TEST_COMPILER_CFLAGS ${TARGET_64_BIT_CFLAGS}) set(ASAN_TEST_DYNAMIC False) configure_lit_site_cfg( ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in @@ -40,7 +54,7 @@ endif() if(CAN_TARGET_i386) set(ASAN_TEST_CONFIG_SUFFIX "32") set(ASAN_TEST_BITS "32") - set(ASAN_TEST_TARGET_CFLAGS ${TARGET_32_BIT_CFLAGS}) + set(COMPILER_RT_TEST_COMPILER_CFLAGS ${TARGET_32_BIT_CFLAGS}) set(ASAN_TEST_DYNAMIC False) set(ASAN_TEST_TARGET_ARCH "i386") configure_lit_site_cfg( diff --git a/test/asan/lit.cfg b/test/asan/lit.cfg index 7f47b43ed..c96cfaac3 100644 --- a/test/asan/lit.cfg +++ b/test/asan/lit.cfg @@ -4,7 +4,7 @@ import os def get_required_attr(config, attr_name): attr_value = getattr(config, attr_name, None) - if not attr_value: + 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 " diff --git a/test/asan/lit.site.cfg.in b/test/asan/lit.site.cfg.in index 76e0c5542..04a9a49be 100644 --- a/test/asan/lit.site.cfg.in +++ b/test/asan/lit.site.cfg.in @@ -4,7 +4,6 @@ # Tool-specific config options. config.name_suffix = "@ASAN_TEST_CONFIG_SUFFIX@" config.asan_lit_source_dir = "@ASAN_LIT_SOURCE_DIR@" -config.target_cflags = "@ASAN_TEST_TARGET_CFLAGS@" config.clang = "@ASAN_TEST_TARGET_CC@" config.llvm_tools_dir = "@ASAN_TEST_LLVM_TOOLS_DIR@" config.bits = "@ASAN_TEST_BITS@" diff --git a/test/lit.common.cfg b/test/lit.common.cfg index 078ab684a..054d32cde 100644 --- a/test/lit.common.cfg +++ b/test/lit.common.cfg @@ -56,6 +56,9 @@ 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. +config.substitutions.append( ('%run', config.emulator) ) + # Add supported compiler_rt architectures to a list of available features. compiler_rt_arch = getattr(config, 'compiler_rt_arch', None) if compiler_rt_arch: diff --git a/test/lit.common.configured.in b/test/lit.common.configured.in index 7a9dd29b2..10eb7b5e1 100644 --- a/test/lit.common.configured.in +++ b/test/lit.common.configured.in @@ -8,6 +8,7 @@ def set_default(attr, value): # Generic config options for all compiler-rt lit tests. set_default("target_triple", "@TARGET_TRIPLE@") +set_default("target_cflags", "@COMPILER_RT_TEST_COMPILER_FLAGS@") set_default("host_arch", "@HOST_ARCH@") set_default("target_arch", "@HOST_ARCH@") set_default("host_os", "@HOST_OS@") @@ -22,6 +23,7 @@ set_default("compiler_rt_arch", "@COMPILER_RT_SUPPORTED_ARCH@") set_default("python_executable", "@PYTHON_EXECUTABLE@") set_default("compiler_rt_debug", @COMPILER_RT_DEBUG_PYBOOL@) set_default("compiler_rt_libdir", "@COMPILER_RT_LIBRARY_OUTPUT_DIR@") +set_default("emulator", "@COMPILER_RT_EMULATOR@") # LLVM tools dir can be passed in lit parameters, so try to # apply substitution. diff --git a/test/lsan/lit.common.cfg b/test/lsan/lit.common.cfg index f46151515..7411d7a98 100644 --- a/test/lsan/lit.common.cfg +++ b/test/lsan/lit.common.cfg @@ -6,7 +6,7 @@ import os def get_required_attr(config, attr_name): attr_value = getattr(config, attr_name, None) - if not attr_value: + 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 " diff --git a/test/profile/instrprof-basic.c b/test/profile/instrprof-basic.c index b84c96dab..3db083140 100644 --- a/test/profile/instrprof-basic.c +++ b/test/profile/instrprof-basic.c @@ -1,5 +1,5 @@ // RUN: %clang_profgen -o %t -O3 %s -// RUN: env LLVM_PROFILE_FILE=%t.profraw %t +// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t // RUN: llvm-profdata merge -o %t.profdata %t.profraw // RUN: %clang_profuse=%t.profdata -o - -S -emit-llvm %s | FileCheck %s diff --git a/test/profile/lit.cfg b/test/profile/lit.cfg index dcfd36e6f..da09f1a61 100644 --- a/test/profile/lit.cfg +++ b/test/profile/lit.cfg @@ -27,10 +27,16 @@ if config.test_exec_root is None: # Test suffixes. config.suffixes = ['.c', '.cc', '.cpp', '.m', '.mm', '.ll', '.test'] +# Clang flags. +clang_cflags = [config.target_cflags] + +def build_invocation(compile_flags): + return " " + " ".join([config.clang] + compile_flags) + " " + # Add clang substitutions. -config.substitutions.append( ("%clang ", config.clang + " ") ) -config.substitutions.append( ("%clang_profgen ", config.clang + " -fprofile-instr-generate ") ) -config.substitutions.append( ("%clang_profuse=", config.clang + " -fprofile-instr-use=") ) +config.substitutions.append( ("%clang ", build_invocation([])) ) +config.substitutions.append( ("%clang_profgen ", build_invocation(clang_cflags) + " -fprofile-instr-generate ") ) +config.substitutions.append( ("%clang_profuse=", build_invocation(clang_cflags) + " -fprofile-instr-use=") ) # Profile tests are currently supported on Linux and Darwin only. if config.host_os not in ['Linux', 'Darwin']: diff --git a/test/ubsan/lit.common.cfg b/test/ubsan/lit.common.cfg index 1e32653fe..61eec0341 100644 --- a/test/ubsan/lit.common.cfg +++ b/test/ubsan/lit.common.cfg @@ -4,7 +4,7 @@ import os def get_required_attr(config, attr_name): attr_value = getattr(config, attr_name, None) - if not attr_value: + 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 " -- cgit v1.2.3