summaryrefslogtreecommitdiff
path: root/test/lsan
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
commit3c500481535330e5188eb198c9e06d9ccba739c5 (patch)
treedc35d26ca2161dde4a8c90a6e936cf584dd17703 /test/lsan
parentd4f13ca07b5d463732187c9e3d15653cdf88e2f5 (diff)
[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. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@284722 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/lsan')
-rw-r--r--test/lsan/TestCases/cleanup_in_tsd_destructor.c5
-rw-r--r--test/lsan/TestCases/large_allocation_leak.cc5
-rw-r--r--test/lsan/TestCases/pointer_to_self.cc5
-rw-r--r--test/lsan/TestCases/stale_stack_leak.cc11
-rw-r--r--test/lsan/TestCases/use_after_return.cc7
-rw-r--r--test/lsan/TestCases/use_globals_initialized.cc5
-rw-r--r--test/lsan/TestCases/use_globals_uninitialized.cc5
-rw-r--r--test/lsan/TestCases/use_poisoned_asan.cc5
-rw-r--r--test/lsan/TestCases/use_registers.cc5
-rw-r--r--test/lsan/TestCases/use_stacks.cc5
-rw-r--r--test/lsan/TestCases/use_stacks_threaded.cc5
-rw-r--r--test/lsan/TestCases/use_tls_dynamic.cc5
-rw-r--r--test/lsan/TestCases/use_tls_pthread_specific_dynamic.cc5
-rw-r--r--test/lsan/TestCases/use_tls_pthread_specific_static.cc5
-rw-r--r--test/lsan/TestCases/use_tls_static.cc5
-rw-r--r--test/lsan/TestCases/use_unaligned.cc5
16 files changed, 52 insertions, 36 deletions
diff --git a/test/lsan/TestCases/cleanup_in_tsd_destructor.c b/test/lsan/TestCases/cleanup_in_tsd_destructor.c
index debf05c20..c43f696af 100644
--- a/test/lsan/TestCases/cleanup_in_tsd_destructor.c
+++ b/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/test/lsan/TestCases/large_allocation_leak.cc b/test/lsan/TestCases/large_allocation_leak.cc
index f41143a8a..70b36c96e 100644
--- a/test/lsan/TestCases/large_allocation_leak.cc
+++ b/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/test/lsan/TestCases/pointer_to_self.cc b/test/lsan/TestCases/pointer_to_self.cc
index 63bde2ccf..5696a6565 100644
--- a/test/lsan/TestCases/pointer_to_self.cc
+++ b/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/test/lsan/TestCases/stale_stack_leak.cc b/test/lsan/TestCases/stale_stack_leak.cc
index 4b8a54edf..4bba1f73c 100644
--- a/test/lsan/TestCases/stale_stack_leak.cc
+++ b/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/test/lsan/TestCases/use_after_return.cc b/test/lsan/TestCases/use_after_return.cc
index eb917c01e..903e3e373 100644
--- a/test/lsan/TestCases/use_after_return.cc
+++ b/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/test/lsan/TestCases/use_globals_initialized.cc b/test/lsan/TestCases/use_globals_initialized.cc
index 172d22a9f..bb2b3f659 100644
--- a/test/lsan/TestCases/use_globals_initialized.cc
+++ b/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/test/lsan/TestCases/use_globals_uninitialized.cc b/test/lsan/TestCases/use_globals_uninitialized.cc
index 2daa66161..46d9f65a8 100644
--- a/test/lsan/TestCases/use_globals_uninitialized.cc
+++ b/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/test/lsan/TestCases/use_poisoned_asan.cc b/test/lsan/TestCases/use_poisoned_asan.cc
index a1c544c55..c2b7bbcfd 100644
--- a/test/lsan/TestCases/use_poisoned_asan.cc
+++ b/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/test/lsan/TestCases/use_registers.cc b/test/lsan/TestCases/use_registers.cc
index 74301a26c..49c370261 100644
--- a/test/lsan/TestCases/use_registers.cc
+++ b/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/test/lsan/TestCases/use_stacks.cc b/test/lsan/TestCases/use_stacks.cc
index 7afcde15c..708f352d7 100644
--- a/test/lsan/TestCases/use_stacks.cc
+++ b/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/test/lsan/TestCases/use_stacks_threaded.cc b/test/lsan/TestCases/use_stacks_threaded.cc
index a1d4383e9..9effa325c 100644
--- a/test/lsan/TestCases/use_stacks_threaded.cc
+++ b/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/test/lsan/TestCases/use_tls_dynamic.cc b/test/lsan/TestCases/use_tls_dynamic.cc
index 207894b0f..208df11ea 100644
--- a/test/lsan/TestCases/use_tls_dynamic.cc
+++ b/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/test/lsan/TestCases/use_tls_pthread_specific_dynamic.cc b/test/lsan/TestCases/use_tls_pthread_specific_dynamic.cc
index 14883712e..b80c4603e 100644
--- a/test/lsan/TestCases/use_tls_pthread_specific_dynamic.cc
+++ b/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/test/lsan/TestCases/use_tls_pthread_specific_static.cc b/test/lsan/TestCases/use_tls_pthread_specific_static.cc
index 1fd5681b6..2225bf1e9 100644
--- a/test/lsan/TestCases/use_tls_pthread_specific_static.cc
+++ b/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/test/lsan/TestCases/use_tls_static.cc b/test/lsan/TestCases/use_tls_static.cc
index 50db23abb..6f04ba27e 100644
--- a/test/lsan/TestCases/use_tls_static.cc
+++ b/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/test/lsan/TestCases/use_unaligned.cc b/test/lsan/TestCases/use_unaligned.cc
index 3e43ed4c0..8ecfa9ba6 100644
--- a/test/lsan/TestCases/use_unaligned.cc
+++ b/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: