[compiler-rt] r281075 - [asan] Disable handle_abort in Android tests.

Evgeniy Stepanov via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 9 11:43:25 PDT 2016


Author: eugenis
Date: Fri Sep  9 13:43:24 2016
New Revision: 281075

URL: http://llvm.org/viewvc/llvm-project?rev=281075&view=rev
Log:
[asan] Disable handle_abort in Android tests.

The same thing is already done on Mac. handle_abort slows down tests
significantly because it triggers tombstone collection on Android;
also, it changes failed test outcome from "not-crash" to "crash" (as
in "bin/not --crash").

This change adds handle_abort=0 to asan options on android (test
only!), and also tweaks android_run.py to semi-correctly pass the
crash/no-crash status to the caller.

Modified:
    compiler-rt/trunk/test/asan/TestCases/Linux/abort_on_error.cc
    compiler-rt/trunk/test/asan/TestCases/atexit_stats.cc
    compiler-rt/trunk/test/asan/android_commands/android_run.py
    compiler-rt/trunk/test/asan/lit.cfg

Modified: compiler-rt/trunk/test/asan/TestCases/Linux/abort_on_error.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Linux/abort_on_error.cc?rev=281075&r1=281074&r2=281075&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Linux/abort_on_error.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Linux/abort_on_error.cc Fri Sep  9 13:43:24 2016
@@ -9,6 +9,8 @@
 // lit doesn't set ASAN_OPTIONS anyway.
 // RUN: not %run %t 2>&1 | FileCheck %s
 
+// UNSUPPORTED: android
+
 #include <stdlib.h>
 int main() {
   char *x = (char*)malloc(10 * sizeof(char));

Modified: compiler-rt/trunk/test/asan/TestCases/atexit_stats.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/atexit_stats.cc?rev=281075&r1=281074&r2=281075&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/atexit_stats.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/atexit_stats.cc Fri Sep  9 13:43:24 2016
@@ -2,9 +2,9 @@
 // RUN: %clangxx_asan -O3 %s -o %t
 // RUN: %env_asan_opts=atexit=1:print_stats=1 %run %t 2>&1 | FileCheck %s
 //
-// No atexit output on Android due to
+// No atexit output in older versions of Android due to
 // https://code.google.com/p/address-sanitizer/issues/detail?id=263
-// XFAIL: android
+// UNSUPPORTED: android
 
 #include <stdlib.h>
 #if !defined(__APPLE__) && !defined(__FreeBSD__)

Modified: compiler-rt/trunk/test/asan/android_commands/android_run.py
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/android_commands/android_run.py?rev=281075&r1=281074&r2=281075&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/android_commands/android_run.py (original)
+++ compiler-rt/trunk/test/asan/android_commands/android_run.py Fri Sep  9 13:43:24 2016
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-import os, sys, subprocess, tempfile
+import os, signal, sys, subprocess, tempfile
 from android_common import *
 
 ANDROID_TMPDIR = '/data/local/tmp/Output'
@@ -34,4 +34,9 @@ if ret != 0:
 
 sys.stdout.write(pull_from_device(device_stdout))
 sys.stderr.write(pull_from_device(device_stderr))
-sys.exit(int(pull_from_device(device_exitcode)))
+retcode = int(pull_from_device(device_exitcode))
+# If the device process died with a signal, do abort().
+# Not exactly the same, but good enough to fool "not --crash".
+if retcode > 128:
+  os.kill(os.getpid(), signal.SIGABRT)
+sys.exit(retcode)

Modified: compiler-rt/trunk/test/asan/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/lit.cfg?rev=281075&r1=281074&r2=281075&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/lit.cfg (original)
+++ compiler-rt/trunk/test/asan/lit.cfg Fri Sep  9 13:43:24 2016
@@ -37,6 +37,12 @@ if config.host_os == 'Darwin':
   # Also, make sure we do not overwhelm the syslog while testing.
   default_asan_opts = 'abort_on_error=0'
   default_asan_opts += ':log_to_syslog=0'
+elif config.android:
+  # The same as on Darwin, we default to "abort_on_error=1" which slows down
+  # testing. Also, all existing tests are using "not" instead of "not --crash"
+  # which does not work for abort()-terminated programs.
+  default_asan_opts = 'abort_on_error=0'
+
 if default_asan_opts:
   config.environment['ASAN_OPTIONS'] = default_asan_opts
   default_asan_opts += ':'




More information about the llvm-commits mailing list