aboutsummaryrefslogtreecommitdiff
path: root/test
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
commitec24a604d8796844dac8a3817e604a7b1b039504 (patch)
tree1f9983200ffa38b78416ecc2d54e2dbc9e88c5f2 /test
parenta0ddec879cc5bf65904736b3fb88c1f2699080e4 (diff)
[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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@335123 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/asan/CMakeLists.txt17
-rw-r--r--test/asan/lit.cfg2
-rw-r--r--test/asan/lit.site.cfg.in3
-rw-r--r--test/fuzzer/CMakeLists.txt9
-rw-r--r--test/fuzzer/lit.cfg2
-rw-r--r--test/fuzzer/lit.site.cfg.in2
-rw-r--r--test/lit.common.cfg50
-rw-r--r--test/lit.common.configured.in3
-rwxr-xr-xtest/sanitizer_common/ios_commands/iossim_prepare.py5
-rw-r--r--test/tsan/CMakeLists.txt17
-rw-r--r--test/tsan/lit.cfg2
-rw-r--r--test/tsan/lit.site.cfg.in3
12 files changed, 68 insertions, 47 deletions
diff --git a/test/asan/CMakeLists.txt b/test/asan/CMakeLists.txt
index b63ac4075..e6d1df5e0 100644
--- a/test/asan/CMakeLists.txt
+++ b/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/test/asan/lit.cfg b/test/asan/lit.cfg
index 6b6595e8d..855e8e848 100644
--- a/test/asan/lit.cfg
+++ b/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/test/asan/lit.site.cfg.in b/test/asan/lit.site.cfg.in
index 6c8f882bc..6282fd881 100644
--- a/test/asan/lit.site.cfg.in
+++ b/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/test/fuzzer/CMakeLists.txt b/test/fuzzer/CMakeLists.txt
index 1c397566e..25967a85a 100644
--- a/test/fuzzer/CMakeLists.txt
+++ b/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/test/fuzzer/lit.cfg b/test/fuzzer/lit.cfg
index 95674fb9a..86740e753 100644
--- a/test/fuzzer/lit.cfg
+++ b/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/test/fuzzer/lit.site.cfg.in b/test/fuzzer/lit.site.cfg.in
index cbb74f37d..031d9641f 100644
--- a/test/fuzzer/lit.site.cfg.in
+++ b/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/test/lit.common.cfg b/test/lit.common.cfg
index 5c01df6d9..e34e52583 100644
--- a/test/lit.common.cfg
+++ b/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/test/lit.common.configured.in b/test/lit.common.configured.in
index 32a88200b..ebe66a9a2 100644
--- a/test/lit.common.configured.in
+++ b/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/test/sanitizer_common/ios_commands/iossim_prepare.py b/test/sanitizer_common/ios_commands/iossim_prepare.py
new file mode 100755
index 000000000..4b618fe9d
--- /dev/null
+++ b/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/test/tsan/CMakeLists.txt b/test/tsan/CMakeLists.txt
index 2b1d3004b..ba0fd9f23 100644
--- a/test/tsan/CMakeLists.txt
+++ b/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/test/tsan/lit.cfg b/test/tsan/lit.cfg
index 0128d958b..233d273f3 100644
--- a/test/tsan/lit.cfg
+++ b/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/test/tsan/lit.site.cfg.in b/test/tsan/lit.site.cfg.in
index a215e664a..6dec5f92b 100644
--- a/test/tsan/lit.site.cfg.in
+++ b/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@"