summaryrefslogtreecommitdiffstats
path: root/bus/dispatch.c
diff options
context:
space:
mode:
Diffstat (limited to 'bus/dispatch.c')
-rw-r--r--bus/dispatch.c61
1 files changed, 27 insertions, 34 deletions
diff --git a/bus/dispatch.c b/bus/dispatch.c
index 7db4ac29..2b1dc782 100644
--- a/bus/dispatch.c
+++ b/bus/dispatch.c
@@ -916,49 +916,42 @@ check_hello_connection (BusContext *context)
return TRUE;
}
-static void
-check1_try_iterations (BusContext *context,
- const char *description,
- Check1Func func)
+typedef struct
{
- int approx_mallocs;
-
- /* Run once to see about how many mallocs are involved */
-
- _dbus_set_fail_alloc_counter (_DBUS_INT_MAX);
-
- if (! (*func) (context))
- _dbus_assert_not_reached ("test failed");
+ Check1Func func;
+ BusContext *context;
+} Check1Data;
- approx_mallocs = _DBUS_INT_MAX - _dbus_get_fail_alloc_counter ();
+static dbus_bool_t
+check_oom_check1_func (void *data)
+{
+ Check1Data *d = data;
- _dbus_verbose ("=================\n%s: about %d mallocs total\n=================\n",
- description, approx_mallocs);
-
- approx_mallocs += 10; /* fudge factor */
-
- /* Now run failing each malloc */
+ if (! (* d->func) (d->context))
+ return FALSE;
- while (approx_mallocs >= 0)
+ if (!check_no_leftovers (d->context))
{
- _dbus_set_fail_alloc_counter (approx_mallocs);
-
- _dbus_verbose ("\n===\n %s: (will fail malloc %d)\n===\n",
- description, approx_mallocs);
+ _dbus_warn ("Messages were left over, should be covered by test suite");
+ return FALSE;
+ }
- if (! (*func) (context))
- _dbus_assert_not_reached ("test failed");
+ return TRUE;
+}
- if (!check_no_leftovers (context))
- _dbus_assert_not_reached ("Messages were left over, should be covered by test suite");
-
- approx_mallocs -= 1;
- }
+static void
+check1_try_iterations (BusContext *context,
+ const char *description,
+ Check1Func func)
+{
+ Check1Data d;
- _dbus_set_fail_alloc_counter (_DBUS_INT_MAX);
+ d.func = func;
+ d.context = context;
- _dbus_verbose ("=================\n%s: all iterations passed\n=================\n",
- description);
+ if (!_dbus_test_oom_handling (description, check_oom_check1_func,
+ &d))
+ _dbus_assert_not_reached ("test failed");
}
dbus_bool_t