[PATCH] D56712: compiler-rt/test: Add a couple of convenience features for Android.

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 15 02:03:07 PST 2019


pcc created this revision.
pcc added a reviewer: eugenis.
Herald added subscribers: mgorny, dberris, kubamracek, srhines.

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.


Repository:
  rL LLVM

https://reviews.llvm.org/D56712

Files:
  compiler-rt/test/hwasan/CMakeLists.txt
  compiler-rt/test/hwasan/lit.site.cfg.in
  compiler-rt/test/lit.common.cfg
  compiler-rt/test/lit.common.configured.in


Index: compiler-rt/test/lit.common.configured.in
===================================================================
--- compiler-rt/test/lit.common.configured.in
+++ compiler-rt/test/lit.common.configured.in
@@ -36,6 +36,8 @@
 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)
 
Index: compiler-rt/test/lit.common.cfg
===================================================================
--- compiler-rt/test/lit.common.cfg
+++ compiler-rt/test/lit.common.cfg
@@ -276,9 +276,14 @@
   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 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
Index: compiler-rt/test/hwasan/lit.site.cfg.in
===================================================================
--- compiler-rt/test/hwasan/lit.site.cfg.in
+++ 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")
Index: compiler-rt/test/hwasan/CMakeLists.txt
===================================================================
--- compiler-rt/test/hwasan/CMakeLists.txt
+++ compiler-rt/test/hwasan/CMakeLists.txt
@@ -11,6 +11,9 @@
   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)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56712.181747.patch
Type: text/x-patch
Size: 3109 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190115/9b2a404f/attachment.bin>


More information about the llvm-commits mailing list