summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2012-03-06 17:26:24 +0100
committerIvan Maidanski <ivmai@mail.ru>2012-03-06 17:40:35 +0100
commitd952e32f2864c157cfa2583355a17c5cf7796663 (patch)
tree9ca6c05f4a76a086e285700f58eb53433ff02f01 /tests
parent1a4dd0e75fd177ddf7eadf8654057ed243fc0c2d (diff)
Fix gctest (for Win32) to avoid GC_print_stats internal variable usage
(Apply commit 9dc445d from 'master' branch) * include/private/gc_priv.h (GC_print_stats): Update the comment. * tests/test.c (GC_print_stats, run_one_test, check_heap_stats): Rename GC_print_stats to print_stats (since the former is used internally by GC and not exported). * tests/test.c (print_stats): Always define (either as a macro or a static int variable) regardless of GC_DLL and SMALL_CONFIG. * tests/test.c (INIT_PRINT_STATS): New macro (used to initialize print_stats if needed); GETENV is used if needed and available. * tests/test.c (GC_COND_INIT): Invoke INIT_PRINT_STATS.
Diffstat (limited to 'tests')
-rw-r--r--tests/test.c43
1 files changed, 27 insertions, 16 deletions
diff --git a/tests/test.c b/tests/test.c
index 70d7733..8d20479 100644
--- a/tests/test.c
+++ b/tests/test.c
@@ -56,14 +56,25 @@
# include <windows.h>
# endif
-# ifdef GC_DLL
-# ifdef GC_PRINT_VERBOSE_STATS
-# define GC_print_stats VERBOSE
-# else
-# define GC_print_stats 0 /* Not exported from DLL */
- /* Redefine to 1 to generate output. */
-# endif
+#ifdef GC_PRINT_VERBOSE_STATS
+# define print_stats VERBOSE
+# define INIT_PRINT_STATS /* empty */
+#else
+ /* Use own variable as GC_print_stats might not be exported. */
+ static int print_stats = 0;
+# ifdef GC_READ_ENV_FILE
+ /* GETENV uses GC internal function in this case. */
+# define INIT_PRINT_STATS /* empty */
+# else
+# define INIT_PRINT_STATS \
+ { \
+ if (0 != GETENV("GC_PRINT_VERBOSE_STATS")) \
+ print_stats = VERBOSE; \
+ else if (0 != GETENV("GC_PRINT_STATS")) \
+ print_stats = 1; \
+ }
# endif
+#endif /* !GC_PRINT_VERBOSE_STATS */
# ifdef PCR
# include "th/PCR_ThCrSec.h"
@@ -98,9 +109,9 @@
#if defined(CYGWIN32) || defined (AIX) || defined(DARWIN) \
|| defined(THREAD_LOCAL_ALLOC) \
|| (defined(MSWINCE) && !defined(GC_WINMAIN_REDIRECT))
-# define GC_COND_INIT() GC_INIT(); CHECH_GCLIB_VERSION
+# define GC_COND_INIT() GC_INIT(); CHECH_GCLIB_VERSION; INIT_PRINT_STATS
#else
-# define GC_COND_INIT() CHECH_GCLIB_VERSION
+# define GC_COND_INIT() CHECH_GCLIB_VERSION; INIT_PRINT_STATS
#endif
#define CHECK_OUT_OF_MEMORY(p) \
@@ -1204,7 +1215,7 @@ void run_one_test(void)
/* Repeated list reversal test. */
GET_TIME(start_time);
reverse_test();
- if (GC_print_stats) {
+ if (print_stats) {
GET_TIME(reverse_time);
time_diff = MS_TIME_DIFF(reverse_time, start_time);
GC_log_printf("-------------Finished reverse_test at time %u (%p)\n",
@@ -1212,7 +1223,7 @@ void run_one_test(void)
}
# ifndef DBG_HDRS_ALL
typed_test();
- if (GC_print_stats) {
+ if (print_stats) {
GET_TIME(typed_time);
time_diff = MS_TIME_DIFF(typed_time, start_time);
GC_log_printf("-------------Finished typed_test at time %u (%p)\n",
@@ -1220,7 +1231,7 @@ void run_one_test(void)
}
# endif /* DBG_HDRS_ALL */
tree_test();
- if (GC_print_stats) {
+ if (print_stats) {
GET_TIME(tree_time);
time_diff = MS_TIME_DIFF(tree_time, start_time);
GC_log_printf("-------------Finished tree_test at time %u (%p)\n",
@@ -1228,7 +1239,7 @@ void run_one_test(void)
}
/* Run reverse_test a second time, so we hopefully notice corruption. */
reverse_test();
- if (GC_print_stats) {
+ if (print_stats) {
GET_TIME(reverse_time);
time_diff = MS_TIME_DIFF(reverse_time, start_time);
GC_log_printf(
@@ -1247,12 +1258,12 @@ void run_one_test(void)
GC_gcollect();
tiny_reverse_test(0);
GC_gcollect();
- if (GC_print_stats)
+ if (print_stats)
GC_log_printf("Finished a child process\n");
exit(0);
}
# endif
- if (GC_print_stats)
+ if (print_stats)
GC_log_printf("Finished %p\n", &start_time);
}
@@ -1308,7 +1319,7 @@ void check_heap_stats(void)
# endif
GC_invoke_finalizers();
}
- if (GC_print_stats) {
+ if (print_stats) {
GC_log_printf("Primordial thread stack bottom: %p\n",
GC_stackbottom);
}