[compiler-rt] r313444 - [sanitizer] Support check-asan on Android

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 15 22:14:05 PDT 2017


Author: vitalybuka
Date: Fri Sep 15 22:14:05 2017
New Revision: 313444

URL: http://llvm.org/viewvc/llvm-project?rev=313444&view=rev
Log:
[sanitizer] Support check-asan on Android

This patch enabled asan tests from sanitizer_common.

Modified:
    compiler-rt/trunk/test/asan/TestCases/Linux/abort_on_error.cc
    compiler-rt/trunk/test/sanitizer_common/CMakeLists.txt
    compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/abort_on_error.cc
    compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/iconv_test.c
    compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/ptrace.cc
    compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/sysconf_interceptor_bypass_test.cc
    compiler-rt/trunk/test/sanitizer_common/TestCases/get_module_and_offset_for_pc.cc
    compiler-rt/trunk/test/sanitizer_common/TestCases/options-include.cc
    compiler-rt/trunk/test/sanitizer_common/TestCases/print-stack-trace.cc
    compiler-rt/trunk/test/sanitizer_common/lit.common.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=313444&r1=313443&r2=313444&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 15 22:14:05 2017
@@ -9,6 +9,7 @@
 // lit doesn't set ASAN_OPTIONS anyway.
 // RUN: not %run %t 2>&1 | FileCheck %s
 
+// Android runs with abort_on_error=0
 // UNSUPPORTED: android
 
 #include <stdlib.h>

