summaryrefslogtreecommitdiff
path: root/test/ubsan/TestCases
diff options
context:
space:
mode:
authorAlexey Samsonov <vonosmas@gmail.com>2014-07-29 00:30:01 +0000
committerAlexey Samsonov <vonosmas@gmail.com>2014-07-29 00:30:01 +0000
commitf6c4be8c3725ad81c7d4b43517fd5d919a4f4240 (patch)
treeabc2c7b5d93da3d532bbf7a03f62b04ccb109cca /test/ubsan/TestCases
parent4cac71682e747a3ab9d507a84be9ce3696294081 (diff)
[UBSan] Try to enable pipefail in UBSan lit tests to make them behave more predictably
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@214149 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/ubsan/TestCases')
-rw-r--r--test/ubsan/TestCases/Float/cast-overflow.cpp19
-rw-r--r--test/ubsan/TestCases/Integer/no-recover.cpp2
-rw-r--r--test/ubsan/TestCases/Misc/bool.cpp2
-rw-r--r--test/ubsan/TestCases/Misc/bounds.cpp8
-rw-r--r--test/ubsan/TestCases/Misc/enum.cpp2
-rw-r--r--test/ubsan/TestCases/Misc/missing_return.cpp2
-rw-r--r--test/ubsan/TestCases/Misc/unreachable.cpp2
-rw-r--r--test/ubsan/TestCases/TypeCheck/null.cpp2
-rw-r--r--test/ubsan/TestCases/TypeCheck/vptr.cpp20
9 files changed, 27 insertions, 32 deletions
diff --git a/test/ubsan/TestCases/Float/cast-overflow.cpp b/test/ubsan/TestCases/Float/cast-overflow.cpp
index cc6f9ad13..28a6672b0 100644
--- a/test/ubsan/TestCases/Float/cast-overflow.cpp
+++ b/test/ubsan/TestCases/Float/cast-overflow.cpp
@@ -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.
diff --git a/test/ubsan/TestCases/Integer/no-recover.cpp b/test/ubsan/TestCases/Integer/no-recover.cpp
index 90dfd2eef..575bd0a55 100644
--- a/test/ubsan/TestCases/Integer/no-recover.cpp
+++ b/test/ubsan/TestCases/Integer/no-recover.cpp
@@ -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>
diff --git a/test/ubsan/TestCases/Misc/bool.cpp b/test/ubsan/TestCases/Misc/bool.cpp
index 5fe5cf128..37ecea27c 100644
--- a/test/ubsan/TestCases/Misc/bool.cpp
+++ b/test/ubsan/TestCases/Misc/bool.cpp
@@ -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;
diff --git a/test/ubsan/TestCases/Misc/bounds.cpp b/test/ubsan/TestCases/Misc/bounds.cpp
index ea59b02fc..ffcac528b 100644
--- a/test/ubsan/TestCases/Misc/bounds.cpp
+++ b/test/ubsan/TestCases/Misc/bounds.cpp
@@ -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]'
}
diff --git a/test/ubsan/TestCases/Misc/enum.cpp b/test/ubsan/TestCases/Misc/enum.cpp
index c95ce8270..49ac7c6bb 100644
--- a/test/ubsan/TestCases/Misc/enum.cpp
+++ b/test/ubsan/TestCases/Misc/enum.cpp
@@ -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
diff --git a/test/ubsan/TestCases/Misc/missing_return.cpp b/test/ubsan/TestCases/Misc/missing_return.cpp
index 04bc791e1..20ede152b 100644
--- a/test/ubsan/TestCases/Misc/missing_return.cpp
+++ b/test/ubsan/TestCases/Misc/missing_return.cpp
@@ -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() {
diff --git a/test/ubsan/TestCases/Misc/unreachable.cpp b/test/ubsan/TestCases/Misc/unreachable.cpp
index ba760635e..e1206edb3 100644
--- a/test/ubsan/TestCases/Misc/unreachable.cpp
+++ b/test/ubsan/TestCases/Misc/unreachable.cpp
@@ -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
diff --git a/test/ubsan/TestCases/TypeCheck/null.cpp b/test/ubsan/TestCases/TypeCheck/null.cpp
index 47f5270e5..2a90f7fb9 100644
--- a/test/ubsan/TestCases/TypeCheck/null.cpp
+++ b/test/ubsan/TestCases/TypeCheck/null.cpp
@@ -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
diff --git a/test/ubsan/TestCases/TypeCheck/vptr.cpp b/test/ubsan/TestCases/TypeCheck/vptr.cpp
index 68ca6926d..7fd5804da 100644
--- a/test/ubsan/TestCases/TypeCheck/vptr.cpp
+++ b/test/ubsan/TestCases/TypeCheck/vptr.cpp
@@ -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;
}