From 5c909fa013fc285f010a95e8d387e0ef3412da9c Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Wed, 30 Dec 2015 11:52:19 +0000 Subject: Vendor import of compiler-rt trunk r256633: https://llvm.org/svn/llvm-project/compiler-rt/trunk@256633 --- test/ubsan/TestCases/Misc/Linux/coverage-levels.cc | 39 -------------------- test/ubsan/TestCases/Misc/Linux/ubsan_options.cc | 2 +- test/ubsan/TestCases/Misc/bool.cpp | 7 ++-- test/ubsan/TestCases/Misc/coverage-levels.cc | 41 ++++++++++++++++++++++ test/ubsan/TestCases/Misc/log-path_test.cc | 7 ++-- test/ubsan/TestCases/Misc/missing_return.cpp | 2 +- test/ubsan/TestCases/Misc/nonnull-arg.cpp | 11 +++--- 7 files changed, 60 insertions(+), 49 deletions(-) delete mode 100644 test/ubsan/TestCases/Misc/Linux/coverage-levels.cc create mode 100644 test/ubsan/TestCases/Misc/coverage-levels.cc (limited to 'test/ubsan/TestCases/Misc') diff --git a/test/ubsan/TestCases/Misc/Linux/coverage-levels.cc b/test/ubsan/TestCases/Misc/Linux/coverage-levels.cc deleted file mode 100644 index df6e835dd9df..000000000000 --- a/test/ubsan/TestCases/Misc/Linux/coverage-levels.cc +++ /dev/null @@ -1,39 +0,0 @@ -// Test various levels of coverage -// -// RUN: mkdir -p %T/coverage-levels -// RUN: OPT=coverage=1:verbosity=1:coverage_dir=%T/coverage-levels -// RUN: %clangxx -fsanitize=shift -DGOOD_SHIFT=1 -O1 -fsanitize-coverage=func %s -o %t -// RUN: UBSAN_OPTIONS=$OPT %run %t 2>&1 | FileCheck %s --check-prefix=CHECK1 --check-prefix=CHECK_NOWARN -// RUN: %clangxx -fsanitize=undefined -DGOOD_SHIFT=1 -O1 -fsanitize-coverage=func %s -o %t -// RUN: UBSAN_OPTIONS=$OPT %run %t 2>&1 | FileCheck %s --check-prefix=CHECK1 --check-prefix=CHECK_NOWARN - -// RUN: %clangxx -fsanitize=shift -O1 -fsanitize-coverage=func %s -o %t -// RUN: UBSAN_OPTIONS=$OPT %run %t 2>&1 | FileCheck %s --check-prefix=CHECK1 --check-prefix=CHECK_WARN -// RUN: %clangxx -fsanitize=shift -O1 -fsanitize-coverage=bb %s -o %t -// RUN: UBSAN_OPTIONS=$OPT %run %t 2>&1 | FileCheck %s --check-prefix=CHECK2 --check-prefix=CHECK_WARN -// RUN: %clangxx -fsanitize=shift -O1 -fsanitize-coverage=edge %s -o %t -// RUN: UBSAN_OPTIONS=$OPT %run %t 2>&1 | FileCheck %s --check-prefix=CHECK3 --check-prefix=CHECK_WARN - -// Coverage is not yet implemented in TSan. -// XFAIL: ubsan-tsan - -volatile int sink; -int main(int argc, char **argv) { - int shift = argc * 32; -#if GOOD_SHIFT - shift = 3; -#endif - if ((argc << shift) == 16) // False. - return 1; - return 0; -} - -// CHECK_WARN: shift exponent 32 is too large -// CHECK_NOWARN-NOT: ERROR -// FIXME: Currently, coverage instrumentation kicks in after ubsan, so we get -// more than the minimal number of instrumented blocks. -// FIXME: Currently, ubsan with -fno-sanitize-recover and w/o asan will fail -// to dump coverage. -// CHECK1: 1 PCs written -// CHECK2: 3 PCs written -// CHECK3: 4 PCs written diff --git a/test/ubsan/TestCases/Misc/Linux/ubsan_options.cc b/test/ubsan/TestCases/Misc/Linux/ubsan_options.cc index 2be8792cce96..eac4c32a2839 100644 --- a/test/ubsan/TestCases/Misc/Linux/ubsan_options.cc +++ b/test/ubsan/TestCases/Misc/Linux/ubsan_options.cc @@ -1,5 +1,5 @@ // RUN: %clangxx -fsanitize=integer -fsanitize-recover=integer %s -o %t -// RUN: not %t 2>&1 | FileCheck %s +// RUN: not %run %t 2>&1 | FileCheck %s // __ubsan_default_options() doesn't work on Darwin. // XFAIL: darwin diff --git a/test/ubsan/TestCases/Misc/bool.cpp b/test/ubsan/TestCases/Misc/bool.cpp index 37ecea27c941..f6dc24e4bc78 100644 --- a/test/ubsan/TestCases/Misc/bool.cpp +++ b/test/ubsan/TestCases/Misc/bool.cpp @@ -1,10 +1,13 @@ -// RUN: %clangxx -fsanitize=bool %s -O3 -o %t && not %run %t 2>&1 | FileCheck %s +// RUN: %clangxx -fsanitize=bool %s -O3 -o %t +// RUN: not %run %t 2>&1 | FileCheck %s +// RUN: %env_ubsan_opts=print_summary=1:report_error_type=1 not %run %t 2>&1 | FileCheck %s --check-prefix=SUMMARY unsigned char NotABool = 123; int main(int argc, char **argv) { bool *p = (bool*)&NotABool; - // CHECK: bool.cpp:9:10: runtime error: load of value 123, which is not a valid value for type 'bool' + // CHECK: bool.cpp:[[@LINE+1]]:10: runtime error: load of value 123, which is not a valid value for type 'bool' return *p; + // SUMMARY: SUMMARY: {{.*}}Sanitizer: invalid-bool-load {{.*}}bool.cpp:[[@LINE-1]] } diff --git a/test/ubsan/TestCases/Misc/coverage-levels.cc b/test/ubsan/TestCases/Misc/coverage-levels.cc new file mode 100644 index 000000000000..046d8868e4d7 --- /dev/null +++ b/test/ubsan/TestCases/Misc/coverage-levels.cc @@ -0,0 +1,41 @@ +// Test various levels of coverage +// +// FIXME: Port the environment variable logic below for the lit shell. +// REQUIRES: shell +// +// RUN: mkdir -p %T/coverage-levels +// RUN: %clangxx -fsanitize=shift -DGOOD_SHIFT=1 -O1 -fsanitize-coverage=func %s -o %t +// RUN: %env_ubsan_opts=coverage=1:verbosity=1:coverage_dir=%T/coverage-levels %run %t 2>&1 | FileCheck %s --check-prefix=CHECK1 --check-prefix=CHECK_NOWARN +// RUN: %clangxx -fsanitize=undefined -DGOOD_SHIFT=1 -O1 -fsanitize-coverage=func %s -o %t +// RUN: %env_ubsan_opts=coverage=1:verbosity=1:coverage_dir=%T/coverage-levels %run %t 2>&1 | FileCheck %s --check-prefix=CHECK1 --check-prefix=CHECK_NOWARN + +// RUN: %clangxx -fsanitize=shift -O1 -fsanitize-coverage=func %s -o %t +// RUN: %env_ubsan_opts=coverage=1:verbosity=1:coverage_dir=%T/coverage-levels %run %t 2>&1 | FileCheck %s --check-prefix=CHECK1 --check-prefix=CHECK_WARN +// RUN: %clangxx -fsanitize=shift -O1 -fsanitize-coverage=bb %s -o %t +// RUN: %env_ubsan_opts=coverage=1:verbosity=1:coverage_dir=%T/coverage-levels %run %t 2>&1 | FileCheck %s --check-prefix=CHECK2 --check-prefix=CHECK_WARN +// RUN: %clangxx -fsanitize=shift -O1 -fsanitize-coverage=edge %s -o %t +// RUN: %env_ubsan_opts=coverage=1:verbosity=1:coverage_dir=%T/coverage-levels %run %t 2>&1 | FileCheck %s --check-prefix=CHECK3 --check-prefix=CHECK_WARN + +// Coverage is not yet implemented in TSan. +// XFAIL: ubsan-tsan + +volatile int sink; +int main(int argc, char **argv) { + int shift = argc * 32; +#if GOOD_SHIFT + shift = 3; +#endif + if ((argc << shift) == 16) // False. + return 1; + return 0; +} + +// CHECK_WARN: shift exponent 32 is too large +// CHECK_NOWARN-NOT: ERROR +// FIXME: Currently, coverage instrumentation kicks in after ubsan, so we get +// more than the minimal number of instrumented blocks. +// FIXME: Currently, ubsan with -fno-sanitize-recover and w/o asan will fail +// to dump coverage. +// CHECK1: 1 PCs written +// CHECK2: 3 PCs written +// CHECK3: 3 PCs written diff --git a/test/ubsan/TestCases/Misc/log-path_test.cc b/test/ubsan/TestCases/Misc/log-path_test.cc index b39e1b077e27..5b45f0b6f847 100644 --- a/test/ubsan/TestCases/Misc/log-path_test.cc +++ b/test/ubsan/TestCases/Misc/log-path_test.cc @@ -1,6 +1,9 @@ // FIXME: https://code.google.com/p/address-sanitizer/issues/detail?id=316 // XFAIL: android +// The globs below do not work in the lit shell. +// REQUIRES: shell + // RUN: %clangxx -fsanitize=undefined %s -O1 -o %t // Regular run. @@ -9,12 +12,12 @@ // Good log_path. // RUN: rm -f %t.log.* -// RUN: env UBSAN_OPTIONS=log_path=%t.log %run %t -4 2> %t.out +// RUN: %env_ubsan_opts=log_path='"%t.log"' %run %t -4 2> %t.out // RUN: FileCheck %s --check-prefix=CHECK-ERROR < %t.log.* // Run w/o errors should not produce any log. // RUN: rm -f %t.log.* -// RUN: env UBSAN_OPTIONS=log_path=%t.log %run %t 4 +// RUN: %env_ubsan_opts=log_path='"%t.log"' %run %t 4 // RUN: not cat %t.log.* // FIXME: log_path is not supported on Windows yet. diff --git a/test/ubsan/TestCases/Misc/missing_return.cpp b/test/ubsan/TestCases/Misc/missing_return.cpp index 75e26df536a6..68082272d62c 100644 --- a/test/ubsan/TestCases/Misc/missing_return.cpp +++ b/test/ubsan/TestCases/Misc/missing_return.cpp @@ -1,6 +1,6 @@ // RUN: %clangxx -fsanitize=return -g %s -O3 -o %t // RUN: not %run %t 2>&1 | FileCheck %s -// RUN: env UBSAN_OPTIONS=print_stacktrace=1 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%os-STACKTRACE +// RUN: %env_ubsan_opts=print_stacktrace=1 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%os-STACKTRACE // CHECK: missing_return.cpp:[[@LINE+1]]:5: runtime error: execution reached the end of a value-returning function without returning a value int f() { diff --git a/test/ubsan/TestCases/Misc/nonnull-arg.cpp b/test/ubsan/TestCases/Misc/nonnull-arg.cpp index 084dedc27b85..0332d96c0213 100644 --- a/test/ubsan/TestCases/Misc/nonnull-arg.cpp +++ b/test/ubsan/TestCases/Misc/nonnull-arg.cpp @@ -7,6 +7,9 @@ // RUN: not %run %t 0m 2>&1 | FileCheck %s --check-prefix=METHOD // RUN: not %run %t 0f 2>&1 | FileCheck %s --check-prefix=FUNC // RUN: not %run %t 0v 2>&1 | FileCheck %s --check-prefix=VARIADIC +// +// AArch64 lacks variadic instrumentation for MSAN. +// REQUIRES: stable-runtime class C { int *null_; @@ -40,19 +43,19 @@ int main(int argc, char *argv[]) { case 'c': return C(0x0, arg).value(); // CTOR: {{.*}}nonnull-arg.cpp:[[@LINE-1]]:21: runtime error: null pointer passed as argument 2, which is declared to never be null - // CTOR-NEXT: {{.*}}nonnull-arg.cpp:16:31: note: nonnull attribute specified here + // CTOR-NEXT: {{.*}}nonnull-arg.cpp:19:31: note: nonnull attribute specified here case 'm': return C(0x0, &local).method(arg, 0x0); // METHOD: {{.*}}nonnull-arg.cpp:[[@LINE-1]]:36: runtime error: null pointer passed as argument 1, which is declared to never be null - // METHOD-NEXT: {{.*}}nonnull-arg.cpp:19:54: note: nonnull attribute specified here + // METHOD-NEXT: {{.*}}nonnull-arg.cpp:22:54: note: nonnull attribute specified here case 'f': return func(arg); // FUNC: {{.*}}nonnull-arg.cpp:[[@LINE-1]]:19: runtime error: null pointer passed as argument 1, which is declared to never be null - // FUNC-NEXT: {{.*}}nonnull-arg.cpp:24:16: note: nonnull attribute specified here + // FUNC-NEXT: {{.*}}nonnull-arg.cpp:27:16: note: nonnull attribute specified here case 'v': return variadic(42, arg); // VARIADIC: {{.*}}nonnull-arg.cpp:[[@LINE-1]]:27: runtime error: null pointer passed as argument 2, which is declared to never be null - // VARIADIC-NEXT: {{.*}}nonnull-arg.cpp:27:16: note: nonnull attribute specified here + // VARIADIC-NEXT: {{.*}}nonnull-arg.cpp:30:16: note: nonnull attribute specified here } return 0; } -- cgit v1.2.3