summaryrefslogtreecommitdiffstats
path: root/compiler-rt
diff options
context:
space:
mode:
authorKuba Mracek <mracek@apple.com>2018-06-20 13:33:42 +0000
committerKuba Mracek <mracek@apple.com>2018-06-20 13:33:42 +0000
commitbadaa15c889b4e36788d3a6fc6836cf4db66e36a (patch)
tree1e06b0671aebb3e9f38a3d2c45320aa8a30b5192 /compiler-rt
parenteae99120b00e035602eca4a5c4aad52e025d07b3 (diff)
downloadbcm5719-llvm-badaa15c889b4e36788d3a6fc6836cf4db66e36a.tar.gz
bcm5719-llvm-badaa15c889b4e36788d3a6fc6836cf4db66e36a.zip
[sanitizer] Unify and generalize Apple platforms in CMake and lit test configs
There's more platforms than just "ios" and "iossim" that we should support, and adding more lit config variables for each platform isn't great. Let's generalize and have a single value that determines what the platform under test is. Differential Revision: https://reviews.llvm.org/D48309 llvm-svn: 335123
Diffstat (limited to 'compiler-rt')
-rw-r--r--compiler-rt/test/asan/CMakeLists.txt17
-rw-r--r--compiler-rt/test/asan/lit.cfg2
-rw-r--r--compiler-rt/test/asan/lit.site.cfg.in3
-rw-r--r--compiler-rt/test/fuzzer/CMakeLists.txt9
-rw-r--r--compiler-rt/test/fuzzer/lit.cfg2
-rw-r--r--compiler-rt/test/fuzzer/lit.site.cfg.in2
-rw-r--r--compiler-rt/test/lit.common.cfg50
-rw-r--r--compiler-rt/test/lit.common.configured.in3
-rwxr-xr-xcompiler-rt/test/sanitizer_common/ios_commands/iossim_prepare.py5
-rw-r--r--compiler-rt/test/tsan/CMakeLists.txt17
-rw-r--r--compiler-rt/test/tsan/lit.cfg2
-rw-r--r--compiler-rt/test/tsan/lit.site.cfg.in3
12 files changed, 68 insertions, 47 deletions
diff --git a/compiler-rt/test/asan/CMakeLists.txt b/compiler-rt/test/asan/CMakeLists.txt
index b63ac4075d3..e6d1df5e039 100644
--- a/compiler-rt/test/asan/CMakeLists.txt
+++ b/compiler-rt/test/asan/CMakeLists.txt
@@ -51,10 +51,7 @@ foreach(arch ${ASAN_TEST_ARCH})
set(ASAN_TEST_TARGET_ARCH ${arch})
endif()
- set(ASAN_TEST_IOS "0")
- pythonize_bool(ASAN_TEST_IOS)
- set(ASAN_TEST_IOSSIM "0")
- pythonize_bool(ASAN_TEST_IOSSIM)
+ set(ASAN_TEST_APPLE_PLATFORM "osx")
string(TOLOWER "-${arch}-${OS_NAME}" ASAN_TEST_CONFIG_SUFFIX)
get_bits_for_arch(${arch} ASAN_TEST_BITS)
@@ -93,16 +90,13 @@ if(APPLE)
set(EXCLUDE_FROM_ALL ON)
set(ASAN_TEST_TARGET_CC ${COMPILER_RT_TEST_COMPILER})
- set(ASAN_TEST_IOS "1")
- pythonize_bool(ASAN_TEST_IOS)
set(ASAN_TEST_DYNAMIC True)
foreach(arch ${DARWIN_iossim_ARCHS})
- set(ASAN_TEST_IOSSIM "1")
- pythonize_bool(ASAN_TEST_IOSSIM)
+ set(ASAN_TEST_APPLE_PLATFORM "iossim")
set(ASAN_TEST_TARGET_ARCH ${arch})
set(ASAN_TEST_TARGET_CFLAGS "-arch ${arch} -isysroot ${DARWIN_iossim_SYSROOT} ${COMPILER_RT_TEST_COMPILER_CFLAGS}")
- set(ASAN_TEST_CONFIG_SUFFIX "-${arch}-iossim")
+ set(ASAN_TEST_CONFIG_SUFFIX "-${arch}-${ASAN_TEST_APPLE_PLATFORM}")
get_bits_for_arch(${arch} ASAN_TEST_BITS)
string(TOUPPER ${arch} ARCH_UPPER_CASE)
set(CONFIG_NAME "IOSSim${ARCH_UPPER_CASE}Config")
@@ -116,11 +110,10 @@ if(APPLE)
endforeach()
foreach (arch ${DARWIN_ios_ARCHS})
- set(ASAN_TEST_IOSSIM "0")
- pythonize_bool(ASAN_TEST_IOSSIM)
+ set(ASAN_TEST_APPLE_PLATFORM "ios")
set(ASAN_TEST_TARGET_ARCH ${arch})
set(ASAN_TEST_TARGET_CFLAGS "-arch ${arch} -isysroot ${DARWIN_ios_SYSROOT} ${COMPILER_RT_TEST_COMPILER_CFLAGS}")
- set(ASAN_TEST_CONFIG_SUFFIX "-${arch}-ios")
+ set(ASAN_TEST_CONFIG_SUFFIX "-${arch}-${ASAN_TEST_APPLE_PLATFORM}")
get_bits_for_arch(${arch} ASAN_TEST_BITS)
string(TOUPPER ${arch} ARCH_UPPER_CASE)
set(CONFIG_NAME "IOS${ARCH_UPPER_CASE}Config")
diff --git a/compiler-rt/test/asan/lit.cfg b/compiler-rt/test/asan/lit.cfg
index 6b6595e8da1..855e8e84876 100644
--- a/compiler-rt/test/asan/lit.cfg
+++ b/compiler-rt/test/asan/lit.cfg
@@ -214,5 +214,5 @@ if config.host_os not in ['Linux', 'Darwin', 'FreeBSD', 'SunOS', 'Windows', 'Net
if config.host_os == 'Darwin':
if config.target_arch in ["x86_64", "x86_64h"]:
config.parallelism_group = "darwin-64bit-sanitizer"
- elif config.ios and not config.iossim:
+ elif config.apple_platform != "osx" and not config.apple_platform.endswith("sim"):
config.parallelism_group = "darwin-ios-device-sanitizer"
diff --git a/compiler-rt/test/asan/lit.site.cfg.in b/compiler-rt/test/asan/lit.site.cfg.in
index 6c8f882bcc2..6282fd881e5 100644
--- a/compiler-rt/test/asan/lit.site.cfg.in
+++ b/compiler-rt/test/asan/lit.site.cfg.in
@@ -5,8 +5,7 @@ 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.ios = @ASAN_TEST_IOS_PYBOOL@
-config.iossim = @ASAN_TEST_IOSSIM_PYBOOL@
+config.apple_platform = "@ASAN_TEST_APPLE_PLATFORM@"
config.asan_dynamic = @ASAN_TEST_DYNAMIC@
config.target_arch = "@ASAN_TEST_TARGET_ARCH@"
diff --git a/compiler-rt/test/fuzzer/CMakeLists.txt b/compiler-rt/test/fuzzer/CMakeLists.txt
index 1c397566efb..25967a85a8c 100644
--- a/compiler-rt/test/fuzzer/CMakeLists.txt
+++ b/compiler-rt/test/fuzzer/CMakeLists.txt
@@ -10,8 +10,6 @@ endif()
set(EXCLUDE_FROM_ALL ON)
add_custom_target(check-fuzzer)
-set(LIBFUZZER_TEST_IOS "0")
-pythonize_bool(LIBFUZZER_TEST_IOS)
if(COMPILER_RT_INCLUDE_TESTS)
# libFuzzer unit tests.
@@ -40,6 +38,8 @@ macro(test_fuzzer stdlib)
set(LIBFUZZER_TEST_COMPILER ${COMPILER_RT_TEST_COMPILER})
get_test_cc_for_arch(${arch} LIBFUZZER_TEST_COMPILER LIBFUZZER_TEST_FLAGS)
+ set(LIBFUZZER_TEST_APPLE_PLATFORM "osx")
+
set(LIBFUZZER_TEST_STDLIB ${stdlib})
string(TOUPPER ${arch} ARCH_UPPER_CASE)
@@ -78,11 +78,10 @@ if (APPLE)
set(EXCLUDE_FROM_ALL ON)
foreach(arch ${DARWIN_ios_ARCHS})
- set(LIBFUZZER_TEST_IOS "1")
- pythonize_bool(LIBFUZZER_TEST_IOS)
+ set(LIBFUZZER_TEST_APPLE_PLATFORM "ios")
set(LIBFUZZER_TEST_TARGET_ARCH ${arch})
set(LIBFUZZER_TEST_FLAGS "-arch ${arch} -isysroot ${DARWIN_ios_SYSROOT} ${COMPILER_RT_TEST_COMPILER_CFLAGS}")
- set(LIBFUZZER_TEST_CONFIG_SUFFIX "-${arch}-ios")
+ set(LIBFUZZER_TEST_CONFIG_SUFFIX "-${arch}-${LIBFUZZER_TEST_APPLE_PLATFORM}")
string(TOUPPER ${arch} ARCH_UPPER_CASE)
set(CONFIG_NAME "IOS${ARCH_UPPER_CASE}Config")
configure_lit_site_cfg(
diff --git a/compiler-rt/test/fuzzer/lit.cfg b/compiler-rt/test/fuzzer/lit.cfg
index 95674fb9ac7..86740e7532f 100644
--- a/compiler-rt/test/fuzzer/lit.cfg
+++ b/compiler-rt/test/fuzzer/lit.cfg
@@ -96,5 +96,5 @@ config.substitutions.append(('%no_fuzzer_c_compiler',
if config.host_os == 'Darwin':
if config.target_arch in ["x86_64", "x86_64h"]:
config.parallelism_group = "darwin-64bit-sanitizer"
- elif config.ios and not config.iossim:
+ elif config.apple_platform != "osx" and not config.apple_platform.endswith("sim"):
config.parallelism_group = "darwin-ios-device-sanitizer"
diff --git a/compiler-rt/test/fuzzer/lit.site.cfg.in b/compiler-rt/test/fuzzer/lit.site.cfg.in
index cbb74f37d56..031d9641fa5 100644
--- a/compiler-rt/test/fuzzer/lit.site.cfg.in
+++ b/compiler-rt/test/fuzzer/lit.site.cfg.in
@@ -6,7 +6,7 @@ config.cpp_compiler = "@LIBFUZZER_TEST_COMPILER@"
config.target_flags = "@LIBFUZZER_TEST_FLAGS@"
config.c_compiler = "@LIBFUZZER_TEST_COMPILER@"
config.stdlib = "@LIBFUZZER_TEST_STDLIB@"
-config.ios = @LIBFUZZER_TEST_IOS_PYBOOL@
+config.apple_platform = "@LIBFUZZER_TEST_APPLE_PLATFORM@"
config.name_suffix = "@LIBFUZZER_TEST_CONFIG_SUFFIX@"
config.osx_sysroot_flag = "@OSX_SYSROOT_FLAG@"
diff --git a/compiler-rt/test/lit.common.cfg b/compiler-rt/test/lit.common.cfg
index 5c01df6d9e5..e34e52583b9 100644
--- a/compiler-rt/test/lit.common.cfg
+++ b/compiler-rt/test/lit.common.cfg
@@ -7,6 +7,7 @@ import os
import platform
import re
import subprocess
+import json
import lit.formats
import lit.util
@@ -104,17 +105,50 @@ if config.emulator:
config.substitutions.append( ('%run', config.emulator) )
config.substitutions.append( ('%env ', "env ") )
config.compile_wrapper = ""
-elif config.ios:
+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_IOSSIM_TEST_DEVICE_IDENTIFIER" if config.iossim else "SANITIZER_IOS_TEST_DEVICE_IDENTIFIER"
- if device_id_env in os.environ: config.environment[device_id_env] = os.environ[device_id_env]
+ if ios_or_iossim == "iossim":
+ config.available_features.add('iossim')
+ 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, "iossim_run.py" if config.iossim else "ios_run.py")
+
+ device_id_env = "SANITIZER_" + ios_or_iossim.upper() + "_TEST_DEVICE_IDENTIFIER"
+ 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))
- env_wrapper = os.path.join(ios_commands_dir, "iossim_env.py" if config.iossim else "ios_env.py")
config.substitutions.append(('%env ', env_wrapper + " "))
- compile_wrapper = os.path.join(ios_commands_dir, "iossim_compile.py" if config.iossim else "ios_compile.py")
config.compile_wrapper = compile_wrapper
+
+ prepare_output = subprocess.check_output([prepare_script, config.apple_platform, config.clang]).strip()
+ 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") + " "
@@ -202,7 +236,7 @@ if config.host_os == 'Darwin':
config.substitutions.append( ("%macos_min_target_10_11", "-mmacosx-version-min=10.11") )
- isIOS = getattr(config, 'ios', False)
+ 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") )
@@ -304,7 +338,7 @@ if platform.system() == 'Darwin':
# The current implementation of the tools in sanitizer_common/ios_comamnds
# do not support parallel execution so force sequential execution of the
# tests on iOS devices.
-if config.host_os == 'Darwin' and config.ios and not config.iossim:
+if config.host_os == 'Darwin' and config.apple_platform != "osx" and not config.apple_platform.endswith("sim"):
lit_config.warning("iOS device test cases being run sequentially")
lit_config.parallelism_groups["darwin-ios-device-sanitizer"] = 1
diff --git a/compiler-rt/test/lit.common.configured.in b/compiler-rt/test/lit.common.configured.in
index 32a88200bf2..ebe66a9a272 100644
--- a/compiler-rt/test/lit.common.configured.in
+++ b/compiler-rt/test/lit.common.configured.in
@@ -26,8 +26,7 @@ set_default("compiler_rt_debug", @COMPILER_RT_DEBUG_PYBOOL@)
set_default("compiler_rt_libdir", "@COMPILER_RT_RESOLVED_LIBRARY_OUTPUT_DIR@")
set_default("emulator", "@COMPILER_RT_EMULATOR@")
set_default("asan_shadow_scale", "@COMPILER_RT_ASAN_SHADOW_SCALE@")
-set_default("ios", False)
-set_default("iossim", False)
+set_default("apple_platform", None)
set_default("sanitizer_can_use_cxxabi", @SANITIZER_CAN_USE_CXXABI_PYBOOL@)
set_default("has_lld", @COMPILER_RT_HAS_LLD_PYBOOL@)
set_default("can_symbolize", @CAN_SYMBOLIZE@)
diff --git a/compiler-rt/test/sanitizer_common/ios_commands/iossim_prepare.py b/compiler-rt/test/sanitizer_common/ios_commands/iossim_prepare.py
new file mode 100755
index 00000000000..4b618fe9de8
--- /dev/null
+++ b/compiler-rt/test/sanitizer_common/ios_commands/iossim_prepare.py
@@ -0,0 +1,5 @@
+#!/usr/bin/python
+
+import os, sys, subprocess, json
+
+print(json.dumps({"env": {}}))
diff --git a/compiler-rt/test/tsan/CMakeLists.txt b/compiler-rt/test/tsan/CMakeLists.txt
index 2b1d3004b1d..ba0fd9f23a3 100644
--- a/compiler-rt/test/tsan/CMakeLists.txt
+++ b/compiler-rt/test/tsan/CMakeLists.txt
@@ -24,10 +24,7 @@ if(APPLE)
endif()
foreach(arch ${TSAN_TEST_ARCH})
- set(TSAN_TEST_IOS "0")
- pythonize_bool(TSAN_TEST_IOS)
- set(TSAN_TEST_IOSSIM "0")
- pythonize_bool(TSAN_TEST_IOSSIM)
+ set(TSAN_TEST_APPLE_PLATFORM "osx")
set(TSAN_TEST_TARGET_ARCH ${arch})
string(TOLOWER "-${arch}" TSAN_TEST_CONFIG_SUFFIX)
@@ -51,15 +48,12 @@ if(APPLE)
set(EXCLUDE_FROM_ALL ON)
set(TSAN_TEST_TARGET_CC ${COMPILER_RT_TEST_COMPILER})
- set(TSAN_TEST_IOS "1")
- pythonize_bool(TSAN_TEST_IOS)
+ set(TSAN_TEST_APPLE_PLATFORM "iossim")
set(arch "x86_64")
- set(TSAN_TEST_IOSSIM "1")
- pythonize_bool(TSAN_TEST_IOSSIM)
set(TSAN_TEST_TARGET_ARCH ${arch})
set(TSAN_TEST_TARGET_CFLAGS "-arch ${arch} -isysroot ${DARWIN_iossim_SYSROOT} ${COMPILER_RT_TEST_COMPILER_CFLAGS}")
- set(TSAN_TEST_CONFIG_SUFFIX "-${arch}-iossim")
+ set(TSAN_TEST_CONFIG_SUFFIX "-${arch}-${TSAN_TEST_APPLE_PLATFORM}")
string(TOUPPER ${arch} ARCH_UPPER_CASE)
set(CONFIG_NAME "IOSSim${ARCH_UPPER_CASE}Config")
configure_lit_site_cfg(
@@ -70,12 +64,11 @@ if(APPLE)
${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/
DEPENDS ${TSAN_TEST_DEPS})
+ set(TSAN_TEST_APPLE_PLATFORM "ios")
set(arch "arm64")
- set(TSAN_TEST_IOSSIM "0")
- pythonize_bool(TSAN_TEST_IOSSIM)
set(TSAN_TEST_TARGET_ARCH ${arch})
set(TSAN_TEST_TARGET_CFLAGS "-arch ${arch} -isysroot ${DARWIN_ios_SYSROOT} ${COMPILER_RT_TEST_COMPILER_CFLAGS}")
- set(TSAN_TEST_CONFIG_SUFFIX "-${arch}-ios")
+ set(TSAN_TEST_CONFIG_SUFFIX "-${arch}-${TSAN_TEST_APPLE_PLATFORM}")
string(TOUPPER ${arch} ARCH_UPPER_CASE)
set(CONFIG_NAME "IOS${ARCH_UPPER_CASE}Config")
configure_lit_site_cfg(
diff --git a/compiler-rt/test/tsan/lit.cfg b/compiler-rt/test/tsan/lit.cfg
index 0128d958bd0..233d273f313 100644
--- a/compiler-rt/test/tsan/lit.cfg
+++ b/compiler-rt/test/tsan/lit.cfg
@@ -88,5 +88,5 @@ if config.android:
if config.host_os == 'Darwin':
if config.target_arch in ["x86_64", "x86_64h"]:
config.parallelism_group = "darwin-64bit-sanitizer"
- elif config.ios and not config.iossim:
+ elif config.apple_platform != "osx" and not config.apple_platform.endswith("sim"):
config.parallelism_group = "darwin-ios-device-sanitizer"
diff --git a/compiler-rt/test/tsan/lit.site.cfg.in b/compiler-rt/test/tsan/lit.site.cfg.in
index a215e664a5b..6dec5f92b27 100644
--- a/compiler-rt/test/tsan/lit.site.cfg.in
+++ b/compiler-rt/test/tsan/lit.site.cfg.in
@@ -3,8 +3,7 @@
config.name_suffix = "@TSAN_TEST_CONFIG_SUFFIX@"
config.tsan_lit_source_dir = "@TSAN_LIT_SOURCE_DIR@"
config.has_libcxx = @TSAN_HAS_LIBCXX@
-config.ios = @TSAN_TEST_IOS_PYBOOL@
-config.iossim = @TSAN_TEST_IOSSIM_PYBOOL@
+config.apple_platform = "@TSAN_TEST_APPLE_PLATFORM@"
config.target_cflags = "@TSAN_TEST_TARGET_CFLAGS@"
config.target_arch = "@TSAN_TEST_TARGET_ARCH@"
OpenPOWER on IntegriCloud