diff options
author | Simon McVittie <smcv@collabora.com> | 2017-11-28 13:29:58 +0000 |
---|---|---|
committer | Simon McVittie <smcv@collabora.com> | 2017-12-04 11:52:59 +0000 |
commit | c58238f53fc2547063d842ed1cae91137af22458 (patch) | |
tree | b87d09d905e12d4769aaaab69bbe6d4815ec4c1f | |
parent | 5c91d85f3ed462dac1e011aab216c9021e826773 (diff) |
_dbus_test_oom_handling: print TAP diagnostics
These aren't *that* verbose, so it seems OK to print them all the time,
not just in the needlessly spammy verbose mode.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=100317
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Signed-off-by: Simon McVittie <smcv@collabora.com>
-rw-r--r-- | dbus/dbus-internals.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/dbus/dbus-internals.c b/dbus/dbus-internals.c index a20a5395..126e3e4b 100644 --- a/dbus/dbus-internals.c +++ b/dbus/dbus-internals.c @@ -26,6 +26,7 @@ #include "dbus-protocol.h" #include "dbus-marshal-basic.h" #include "dbus-test.h" +#include "dbus-test-tap.h" #include "dbus-valgrind-internal.h" #include <stdio.h> #include <stdarg.h> @@ -1044,15 +1045,15 @@ _dbus_test_oom_handling (const char *description, _dbus_set_fail_alloc_counter (_DBUS_INT_MAX); - _dbus_verbose ("Running once to count mallocs\n"); - + _dbus_test_diag ("Running \"%s\" once to count mallocs", description); + if (!(* func) (data, TRUE)) return FALSE; - + approx_mallocs = _DBUS_INT_MAX - _dbus_get_fail_alloc_counter (); - _dbus_verbose ("\n=================\n%s: about %d mallocs total\n=================\n", - description, approx_mallocs); + _dbus_test_diag ("\"%s\" has about %d mallocs in total", + description, approx_mallocs); setting = _dbus_getenv ("DBUS_TEST_MALLOC_FAILURES"); if (setting != NULL) @@ -1072,21 +1073,26 @@ _dbus_test_oom_handling (const char *description, if (max_failures_to_try < 1) { - _dbus_verbose ("not testing OOM handling\n"); + _dbus_test_diag ("not testing OOM handling"); return TRUE; } + _dbus_test_diag ("testing \"%s\" with up to %d consecutive malloc failures", + description, max_failures_to_try); + i = setting ? max_failures_to_try - 1 : 1; while (i < max_failures_to_try) { + _dbus_test_diag ("testing \"%s\" with %d consecutive malloc failures", + description, i + 1); + _dbus_set_fail_alloc_failures (i); if (!run_failing_each_malloc (approx_mallocs, description, func, data)) return FALSE; ++i; } - _dbus_verbose ("\n=================\n%s: all iterations passed\n=================\n", - description); + _dbus_verbose ("\"%s\" coped OK with malloc failures", description); return TRUE; } |