Modified: compiler-rt/trunk/test/sanitizer_common/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/CMakeLists.txt?rev=313444&r1=313443&r2=313444&view=diff
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/CMakeLists.txt (original)
+++ compiler-rt/trunk/test/sanitizer_common/CMakeLists.txt Fri Sep 15 22:14:05 2017
@@ -4,7 +4,7 @@ set(SANITIZER_COMMON_TEST_DEPS ${SANITIZ
 set(SANITIZER_COMMON_TESTSUITES)
 
 set(SUPPORTED_TOOLS)
-if(CMAKE_SYSTEM_NAME MATCHES "Darwin|Linux|FreeBSD|NetBSD" AND NOT ANDROID)
+if(CMAKE_SYSTEM_NAME MATCHES "Darwin|Linux|FreeBSD|NetBSD")
   list(APPEND SUPPORTED_TOOLS asan)
 endif()
 if(CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT ANDROID)
@@ -43,8 +43,11 @@ if(COMPILER_RT_INCLUDE_TESTS)
   configure_lit_site_cfg(
     ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in
     ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg)
-  list(APPEND SANITIZER_COMMON_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/Unit)
-  list(APPEND SANITIZER_COMMON_TEST_DEPS SanitizerUnitTests)
+  # FIXME: support unit test in the android test runner
+  if (NOT ANDROID)
+    list(APPEND SANITIZER_COMMON_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/Unit)
+    list(APPEND SANITIZER_COMMON_TEST_DEPS SanitizerUnitTests)
+  endif()
 endif()
 
 if(SANITIZER_COMMON_TESTSUITES)

Modified: compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/abort_on_error.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/abort_on_error.cc?rev=313444&r1=313443&r2=313444&view=diff
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/abort_on_error.cc (original)
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/abort_on_error.cc Fri Sep 15 22:14:05 2017
@@ -10,6 +10,9 @@
 // lit doesn't set options anyway.
 // RUN: not %run %t 2>&1
 
+// Android needs abort_on_error=0
+// UNSUPPORTED: android
+
 namespace __sanitizer {
 void Die();
 }

Modified: compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/iconv_test.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/iconv_test.c?rev=313444&r1=313443&r2=313444&view=diff
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/iconv_test.c (original)
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/iconv_test.c Fri Sep 15 22:14:05 2017
@@ -1,6 +1,9 @@
 // RUN: %clang %s -o %t && %run %t
 // Verify that even if iconv returned -1
 // we still treat the initialized part of outbuf as properly initialized.
+
+// UNSUPPORTED: android
+
 #include <iconv.h>
 #include <assert.h>
 #include <stdio.h>

Modified: compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/ptrace.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/ptrace.cc?rev=313444&r1=313443&r2=313444&view=diff
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/ptrace.cc (original)
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/ptrace.cc Fri Sep 15 22:14:05 2017
@@ -1,5 +1,7 @@
 // RUN: %clangxx -O0 %s -o %t && %run %t
 
+// UNSUPPORTED: android
+
 #include <assert.h>
 #include <signal.h>
 #include <stdio.h>

Modified: compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/sysconf_interceptor_bypass_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/sysconf_interceptor_bypass_test.cc?rev=313444&r1=313443&r2=313444&view=diff
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/sysconf_interceptor_bypass_test.cc (original)
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/sysconf_interceptor_bypass_test.cc Fri Sep 15 22:14:05 2017
@@ -1,5 +1,7 @@
 // RUN: %clangxx -O2 %s -o %t && %run %t 2>&1 | FileCheck %s
 
+// XFAIL: android
+
 #include <stdio.h>
 
 // getauxval() used instead of sysconf() in GetPageSize() is defined starting

Modified: compiler-rt/trunk/test/sanitizer_common/TestCases/get_module_and_offset_for_pc.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/get_module_and_offset_for_pc.cc?rev=313444&r1=313443&r2=313444&view=diff
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/get_module_and_offset_for_pc.cc (original)
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/get_module_and_offset_for_pc.cc Fri Sep 15 22:14:05 2017
@@ -1,8 +1,10 @@
 // RUN: %clangxx -DSHARED %s -shared -o %T/get_module_and_offset_for_pc.so -fPIC
 // RUN: %clangxx -DSO_DIR=\"%T\" -O0 %s -ldl -o %t
 // RUN: %run %t 2>&1 | FileCheck %s
+
 // UNSUPPORTED: i386-darwin
-//
+// XFAIL: android
+
 // Tests __sanitizer_get_module_and_offset_for_pc.
 
 #include <assert.h>

Modified: compiler-rt/trunk/test/sanitizer_common/TestCases/options-include.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/options-include.cc?rev=313444&r1=313443&r2=313444&view=diff
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/options-include.cc (original)
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/options-include.cc Fri Sep 15 22:14:05 2017
@@ -34,6 +34,8 @@
 // RUN: %env_tool_opts=include_if_exists='"%t.options-not-found.%b"' %run %t 2>&1 | tee %t.out
 // RUN: FileCheck %s --check-prefix=CHECK-WITHOUT-HELP --check-prefix=CHECK-FOUND < %t.out
 
+// Android tests run on remote device so includes will not work.
+// UNSUPPORTED: android
 
 #include <stdio.h>
 

Modified: compiler-rt/trunk/test/sanitizer_common/TestCases/print-stack-trace.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/print-stack-trace.cc?rev=313444&r1=313443&r2=313444&view=diff
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/print-stack-trace.cc (original)
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/print-stack-trace.cc Fri Sep 15 22:14:05 2017
@@ -1,6 +1,6 @@
 // RUN: %clangxx -O0 %s -o %t && %env_tool_opts=stack_trace_format=DEFAULT %run %t 2>&1 | FileCheck %s
 // RUN: %clangxx -O3 %s -o %t && %env_tool_opts=stack_trace_format=DEFAULT %run %t 2>&1 | FileCheck %s
-// RUN: %env_tool_opts=stack_trace_format='"frame:%n lineno:%l"' %run %t 2>&1 | FileCheck %s --check-prefix=CUSTOM
+// RUN: %env_tool_opts=stack_trace_format=frame%n_lineno%l %run %t 2>&1 | FileCheck %s --check-prefix=CUSTOM
 // RUN: %env_tool_opts=symbolize_inline_frames=false:stack_trace_format=DEFAULT %run %t 2>&1 | FileCheck %s --check-prefix=NOINLINE
 
 // UNSUPPORTED: darwin
@@ -19,8 +19,8 @@ int main() {
 // CHECK: {{    #1 0x.* in FooBarBaz(\(\))? .*}}print-stack-trace.cc:[[@LINE-8]]
 // CHECK: {{    #2 0x.* in main.*}}print-stack-trace.cc:[[@LINE-5]]
 
-// CUSTOM: frame:1 lineno:[[@LINE-11]]
-// CUSTOM: frame:2 lineno:[[@LINE-8]]
+// CUSTOM: frame1_lineno[[@LINE-11]]
+// CUSTOM: frame2_lineno[[@LINE-8]]
 
 // NOINLINE: #0 0x{{.*}} in __sanitizer_print_stack_trace
 // NOINLINE: #1 0x{{.*}} in main{{.*}}print-stack-trace.cc:[[@LINE-15]]

Modified: compiler-rt/trunk/test/sanitizer_common/lit.common.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/lit.common.cfg?rev=313444&r1=313443&r2=313444&view=diff
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/lit.common.cfg (original)
+++ compiler-rt/trunk/test/sanitizer_common/lit.common.cfg Fri Sep 15 22:14:05 2017
@@ -36,6 +36,12 @@ if config.host_os == 'Darwin':
   # On Darwin, we default to `abort_on_error=1`, which would make tests run
   # much slower. Let's override this and run lit tests with 'abort_on_error=0'.
   default_tool_options += ['abort_on_error=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_tool_options += ['abort_on_error=0']
+
 default_tool_options_str = ':'.join(default_tool_options)
 if default_tool_options_str:
   config.environment[tool_options] = default_tool_options_str
@@ -45,7 +51,7 @@ clang_cflags = config.debug_info_flags +
 clang_cxxflags = config.cxx_mode_flags + clang_cflags
 
 def build_invocation(compile_flags):
-  return " " + " ".join([config.clang] + compile_flags) + " "
+  return " " + " ".join([config.compile_wrapper, config.clang] + compile_flags) + " "
 
 config.substitutions.append( ("%clang ", build_invocation(clang_cflags)) )
 config.substitutions.append( ("%clangxx ", build_invocation(clang_cxxflags)) )




More information about the llvm-commits mailing list