Make ASan and TSan tests a bit less brittle with @LINE FileCheck macro
llvm-svn: 171181
This commit is contained in:
parent
9785f519b4
commit
f96bfd8849
|
|
@ -22,7 +22,7 @@ int __attribute__((noinline)) initX() {
|
|||
return y + 1;
|
||||
// CHECK: {{AddressSanitizer: initialization-order-fiasco}}
|
||||
// CHECK: {{READ of size .* at 0x.* thread T0}}
|
||||
// CHECK: {{#0 0x.* in .*initX.* .*initialization-bug-any-order.cc:22}}
|
||||
// CHECK: {{#0 0x.* in .*initX.* .*initialization-bug-any-order.cc:}}[[@LINE-3]]
|
||||
// CHECK: {{0x.* is located 0 bytes inside of global variable .*y.*}}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ int main(int argc, char **argv) {
|
|||
memset(ZZZ, 0, 10);
|
||||
int res = YYY[argc * 10]; // BOOOM
|
||||
// CHECK: {{READ of size 1 at 0x.* thread T0}}
|
||||
// CHECK: {{ #0 0x.* in _?main .*global-overflow.cc:18}}
|
||||
// CHECK: {{ #0 0x.* in _?main .*global-overflow.cc:}}[[@LINE-2]]
|
||||
// CHECK: {{0x.* is located 0 bytes to the right of global variable}}
|
||||
// CHECK: {{.*YYY.* of size 10}}
|
||||
res += XXX[argc] + ZZZ[argc];
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ int main(int argc, char **argv) {
|
|||
memset(x, 0, 10);
|
||||
int res = x[argc * 10]; // BOOOM
|
||||
// CHECK: {{READ of size 1 at 0x.* thread T0}}
|
||||
// CHECK: {{ #0 0x.* in _?main .*heap-overflow.cc:23}}
|
||||
// CHECK: {{ #0 0x.* in _?main .*heap-overflow.cc:}}[[@LINE-2]]
|
||||
// CHECK: {{0x.* is located 0 bytes to the right of 10-byte region}}
|
||||
// CHECK: {{allocated by thread T0 here:}}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,14 @@ static void LargeFunction(int *x, int zero) {
|
|||
x[8]++;
|
||||
x[9]++;
|
||||
|
||||
// CHECK: {{.*ERROR: AddressSanitizer: heap-buffer-overflow on address}}
|
||||
// CHECK: {{0x.* at pc 0x.* bp 0x.* sp 0x.*}}
|
||||
// CHECK: {{READ of size 4 at 0x.* thread T0}}
|
||||
x[zero + 111]++; // we should report this exact line
|
||||
// atos incorrectly extracts the symbol name for the static functions on
|
||||
// Darwin.
|
||||
// CHECK-Linux: {{#0 0x.* in LargeFunction.*large_func_test.cc:}}[[@LINE-3]]
|
||||
// CHECK-Darwin: {{#0 0x.* in .*LargeFunction.*large_func_test.cc}}:[[@LINE-4]]
|
||||
|
||||
x[10]++;
|
||||
x[11]++;
|
||||
|
|
@ -46,20 +53,10 @@ static void LargeFunction(int *x, int zero) {
|
|||
int main(int argc, char **argv) {
|
||||
int *x = new int[100];
|
||||
LargeFunction(x, argc - 1);
|
||||
// CHECK: {{ #1 0x.* in _?main .*large_func_test.cc:}}[[@LINE-1]]
|
||||
// CHECK: {{0x.* is located 44 bytes to the right of 400-byte region}}
|
||||
// CHECK: {{allocated by thread T0 here:}}
|
||||
// CHECK: {{ #0 0x.* in operator new.*}}
|
||||
// CHECK: {{ #1 0x.* in _?main .*large_func_test.cc:}}[[@LINE-6]]
|
||||
delete x;
|
||||
}
|
||||
|
||||
// CHECK: {{.*ERROR: AddressSanitizer: heap-buffer-overflow on address}}
|
||||
// CHECK: {{0x.* at pc 0x.* bp 0x.* sp 0x.*}}
|
||||
// CHECK: {{READ of size 4 at 0x.* thread T0}}
|
||||
|
||||
// atos incorrectly extracts the symbol name for the static functions on
|
||||
// Darwin.
|
||||
// CHECK-Linux: {{ #0 0x.* in LargeFunction.*large_func_test.cc:32}}
|
||||
// CHECK-Darwin: {{ #0 0x.* in .*LargeFunction.*large_func_test.cc:32}}
|
||||
|
||||
// CHECK: {{ #1 0x.* in _?main .*large_func_test.cc:48}}
|
||||
// CHECK: {{0x.* is located 44 bytes to the right of 400-byte region}}
|
||||
// CHECK: {{allocated by thread T0 here:}}
|
||||
// CHECK: {{ #0 0x.* in operator new.*}}
|
||||
// CHECK: {{ #1 0x.* in _?main .*large_func_test.cc:47}}
|
||||
|
|
|
|||
|
|
@ -17,18 +17,15 @@
|
|||
|
||||
__attribute__((noinline))
|
||||
static void NullDeref(int *ptr) {
|
||||
ptr[10]++;
|
||||
// CHECK: ERROR: AddressSanitizer: SEGV on unknown address
|
||||
// CHECK: {{0x0*00028 .*pc 0x.*}}
|
||||
// CHECK: {{AddressSanitizer can not provide additional info.}}
|
||||
ptr[10]++; // BOOM
|
||||
// atos on Mac cannot extract the symbol name correctly.
|
||||
// CHECK-Linux: {{ #0 0x.* in NullDeref.*null_deref.cc:}}[[@LINE-2]]
|
||||
// CHECK-Darwin: {{ #0 0x.* in .*NullDeref.*null_deref.cc:}}[[@LINE-3]]
|
||||
}
|
||||
int main() {
|
||||
NullDeref((int*)0);
|
||||
// CHECK: {{ #1 0x.* in _?main.*null_deref.cc:}}[[@LINE-1]]
|
||||
}
|
||||
|
||||
// CHECK: ERROR: AddressSanitizer: SEGV on unknown address
|
||||
// CHECK: {{0x0*00028 .*pc 0x.*}}
|
||||
// CHECK: {{AddressSanitizer can not provide additional info.}}
|
||||
|
||||
// atos on Mac cannot extract the symbol name correctly.
|
||||
// CHECK-Linux: {{ #0 0x.* in NullDeref.*null_deref.cc:20}}
|
||||
// CHECK-Darwin: {{ #0 0x.* in .*NullDeref.*null_deref.cc:20}}
|
||||
|
||||
// CHECK: {{ #1 0x.* in _?main.*null_deref.cc:23}}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ int main() {
|
|||
return x[5];
|
||||
// CHECK: heap-use-after-free
|
||||
// CHECK: free
|
||||
// CHECK: main{{.*}}sanity_check_pure_c.c:12
|
||||
// CHECK: main{{.*}}sanity_check_pure_c.c:[[@LINE-4]]
|
||||
// CHECK: malloc
|
||||
// CHECK: main{{.*}}sanity_check_pure_c.c:11
|
||||
// CHECK: main{{.*}}sanity_check_pure_c.c:[[@LINE-7]]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,6 +49,6 @@ int main(int argc, char *argv[]) {
|
|||
// CHECK: {{.*ERROR: AddressSanitizer: global-buffer-overflow}}
|
||||
// CHECK: {{READ of size 4 at 0x.* thread T0}}
|
||||
// CHECK: {{ #0 0x.*}}
|
||||
// CHECK: {{ #1 0x.* in _?main .*shared-lib-test.cc:48}}
|
||||
// CHECK: {{ #1 0x.* in _?main .*shared-lib-test.cc:}}[[@LINE-4]]
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ int main(int argc, char **argv) {
|
|||
memset(x, 0, 10);
|
||||
int res = x[argc * 10]; // BOOOM
|
||||
// CHECK: {{READ of size 1 at 0x.* thread T0}}
|
||||
// CHECK: {{ #0 0x.* in _?main .*stack-overflow.cc:14}}
|
||||
// CHECK: {{ #0 0x.* in _?main .*stack-overflow.cc:}}[[@LINE-2]]
|
||||
// CHECK: {{Address 0x.* is .* frame <main>}}
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,16 +25,16 @@ int main(int argc, char **argv) {
|
|||
// CHECK: {{WRITE of size 1 at 0x.* thread T0}}
|
||||
// CHECK-Linux: {{ #0 0x.* in .*strncpy}}
|
||||
// CHECK-Darwin: {{ #0 0x.* in _?wrap_strncpy}}
|
||||
// CHECK: {{ #1 0x.* in _?main .*strncpy-overflow.cc:24}}
|
||||
// CHECK: {{ #1 0x.* in _?main .*strncpy-overflow.cc:}}[[@LINE-4]]
|
||||
// CHECK: {{0x.* is located 0 bytes to the right of 9-byte region}}
|
||||
// CHECK: {{allocated by thread T0 here:}}
|
||||
|
||||
// CHECK-Linux: {{ #0 0x.* in .*malloc}}
|
||||
// CHECK-Linux: {{ #1 0x.* in main .*strncpy-overflow.cc:23}}
|
||||
// CHECK-Linux: {{ #1 0x.* in main .*strncpy-overflow.cc:}}[[@LINE-10]]
|
||||
|
||||
// CHECK-Darwin: {{ #0 0x.* in .*mz_malloc.*}}
|
||||
// CHECK-Darwin: {{ #1 0x.* in malloc_zone_malloc.*}}
|
||||
// CHECK-Darwin: {{ #2 0x.* in malloc.*}}
|
||||
// CHECK-Darwin: {{ #3 0x.* in _?main .*strncpy-overflow.cc:23}}
|
||||
// CHECK-Darwin: {{ #3 0x.* in _?main .*strncpy-overflow.cc:}}[[@LINE-15]]
|
||||
return short_buffer[8];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,13 @@ void *Thread2(void *x) {
|
|||
}
|
||||
|
||||
int main() {
|
||||
// CHECK: WARNING: ThreadSanitizer: data race
|
||||
// CHECK: Write of size 4 at {{.*}} by thread T1
|
||||
// CHECK: (mutexes: write [[M1:M[0-9]+]]):
|
||||
// CHECK: Previous write of size 4 at {{.*}} by thread T2:
|
||||
// CHECK: Mutex [[M1]] created at:
|
||||
// CHECK: #0 pthread_mutex_init
|
||||
// CHECK: #1 main {{.*}}/mutexset1.cc:[[@LINE+1]]
|
||||
pthread_mutex_init(&mtx, 0);
|
||||
pthread_t t[2];
|
||||
pthread_create(&t[0], NULL, Thread1, NULL);
|
||||
|
|
@ -28,12 +35,3 @@ int main() {
|
|||
pthread_join(t[1], NULL);
|
||||
pthread_mutex_destroy(&mtx);
|
||||
}
|
||||
|
||||
// CHECK: WARNING: ThreadSanitizer: data race
|
||||
// CHECK: Write of size 4 at {{.*}} by thread T1
|
||||
// CHECK: (mutexes: write [[M1:M[0-9]+]]):
|
||||
// CHECK: Previous write of size 4 at {{.*}} by thread T2:
|
||||
// CHECK: Mutex [[M1]] created at:
|
||||
// CHECK: #0 pthread_mutex_init
|
||||
// CHECK: #1 main {{.*}}/mutexset1.cc:23
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,13 @@ void *Thread2(void *x) {
|
|||
}
|
||||
|
||||
int main() {
|
||||
// CHECK: WARNING: ThreadSanitizer: data race
|
||||
// CHECK: Write of size 4 at {{.*}} by thread T2:
|
||||
// CHECK: Previous write of size 4 at {{.*}} by thread T1
|
||||
// CHECK: (mutexes: write [[M1:M[0-9]+]]):
|
||||
// CHECK: Mutex [[M1]] created at:
|
||||
// CHECK: #0 pthread_mutex_init
|
||||
// CHECK: #1 main {{.*}}/mutexset2.cc:[[@LINE+1]]
|
||||
pthread_mutex_init(&mtx, 0);
|
||||
pthread_t t[2];
|
||||
pthread_create(&t[0], NULL, Thread1, NULL);
|
||||
|
|
@ -28,12 +35,3 @@ int main() {
|
|||
pthread_join(t[1], NULL);
|
||||
pthread_mutex_destroy(&mtx);
|
||||
}
|
||||
|
||||
// CHECK: WARNING: ThreadSanitizer: data race
|
||||
// CHECK: Write of size 4 at {{.*}} by thread T2:
|
||||
// CHECK: Previous write of size 4 at {{.*}} by thread T1
|
||||
// CHECK: (mutexes: write [[M1:M[0-9]+]]):
|
||||
// CHECK: Mutex [[M1]] created at:
|
||||
// CHECK: #0 pthread_mutex_init
|
||||
// CHECK: #1 main {{.*}}/mutexset2.cc:23
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,16 @@ void *Thread2(void *x) {
|
|||
}
|
||||
|
||||
int main() {
|
||||
// CHECK: WARNING: ThreadSanitizer: data race
|
||||
// CHECK: Write of size 4 at {{.*}} by thread T1
|
||||
// CHECK: (mutexes: write [[M1:M[0-9]+]], write [[M2:M[0-9]+]]):
|
||||
// CHECK: Previous write of size 4 at {{.*}} by thread T2:
|
||||
// CHECK: Mutex [[M1]] created at:
|
||||
// CHECK: #0 pthread_mutex_init
|
||||
// CHECK: #1 main {{.*}}/mutexset3.cc:[[@LINE+4]]
|
||||
// CHECK: Mutex [[M2]] created at:
|
||||
// CHECK: #0 pthread_mutex_init
|
||||
// CHECK: #1 main {{.*}}/mutexset3.cc:[[@LINE+2]]
|
||||
pthread_mutex_init(&mtx1, 0);
|
||||
pthread_mutex_init(&mtx2, 0);
|
||||
pthread_t t[2];
|
||||
|
|
@ -33,15 +43,3 @@ int main() {
|
|||
pthread_mutex_destroy(&mtx1);
|
||||
pthread_mutex_destroy(&mtx2);
|
||||
}
|
||||
|
||||
// CHECK: WARNING: ThreadSanitizer: data race
|
||||
// CHECK: Write of size 4 at {{.*}} by thread T1
|
||||
// CHECK: (mutexes: write [[M1:M[0-9]+]], write [[M2:M[0-9]+]]):
|
||||
// CHECK: Previous write of size 4 at {{.*}} by thread T2:
|
||||
// CHECK: Mutex [[M1]] created at:
|
||||
// CHECK: #0 pthread_mutex_init
|
||||
// CHECK: #1 main {{.*}}/mutexset3.cc:26
|
||||
// CHECK: Mutex [[M2]] created at:
|
||||
// CHECK: #0 pthread_mutex_init
|
||||
// CHECK: #1 main {{.*}}/mutexset3.cc:27
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,16 @@ void *Thread2(void *x) {
|
|||
}
|
||||
|
||||
int main() {
|
||||
// CHECK: WARNING: ThreadSanitizer: data race
|
||||
// CHECK: Write of size 4 at {{.*}} by thread T2:
|
||||
// CHECK: Previous write of size 4 at {{.*}} by thread T1
|
||||
// CHECK: (mutexes: write [[M1:M[0-9]+]], write [[M2:M[0-9]+]]):
|
||||
// CHECK: Mutex [[M1]] created at:
|
||||
// CHECK: #0 pthread_mutex_init
|
||||
// CHECK: #1 main {{.*}}/mutexset4.cc:[[@LINE+4]]
|
||||
// CHECK: Mutex [[M2]] created at:
|
||||
// CHECK: #0 pthread_mutex_init
|
||||
// CHECK: #1 main {{.*}}/mutexset4.cc:[[@LINE+2]]
|
||||
pthread_mutex_init(&mtx1, 0);
|
||||
pthread_mutex_init(&mtx2, 0);
|
||||
pthread_t t[2];
|
||||
|
|
@ -33,15 +43,3 @@ int main() {
|
|||
pthread_mutex_destroy(&mtx1);
|
||||
pthread_mutex_destroy(&mtx2);
|
||||
}
|
||||
|
||||
// CHECK: WARNING: ThreadSanitizer: data race
|
||||
// CHECK: Write of size 4 at {{.*}} by thread T2:
|
||||
// CHECK: Previous write of size 4 at {{.*}} by thread T1
|
||||
// CHECK: (mutexes: write [[M1:M[0-9]+]], write [[M2:M[0-9]+]]):
|
||||
// CHECK: Mutex [[M1]] created at:
|
||||
// CHECK: #0 pthread_mutex_init
|
||||
// CHECK: #1 main {{.*}}/mutexset4.cc:26
|
||||
// CHECK: Mutex [[M2]] created at:
|
||||
// CHECK: #0 pthread_mutex_init
|
||||
// CHECK: #1 main {{.*}}/mutexset4.cc:27
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,17 @@ void *Thread2(void *x) {
|
|||
}
|
||||
|
||||
int main() {
|
||||
// CHECK: WARNING: ThreadSanitizer: data race
|
||||
// CHECK: Write of size 4 at {{.*}} by thread T1
|
||||
// CHECK: (mutexes: write [[M1:M[0-9]+]]):
|
||||
// CHECK: Previous write of size 4 at {{.*}} by thread T2
|
||||
// CHECK: (mutexes: write [[M2:M[0-9]+]]):
|
||||
// CHECK: Mutex [[M1]] created at:
|
||||
// CHECK: #0 pthread_mutex_init
|
||||
// CHECK: #1 main {{.*}}/mutexset5.cc:[[@LINE+4]]
|
||||
// CHECK: Mutex [[M2]] created at:
|
||||
// CHECK: #0 pthread_mutex_init
|
||||
// CHECK: #1 main {{.*}}/mutexset5.cc:[[@LINE+5]]
|
||||
pthread_mutex_init(&mtx1, 0);
|
||||
pthread_mutex_init(&mtx2, 0);
|
||||
pthread_t t[2];
|
||||
|
|
@ -33,16 +44,3 @@ int main() {
|
|||
pthread_mutex_destroy(&mtx1);
|
||||
pthread_mutex_destroy(&mtx2);
|
||||
}
|
||||
|
||||
// CHECK: WARNING: ThreadSanitizer: data race
|
||||
// CHECK: Write of size 4 at {{.*}} by thread T1
|
||||
// CHECK: (mutexes: write [[M1:M[0-9]+]]):
|
||||
// CHECK: Previous write of size 4 at {{.*}} by thread T2
|
||||
// CHECK: (mutexes: write [[M2:M[0-9]+]]):
|
||||
// CHECK: Mutex [[M1]] created at:
|
||||
// CHECK: #0 pthread_mutex_init
|
||||
// CHECK: #1 main {{.*}}/mutexset5.cc:26
|
||||
// CHECK: Mutex [[M2]] created at:
|
||||
// CHECK: #0 pthread_mutex_init
|
||||
// CHECK: #1 main {{.*}}/mutexset5.cc:27
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,17 @@ void *Thread2(void *x) {
|
|||
}
|
||||
|
||||
int main() {
|
||||
// CHECK: WARNING: ThreadSanitizer: data race
|
||||
// CHECK: Write of size 4 at {{.*}} by thread T1
|
||||
// CHECK: (mutexes: write [[M1:M[0-9]+]]):
|
||||
// CHECK: Previous write of size 4 at {{.*}} by thread T2
|
||||
// CHECK: (mutexes: write [[M2:M[0-9]+]], read [[M3:M[0-9]+]]):
|
||||
// CHECK: Mutex [[M1]] created at:
|
||||
// CHECK: #1 main {{.*}}/mutexset6.cc:[[@LINE+5]]
|
||||
// CHECK: Mutex [[M2]] created at:
|
||||
// CHECK: #1 main {{.*}}/mutexset6.cc:[[@LINE+4]]
|
||||
// CHECK: Mutex [[M3]] created at:
|
||||
// CHECK: #1 main {{.*}}/mutexset6.cc:[[@LINE+3]]
|
||||
pthread_mutex_init(&mtx1, 0);
|
||||
pthread_spin_init(&mtx2, 0);
|
||||
pthread_rwlock_init(&mtx3, 0);
|
||||
|
|
@ -40,16 +51,3 @@ int main() {
|
|||
pthread_spin_destroy(&mtx2);
|
||||
pthread_rwlock_destroy(&mtx3);
|
||||
}
|
||||
|
||||
// CHECK: WARNING: ThreadSanitizer: data race
|
||||
// CHECK: Write of size 4 at {{.*}} by thread T1
|
||||
// CHECK: (mutexes: write [[M1:M[0-9]+]]):
|
||||
// CHECK: Previous write of size 4 at {{.*}} by thread T2
|
||||
// CHECK: (mutexes: write [[M2:M[0-9]+]], read [[M3:M[0-9]+]]):
|
||||
// CHECK: Mutex [[M1]] created at:
|
||||
// CHECK: #1 main {{.*}}/mutexset6.cc:31
|
||||
// CHECK: Mutex [[M2]] created at:
|
||||
// CHECK: #1 main {{.*}}/mutexset6.cc:32
|
||||
// CHECK: Mutex [[M3]] created at:
|
||||
// CHECK: #1 main {{.*}}/mutexset6.cc:33
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@
|
|||
#include <unistd.h>
|
||||
|
||||
static void handler(int, siginfo_t*, void*) {
|
||||
// CHECK: WARNING: ThreadSanitizer: signal-unsafe call inside of a signal
|
||||
// CHECK: #0 malloc
|
||||
// CHECK: #1 handler(int, siginfo*, void*) {{.*}}signal_malloc.cc:[[@LINE+1]]
|
||||
volatile char *p = (char*)malloc(1);
|
||||
p[0] = 0;
|
||||
free((void*)p);
|
||||
|
|
@ -20,7 +23,3 @@ int main() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
// CHECK: WARNING: ThreadSanitizer: signal-unsafe call inside of a signal
|
||||
// CHECK: #0 malloc
|
||||
// CHECK: #1 handler(int, siginfo*, void*) {{.*}}signal_malloc.cc:9
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue