From 0592da8c4783d4a1412987ec49b697f3806ebff0 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Fri, 23 Nov 2018 01:17:28 +0300 Subject: [PATCH] Print relevant message in tests not appropriate for leak detection mode * cord/tests/cordtest.c (main): If GC_get_find_leak() then print a message that the test is not designed for leak detection mode (i.e., plenty of leaks could be reported). * tests/disclaim_bench.c (main): Likewise. * tests/disclaim_test.c (main): Likewise. * tests/disclaim_weakmap_test.c (main): Likewise. * tests/initsecondarythread.c (main): Likewise. * tests/middle.c (main): Likewise. * tests/realloc_test.c (main): Likewise. * tests/staticrootstest.c (main): Likewise. * tests/test_cpp.cc (main): Likewise. * tests/threadkey_test.c (main): Likewise. * tests/trace_test.c (main): Likewise. --- cord/tests/cordtest.c | 2 ++ tests/disclaim_bench.c | 2 ++ tests/disclaim_test.c | 2 ++ tests/disclaim_weakmap_test.c | 2 ++ tests/initsecondarythread.c | 2 ++ tests/middle.c | 2 ++ tests/realloc_test.c | 2 ++ tests/staticrootstest.c | 2 ++ tests/test_cpp.cc | 2 ++ tests/threadkey_test.c | 4 +++- tests/trace_test.c | 3 +++ 11 files changed, 24 insertions(+), 1 deletion(-) diff --git a/cord/tests/cordtest.c b/cord/tests/cordtest.c index 73ab82aa..f4868fd5 100644 --- a/cord/tests/cordtest.c +++ b/cord/tests/cordtest.c @@ -312,6 +312,8 @@ int main(void) # ifndef NO_INCREMENTAL GC_enable_incremental(); # endif + if (GC_get_find_leak()) + printf("This test program is not designed for leak detection mode\n"); test_basics(); test_extras(); test_printf(); diff --git a/tests/disclaim_bench.c b/tests/disclaim_bench.c index 8be81cf6..28feb1a5 100644 --- a/tests/disclaim_bench.c +++ b/tests/disclaim_bench.c @@ -121,6 +121,8 @@ int main(int argc, char **argv) model_min = 0; model_max = 2; } + if (GC_get_find_leak()) + printf("This test program is not designed for leak detection mode\n"); keep_arr = (testobj_t *)GC_MALLOC(sizeof(void *) * KEEP_CNT); if (NULL == keep_arr) { diff --git a/tests/disclaim_test.c b/tests/disclaim_test.c index 4febf7f7..f76f5ced 100644 --- a/tests/disclaim_test.c +++ b/tests/disclaim_test.c @@ -241,6 +241,8 @@ int main(void) # ifndef NO_INCREMENTAL GC_enable_incremental(); # endif + if (GC_get_find_leak()) + printf("This test program is not designed for leak detection mode\n"); test_misc_sizes(); diff --git a/tests/disclaim_weakmap_test.c b/tests/disclaim_weakmap_test.c index 9f40e452..7fb63a2f 100644 --- a/tests/disclaim_weakmap_test.c +++ b/tests/disclaim_weakmap_test.c @@ -432,6 +432,8 @@ int main(void) # ifndef NO_INCREMENTAL GC_enable_incremental(); # endif + if (GC_get_find_leak()) + printf("This test program is not designed for leak detection mode\n"); weakobj_free_list = GC_new_free_list(); CHECK_OOM(weakobj_free_list); diff --git a/tests/initsecondarythread.c b/tests/initsecondarythread.c index 788a8625..0ad855d8 100644 --- a/tests/initsecondarythread.c +++ b/tests/initsecondarythread.c @@ -85,6 +85,8 @@ int main(void) GC_INIT(); # endif (void)GC_get_parallel(); /* linking fails if no threads support */ + if (GC_get_find_leak()) + printf("This test program is not designed for leak detection mode\n"); # ifdef GC_PTHREADS if ((code = pthread_create (&t, NULL, thread, NULL)) != 0) { fprintf(stderr, "Thread creation failed %d\n", code); diff --git a/tests/middle.c b/tests/middle.c index 55686f75..9a7cc3d0 100644 --- a/tests/middle.c +++ b/tests/middle.c @@ -11,6 +11,8 @@ int main (void) GC_set_all_interior_pointers(0); GC_INIT(); + if (GC_get_find_leak()) + printf("This test program is not designed for leak detection mode\n"); for (i = 0; i < 20000; ++i) { (void)GC_malloc_atomic(4096); diff --git a/tests/realloc_test.c b/tests/realloc_test.c index c7c80d73..8870971b 100644 --- a/tests/realloc_test.c +++ b/tests/realloc_test.c @@ -10,6 +10,8 @@ int main(void) { unsigned long last_heap_size = 0; GC_INIT(); + if (GC_get_find_leak()) + printf("This test program is not designed for leak detection mode\n"); for (i = 0; i < COUNT; i++) { int **p = GC_NEW(int *); diff --git a/tests/staticrootstest.c b/tests/staticrootstest.c index b43765d0..66aca299 100644 --- a/tests/staticrootstest.c +++ b/tests/staticrootstest.c @@ -49,6 +49,8 @@ int main(void) GC_INIT(); # endif init_staticroot(); + if (GC_get_find_leak()) + printf("This test program is not designed for leak detection mode\n"); if (NULL == staticroot) { fprintf(stderr, "GC_malloc returned NULL\n"); return 2; diff --git a/tests/test_cpp.cc b/tests/test_cpp.cc index db3de022..176b5266 100644 --- a/tests/test_cpp.cc +++ b/tests/test_cpp.cc @@ -309,6 +309,8 @@ void* Undisguise( GC_word i ) { # ifndef NO_INCREMENTAL GC_enable_incremental(); # endif + if (GC_get_find_leak()) + GC_printf("This test program is not designed for leak detection mode\n"); int i, iters, n; # ifndef DONT_USE_STD_ALLOCATOR diff --git a/tests/threadkey_test.c b/tests/threadkey_test.c index e348d724..e224aac9 100644 --- a/tests/threadkey_test.c +++ b/tests/threadkey_test.c @@ -87,8 +87,10 @@ void make_key (void) int main (void) { int i; - GC_INIT (); + GC_INIT(); + if (GC_get_find_leak()) + printf("This test program is not designed for leak detection mode\n"); # ifdef GC_SOLARIS_THREADS pthread_key_create (&key, on_thread_exit); # else diff --git a/tests/trace_test.c b/tests/trace_test.c index 726519d0..d97bbed1 100644 --- a/tests/trace_test.c +++ b/tests/trace_test.c @@ -39,7 +39,10 @@ struct treenode * mktree(int i) { int main(void) { int i; + GC_INIT(); + if (GC_get_find_leak()) + printf("This test program is not designed for leak detection mode\n"); for (i = 0; i < 10; ++i) { root[i] = mktree(12); } -- 2.40.0