Skip to content

Commit 6759fd9

Browse files
author
Greg Fitzgerald
committed
Allow any test to be executed via a %run command.
Configure %run with COMPILER_RT_EMULATOR: $ cmake -DCOMPILER_RT_EMULATOR="qemu-arm -L $SYSROOT" llvm-svn: 207707
1 parent cbb9791 commit 6759fd9

File tree

9 files changed

+35
-11
lines changed

9 files changed

+35
-11
lines changed

compiler-rt/test/asan/CMakeLists.txt

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,32 @@ if(CAN_TARGET_arm_android)
99
get_filename_component(ASAN_TEST_LLVM_TOOLS_DIR ${CMAKE_C_COMPILER} PATH)
1010
set(ASAN_TEST_CONFIG_SUFFIX "-arm-android")
1111
set(ASAN_TEST_BITS "32")
12-
get_target_flags_for_arch(arm_android ASAN_TEST_TARGET_CFLAGS)
12+
get_target_flags_for_arch(arm_android COMPILER_RT_TEST_COMPILER_CFLAGS)
1313
configure_lit_site_cfg(
1414
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
1515
${CMAKE_CURRENT_BINARY_DIR}/ARMAndroidConfig/lit.site.cfg
1616
)
1717
list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/ARMAndroidConfig)
1818
endif()
1919

20+
if(CAN_TARGET_arm)
21+
# This is only true if we are cross-compiling.
22+
# Build all tests with host compiler and use host tools.
23+
set(ASAN_TEST_TARGET_CC ${COMPILER_RT_TEST_COMPILER})
24+
set(ASAN_TEST_CONFIG_SUFFIX "-arm-linux")
25+
set(ASAN_TEST_BITS "32")
26+
set(ASAN_TEST_DYNAMIC False)
27+
configure_lit_site_cfg(
28+
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
29+
${CMAKE_CURRENT_BINARY_DIR}/ARMLinuxConfig/lit.site.cfg
30+
)
31+
list(APPEND ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/ARMLinuxConfig)
32+
endif()
33+
2034
if(CAN_TARGET_x86_64 OR CAN_TARGET_powerpc64)
2135
set(ASAN_TEST_CONFIG_SUFFIX "64")
2236
set(ASAN_TEST_BITS "64")
23-
set(ASAN_TEST_TARGET_CFLAGS ${TARGET_64_BIT_CFLAGS})
37+
set(COMPILER_RT_TEST_COMPILER_CFLAGS ${TARGET_64_BIT_CFLAGS})
2438
set(ASAN_TEST_DYNAMIC False)
2539
configure_lit_site_cfg(
2640
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
@@ -40,7 +54,7 @@ endif()
4054
if(CAN_TARGET_i386)
4155
set(ASAN_TEST_CONFIG_SUFFIX "32")
4256
set(ASAN_TEST_BITS "32")
43-
set(ASAN_TEST_TARGET_CFLAGS ${TARGET_32_BIT_CFLAGS})
57+
set(COMPILER_RT_TEST_COMPILER_CFLAGS ${TARGET_32_BIT_CFLAGS})
4458
set(ASAN_TEST_DYNAMIC False)
4559
set(ASAN_TEST_TARGET_ARCH "i386")
4660
configure_lit_site_cfg(

compiler-rt/test/asan/lit.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import os
44

55
def get_required_attr(config, attr_name):
66
attr_value = getattr(config, attr_name, None)
7-
if not attr_value:
7+
if attr_value == None:
88
lit_config.fatal(
99
"No attribute %r in test configuration! You may need to run "
1010
"tests from your build directory or add this attribute "

compiler-rt/test/asan/lit.site.cfg.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# Tool-specific config options.
55
config.name_suffix = "@ASAN_TEST_CONFIG_SUFFIX@"
66
config.asan_lit_source_dir = "@ASAN_LIT_SOURCE_DIR@"
7-
config.target_cflags = "@ASAN_TEST_TARGET_CFLAGS@"
87
config.clang = "@ASAN_TEST_TARGET_CC@"
98
config.llvm_tools_dir = "@ASAN_TEST_LLVM_TOOLS_DIR@"
109
config.bits = "@ASAN_TEST_BITS@"

compiler-rt/test/lit.common.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ config.substitutions.append(
5656
(' clang', """\n\n*** Do not use 'clangXXX' in tests,
5757
instead define '%clangXXX' substitution in lit config. ***\n\n""") )
5858

59+
# Allow tests to be executed on a simulator or remotely.
60+
config.substitutions.append( ('%run', config.emulator) )
61+
5962
# Add supported compiler_rt architectures to a list of available features.
6063
compiler_rt_arch = getattr(config, 'compiler_rt_arch', None)
6164
if compiler_rt_arch:

compiler-rt/test/lit.common.configured.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ def set_default(attr, value):
88

99
# Generic config options for all compiler-rt lit tests.
1010
set_default("target_triple", "@TARGET_TRIPLE@")
11+
set_default("target_cflags", "@COMPILER_RT_TEST_COMPILER_FLAGS@")
1112
set_default("host_arch", "@HOST_ARCH@")
1213
set_default("target_arch", "@HOST_ARCH@")
1314
set_default("host_os", "@HOST_OS@")
@@ -22,6 +23,7 @@ set_default("compiler_rt_arch", "@COMPILER_RT_SUPPORTED_ARCH@")
2223
set_default("python_executable", "@PYTHON_EXECUTABLE@")
2324
set_default("compiler_rt_debug", @COMPILER_RT_DEBUG_PYBOOL@)
2425
set_default("compiler_rt_libdir", "@COMPILER_RT_LIBRARY_OUTPUT_DIR@")
26+
set_default("emulator", "@COMPILER_RT_EMULATOR@")
2527

2628
# LLVM tools dir can be passed in lit parameters, so try to
2729
# apply substitution.

compiler-rt/test/lsan/lit.common.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import os
66

77
def get_required_attr(config, attr_name):
88
attr_value = getattr(config, attr_name, None)
9-
if not attr_value:
9+
if attr_value == None:
1010
lit_config.fatal(
1111
"No attribute %r in test configuration! You may need to run "
1212
"tests from your build directory or add this attribute "

compiler-rt/test/profile/instrprof-basic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %clang_profgen -o %t -O3 %s
2-
// RUN: env LLVM_PROFILE_FILE=%t.profraw %t
2+
// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t
33
// RUN: llvm-profdata merge -o %t.profdata %t.profraw
44
// RUN: %clang_profuse=%t.profdata -o - -S -emit-llvm %s | FileCheck %s
55

compiler-rt/test/profile/lit.cfg

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,16 @@ if config.test_exec_root is None:
2727
# Test suffixes.
2828
config.suffixes = ['.c', '.cc', '.cpp', '.m', '.mm', '.ll', '.test']
2929

30+
# Clang flags.
31+
clang_cflags = [config.target_cflags]
32+
33+
def build_invocation(compile_flags):
34+
return " " + " ".join([config.clang] + compile_flags) + " "
35+
3036
# Add clang substitutions.
31-
config.substitutions.append( ("%clang ", config.clang + " ") )
32-
config.substitutions.append( ("%clang_profgen ", config.clang + " -fprofile-instr-generate ") )
33-
config.substitutions.append( ("%clang_profuse=", config.clang + " -fprofile-instr-use=") )
37+
config.substitutions.append( ("%clang ", build_invocation([])) )
38+
config.substitutions.append( ("%clang_profgen ", build_invocation(clang_cflags) + " -fprofile-instr-generate ") )
39+
config.substitutions.append( ("%clang_profuse=", build_invocation(clang_cflags) + " -fprofile-instr-use=") )
3440

3541
# Profile tests are currently supported on Linux and Darwin only.
3642
if config.host_os not in ['Linux', 'Darwin']:

compiler-rt/test/ubsan/lit.common.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import os
44

55
def get_required_attr(config, attr_name):
66
attr_value = getattr(config, attr_name, None)
7-
if not attr_value:
7+
if attr_value == None:
88
lit_config.fatal(
99
"No attribute %r in test configuration! You may need to run "
1010
"tests from your build directory or add this attribute "

0 commit comments

Comments
 (0)