[compiler-rt] r214149 - [UBSan] Try to enable pipefail in UBSan lit tests to make them behave more predictably

Rafael EspĂ­ndola rafael.espindola at gmail.com
Thu Jul 31 11:54:28 PDT 2014


thanks!

On 28 July 2014 20:30, Alexey Samsonov <vonosmas at gmail.com> wrote:
> Author: samsonov
> Date: Mon Jul 28 19:30:01 2014
> New Revision: 214149
>
> URL: http://llvm.org/viewvc/llvm-project?rev=214149&view=rev
> Log:
> [UBSan] Try to enable pipefail in UBSan lit tests to make them behave more predictably
>
> Modified:
>     compiler-rt/trunk/test/ubsan/TestCases/Float/cast-overflow.cpp
>     compiler-rt/trunk/test/ubsan/TestCases/Integer/no-recover.cpp
>     compiler-rt/trunk/test/ubsan/TestCases/Misc/bool.cpp
>     compiler-rt/trunk/test/ubsan/TestCases/Misc/bounds.cpp
>     compiler-rt/trunk/test/ubsan/TestCases/Misc/enum.cpp
>     compiler-rt/trunk/test/ubsan/TestCases/Misc/missing_return.cpp
>     compiler-rt/trunk/test/ubsan/TestCases/Misc/unreachable.cpp
>     compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/null.cpp
>     compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/vptr.cpp
>     compiler-rt/trunk/test/ubsan/lit.common.cfg
>
> Modified: compiler-rt/trunk/test/ubsan/TestCases/Float/cast-overflow.cpp
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/ubsan/TestCases/Float/cast-overflow.cpp?rev=214149&r1=214148&r2=214149&view=diff
> ==============================================================================
> --- compiler-rt/trunk/test/ubsan/TestCases/Float/cast-overflow.cpp (original)
> +++ compiler-rt/trunk/test/ubsan/TestCases/Float/cast-overflow.cpp Mon Jul 28 19:30:01 2014
> @@ -1,3 +1,4 @@
> +// FIXME: run this (and other) UBSan tests in both 32- and 64-bit modes (?).
>  // RUN: %clangxx -fsanitize=float-cast-overflow %s -o %t
>  // RUN: %run %t _
>  // RUN: %run %t 0 2>&1 | FileCheck %s --check-prefix=CHECK-0
> @@ -8,22 +9,8 @@
>  // RUN: %run %t 5 2>&1 | FileCheck %s --check-prefix=CHECK-5
>  // RUN: %run %t 6 2>&1 | FileCheck %s --check-prefix=CHECK-6
>  // FIXME: %run %t 7 2>&1 | FileCheck %s --check-prefix=CHECK-7
> -// RUN: %run %t 8 2>&1 | FileCheck %s --check-prefix=CHECK-8
> -// RUN: %run %t 9 2>&1 | FileCheck %s --check-prefix=CHECK-9
> -
> -// FIXME: run all ubsan tests in 32- and 64-bit modes (?).
> -// FIXME: %clangxx -fsanitize=float-cast-overflow -m32 %s -o %t
> -// FIXME: %run %t _
> -// FIXME: %run %t 0 2>&1 | FileCheck %s --check-prefix=CHECK-0
> -// FIXME: %run %t 1 2>&1 | FileCheck %s --check-prefix=CHECK-1
> -// FIXME: %run %t 2 2>&1 | FileCheck %s --check-prefix=CHECK-2
> -// FIXME: %run %t 3 2>&1 | FileCheck %s --check-prefix=CHECK-3
> -// FIXME: %run %t 4 2>&1 | FileCheck %s --check-prefix=CHECK-4
> -// FIXME: %run %t 5 2>&1 | FileCheck %s --check-prefix=CHECK-5
> -// FIXME: %run %t 6 2>&1 | FileCheck %s --check-prefix=CHECK-6
> -// FIXME: %run %t 7 2>&1 | FileCheck %s --check-prefix=CHECK-7
> -// FIXME: %run %t 8 2>&1 | FileCheck %s --check-prefix=CHECK-8
> -// FIXME: %run %t 9 2>&1 | FileCheck %s --check-prefix=CHECK-9
> +// RUN: not %run %t 8 2>&1 | FileCheck %s --check-prefix=CHECK-8
> +// RUN: not %run %t 9 2>&1 | FileCheck %s --check-prefix=CHECK-9
>
>  // This test assumes float and double are IEEE-754 single- and double-precision.
>
>
> Modified: compiler-rt/trunk/test/ubsan/TestCases/Integer/no-recover.cpp
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/ubsan/TestCases/Integer/no-recover.cpp?rev=214149&r1=214148&r2=214149&view=diff
> ==============================================================================
> --- compiler-rt/trunk/test/ubsan/TestCases/Integer/no-recover.cpp (original)
> +++ compiler-rt/trunk/test/ubsan/TestCases/Integer/no-recover.cpp Mon Jul 28 19:30:01 2014
> @@ -1,6 +1,6 @@
>  // RUN: %clangxx -fsanitize=unsigned-integer-overflow %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=RECOVER
>  // RUN: %clangxx -fsanitize=unsigned-integer-overflow -fsanitize-recover %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=RECOVER
> -// RUN: %clangxx -fsanitize=unsigned-integer-overflow -fno-sanitize-recover %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=ABORT
> +// RUN: %clangxx -fsanitize=unsigned-integer-overflow -fno-sanitize-recover %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=ABORT
>
>  #include <stdint.h>
>
>
> Modified: compiler-rt/trunk/test/ubsan/TestCases/Misc/bool.cpp
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/ubsan/TestCases/Misc/bool.cpp?rev=214149&r1=214148&r2=214149&view=diff
> ==============================================================================
> --- compiler-rt/trunk/test/ubsan/TestCases/Misc/bool.cpp (original)
> +++ compiler-rt/trunk/test/ubsan/TestCases/Misc/bool.cpp Mon Jul 28 19:30:01 2014
> @@ -1,4 +1,4 @@
> -// RUN: %clangxx -fsanitize=bool %s -O3 -o %t && %run %t 2>&1 | FileCheck %s
> +// RUN: %clangxx -fsanitize=bool %s -O3 -o %t && not %run %t 2>&1 | FileCheck %s
>
>  unsigned char NotABool = 123;
>
>
> Modified: compiler-rt/trunk/test/ubsan/TestCases/Misc/bounds.cpp
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/ubsan/TestCases/Misc/bounds.cpp?rev=214149&r1=214148&r2=214149&view=diff
> ==============================================================================
> --- compiler-rt/trunk/test/ubsan/TestCases/Misc/bounds.cpp (original)
> +++ compiler-rt/trunk/test/ubsan/TestCases/Misc/bounds.cpp Mon Jul 28 19:30:01 2014
> @@ -1,7 +1,7 @@
>  // RUN: %clangxx -fsanitize=bounds %s -O3 -o %t
>  // RUN: %run %t 0 0 0
>  // RUN: %run %t 1 2 3
> -// RUN: %run %t 2 0 0 2>&1 | FileCheck %s --check-prefix=CHECK-A-2
> +// RUN: not --crash %run %t 2 0 0 2>&1 | FileCheck %s --check-prefix=CHECK-A-2
>  // RUN: %run %t 0 3 0 2>&1 | FileCheck %s --check-prefix=CHECK-B-3
>  // RUN: %run %t 0 0 4 2>&1 | FileCheck %s --check-prefix=CHECK-C-4
>
> @@ -9,7 +9,7 @@ int main(int argc, char **argv) {
>    int arr[2][3][4] = {};
>
>    return arr[argv[1][0] - '0'][argv[2][0] - '0'][argv[3][0] - '0'];
> -  // CHECK-A-2: bounds.cpp:11:10: runtime error: index 2 out of bounds for type 'int [2][3][4]'
> -  // CHECK-B-3: bounds.cpp:11:10: runtime error: index 3 out of bounds for type 'int [3][4]'
> -  // CHECK-C-4: bounds.cpp:11:10: runtime error: index 4 out of bounds for type 'int [4]'
> +  // CHECK-A-2: bounds.cpp:[[@LINE-1]]:10: runtime error: index 2 out of bounds for type 'int [2][3][4]'
> +  // CHECK-B-3: bounds.cpp:[[@LINE-2]]:10: runtime error: index 3 out of bounds for type 'int [3][4]'
> +  // CHECK-C-4: bounds.cpp:[[@LINE-3]]:10: runtime error: index 4 out of bounds for type 'int [4]'
>  }
>
> Modified: compiler-rt/trunk/test/ubsan/TestCases/Misc/enum.cpp
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/ubsan/TestCases/Misc/enum.cpp?rev=214149&r1=214148&r2=214149&view=diff
> ==============================================================================
> --- compiler-rt/trunk/test/ubsan/TestCases/Misc/enum.cpp (original)
> +++ compiler-rt/trunk/test/ubsan/TestCases/Misc/enum.cpp Mon Jul 28 19:30:01 2014
> @@ -1,6 +1,6 @@
>  // RUN: %clangxx -fsanitize=enum %s -O3 -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-PLAIN
>  // RUN: %clangxx -fsanitize=enum -std=c++11 -DE="class E" %s -O3 -o %t && %run %t
> -// RUN: %clangxx -fsanitize=enum -std=c++11 -DE="class E : bool" %s -O3 -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-BOOL
> +// RUN: %clangxx -fsanitize=enum -std=c++11 -DE="class E : bool" %s -O3 -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-BOOL
>
>  enum E { a = 1 } e;
>  #undef E
>
> Modified: compiler-rt/trunk/test/ubsan/TestCases/Misc/missing_return.cpp
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/ubsan/TestCases/Misc/missing_return.cpp?rev=214149&r1=214148&r2=214149&view=diff
> ==============================================================================
> --- compiler-rt/trunk/test/ubsan/TestCases/Misc/missing_return.cpp (original)
> +++ compiler-rt/trunk/test/ubsan/TestCases/Misc/missing_return.cpp Mon Jul 28 19:30:01 2014
> @@ -1,4 +1,4 @@
> -// RUN: %clangxx -fsanitize=return %s -O3 -o %t && %run %t 2>&1 | FileCheck %s
> +// RUN: %clangxx -fsanitize=return %s -O3 -o %t && not %run %t 2>&1 | FileCheck %s
>
>  // CHECK: missing_return.cpp:4:5: runtime error: execution reached the end of a value-returning function without returning a value
>  int f() {
>
> Modified: compiler-rt/trunk/test/ubsan/TestCases/Misc/unreachable.cpp
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/ubsan/TestCases/Misc/unreachable.cpp?rev=214149&r1=214148&r2=214149&view=diff
> ==============================================================================
> --- compiler-rt/trunk/test/ubsan/TestCases/Misc/unreachable.cpp (original)
> +++ compiler-rt/trunk/test/ubsan/TestCases/Misc/unreachable.cpp Mon Jul 28 19:30:01 2014
> @@ -1,4 +1,4 @@
> -// RUN: %clangxx -fsanitize=unreachable %s -O3 -o %t && %run %t 2>&1 | FileCheck %s
> +// RUN: %clangxx -fsanitize=unreachable %s -O3 -o %t && not %run %t 2>&1 | FileCheck %s
>
>  int main(int, char **argv) {
>    // CHECK: unreachable.cpp:5:3: runtime error: execution reached a __builtin_unreachable() call
>
> Modified: compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/null.cpp
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/null.cpp?rev=214149&r1=214148&r2=214149&view=diff
> ==============================================================================
> --- compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/null.cpp (original)
> +++ compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/null.cpp Mon Jul 28 19:30:01 2014
> @@ -1,6 +1,6 @@
>  // RUN: %clangxx -fsanitize=null %s -O3 -o %t
>  // RUN: %run %t l 2>&1 | FileCheck %s --check-prefix=CHECK-LOAD
> -// RUN: %run %t s 2>&1 | FileCheck %s --check-prefix=CHECK-STORE
> +// RUN: not --crash %run %t s 2>&1 | FileCheck %s --check-prefix=CHECK-STORE
>  // RUN: %run %t r 2>&1 | FileCheck %s --check-prefix=CHECK-REFERENCE
>  // RUN: %run %t m 2>&1 | FileCheck %s --check-prefix=CHECK-MEMBER
>  // RUN: %run %t f 2>&1 | FileCheck %s --check-prefix=CHECK-MEMFUN
>
> Modified: compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/vptr.cpp
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/vptr.cpp?rev=214149&r1=214148&r2=214149&view=diff
> ==============================================================================
> --- compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/vptr.cpp (original)
> +++ compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/vptr.cpp Mon Jul 28 19:30:01 2014
> @@ -31,7 +31,10 @@ struct T : S {
>
>  struct U : S, T { virtual int v() { return 2; } };
>
> -T *p = 0;  // Make p global so that lsan does not complain.
> +// Make p global so that lsan does not complain.
> +T *p = 0;
> +
> +int access_p(T *p, char type);
>
>  int main(int, char **argv) {
>    T t;
> @@ -70,7 +73,12 @@ int main(int, char **argv) {
>      break;
>    }
>
> -  switch (argv[1][0]) {
> +  access_p(p, argv[1][0]);
> +  return 0;
> +}
> +
> +int access_p(T *p, char type) {
> +  switch (type) {
>    case 'r':
>      // Binding a reference to storage of appropriate size and alignment is OK.
>      {T &r = *p;}
> @@ -82,7 +90,7 @@ int main(int, char **argv) {
>      // CHECK-MEMBER-NEXT: {{^ .. .. .. ..  .. .. .. .. .. .. .. ..  }}
>      // CHECK-MEMBER-NEXT: {{^              \^~~~~~~~~~~(~~~~~~~~~~~~)? *$}}
>      // CHECK-MEMBER-NEXT: {{^              vptr for}} [[DYN_TYPE]]
> -    // CHECK-MEMBER-NEXT: #0 {{.*}} in main {{.*}}vptr.cpp:[[@LINE+1]]
> +    // CHECK-MEMBER-NEXT: #0 {{.*}} in access_p{{.*}}vptr.cpp:[[@LINE+1]]
>      return p->b;
>
>      // CHECK-NULL-MEMBER: vptr.cpp:[[@LINE-2]]:15: runtime error: member access within address [[PTR:0x[0-9a-f]*]] which does not point to an object of type 'T'
> @@ -90,7 +98,7 @@ int main(int, char **argv) {
>      // CHECK-NULL-MEMBER-NEXT: {{^  ?.. .. .. ..  ?00 00 00 00  ?00 00 00 00  ?}}
>      // CHECK-NULL-MEMBER-NEXT: {{^              \^~~~~~~~~~~(~~~~~~~~~~~~)? *$}}
>      // CHECK-NULL-MEMBER-NEXT: {{^              invalid vptr}}
> -    // CHECK-NULL-MEMBER-NEXT: #0 {{.*}} in main {{.*}}vptr.cpp:[[@LINE-7]]
> +    // CHECK-NULL-MEMBER-NEXT: #0 {{.*}} in access_p{{.*}}vptr.cpp:[[@LINE-7]]
>
>    case 'f':
>      // CHECK-MEMFUN: vptr.cpp:[[@LINE+6]]:12: runtime error: member call on address [[PTR:0x[0-9a-f]*]] which does not point to an object of type 'T'
> @@ -107,7 +115,7 @@ int main(int, char **argv) {
>      // CHECK-OFFSET-NEXT: {{^ .. .. .. ..  .. .. .. .. .. .. .. ..  .. .. .. .. .. .. .. ..  .. .. .. .. .. .. .. ..  }}
>      // CHECK-OFFSET-NEXT: {{^              \^                        (                         ~~~~~~~~~~~~)?~~~~~~~~~~~ *$}}
>      // CHECK-OFFSET-NEXT: {{^                                       (                         )?vptr for}} 'T' base class of [[DYN_TYPE]]
> -    // CHECK-OFFSET-NEXT: #0 {{.*}} in main {{.*}}vptr.cpp:[[@LINE+1]]
> +    // CHECK-OFFSET-NEXT: #0 {{.*}} in access_p{{.*}}vptr.cpp:[[@LINE+1]]
>      return reinterpret_cast<U*>(p)->v() - 2;
>
>    case 'c':
> @@ -116,7 +124,7 @@ int main(int, char **argv) {
>      // CHECK-DOWNCAST-NEXT: {{^ .. .. .. ..  .. .. .. .. .. .. .. ..  }}
>      // CHECK-DOWNCAST-NEXT: {{^              \^~~~~~~~~~~(~~~~~~~~~~~~)? *$}}
>      // CHECK-DOWNCAST-NEXT: {{^              vptr for}} [[DYN_TYPE]]
> -    // CHECK-DOWNCAST-NEXT: #0 {{.*}} in main {{.*}}vptr.cpp:[[@LINE+1]]
> +    // CHECK-DOWNCAST-NEXT: #0 {{.*}} in access_p{{.*}}vptr.cpp:[[@LINE+1]]
>      static_cast<T*>(reinterpret_cast<S*>(p));
>      return 0;
>    }
>
> Modified: compiler-rt/trunk/test/ubsan/lit.common.cfg
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/ubsan/lit.common.cfg?rev=214149&r1=214148&r2=214149&view=diff
> ==============================================================================
> --- compiler-rt/trunk/test/ubsan/lit.common.cfg (original)
> +++ compiler-rt/trunk/test/ubsan/lit.common.cfg Mon Jul 28 19:30:01 2014
> @@ -22,6 +22,7 @@ if ubsan_lit_test_mode == "Standalone":
>  elif ubsan_lit_test_mode == "AddressSanitizer":
>    config.name = 'UndefinedBehaviorSanitizer-AddressSanitizer'
>    clang_ubsan_cflags = ["-fsanitize=address"]
> +  config.environment['ASAN_OPTIONS'] = 'detect_leaks=0'
>  else:
>    lit_config.fatal("Unknown UBSan test mode: %r" % ubsan_lit_test_mode)
>
> @@ -43,5 +44,3 @@ config.suffixes = ['.c', '.cc', '.cpp']
>  # Linux and Darwin only.
>  if config.host_os not in ['Linux', 'Darwin']:
>    config.unsupported = True
> -
> -config.pipefail = False
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list