summaryrefslogtreecommitdiff
path: root/compiler-rt
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2019-01-15 22:06:48 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2019-01-15 22:06:48 +0000
commit6a081ccf9880412717f365420162bbf709bb3edd (patch)
treec60a4fe2e51dc6fafb812a30cdf087bd9d8aa63c /compiler-rt
parent537b19a79be259b2ddf2ae41ac127b9ab3e73cb8 (diff)
compiler-rt/test: Add a couple of convenience features for Android.
Add a ANDROID_SERIAL_FOR_TESTING CMake variable. This lets you run the tests with multiple devices attached without having to set ANDROID_SERIAL. Add a mechanism for pushing files to the device. Currently most sanitizers require llvm-symbolizer and the sanitizer runtime to be pushed to the device. This lets the sanitizer make this happen automatically before running the tests by specifying the paths in the lit.site.cfg file. Differential Revision: https://reviews.llvm.org/D56712
Diffstat (limited to 'compiler-rt')
-rw-r--r--compiler-rt/test/hwasan/CMakeLists.txt3
-rw-r--r--compiler-rt/test/hwasan/lit.site.cfg.in1
-rw-r--r--compiler-rt/test/lit.common.cfg13
-rw-r--r--compiler-rt/test/lit.common.configured.in2
4 files changed, 18 insertions, 1 deletions
diff --git a/compiler-rt/test/hwasan/CMakeLists.txt b/compiler-rt/test/hwasan/CMakeLists.txt
index 972c73250cf..3e397ac067f 100644
--- a/compiler-rt/test/hwasan/CMakeLists.txt
+++ b/compiler-rt/test/hwasan/CMakeLists.txt
@@ -11,6 +11,9 @@ foreach(arch ${HWASAN_TEST_ARCH})
string(TOUPPER ${arch} ARCH_UPPER_CASE)
set(CONFIG_NAME ${ARCH_UPPER_CASE})
+ # FIXME: Set this.
+ 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)
diff --git a/compiler-rt/test/hwasan/lit.site.cfg.in b/compiler-rt/test/hwasan/lit.site.cfg.in
index 7453d1b74dc..e95ea92cd2d 100644
--- a/compiler-rt/test/hwasan/lit.site.cfg.in
+++ b/compiler-rt/test/hwasan/lit.site.cfg.in
@@ -4,6 +4,7 @@
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")
diff --git a/compiler-rt/test/lit.common.cfg b/compiler-rt/test/lit.common.cfg
index cd00f32dd9d..8d94d63f102 100644
--- a/compiler-rt/test/lit.common.cfg
+++ b/compiler-rt/test/lit.common.cfg
@@ -276,9 +276,14 @@ else:
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"]).rstrip()
+ 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:
@@ -290,6 +295,12 @@ if config.android:
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
diff --git a/compiler-rt/test/lit.common.configured.in b/compiler-rt/test/lit.common.configured.in
index 97c6ed5807d..4994ca69b18 100644
--- a/compiler-rt/test/lit.common.configured.in
+++ b/compiler-rt/test/lit.common.configured.in
@@ -36,6 +36,8 @@ set_default("use_thinlto", False)
set_default("use_lto", config.use_thinlto)
set_default("use_newpm", False)
set_default("android", @ANDROID_PYBOOL@)
+set_default("android_serial", "@ANDROID_SERIAL_FOR_TESTING@")
+set_default("android_files_to_push", [])
set_default("have_rpc_xdr_h", @HAVE_RPC_XDR_H@)
config.available_features.add('target-is-%s' % config.target_arch)