From 77b14843ec9990facf63586919c865d59c3a5996 Mon Sep 17 00:00:00 2001 From: Nils Durner Date: Sat, 29 Aug 2009 17:46:36 +0000 Subject: don't fail in testcases --- src/include/gnunet_common.h | 7 ++++--- src/util/common_logging.c | 6 +++++- src/util/test_disk.c | 6 +++--- src/util/test_getopt.c | 2 ++ src/util/test_plugin.c | 4 ++-- src/util/test_time.c | 12 ++++++------ 6 files changed, 22 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h index aacf6328a..614fd3824 100644 --- a/src/include/gnunet_common.h +++ b/src/include/gnunet_common.h @@ -171,10 +171,11 @@ GNUNET_log_from (enum GNUNET_ErrorType kind, /** * Ignore the next n calls to the log function. * - * @param n number of log calls to ignore, use 0 to - * assert that the log skip counter is currently zero. + * @param n number of log calls to ignore + * @param check_reset GNUNET_YES to assert that the log skip counter is currently zero */ -void GNUNET_log_skip (unsigned int n); +void +GNUNET_log_skip (unsigned int n, int check_reset); /** diff --git a/src/util/common_logging.c b/src/util/common_logging.c index 0ed40b839..263aa7bac 100644 --- a/src/util/common_logging.c +++ b/src/util/common_logging.c @@ -273,12 +273,16 @@ flush_bulk (const char *datestr) * Ignore the next n calls to the log function. * * @param n number of log calls to ignore + * @param check_reset GNUNET_YES to assert that the log skip counter is currently zero */ void -GNUNET_log_skip (unsigned int n) +GNUNET_log_skip (unsigned int n, int check_reset) { if (n == 0) skip_log = 0; + if (check_reset) + GNUNET_assert (ok); + } else skip_log += n; } diff --git a/src/util/test_disk.c b/src/util/test_disk.c index f2bdb19d7..f978287ae 100644 --- a/src/util/test_disk.c +++ b/src/util/test_disk.c @@ -102,9 +102,9 @@ testOpenClose () GNUNET_break (0 == UNLINK (".testfile")); /* test that avail goes down as we fill the disk... */ - GNUNET_log_skip (1); + GNUNET_log_skip (1, GNUNET_NO); avail = GNUNET_DISK_get_blocks_available (".testfile"); - GNUNET_log_skip (0); + GNUNET_log_skip (0, GNUNET_NO); fh = GNUNET_DISK_file_open (".testfile", GNUNET_DISK_OPEN_READWRITE | GNUNET_DISK_OPEN_CREATE, GNUNET_DISK_PERM_USER_WRITE | GNUNET_DISK_PERM_USER_READ); @@ -223,7 +223,7 @@ testCanonicalize () static int testChangeOwner () { - GNUNET_log_skip (1); + GNUNET_log_skip (1, GNUNET_NO); if (GNUNET_OK == GNUNET_DISK_file_change_owner ("/dev/null", "unknownuser")) return 1; return 0; diff --git a/src/util/test_getopt.c b/src/util/test_getopt.c index 7168dd8c1..e254ac31f 100644 --- a/src/util/test_getopt.c +++ b/src/util/test_getopt.c @@ -196,7 +196,9 @@ main (int argc, char *argv[]) GNUNET_log_setup ("test_getopt", "WARNING", NULL); /* suppress output from -h, -v options */ +#ifndef MINGW GNUNET_break (0 == CLOSE (1)); +#endif if (0 != testMinimal ()) errCnt++; if (0 != testVerbose ()) diff --git a/src/util/test_plugin.c b/src/util/test_plugin.c index 22bf78b92..e574908a7 100644 --- a/src/util/test_plugin.c +++ b/src/util/test_plugin.c @@ -31,9 +31,9 @@ check () { void *ret; - GNUNET_log_skip (1); + GNUNET_log_skip (1, GNUNET_NO); ret = GNUNET_PLUGIN_load ("libgnunet_plugin_missing", NULL); - GNUNET_log_skip (0); + GNUNET_log_skip (0, GNUNET_NO); if (ret != NULL) return 1; ret = GNUNET_PLUGIN_load ("libgnunet_plugin_test", "in"); diff --git a/src/util/test_time.c b/src/util/test_time.c index 9505952c2..2454efd32 100644 --- a/src/util/test_time.c +++ b/src/util/test_time.c @@ -46,10 +46,10 @@ check () /* test overflow checking in multiply */ rel = GNUNET_TIME_UNIT_SECONDS; - GNUNET_log_skip (1); + GNUNET_log_skip (1, GNUNET_NO); for (i = 0; i < 55; i++) rel = GNUNET_TIME_relative_multiply (rel, 2); - GNUNET_log_skip (0); + GNUNET_log_skip (0, GNUNET_NO); GNUNET_assert (rel.value == GNUNET_TIME_UNIT_FOREVER_REL.value); /* test infinity-check for relative to absolute */ @@ -58,15 +58,15 @@ check () /* check overflow for r2a */ rel.value = ((uint64_t) - 1LL) - 1024; - GNUNET_log_skip (1); + GNUNET_log_skip (1, GNUNET_NO); last = GNUNET_TIME_relative_to_absolute (rel); - GNUNET_log_skip (0); + GNUNET_log_skip (0, GNUNET_NO); GNUNET_assert (last.value == GNUNET_TIME_UNIT_FOREVER_ABS.value); /* check overflow for relative add */ - GNUNET_log_skip (1); + GNUNET_log_skip (1, GNUNET_NO); rel = GNUNET_TIME_relative_add (rel, rel); - GNUNET_log_skip (0); + GNUNET_log_skip (0, GNUNET_NO); GNUNET_assert (rel.value == GNUNET_TIME_UNIT_FOREVER_REL.value); /* check relation check in get_duration */ -- cgit v1.2.3