} CheckData;
static dbus_bool_t
-check_func (void *data)
+check_func (void *data,
+ dbus_bool_t have_memory)
{
CheckData *d;
BusActivationEntry *entry;
if (oom_test)
err = !_dbus_test_oom_handling (description, check_func, data);
else
- err = !check_func (data);
+ err = !check_func (data, TRUE);
if (err)
_dbus_test_fatal ("Test failed");
unsigned int keep_umask : 1;
unsigned int allow_anonymous : 1;
unsigned int systemd_activation : 1;
+#ifdef DBUS_ENABLE_EMBEDDED_TESTS
+ unsigned int quiet_log : 1;
+#endif
dbus_bool_t watches_enabled;
};
if (!_dbus_string_append_printf_valist (&full_msg, msg, args))
goto oom_out;
- _dbus_log (severity, "%s", _dbus_string_get_const_data (&full_msg));
+#ifdef DBUS_ENABLE_EMBEDDED_TESTS
+ if (severity > DBUS_SYSTEM_LOG_WARNING || !context->quiet_log)
+#endif
+ _dbus_log (severity, "%s", _dbus_string_get_const_data (&full_msg));
+
oom_out:
_dbus_string_free (&full_msg);
}
_dbus_server_toggle_all_watches (server, enabled);
}
}
+
+#ifdef DBUS_ENABLE_EMBEDDED_TESTS
+void
+bus_context_quiet_log_begin (BusContext *context)
+{
+ context->quiet_log = TRUE;
+}
+
+void
+bus_context_quiet_log_end (BusContext *context)
+{
+ context->quiet_log = FALSE;
+}
+#endif
DBusError *error);
void bus_context_check_all_watches (BusContext *context);
+#ifdef DBUS_ENABLE_EMBEDDED_TESTS
+void bus_context_quiet_log_begin (BusContext *context);
+void bus_context_quiet_log_end (BusContext *context);
+#endif
+
#endif /* BUS_BUS_H */
} Check1Data;
static dbus_bool_t
-check_oom_check1_func (void *data)
+check_oom_check1_func (void *data,
+ dbus_bool_t have_memory)
{
+ dbus_bool_t ret = TRUE;
Check1Data *d = data;
+ if (!have_memory)
+ bus_context_quiet_log_begin (d->context);
+
if (! (* d->func) (d->context))
- return FALSE;
+ ret = FALSE;
+
+ if (!have_memory)
+ bus_context_quiet_log_end (d->context);
- if (!check_no_leftovers (d->context))
+ if (ret && !check_no_leftovers (d->context))
{
_dbus_warn ("Messages were left over, should be covered by test suite");
- return FALSE;
+ ret = FALSE;
}
- return TRUE;
+ return ret;
}
static void
} Check2Data;
static dbus_bool_t
-check_oom_check2_func (void *data)
+check_oom_check2_func (void *data,
+ dbus_bool_t have_memory)
{
+ dbus_bool_t ret = TRUE;
Check2Data *d = data;
+ if (!have_memory)
+ bus_context_quiet_log_begin (d->context);
+
if (! (* d->func) (d->context, d->connection))
- return FALSE;
+ ret = FALSE;
+
+ if (!have_memory)
+ bus_context_quiet_log_end (d->context);
- if (!check_no_leftovers (d->context))
+ if (ret && !check_no_leftovers (d->context))
{
_dbus_warn ("Messages were left over, should be covered by test suite");
- return FALSE;
+ ret = FALSE;
}
- return TRUE;
+ return ret;
}
static void
}
static dbus_bool_t
-test_parsing (void *data)
+test_parsing (void *data,
+ dbus_bool_t have_memory)
{
BusMatchRule *rule;
/* returns true if good things happen, or if we get OOM */
static dbus_bool_t
-bus_activation_helper_oom_test (void *data)
+bus_activation_helper_oom_test (void *data,
+ dbus_bool_t have_memory)
{
const char *service;
DBusError error;
retval = TRUE;
dbus_error_init (&error);
+
if (!run_launch_helper (service, &error))
{
_DBUS_ASSERT_ERROR_IS_SET (&error);
description, n_mallocs,
_dbus_get_fail_alloc_failures ());
- if (!(* func) (data))
+ if (!(* func) (data, FALSE))
return FALSE;
n_mallocs -= 1;
_dbus_verbose ("Running once to count mallocs\n");
- if (!(* func) (data))
+ if (!(* func) (data, TRUE))
return FALSE;
approx_mallocs = _DBUS_INT_MAX - _dbus_get_fail_alloc_counter ();
const char *format,
va_list args) _DBUS_GNUC_PRINTF (3, 0);
-typedef dbus_bool_t (* DBusTestMemoryFunction) (void *data);
+typedef dbus_bool_t (* DBusTestMemoryFunction) (void *data,
+ dbus_bool_t have_memory);
#ifdef DBUS_ENABLE_EMBEDDED_TESTS
/* Memory debugging */
#define _dbus_disable_mem_pools() (FALSE)
#define _dbus_get_malloc_blocks_outstanding() (0)
-#define _dbus_test_oom_handling(description, func, data) ((*func) (data))
+#define _dbus_test_oom_handling(description, func, data) ((*func) (data, TRUE))
#endif /* !DBUS_ENABLE_EMBEDDED_TESTS */
typedef void (* DBusShutdownFunction) (void *data);
}
static dbus_bool_t
-run_test_nodes_iteration (void *data)
+run_test_nodes_iteration (void *data,
+ dbus_bool_t have_memory)
{
NodeIterationData *nid = data;
DBusTypeReader reader;
}
else
{
- if (!run_test_nodes_iteration (&nid))
+ if (!run_test_nodes_iteration (&nid, TRUE))
_dbus_test_fatal ("no memory");
}
/* Returns TRUE if the right thing happens, but the right thing might
* be OOM. */
static dbus_bool_t
-object_tree_test_iteration (void *data)
+object_tree_test_iteration (void *data,
+ dbus_bool_t have_memory)
{
const char *path0[] = { NULL };
const char *path1[] = { "foo", NULL };
}
static dbus_bool_t
-check_spawn_nonexistent (void *data)
+check_spawn_nonexistent (void *data,
+ dbus_bool_t have_memory)
{
static const char arg_does_not_exist[] = "/this/does/not/exist/32542sdgafgafdg";
}
static dbus_bool_t
-check_spawn_segfault (void *data)
+check_spawn_segfault (void *data,
+ dbus_bool_t have_memory)
{
char *argv[4] = { NULL, NULL, NULL, NULL };
DBusBabysitter *sitter = NULL;
}
static dbus_bool_t
-check_spawn_exit (void *data)
+check_spawn_exit (void *data,
+ dbus_bool_t have_memory)
{
char *argv[4] = { NULL, NULL, NULL, NULL };
DBusBabysitter *sitter = NULL;
}
static dbus_bool_t
-check_spawn_and_kill (void *data)
+check_spawn_and_kill (void *data,
+ dbus_bool_t have_memory)
{
char *argv[4] = { NULL, NULL, NULL, NULL };
DBusBabysitter *sitter = NULL;
/* Return TRUE on success or OOM, as per DBusTestMemoryFunction signature */
static dbus_bool_t
-test_once (void *data)
+test_once (void *data,
+ dbus_bool_t have_memory)
{
gboolean *really_succeeded = data;
Fixture fixture = { NULL, NULL };
{
gboolean really_succeeded = FALSE;
- if (!test_once (&really_succeeded))
+ if (!test_once (&really_succeeded, TRUE))
g_error ("Test failed");
if (!really_succeeded)
/* Return TRUE if the right thing happens, but the right thing might include
* OOM. */
static dbus_bool_t
-test_array (void *contained_signature)
+test_array (void *contained_signature,
+ dbus_bool_t have_memory)
{
DBusMessage *m;
DBusMessageIter iter;
/* Return TRUE if the right thing happens, but the right thing might include
* OOM or inability to pass fds. */
static dbus_bool_t
-test_fd (void *ignored)
+test_fd (void *ignored,
+ dbus_bool_t have_memory)
{
DBusMessage *m = NULL;
DBusPipe pipe;
* Return TRUE if the right thing happens, but the right thing might include
* OOM. */
static dbus_bool_t
-test_zero_iter (void *ignored)
+test_zero_iter (void *ignored,
+ dbus_bool_t have_memory)
{
DBusMessage *m;
DBusMessageIter iter = DBUS_MESSAGE_ITER_INIT_CLOSED;