From d546ac0beeea0d8970f9f267cdc27db6849a1701 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Tue, 15 Jan 2019 22:06:48 +0000 Subject: 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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@351260 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/hwasan/CMakeLists.txt | 3 +++ test/hwasan/lit.site.cfg.in | 1 + test/lit.common.cfg | 13 ++++++++++++- test/lit.common.configured.in | 2 ++ 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/test/hwasan/CMakeLists.txt b/test/hwasan/CMakeLists.txt index 972c73250..3e397ac06 100644 --- a/test/hwasan/CMakeLists.txt +++ b/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/test/hwasan/lit.site.cfg.in b/test/hwasan/lit.site.cfg.in index 7453d1b74..e95ea92cd 100644 --- a/test/hwasan/lit.site.cfg.in +++ b/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/test/lit.common.cfg b/test/lit.common.cfg index cd00f32dd..8d94d63f1 100644 --- a/test/lit.common.cfg +++ b/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/test/lit.common.configured.in b/test/lit.common.configured.in index 97c6ed580..4994ca69b 100644 --- a/test/lit.common.configured.in +++ b/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) -- cgit v1.2.1