summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStrahinja Petrovic <strahinja.petrovic@rt-rk.com>2016-10-20 12:25:57 +0000
committerStrahinja Petrovic <strahinja.petrovic@rt-rk.com>2016-10-20 12:25:57 +0000
commit19610a33c1c95a8d440640e6f9986b08a2bc6869 (patch)
tree5f8694f07b11d36bdf455f3288be0a61d8e81359
parent2a8bef8769ebe355e76060ad964ae95bfaf5eafb (diff)
downloadbcm5719-llvm-19610a33c1c95a8d440640e6f9986b08a2bc6869.tar.gz
bcm5719-llvm-19610a33c1c95a8d440640e6f9986b08a2bc6869.zip
[lsan] [aarch64] Fix printing of pointers in make check tests
This patch replaces fprintf with print_address function in LSAN tests. This is necessary because of different printing of pointers in fprintf and sanitizer's print function. Differential Revision: https://reviews.llvm.org/D25270. llvm-svn: 284722
-rw-r--r--compiler-rt/test/lsan/TestCases/cleanup_in_tsd_destructor.c5
-rw-r--r--compiler-rt/test/lsan/TestCases/large_allocation_leak.cc5
-rw-r--r--compiler-rt/test/lsan/TestCases/pointer_to_self.cc5
-rw-r--r--compiler-rt/test/lsan/TestCases/stale_stack_leak.cc11
-rw-r--r--compiler-rt/test/lsan/TestCases/use_after_return.cc7
-rw-r--r--compiler-rt/test/lsan/TestCases/use_globals_initialized.cc5
-rw-r--r--compiler-rt/test/lsan/TestCases/use_globals_uninitialized.cc5
-rw-r--r--compiler-rt/test/lsan/TestCases/use_poisoned_asan.cc5
-rw-r--r--compiler-rt/test/lsan/TestCases/use_registers.cc5
-rw-r--r--compiler-rt/test/lsan/TestCases/use_stacks.cc5
-rw-r--r--compiler-rt/test/lsan/TestCases/use_stacks_threaded.cc5
-rw-r--r--compiler-rt/test/lsan/TestCases/use_tls_dynamic.cc5
-rw-r--r--compiler-rt/test/lsan/TestCases/use_tls_pthread_specific_dynamic.cc5
-rw-r--r--compiler-rt/test/lsan/TestCases/use_tls_pthread_specific_static.cc5
-rw-r--r--compiler-rt/test/lsan/TestCases/use_tls_static.cc5
-rw-r--r--compiler-rt/test/lsan/TestCases/use_unaligned.cc5
16 files changed, 52 insertions, 36 deletions
diff --git a/compiler-rt/test/lsan/TestCases/cleanup_in_tsd_destructor.c b/compiler-rt/test/lsan/TestCases/cleanup_in_tsd_destructor.c
index debf05c2047..c43f696af91 100644
--- a/compiler-rt/test/lsan/TestCases/cleanup_in_tsd_destructor.c
+++ b/compiler-rt/test/lsan/TestCases/cleanup_in_tsd_destructor.c
@@ -14,6 +14,7 @@
#include <stdlib.h>
#include "sanitizer/lsan_interface.h"
+#include "../../tsan/test.h"
pthread_key_t key;
__thread void *p;
@@ -25,7 +26,7 @@ void key_destructor(void *arg) {
void *thread_func(void *arg) {
p = malloc(1337);
- fprintf(stderr, "Test alloc: %p.\n", p);
+ print_address("Test alloc: ", 1, p);
int res = pthread_setspecific(key, (void*)1);
assert(res == 0);
return 0;
@@ -41,5 +42,5 @@ int main() {
assert(res == 0);
return 0;
}
-// CHECK: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
// CHECK: [[ADDR]] (1337 bytes)
diff --git a/compiler-rt/test/lsan/TestCases/large_allocation_leak.cc b/compiler-rt/test/lsan/TestCases/large_allocation_leak.cc
index f41143a8a50..70b36c96e2b 100644
--- a/compiler-rt/test/lsan/TestCases/large_allocation_leak.cc
+++ b/compiler-rt/test/lsan/TestCases/large_allocation_leak.cc
@@ -5,14 +5,15 @@
#include <stdio.h>
#include <stdlib.h>
+#include "../../tsan/test.h"
int main() {
// maxsize in primary allocator is always less than this (1 << 25).
void *large_alloc = malloc(33554432);
- fprintf(stderr, "Test alloc: %p.\n", large_alloc);
+ print_address("Test alloc: ", 1, large_alloc);
return 0;
}
-// CHECK: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
// CHECK: LeakSanitizer: detected memory leaks
// CHECK: [[ADDR]] (33554432 bytes)
// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
diff --git a/compiler-rt/test/lsan/TestCases/pointer_to_self.cc b/compiler-rt/test/lsan/TestCases/pointer_to_self.cc
index 63bde2ccf35..5696a6565dd 100644
--- a/compiler-rt/test/lsan/TestCases/pointer_to_self.cc
+++ b/compiler-rt/test/lsan/TestCases/pointer_to_self.cc
@@ -6,13 +6,14 @@
#include <stdio.h>
#include <stdlib.h>
+#include "../../tsan/test.h"
int main() {
void *p = malloc(1337);
*reinterpret_cast<void **>(p) = p;
- fprintf(stderr, "Test alloc: %p.\n", p);
+ print_address("Test alloc: ", 1, p);
}
-// CHECK: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
// CHECK: LeakSanitizer: detected memory leaks
// CHECK: [[ADDR]] (1337 bytes)
// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
diff --git a/compiler-rt/test/lsan/TestCases/stale_stack_leak.cc b/compiler-rt/test/lsan/TestCases/stale_stack_leak.cc
index 4b8a54edf4c..4bba1f73c52 100644
--- a/compiler-rt/test/lsan/TestCases/stale_stack_leak.cc
+++ b/compiler-rt/test/lsan/TestCases/stale_stack_leak.cc
@@ -6,6 +6,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include "../../tsan/test.h"
void **pp;
@@ -18,7 +19,7 @@ void *PutPointerOnStaleStack(void *p) {
void *locals[2048];
locals[0] = p;
pp = &locals[0];
- fprintf(stderr, "Test alloc: %p.\n", locals[0]);
+ print_address("Test alloc: ", 1, locals[0]);
return 0;
}
@@ -33,11 +34,11 @@ int main() {
__attribute__((destructor))
__attribute__((no_sanitize_address))
void ConfirmPointerHasSurvived() {
- fprintf(stderr, "Value after LSan: %p.\n", *pp);
+ print_address("Value after LSan: ", 1, *pp);
}
-// CHECK: Test alloc: [[ADDR:.*]].
-// CHECK-sanity: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
+// CHECK-sanity: Test alloc: [[ADDR:0x[0-9,a-f]+]]
// CHECK: LeakSanitizer: detected memory leaks
// CHECK: [[ADDR]] (1337 bytes)
// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
-// CHECK-sanity: Value after LSan: [[ADDR]].
+// CHECK-sanity: Value after LSan: [[ADDR]]
diff --git a/compiler-rt/test/lsan/TestCases/use_after_return.cc b/compiler-rt/test/lsan/TestCases/use_after_return.cc
index eb917c01ea8..903e3e37357 100644
--- a/compiler-rt/test/lsan/TestCases/use_after_return.cc
+++ b/compiler-rt/test/lsan/TestCases/use_after_return.cc
@@ -8,16 +8,17 @@
#include <stdio.h>
#include <stdlib.h>
+#include "../../tsan/test.h"
int main() {
void *stack_var = malloc(1337);
- fprintf(stderr, "Test alloc: %p.\n", stack_var);
+ print_address("Test alloc: ", 1, stack_var);
// Take pointer to variable, to ensure it's not optimized into a register.
- fprintf(stderr, "Stack var at: %p.\n", &stack_var);
+ print_address("Stack var at: ", 1, &stack_var);
// Do not return from main to prevent the pointer from going out of scope.
exit(0);
}
-// CHECK: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
// CHECK: LeakSanitizer: detected memory leaks
// CHECK: [[ADDR]] (1337 bytes)
// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
diff --git a/compiler-rt/test/lsan/TestCases/use_globals_initialized.cc b/compiler-rt/test/lsan/TestCases/use_globals_initialized.cc
index 172d22a9f05..bb2b3f659f7 100644
--- a/compiler-rt/test/lsan/TestCases/use_globals_initialized.cc
+++ b/compiler-rt/test/lsan/TestCases/use_globals_initialized.cc
@@ -7,15 +7,16 @@
#include <stdio.h>
#include <stdlib.h>
+#include "../../tsan/test.h"
void *data_var = (void *)1;
int main() {
data_var = malloc(1337);
- fprintf(stderr, "Test alloc: %p.\n", data_var);
+ print_address("Test alloc: ", 1, data_var);
return 0;
}
-// CHECK: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
// CHECK: LeakSanitizer: detected memory leaks
// CHECK: [[ADDR]] (1337 bytes)
// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
diff --git a/compiler-rt/test/lsan/TestCases/use_globals_uninitialized.cc b/compiler-rt/test/lsan/TestCases/use_globals_uninitialized.cc
index 2daa661611f..46d9f65a819 100644
--- a/compiler-rt/test/lsan/TestCases/use_globals_uninitialized.cc
+++ b/compiler-rt/test/lsan/TestCases/use_globals_uninitialized.cc
@@ -7,15 +7,16 @@
#include <stdio.h>
#include <stdlib.h>
+#include "../../tsan/test.h"
void *bss_var;
int main() {
bss_var = malloc(1337);
- fprintf(stderr, "Test alloc: %p.\n", bss_var);
+ print_address("Test alloc: ", 1, bss_var);
return 0;
}
-// CHECK: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
// CHECK: LeakSanitizer: detected memory leaks
// CHECK: [[ADDR]] (1337 bytes)
// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
diff --git a/compiler-rt/test/lsan/TestCases/use_poisoned_asan.cc b/compiler-rt/test/lsan/TestCases/use_poisoned_asan.cc
index a1c544c55f2..c2b7bbcfd07 100644
--- a/compiler-rt/test/lsan/TestCases/use_poisoned_asan.cc
+++ b/compiler-rt/test/lsan/TestCases/use_poisoned_asan.cc
@@ -9,17 +9,18 @@
#include <stdlib.h>
#include <sanitizer/asan_interface.h>
#include <assert.h>
+#include "../../tsan/test.h"
void **p;
int main() {
p = new void *;
*p = malloc(1337);
- fprintf(stderr, "Test alloc: %p.\n", *p);
+ print_address("Test alloc: ", 1, *p);
__asan_poison_memory_region(p, sizeof(*p));
return 0;
}
-// CHECK: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
// CHECK: LeakSanitizer: detected memory leaks
// CHECK: [[ADDR]] (1337 bytes)
// CHECK: SUMMARY: AddressSanitizer:
diff --git a/compiler-rt/test/lsan/TestCases/use_registers.cc b/compiler-rt/test/lsan/TestCases/use_registers.cc
index 74301a26c32..49c3702618f 100644
--- a/compiler-rt/test/lsan/TestCases/use_registers.cc
+++ b/compiler-rt/test/lsan/TestCases/use_registers.cc
@@ -10,6 +10,7 @@
#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
+#include "../../tsan/test.h"
extern "C"
void *registers_thread_func(void *arg) {
@@ -35,7 +36,7 @@ void *registers_thread_func(void *arg) {
#else
#error "Test is not supported on this architecture."
#endif
- fprintf(stderr, "Test alloc: %p.\n", p);
+ print_address("Test alloc: ", 1, p);
fflush(stderr);
__sync_fetch_and_xor(sync, 1);
while (true)
@@ -51,7 +52,7 @@ int main() {
sched_yield();
return 0;
}
-// CHECK: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
// CHECK: LeakSanitizer: detected memory leaks
// CHECK: [[ADDR]] (1337 bytes)
// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
diff --git a/compiler-rt/test/lsan/TestCases/use_stacks.cc b/compiler-rt/test/lsan/TestCases/use_stacks.cc
index 7afcde15c73..708f352d782 100644
--- a/compiler-rt/test/lsan/TestCases/use_stacks.cc
+++ b/compiler-rt/test/lsan/TestCases/use_stacks.cc
@@ -7,14 +7,15 @@
#include <stdio.h>
#include <stdlib.h>
+#include "../../tsan/test.h"
int main() {
void *stack_var = malloc(1337);
- fprintf(stderr, "Test alloc: %p.\n", stack_var);
+ print_address("Test alloc: ", 1, stack_var);
// Do not return from main to prevent the pointer from going out of scope.
exit(0);
}
-// CHECK: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
// CHECK: LeakSanitizer: detected memory leaks
// CHECK: [[ADDR]] (1337 bytes)
// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
diff --git a/compiler-rt/test/lsan/TestCases/use_stacks_threaded.cc b/compiler-rt/test/lsan/TestCases/use_stacks_threaded.cc
index a1d4383e956..9effa325cc5 100644
--- a/compiler-rt/test/lsan/TestCases/use_stacks_threaded.cc
+++ b/compiler-rt/test/lsan/TestCases/use_stacks_threaded.cc
@@ -10,12 +10,13 @@
#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
+#include "../../tsan/test.h"
extern "C"
void *stacks_thread_func(void *arg) {
int *sync = reinterpret_cast<int *>(arg);
void *p = malloc(1337);
- fprintf(stderr, "Test alloc: %p.\n", p);
+ print_address("Test alloc: ", 1, p);
fflush(stderr);
__sync_fetch_and_xor(sync, 1);
while (true)
@@ -31,7 +32,7 @@ int main() {
sched_yield();
return 0;
}
-// CHECK: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
// CHECK: LeakSanitizer: detected memory leaks
// CHECK: [[ADDR]] (1337 bytes)
// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
diff --git a/compiler-rt/test/lsan/TestCases/use_tls_dynamic.cc b/compiler-rt/test/lsan/TestCases/use_tls_dynamic.cc
index 207894b0fff..208df11ea89 100644
--- a/compiler-rt/test/lsan/TestCases/use_tls_dynamic.cc
+++ b/compiler-rt/test/lsan/TestCases/use_tls_dynamic.cc
@@ -12,6 +12,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string>
+#include "../../tsan/test.h"
int main(int argc, char *argv[]) {
std::string path = std::string(argv[0]) + "-so.so";
@@ -26,10 +27,10 @@ int main(int argc, char *argv[]) {
// If we don't know about dynamic TLS, we will return a false leak above.
void **p_in_tls = StoreToTLS(p);
assert(*p_in_tls == p);
- fprintf(stderr, "Test alloc: %p.\n", p);
+ print_address("Test alloc: ", 1, p);
return 0;
}
-// CHECK: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
// CHECK: LeakSanitizer: detected memory leaks
// CHECK: [[ADDR]] (1337 bytes)
// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
diff --git a/compiler-rt/test/lsan/TestCases/use_tls_pthread_specific_dynamic.cc b/compiler-rt/test/lsan/TestCases/use_tls_pthread_specific_dynamic.cc
index 14883712e60..b80c4603e5d 100644
--- a/compiler-rt/test/lsan/TestCases/use_tls_pthread_specific_dynamic.cc
+++ b/compiler-rt/test/lsan/TestCases/use_tls_pthread_specific_dynamic.cc
@@ -9,6 +9,7 @@
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
+#include "../../tsan/test.h"
// From glibc: this many keys are stored in the thread descriptor directly.
const unsigned PTHREAD_KEY_2NDLEVEL_SIZE = 32;
@@ -28,10 +29,10 @@ int main() {
void *p = malloc(1337);
res = pthread_setspecific(key, p);
assert(res == 0);
- fprintf(stderr, "Test alloc: %p.\n", p);
+ print_address("Test alloc: ", 1, p);
return 0;
}
-// CHECK: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
// CHECK: LeakSanitizer: detected memory leaks
// CHECK: [[ADDR]] (1337 bytes)
// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
diff --git a/compiler-rt/test/lsan/TestCases/use_tls_pthread_specific_static.cc b/compiler-rt/test/lsan/TestCases/use_tls_pthread_specific_static.cc
index 1fd5681b608..2225bf1e9f1 100644
--- a/compiler-rt/test/lsan/TestCases/use_tls_pthread_specific_static.cc
+++ b/compiler-rt/test/lsan/TestCases/use_tls_pthread_specific_static.cc
@@ -9,6 +9,7 @@
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
+#include "../../tsan/test.h"
// From glibc: this many keys are stored in the thread descriptor directly.
const unsigned PTHREAD_KEY_2NDLEVEL_SIZE = 32;
@@ -22,10 +23,10 @@ int main() {
void *p = malloc(1337);
res = pthread_setspecific(key, p);
assert(res == 0);
- fprintf(stderr, "Test alloc: %p.\n", p);
+ print_address("Test alloc: ", 1, p);
return 0;
}
-// CHECK: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
// CHECK: LeakSanitizer: detected memory leaks
// CHECK: [[ADDR]] (1337 bytes)
// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
diff --git a/compiler-rt/test/lsan/TestCases/use_tls_static.cc b/compiler-rt/test/lsan/TestCases/use_tls_static.cc
index 50db23abb82..6f04ba27e17 100644
--- a/compiler-rt/test/lsan/TestCases/use_tls_static.cc
+++ b/compiler-rt/test/lsan/TestCases/use_tls_static.cc
@@ -7,15 +7,16 @@
#include <stdio.h>
#include <stdlib.h>
+#include "../../tsan/test.h"
__thread void *tls_var;
int main() {
tls_var = malloc(1337);
- fprintf(stderr, "Test alloc: %p.\n", tls_var);
+ print_address("Test alloc: ", 1, tls_var);
return 0;
}
-// CHECK: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
// CHECK: LeakSanitizer: detected memory leaks
// CHECK: [[ADDR]] (1337 bytes)
// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
diff --git a/compiler-rt/test/lsan/TestCases/use_unaligned.cc b/compiler-rt/test/lsan/TestCases/use_unaligned.cc
index 3e43ed4c092..8ecfa9ba6f4 100644
--- a/compiler-rt/test/lsan/TestCases/use_unaligned.cc
+++ b/compiler-rt/test/lsan/TestCases/use_unaligned.cc
@@ -7,17 +7,18 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include "../../tsan/test.h"
void *arr[2];
int main() {
void *p = malloc(1337);
- fprintf(stderr, "Test alloc: %p.\n", p);
+ print_address("Test alloc: ", 1, p);
char *char_arr = (char *)arr;
memcpy(char_arr + 1, &p, sizeof(p));
return 0;
}
-// CHECK: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
// CHECK: LeakSanitizer: detected memory leaks
// CHECK: [[ADDR]] (1337 bytes)
// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
OpenPOWER on IntegriCloud