1 /* Integration tests for monitor-mode D-Bus connections
3 * Copyright © 2010-2011 Nokia Corporation
4 * Copyright © 2015 Collabora Ltd.
6 * Permission is hereby granted, free of charge, to any person
7 * obtaining a copy of this software and associated documentation files
8 * (the "Software"), to deal in the Software without restriction,
9 * including without limitation the rights to use, copy, modify, merge,
10 * publish, distribute, sublicense, and/or sell copies of the Software,
11 * and to permit persons to whom the Software is furnished to do so,
12 * subject to the following conditions:
14 * The above copyright notice and this permission notice shall be
15 * included in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 #include "test-utils-glib.h"
34 const char *config_file;
35 const char * const *match_rules;
36 gboolean care_about_our_names;
48 DBusConnection *monitor;
49 DBusConnection *sender;
50 DBusConnection *recipient;
54 const char *monitor_name;
55 const char *sender_name;
56 const char *recipient_name;
58 DBusConnection *systemd;
59 const char *systemd_name;
60 DBusMessage *systemd_message;
61 DBusConnection *activated;
62 const char *activated_name;
63 DBusMessage *activated_message;
66 static const char * const no_match_rules[] = {
70 static const char * const wildcard_match_rules[] = {
76 static const char * const eavesdrop_match_rules[] = {
82 static const char * const no_eavesdrop_match_rules[] = {
88 static const char * const selective_match_rules[] = {
89 "interface='com.example.Interesting'",
90 "interface='com.example.Fun'",
95 static Config forbidding_config = {
96 "valid-config-files/forbidding.conf",
101 static Config wildcard_config = {
103 wildcard_match_rules,
107 static Config selective_config = {
109 selective_match_rules,
113 static Config no_rules_config = {
119 static Config eavesdrop_config = {
121 eavesdrop_match_rules,
125 static Config no_eavesdrop_config = {
127 no_eavesdrop_match_rules,
131 static Config fake_systemd_config = {
132 "valid-config-files/systemd-activation.conf",
137 static Config side_effects_config = {
143 static inline const char *
144 not_null2 (const char *x,
145 const char *fallback)
153 static inline const char *
154 not_null (const char *x)
156 return not_null2 (x, "(null)");
159 #define log_message(m) _log_message (m, __FILE__, __LINE__)
163 _log_message (DBusMessage *m,
167 g_test_message ("%s:%d: message type %d (%s)", file, line,
168 dbus_message_get_type (m),
169 dbus_message_type_to_string (dbus_message_get_type (m)));
170 g_test_message ("\tfrom: %s",
171 not_null2 (dbus_message_get_sender (m), "(dbus-daemon)"));
172 g_test_message ("\tto: %s",
173 not_null2 (dbus_message_get_destination (m), "(broadcast)"));
174 g_test_message ("\tpath: %s",
175 not_null (dbus_message_get_path (m)));
176 g_test_message ("\tinterface: %s",
177 not_null (dbus_message_get_interface (m)));
178 g_test_message ("\tmember: %s",
179 not_null (dbus_message_get_member (m)));
180 g_test_message ("\tsignature: %s",
181 not_null (dbus_message_get_signature (m)));
182 g_test_message ("\terror name: %s",
183 not_null (dbus_message_get_error_name (m)));
185 if (strcmp ("s", dbus_message_get_signature (m)) == 0)
187 DBusError e = DBUS_ERROR_INIT;
190 dbus_message_get_args (m, &e,
191 DBUS_TYPE_STRING, &s,
193 test_assert_no_error (&e);
194 g_test_message ("\tstring payload: %s", s);
198 /* these are macros so they get the right line number */
200 #define assert_hello(m) \
202 g_assert_cmpstr (dbus_message_type_to_string (dbus_message_get_type (m)), \
203 ==, dbus_message_type_to_string (DBUS_MESSAGE_TYPE_METHOD_CALL)); \
204 g_assert_cmpstr (dbus_message_get_destination (m), ==, DBUS_SERVICE_DBUS); \
205 g_assert_cmpstr (dbus_message_get_path (m), ==, DBUS_PATH_DBUS); \
206 g_assert_cmpstr (dbus_message_get_interface (m), ==, DBUS_INTERFACE_DBUS); \
207 g_assert_cmpstr (dbus_message_get_member (m), ==, "Hello"); \
208 g_assert_cmpstr (dbus_message_get_signature (m), ==, ""); \
209 g_assert_cmpint (dbus_message_get_serial (m), !=, 0); \
210 g_assert_cmpint (dbus_message_get_reply_serial (m), ==, 0); \
213 #define assert_hello_reply(m) \
215 DBusError _e = DBUS_ERROR_INIT; \
218 g_assert_cmpstr (dbus_message_type_to_string (dbus_message_get_type (m)), \
219 ==, dbus_message_type_to_string (DBUS_MESSAGE_TYPE_METHOD_RETURN)); \
220 g_assert_cmpstr (dbus_message_get_sender (m), ==, DBUS_SERVICE_DBUS); \
221 g_assert_cmpstr (dbus_message_get_path (m), ==, NULL); \
222 g_assert_cmpstr (dbus_message_get_interface (m), ==, NULL); \
223 g_assert_cmpstr (dbus_message_get_member (m), ==, NULL); \
224 g_assert_cmpstr (dbus_message_get_signature (m), ==, "s"); \
225 g_assert_cmpint (dbus_message_get_serial (m), !=, 0); \
226 g_assert_cmpint (dbus_message_get_reply_serial (m), !=, 0); \
228 dbus_message_get_args (m, &_e, \
229 DBUS_TYPE_STRING, &_s, \
230 DBUS_TYPE_INVALID); \
231 test_assert_no_error (&_e); \
232 g_assert_cmpstr (dbus_message_get_destination (m), ==, _s); \
235 #define assert_name_acquired(m) \
237 DBusError _e = DBUS_ERROR_INIT; \
240 g_assert_cmpstr (dbus_message_type_to_string (dbus_message_get_type (m)), \
241 ==, dbus_message_type_to_string (DBUS_MESSAGE_TYPE_SIGNAL)); \
242 g_assert_cmpstr (dbus_message_get_sender (m), ==, DBUS_SERVICE_DBUS); \
243 g_assert_cmpstr (dbus_message_get_path (m), ==, DBUS_PATH_DBUS); \
244 g_assert_cmpstr (dbus_message_get_interface (m), ==, DBUS_INTERFACE_DBUS); \
245 g_assert_cmpstr (dbus_message_get_member (m), ==, "NameAcquired"); \
246 g_assert_cmpstr (dbus_message_get_signature (m), ==, "s"); \
247 g_assert_cmpint (dbus_message_get_serial (m), !=, 0); \
248 g_assert_cmpint (dbus_message_get_reply_serial (m), ==, 0); \
250 dbus_message_get_args (m, &_e, \
251 DBUS_TYPE_STRING, &_s, \
252 DBUS_TYPE_INVALID); \
253 test_assert_no_error (&_e); \
254 g_assert_cmpstr (dbus_message_get_destination (m), ==, _s); \
257 #define assert_method_call(m, sender, \
258 destination, path, iface, method, signature) \
260 g_assert_cmpstr (dbus_message_type_to_string (dbus_message_get_type (m)), \
261 ==, dbus_message_type_to_string (DBUS_MESSAGE_TYPE_METHOD_CALL)); \
262 g_assert_cmpstr (dbus_message_get_sender (m), ==, sender); \
263 g_assert_cmpstr (dbus_message_get_destination (m), ==, destination); \
264 g_assert_cmpstr (dbus_message_get_path (m), ==, path); \
265 g_assert_cmpstr (dbus_message_get_interface (m), ==, iface); \
266 g_assert_cmpstr (dbus_message_get_member (m), ==, method); \
267 g_assert_cmpstr (dbus_message_get_signature (m), ==, signature); \
268 g_assert_cmpint (dbus_message_get_serial (m), !=, 0); \
269 g_assert_cmpint (dbus_message_get_reply_serial (m), ==, 0); \
272 #define assert_signal(m, \
273 sender, path, iface, member, signature, \
276 g_assert_cmpstr (dbus_message_type_to_string (dbus_message_get_type (m)), \
277 ==, dbus_message_type_to_string (DBUS_MESSAGE_TYPE_SIGNAL)); \
278 g_assert_cmpstr (dbus_message_get_sender (m), ==, sender); \
279 g_assert_cmpstr (dbus_message_get_destination (m), ==, destination); \
280 g_assert_cmpstr (dbus_message_get_path (m), ==, path); \
281 g_assert_cmpstr (dbus_message_get_interface (m), ==, iface); \
282 g_assert_cmpstr (dbus_message_get_member (m), ==, member); \
283 g_assert_cmpstr (dbus_message_get_signature (m), ==, signature); \
284 g_assert_cmpint (dbus_message_get_serial (m), !=, 0); \
285 g_assert_cmpint (dbus_message_get_reply_serial (m), ==, 0); \
288 #define assert_method_reply(m, sender, destination, signature) \
290 g_assert_cmpstr (dbus_message_type_to_string (dbus_message_get_type (m)), \
291 ==, dbus_message_type_to_string (DBUS_MESSAGE_TYPE_METHOD_RETURN)); \
292 g_assert_cmpstr (dbus_message_get_sender (m), ==, sender); \
293 g_assert_cmpstr (dbus_message_get_destination (m), ==, destination); \
294 g_assert_cmpstr (dbus_message_get_path (m), ==, NULL); \
295 g_assert_cmpstr (dbus_message_get_interface (m), ==, NULL); \
296 g_assert_cmpstr (dbus_message_get_member (m), ==, NULL); \
297 g_assert_cmpstr (dbus_message_get_signature (m), ==, signature); \
298 g_assert_cmpint (dbus_message_get_serial (m), !=, 0); \
299 g_assert_cmpint (dbus_message_get_reply_serial (m), !=, 0); \
302 #define assert_error_reply(m, sender, destination, error_name) \
304 g_assert_cmpstr (dbus_message_type_to_string (dbus_message_get_type (m)), \
305 ==, dbus_message_type_to_string (DBUS_MESSAGE_TYPE_ERROR)); \
306 g_assert_cmpstr (dbus_message_get_sender (m), ==, sender); \
307 g_assert_cmpstr (dbus_message_get_destination (m), ==, destination); \
308 g_assert_cmpstr (dbus_message_get_error_name (m), ==, error_name); \
309 g_assert_cmpstr (dbus_message_get_path (m), ==, NULL); \
310 g_assert_cmpstr (dbus_message_get_interface (m), ==, NULL); \
311 g_assert_cmpstr (dbus_message_get_member (m), ==, NULL); \
312 g_assert_cmpstr (dbus_message_get_signature (m), ==, "s"); \
313 g_assert_cmpint (dbus_message_get_serial (m), !=, 0); \
314 g_assert_cmpint (dbus_message_get_reply_serial (m), !=, 0); \
317 /* This is called after processing pending replies to our own method
318 * calls, but before anything else.
320 static DBusHandlerResult
321 monitor_filter (DBusConnection *connection,
322 DBusMessage *message,
325 Fixture *f = user_data;
327 g_assert_cmpstr (dbus_message_get_interface (message), !=,
328 "com.example.Tedious");
330 /* we are not interested in the monitor getting NameAcquired or NameLost
332 if (f->config == NULL || !f->config->care_about_our_names)
334 if (dbus_message_is_signal (message, DBUS_INTERFACE_DBUS,
336 dbus_message_is_signal (message, DBUS_INTERFACE_DBUS,
339 DBusError e = DBUS_ERROR_INIT;
342 dbus_message_get_args (message, &e,
343 DBUS_TYPE_STRING, &s,
345 test_assert_no_error (&e);
347 if (strcmp (s, f->monitor_name) == 0)
350 return DBUS_HANDLER_RESULT_HANDLED;
355 g_queue_push_tail (&f->monitored, dbus_message_ref (message));
357 return DBUS_HANDLER_RESULT_HANDLED;
360 static DBusHandlerResult
361 recipient_filter (DBusConnection *connection,
362 DBusMessage *message,
365 g_assert_cmpstr (dbus_message_get_interface (message), !=,
366 "com.example.CannotSend");
367 g_assert_cmpstr (dbus_message_get_interface (message), !=,
368 "com.example.CannotReceive");
370 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
373 static DBusHandlerResult
374 systemd_filter (DBusConnection *connection,
375 DBusMessage *message,
378 Fixture *f = user_data;
380 if (dbus_message_is_signal (message, DBUS_INTERFACE_DBUS,
382 dbus_message_is_signal (message, DBUS_INTERFACE_DBUS,
385 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
388 g_assert (f->systemd_message == NULL);
389 f->systemd_message = dbus_message_ref (message);
391 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
394 static DBusHandlerResult
395 activated_filter (DBusConnection *connection,
396 DBusMessage *message,
399 Fixture *f = user_data;
401 if (dbus_message_is_signal (message, DBUS_INTERFACE_DBUS,
403 dbus_message_is_signal (message, DBUS_INTERFACE_DBUS,
406 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
409 g_assert (f->activated_message == NULL);
410 f->activated_message = dbus_message_ref (message);
412 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
417 gconstpointer context)
421 f->ctx = test_main_context_get ();
424 dbus_error_init (&f->e);
426 f->address = test_get_dbus_daemon (f->config ? f->config->config_file : NULL,
427 TEST_USER_ME, &f->daemon_pid);
429 if (f->address == NULL)
432 f->monitor = test_connect_to_bus (f->ctx, f->address);
433 f->monitor_name = dbus_bus_get_unique_name (f->monitor);
434 f->sender = test_connect_to_bus (f->ctx, f->address);
435 f->sender_name = dbus_bus_get_unique_name (f->sender);
436 f->recipient = test_connect_to_bus (f->ctx, f->address);
437 f->recipient_name = dbus_bus_get_unique_name (f->recipient);
439 if (!dbus_connection_add_filter (f->monitor, monitor_filter, f, NULL))
442 if (!dbus_connection_add_filter (f->recipient, recipient_filter, f, NULL))
447 become_monitor (Fixture *f)
452 DBusMessageIter appender, array_appender;
453 const char * const *match_rules;
455 dbus_uint32_t zero = 0;
457 if (f->config != NULL && f->config->match_rules != NULL)
458 match_rules = f->config->match_rules;
460 match_rules = wildcard_match_rules;
462 m = dbus_message_new_method_call (DBUS_SERVICE_DBUS,
463 DBUS_PATH_DBUS, DBUS_INTERFACE_MONITORING, "BecomeMonitor");
468 dbus_message_iter_init_append (m, &appender);
470 if (!dbus_message_iter_open_container (&appender, DBUS_TYPE_ARRAY, "s",
474 for (i = 0; match_rules[i] != NULL; i++)
476 if (!dbus_message_iter_append_basic (&array_appender, DBUS_TYPE_STRING,
481 if (!dbus_message_iter_close_container (&appender, &array_appender) ||
482 !dbus_message_iter_append_basic (&appender, DBUS_TYPE_UINT32, &zero))
485 if (!dbus_connection_send_with_reply (f->monitor, m, &pc,
486 DBUS_TIMEOUT_USE_DEFAULT) ||
490 dbus_message_unref (m);
493 if (dbus_pending_call_get_completed (pc))
494 test_pending_call_store_reply (pc, &m);
495 else if (!dbus_pending_call_set_notify (pc, test_pending_call_store_reply,
500 test_main_context_iterate (f->ctx, TRUE);
502 ok = dbus_message_get_args (m, &f->e,
504 test_assert_no_error (&f->e);
507 dbus_pending_call_unref (pc);
508 dbus_message_unref (m);
513 * Test the side-effects of becoming a monitor.
516 test_become_monitor (Fixture *f,
517 gconstpointer context)
521 dbus_bool_t got_unique = FALSE, got_a = FALSE, got_b = FALSE, got_c = FALSE;
522 dbus_bool_t lost_unique = FALSE, lost_a = FALSE, lost_b = FALSE, lost_c = FALSE;
524 if (f->address == NULL)
527 ret = dbus_bus_request_name (f->monitor, "com.example.A",
528 DBUS_NAME_FLAG_DO_NOT_QUEUE, &f->e);
529 test_assert_no_error (&f->e);
530 g_assert_cmpint (ret, ==, DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER);
532 ret = dbus_bus_request_name (f->monitor, "com.example.B",
533 DBUS_NAME_FLAG_DO_NOT_QUEUE, &f->e);
534 test_assert_no_error (&f->e);
535 g_assert_cmpint (ret, ==, DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER);
537 ret = dbus_bus_request_name (f->monitor, "com.example.C",
538 DBUS_NAME_FLAG_DO_NOT_QUEUE, &f->e);
539 test_assert_no_error (&f->e);
540 g_assert_cmpint (ret, ==, DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER);
542 while (!got_unique || !got_a || !got_b || !got_c)
544 if (g_queue_is_empty (&f->monitored))
545 test_main_context_iterate (f->ctx, TRUE);
547 while ((m = g_queue_pop_head (&f->monitored)) != NULL)
549 if (dbus_message_is_signal (m, DBUS_INTERFACE_DBUS,
553 dbus_bool_t ok = dbus_message_get_args (m, &f->e,
554 DBUS_TYPE_STRING, &name,
557 g_assert_cmpstr (dbus_message_get_path (m), ==,
560 test_assert_no_error (&f->e);
563 if (g_str_equal (name, f->monitor_name))
565 g_assert (!got_unique);
568 else if (g_str_equal (name, "com.example.A"))
573 else if (g_str_equal (name, "com.example.B"))
580 g_assert_cmpstr (name, ==, "com.example.C");
587 g_error ("unexpected message %s.%s",
588 dbus_message_get_interface (m),
589 dbus_message_get_member (m));
592 dbus_message_unref (m);
598 while (!lost_unique || !lost_a || !lost_b || !lost_c)
600 if (g_queue_is_empty (&f->monitored))
601 test_main_context_iterate (f->ctx, TRUE);
603 while ((m = g_queue_pop_head (&f->monitored)) != NULL)
605 if (dbus_message_is_signal (m, DBUS_INTERFACE_DBUS,
609 dbus_bool_t ok = dbus_message_get_args (m, &f->e,
610 DBUS_TYPE_STRING, &name,
613 test_assert_no_error (&f->e);
616 if (g_str_equal (name, f->monitor_name))
618 g_assert (!lost_unique);
621 else if (g_str_equal (name, "com.example.A"))
626 else if (g_str_equal (name, "com.example.B"))
633 g_assert_cmpstr (name, ==, "com.example.C");
640 g_error ("unexpected message %s.%s",
641 dbus_message_get_interface (m),
642 dbus_message_get_member (m));
645 dbus_message_unref (m);
649 /* Calling methods is forbidden; we get disconnected. */
650 dbus_bus_add_match (f->monitor, "", &f->e);
651 g_assert_cmpstr (f->e.name, ==, DBUS_ERROR_NO_REPLY);
652 g_assert (!dbus_connection_get_is_connected (f->monitor));
656 if (g_queue_is_empty (&f->monitored))
657 test_main_context_iterate (f->ctx, TRUE);
659 /* When we iterate all the connection's messages, we see ourselves
660 * losing all our names, then we're disconnected. */
661 while ((m = g_queue_pop_head (&f->monitored)) != NULL)
663 if (dbus_message_is_signal (m, DBUS_INTERFACE_LOCAL, "Disconnected"))
665 dbus_message_unref (m);
670 g_error ("unexpected message %s.%s",
671 dbus_message_get_interface (m),
672 dbus_message_get_member (m));
675 dbus_message_unref (m);
687 test_broadcast (Fixture *f,
688 gconstpointer context)
692 if (f->address == NULL)
695 dbus_bus_add_match (f->recipient, "type='signal'", &f->e);
696 test_assert_no_error (&f->e);
700 m = dbus_message_new_signal ("/foo", "com.example.bar", "BroadcastSignal1");
701 dbus_connection_send (f->sender, m, NULL);
702 dbus_message_unref (m);
704 m = dbus_message_new_signal ("/foo", "com.example.bar", "BroadcastSignal2");
705 dbus_connection_send (f->sender, m, NULL);
706 dbus_message_unref (m);
708 m = dbus_message_new_signal ("/foo", "com.example.bar", "BroadcastSignal3");
709 dbus_connection_send (f->sender, m, NULL);
710 dbus_message_unref (m);
712 while (g_queue_get_length (&f->monitored) < 3)
713 test_main_context_iterate (f->ctx, TRUE);
715 m = g_queue_pop_head (&f->monitored);
716 assert_signal (m, f->sender_name, "/foo", "com.example.bar",
717 "BroadcastSignal1", "", NULL);
718 dbus_message_unref (m);
720 m = g_queue_pop_head (&f->monitored);
721 assert_signal (m, f->sender_name, "/foo", "com.example.bar",
722 "BroadcastSignal2", "", NULL);
723 dbus_message_unref (m);
725 m = g_queue_pop_head (&f->monitored);
726 assert_signal (m, f->sender_name, "/foo", "com.example.bar",
727 "BroadcastSignal3", "", NULL);
728 dbus_message_unref (m);
730 m = g_queue_pop_head (&f->monitored);
731 g_assert (m == NULL);
735 test_forbidden_broadcast (Fixture *f,
736 gconstpointer context)
740 if (f->address == NULL)
743 dbus_bus_add_match (f->recipient, "type='signal'", &f->e);
744 test_assert_no_error (&f->e);
748 m = dbus_message_new_signal ("/foo", "com.example.CannotSend",
750 dbus_connection_send (f->sender, m, NULL);
751 dbus_message_unref (m);
753 m = dbus_message_new_signal ("/foo", "com.example.CannotReceive",
755 dbus_connection_send (f->sender, m, NULL);
756 dbus_message_unref (m);
758 m = dbus_message_new_signal ("/foo", "com.example.CannotSend",
760 dbus_connection_send (f->sender, m, NULL);
761 dbus_message_unref (m);
763 while (g_queue_get_length (&f->monitored) < 6)
764 test_main_context_iterate (f->ctx, TRUE);
766 m = g_queue_pop_head (&f->monitored);
767 assert_signal (m, f->sender_name, "/foo", "com.example.CannotSend",
768 "BroadcastSignal1", "", NULL);
769 dbus_message_unref (m);
771 m = g_queue_pop_head (&f->monitored);
772 assert_error_reply (m, DBUS_SERVICE_DBUS, f->sender_name,
773 DBUS_ERROR_ACCESS_DENIED);
774 dbus_message_unref (m);
776 m = g_queue_pop_head (&f->monitored);
777 assert_signal (m, f->sender_name, "/foo", "com.example.CannotReceive",
778 "BroadcastSignal2", "", NULL);
779 dbus_message_unref (m);
781 m = g_queue_pop_head (&f->monitored);
782 assert_error_reply (m, DBUS_SERVICE_DBUS, f->sender_name,
783 DBUS_ERROR_ACCESS_DENIED);
784 dbus_message_unref (m);
786 m = g_queue_pop_head (&f->monitored);
787 assert_signal (m, f->sender_name, "/foo", "com.example.CannotSend",
788 "BroadcastSignal3", "", NULL);
789 dbus_message_unref (m);
791 m = g_queue_pop_head (&f->monitored);
792 assert_error_reply (m, DBUS_SERVICE_DBUS, f->sender_name,
793 DBUS_ERROR_ACCESS_DENIED);
794 dbus_message_unref (m);
796 m = g_queue_pop_head (&f->monitored);
797 g_assert (m == NULL);
801 test_unicast_signal (Fixture *f,
802 gconstpointer context)
806 if (f->address == NULL)
811 m = dbus_message_new_signal ("/foo", "com.example.bar", "UnicastSignal1");
812 if (!dbus_message_set_destination (m, f->recipient_name))
814 dbus_connection_send (f->sender, m, NULL);
815 dbus_message_unref (m);
817 m = dbus_message_new_signal ("/foo", "com.example.bar", "UnicastSignal2");
818 if (!dbus_message_set_destination (m, f->recipient_name))
820 dbus_connection_send (f->sender, m, NULL);
821 dbus_message_unref (m);
823 m = dbus_message_new_signal ("/foo", "com.example.bar", "UnicastSignal3");
824 if (!dbus_message_set_destination (m, f->recipient_name))
826 dbus_connection_send (f->sender, m, NULL);
827 dbus_message_unref (m);
829 while (g_queue_get_length (&f->monitored) < 3)
830 test_main_context_iterate (f->ctx, TRUE);
832 m = g_queue_pop_head (&f->monitored);
833 assert_signal (m, f->sender_name, "/foo",
834 "com.example.bar", "UnicastSignal1", "", f->recipient_name);
835 dbus_message_unref (m);
837 m = g_queue_pop_head (&f->monitored);
838 assert_signal (m, f->sender_name, "/foo",
839 "com.example.bar", "UnicastSignal2", "", f->recipient_name);
840 dbus_message_unref (m);
842 m = g_queue_pop_head (&f->monitored);
843 assert_signal (m, f->sender_name, "/foo",
844 "com.example.bar", "UnicastSignal3", "", f->recipient_name);
845 dbus_message_unref (m);
847 m = g_queue_pop_head (&f->monitored);
848 g_assert (m == NULL);
852 test_forbidden (Fixture *f,
853 gconstpointer context)
857 if (f->address == NULL)
862 m = dbus_message_new_signal ("/foo", "com.example.CannotSend",
864 if (!dbus_message_set_destination (m, f->recipient_name))
866 dbus_connection_send (f->sender, m, NULL);
867 dbus_message_unref (m);
869 m = dbus_message_new_signal ("/foo", "com.example.CannotReceive",
871 if (!dbus_message_set_destination (m, f->recipient_name))
873 dbus_connection_send (f->sender, m, NULL);
874 dbus_message_unref (m);
876 m = dbus_message_new_signal ("/foo", "com.example.CannotSend",
878 if (!dbus_message_set_destination (m, f->recipient_name))
880 dbus_connection_send (f->sender, m, NULL);
881 dbus_message_unref (m);
883 while (g_queue_get_length (&f->monitored) < 6)
884 test_main_context_iterate (f->ctx, TRUE);
886 m = g_queue_pop_head (&f->monitored);
887 assert_signal (m, f->sender_name, "/foo",
888 "com.example.CannotSend", "UnicastSignal1", "", f->recipient_name);
889 dbus_message_unref (m);
891 m = g_queue_pop_head (&f->monitored);
892 assert_error_reply (m, DBUS_SERVICE_DBUS, f->sender_name,
893 DBUS_ERROR_ACCESS_DENIED);
894 dbus_message_unref (m);
896 m = g_queue_pop_head (&f->monitored);
897 assert_signal (m, f->sender_name, "/foo",
898 "com.example.CannotReceive", "UnicastSignal2", "", f->recipient_name);
899 dbus_message_unref (m);
901 m = g_queue_pop_head (&f->monitored);
902 assert_error_reply (m, DBUS_SERVICE_DBUS, f->sender_name,
903 DBUS_ERROR_ACCESS_DENIED);
904 dbus_message_unref (m);
906 m = g_queue_pop_head (&f->monitored);
907 assert_signal (m, f->sender_name, "/foo",
908 "com.example.CannotSend", "UnicastSignal3", "", f->recipient_name);
909 dbus_message_unref (m);
911 m = g_queue_pop_head (&f->monitored);
912 assert_error_reply (m, DBUS_SERVICE_DBUS, f->sender_name,
913 DBUS_ERROR_ACCESS_DENIED);
914 dbus_message_unref (m);
916 m = g_queue_pop_head (&f->monitored);
917 g_assert (m == NULL);
921 test_method_call (Fixture *f,
922 gconstpointer context)
926 if (f->address == NULL)
931 m = dbus_message_new_method_call (f->recipient_name, "/foo", "com.example.bar",
933 dbus_connection_send (f->sender, m, NULL);
934 dbus_message_unref (m);
936 while (g_queue_get_length (&f->monitored) < 2)
937 test_main_context_iterate (f->ctx, TRUE);
939 m = g_queue_pop_head (&f->monitored);
940 assert_method_call (m, f->sender_name, f->recipient_name, "/foo",
941 "com.example.bar", "Call1", "");
942 dbus_message_unref (m);
944 m = g_queue_pop_head (&f->monitored);
945 assert_error_reply (m, f->recipient_name, f->sender_name,
946 DBUS_ERROR_UNKNOWN_METHOD);
947 dbus_message_unref (m);
949 m = g_queue_pop_head (&f->monitored);
950 g_assert (m == NULL);
954 test_forbidden_method_call (Fixture *f,
955 gconstpointer context)
959 if (f->address == NULL)
964 m = dbus_message_new_method_call (f->recipient_name, "/foo",
965 "com.example.CannotSend", "Call1");
966 dbus_connection_send (f->sender, m, NULL);
967 dbus_message_unref (m);
969 while (g_queue_get_length (&f->monitored) < 2)
970 test_main_context_iterate (f->ctx, TRUE);
972 m = g_queue_pop_head (&f->monitored);
973 assert_method_call (m, f->sender_name, f->recipient_name, "/foo",
974 "com.example.CannotSend", "Call1", "");
975 dbus_message_unref (m);
977 m = g_queue_pop_head (&f->monitored);
978 assert_error_reply (m, DBUS_SERVICE_DBUS, f->sender_name,
979 DBUS_ERROR_ACCESS_DENIED);
980 dbus_message_unref (m);
982 m = g_queue_pop_head (&f->monitored);
983 g_assert (m == NULL);
985 m = dbus_message_new_method_call (f->recipient_name, "/foo",
986 "com.example.CannotReceive", "Call2");
987 dbus_connection_send (f->sender, m, NULL);
988 dbus_message_unref (m);
990 while (g_queue_get_length (&f->monitored) < 2)
991 test_main_context_iterate (f->ctx, TRUE);
993 m = g_queue_pop_head (&f->monitored);
994 assert_method_call (m, f->sender_name, f->recipient_name, "/foo",
995 "com.example.CannotReceive", "Call2", "");
996 dbus_message_unref (m);
998 m = g_queue_pop_head (&f->monitored);
999 assert_error_reply (m, DBUS_SERVICE_DBUS, f->sender_name,
1000 DBUS_ERROR_ACCESS_DENIED);
1001 dbus_message_unref (m);
1003 m = g_queue_pop_head (&f->monitored);
1004 g_assert (m == NULL);
1008 test_dbus_daemon (Fixture *f,
1009 gconstpointer context)
1014 if (f->address == NULL)
1019 res = dbus_bus_request_name (f->sender, "com.example.Sender",
1020 DBUS_NAME_FLAG_DO_NOT_QUEUE, &f->e);
1021 test_assert_no_error (&f->e);
1022 g_assert_cmpint (res, ==, DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER);
1024 res = dbus_bus_release_name (f->sender, "com.example.Sender", &f->e);
1025 test_assert_no_error (&f->e);
1026 g_assert_cmpint (res, ==, DBUS_RELEASE_NAME_REPLY_RELEASED);
1028 while (g_queue_get_length (&f->monitored) < 8)
1029 test_main_context_iterate (f->ctx, TRUE);
1031 m = g_queue_pop_head (&f->monitored);
1032 assert_method_call (m, f->sender_name, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS,
1033 DBUS_INTERFACE_DBUS, "RequestName", "su");
1034 dbus_message_unref (m);
1036 m = g_queue_pop_head (&f->monitored);
1037 assert_signal (m, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS,
1038 "NameOwnerChanged", "sss", NULL);
1039 dbus_message_unref (m);
1041 /* FIXME: should we get this? */
1042 m = g_queue_pop_head (&f->monitored);
1043 assert_signal (m, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS,
1044 "NameAcquired", "s", f->sender_name);
1045 dbus_message_unref (m);
1047 m = g_queue_pop_head (&f->monitored);
1048 assert_method_reply (m, DBUS_SERVICE_DBUS, f->sender_name, "u");
1049 dbus_message_unref (m);
1051 m = g_queue_pop_head (&f->monitored);
1052 assert_method_call (m, f->sender_name, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS,
1053 DBUS_INTERFACE_DBUS, "ReleaseName", "s");
1054 dbus_message_unref (m);
1056 /* FIXME: should we get this? */
1057 m = g_queue_pop_head (&f->monitored);
1058 assert_signal (m, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS,
1059 "NameLost", "s", f->sender_name);
1060 dbus_message_unref (m);
1062 m = g_queue_pop_head (&f->monitored);
1063 assert_signal (m, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS,
1064 "NameOwnerChanged", "sss", NULL);
1065 dbus_message_unref (m);
1067 m = g_queue_pop_head (&f->monitored);
1068 assert_method_reply (m, DBUS_SERVICE_DBUS, f->sender_name, "u");
1069 dbus_message_unref (m);
1071 m = g_queue_pop_head (&f->monitored);
1072 g_assert (m == NULL);
1076 test_selective (Fixture *f,
1077 gconstpointer context)
1081 if (f->address == NULL)
1084 /* Match rules added before becoming a monitor should be cleared:
1085 * if they weren't, this test would get Interesting twice, then Tedious,
1086 * and only see Fun after that. */
1087 dbus_bus_add_match (f->monitor,
1088 "eavesdrop='true',interface='com.example.Interesting'", &f->e);
1089 test_assert_no_error (&f->e);
1090 dbus_bus_add_match (f->monitor,
1091 "eavesdrop='true',interface='com.example.Tedious'", &f->e);
1092 test_assert_no_error (&f->e);
1096 m = dbus_message_new_signal ("/foo", "com.example.Interesting",
1098 if (!dbus_message_set_destination (m, f->recipient_name))
1100 dbus_connection_send (f->sender, m, NULL);
1101 dbus_message_unref (m);
1103 m = dbus_message_new_signal ("/foo", "com.example.Tedious",
1105 if (!dbus_message_set_destination (m, f->recipient_name))
1107 dbus_connection_send (f->sender, m, NULL);
1108 dbus_message_unref (m);
1110 m = dbus_message_new_signal ("/foo", "com.example.Fun",
1112 if (!dbus_message_set_destination (m, f->recipient_name))
1114 dbus_connection_send (f->sender, m, NULL);
1115 dbus_message_unref (m);
1117 while (g_queue_get_length (&f->monitored) < 2)
1118 test_main_context_iterate (f->ctx, TRUE);
1120 /* We get the interesting signal and the fun signal, but not the tedious
1123 m = g_queue_pop_head (&f->monitored);
1124 assert_signal (m, f->sender_name, "/foo",
1125 "com.example.Interesting", "UnicastSignal1", "", f->recipient_name);
1126 dbus_message_unref (m);
1128 m = g_queue_pop_head (&f->monitored);
1129 assert_signal (m, f->sender_name, "/foo",
1130 "com.example.Fun", "UnicastSignal3", "", f->recipient_name);
1131 dbus_message_unref (m);
1133 m = g_queue_pop_head (&f->monitored);
1134 g_assert (m == NULL);
1138 expect_new_connection (Fixture *f)
1142 while (g_queue_get_length (&f->monitored) < 4)
1143 test_main_context_iterate (f->ctx, TRUE);
1145 m = g_queue_pop_head (&f->monitored);
1147 dbus_message_unref (m);
1149 m = g_queue_pop_head (&f->monitored);
1150 assert_hello_reply (m);
1151 dbus_message_unref (m);
1153 m = g_queue_pop_head (&f->monitored);
1154 assert_signal (m, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS,
1155 "NameOwnerChanged", "sss", NULL);
1156 dbus_message_unref (m);
1158 m = g_queue_pop_head (&f->monitored);
1159 assert_name_acquired (m);
1160 dbus_message_unref (m);
1164 take_well_known_name (Fixture *f,
1165 DBusConnection *connection,
1170 ret = dbus_bus_request_name (connection, name,
1171 DBUS_NAME_FLAG_DO_NOT_QUEUE, &f->e);
1172 test_assert_no_error (&f->e);
1173 g_assert_cmpint (ret, ==, DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER);
1177 expect_take_well_known_name (Fixture *f,
1178 DBusConnection *connection,
1182 const char *connection_name = dbus_bus_get_unique_name (connection);
1184 while (g_queue_get_length (&f->monitored) < 4)
1185 test_main_context_iterate (f->ctx, TRUE);
1187 m = g_queue_pop_head (&f->monitored);
1188 assert_method_call (m, connection_name, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS,
1189 DBUS_INTERFACE_DBUS, "RequestName", "su");
1190 dbus_message_unref (m);
1192 m = g_queue_pop_head (&f->monitored);
1193 assert_signal (m, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS,
1194 "NameOwnerChanged", "sss", NULL);
1195 dbus_message_unref (m);
1197 m = g_queue_pop_head (&f->monitored);
1198 assert_signal (m, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS,
1199 "NameAcquired", "s", connection_name);
1200 dbus_message_unref (m);
1202 m = g_queue_pop_head (&f->monitored);
1203 assert_method_reply (m, DBUS_SERVICE_DBUS, connection_name, "u");
1204 dbus_message_unref (m);
1208 test_activation (Fixture *f,
1209 gconstpointer context)
1213 if (f->address == NULL)
1218 /* The sender sends a message to an activatable service. */
1219 m = dbus_message_new_signal ("/foo", "com.example.bar", "UnicastSignal1");
1220 if (!dbus_message_set_destination (m, "com.example.SystemdActivatable1"))
1222 dbus_connection_send (f->sender, m, NULL);
1223 dbus_message_unref (m);
1225 /* We observe the activation request, and the message that caused it,
1226 * before systemd has even joined the bus. */
1227 while (g_queue_get_length (&f->monitored) < 2)
1228 test_main_context_iterate (f->ctx, TRUE);
1230 m = g_queue_pop_head (&f->monitored);
1231 assert_signal (m, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS,
1232 "org.freedesktop.systemd1.Activator", "ActivationRequest", "s",
1233 "org.freedesktop.systemd1");
1234 dbus_message_unref (m);
1235 m = g_queue_pop_head (&f->monitored);
1236 assert_signal (m, f->sender_name, "/foo",
1237 "com.example.bar", "UnicastSignal1", "",
1238 "com.example.SystemdActivatable1");
1239 dbus_message_unref (m);
1241 /* The fake systemd connects to the bus. */
1242 f->systemd = test_connect_to_bus (f->ctx, f->address);
1243 if (!dbus_connection_add_filter (f->systemd, systemd_filter, f, NULL))
1245 f->systemd_name = dbus_bus_get_unique_name (f->systemd);
1247 expect_new_connection (f);
1248 take_well_known_name (f, f->systemd, "org.freedesktop.systemd1");
1249 expect_take_well_known_name (f, f->systemd, "org.freedesktop.systemd1");
1251 /* It gets its activation request. */
1252 while (f->systemd_message == NULL)
1253 test_main_context_iterate (f->ctx, TRUE);
1255 m = f->systemd_message;
1256 f->systemd_message = NULL;
1257 assert_signal (m, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS,
1258 "org.freedesktop.systemd1.Activator", "ActivationRequest", "s",
1259 "org.freedesktop.systemd1");
1260 dbus_message_unref (m);
1262 /* systemd starts the activatable service. */
1263 f->activated = test_connect_to_bus (f->ctx, f->address);
1264 if (!dbus_connection_add_filter (f->activated, activated_filter,
1267 f->activated_name = dbus_bus_get_unique_name (f->activated);
1269 expect_new_connection (f);
1270 take_well_known_name (f, f->activated, "com.example.SystemdActivatable1");
1271 expect_take_well_known_name (f, f->activated,
1272 "com.example.SystemdActivatable1");
1274 /* The message is delivered to the activatable service. */
1275 while (f->activated_message == NULL)
1276 test_main_context_iterate (f->ctx, TRUE);
1278 m = f->activated_message;
1279 f->activated_message = NULL;
1280 assert_signal (m, f->sender_name, "/foo",
1281 "com.example.bar", "UnicastSignal1", "",
1282 "com.example.SystemdActivatable1");
1283 dbus_message_unref (m);
1285 /* The sender sends a message to a different activatable service. */
1286 m = dbus_message_new_signal ("/foo", "com.example.bar", "UnicastSignal2");
1287 if (!dbus_message_set_destination (m, "com.example.SystemdActivatable2"))
1289 dbus_connection_send (f->sender, m, NULL);
1290 dbus_message_unref (m);
1292 /* This time systemd is already ready for it. */
1293 while (g_queue_get_length (&f->monitored) < 2 ||
1294 f->systemd_message == NULL)
1295 test_main_context_iterate (f->ctx, TRUE);
1297 m = f->systemd_message;
1298 f->systemd_message = NULL;
1299 assert_signal (m, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS,
1300 "org.freedesktop.systemd1.Activator", "ActivationRequest", "s",
1301 "org.freedesktop.systemd1");
1302 dbus_message_unref (m);
1304 /* The monitor sees the activation request and the signal that
1306 m = g_queue_pop_head (&f->monitored);
1307 assert_signal (m, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS,
1308 "org.freedesktop.systemd1.Activator", "ActivationRequest", "s",
1309 "org.freedesktop.systemd1");
1310 dbus_message_unref (m);
1311 m = g_queue_pop_head (&f->monitored);
1312 assert_signal (m, f->sender_name, "/foo",
1313 "com.example.bar", "UnicastSignal2", "",
1314 "com.example.SystemdActivatable2");
1315 dbus_message_unref (m);
1317 /* The activatable service takes its name. Here I'm faking it by using
1318 * an existing connection. */
1319 take_well_known_name (f, f->activated, "com.example.SystemdActivatable2");
1321 /* The message is delivered to the activatable service.
1322 * Implementation detail: the monitor sees this happen before it even
1323 * sees that the name request happened, which is pretty odd. */
1324 while (f->activated_message == NULL)
1325 test_main_context_iterate (f->ctx, TRUE);
1327 m = f->activated_message;
1328 f->activated_message = NULL;
1329 assert_signal (m, f->sender_name, "/foo",
1330 "com.example.bar", "UnicastSignal2", "",
1331 "com.example.SystemdActivatable2");
1332 dbus_message_unref (m);
1334 expect_take_well_known_name (f, f->activated,
1335 "com.example.SystemdActivatable2");
1337 /* A third activation. */
1338 m = dbus_message_new_signal ("/foo", "com.example.bar", "UnicastSignal3");
1339 if (!dbus_message_set_destination (m, "com.example.SystemdActivatable3"))
1341 dbus_connection_send (f->sender, m, NULL);
1342 dbus_message_unref (m);
1344 /* Once again, we see the activation request and the reason. */
1345 while (g_queue_get_length (&f->monitored) < 2)
1346 test_main_context_iterate (f->ctx, TRUE);
1348 m = g_queue_pop_head (&f->monitored);
1349 assert_signal (m, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS,
1350 "org.freedesktop.systemd1.Activator", "ActivationRequest", "s",
1351 "org.freedesktop.systemd1");
1352 dbus_message_unref (m);
1353 m = g_queue_pop_head (&f->monitored);
1354 assert_signal (m, f->sender_name, "/foo",
1355 "com.example.bar", "UnicastSignal3", "",
1356 "com.example.SystemdActivatable3");
1357 dbus_message_unref (m);
1359 /* systemd gets the request too. */
1360 while (f->systemd_message == NULL)
1361 test_main_context_iterate (f->ctx, TRUE);
1363 m = f->systemd_message;
1364 f->systemd_message = NULL;
1365 assert_signal (m, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS,
1366 "org.freedesktop.systemd1.Activator", "ActivationRequest", "s",
1367 "org.freedesktop.systemd1");
1368 dbus_message_unref (m);
1370 /* This time activation fails */
1371 m = dbus_message_new_signal ("/org/freedesktop/systemd1",
1372 "org.freedesktop.systemd1.Activator", "ActivationFailure");
1376 const char *unit = "dbus-com.example.SystemdActivatable3.service";
1377 const char *error_name = "com.example.Nope";
1378 const char *error_message = "Computer says no";
1380 if (!dbus_message_append_args (m,
1381 DBUS_TYPE_STRING, &unit,
1382 DBUS_TYPE_STRING, &error_name,
1383 DBUS_TYPE_STRING, &error_message,
1389 if (!dbus_message_set_destination (m, "org.freedesktop.DBus"))
1391 dbus_connection_send (f->systemd, m, NULL);
1392 dbus_message_unref (m);
1394 /* The monitor sees activation fail */
1396 /* Once again, we see the activation request and the reason. */
1397 while (g_queue_get_length (&f->monitored) < 1)
1398 test_main_context_iterate (f->ctx, TRUE);
1400 m = g_queue_pop_head (&f->monitored);
1401 assert_error_reply (m, DBUS_SERVICE_DBUS, f->sender_name,
1402 "com.example.Nope");
1403 dbus_message_unref (m);
1407 teardown (Fixture *f,
1408 gconstpointer context G_GNUC_UNUSED)
1410 dbus_error_free (&f->e);
1411 g_clear_error (&f->ge);
1413 if (f->monitor != NULL)
1415 dbus_connection_remove_filter (f->monitor, monitor_filter, f);
1416 dbus_connection_close (f->monitor);
1417 dbus_connection_unref (f->monitor);
1421 if (f->sender != NULL)
1423 dbus_connection_close (f->sender);
1424 dbus_connection_unref (f->sender);
1428 if (f->recipient != NULL)
1430 dbus_connection_remove_filter (f->recipient, recipient_filter, f);
1431 dbus_connection_close (f->recipient);
1432 dbus_connection_unref (f->recipient);
1433 f->recipient = NULL;
1436 if (f->systemd != NULL)
1438 dbus_connection_remove_filter (f->systemd, systemd_filter, f);
1439 dbus_connection_close (f->systemd);
1440 dbus_connection_unref (f->systemd);
1444 if (f->activated != NULL)
1446 dbus_connection_remove_filter (f->activated, activated_filter, f);
1447 dbus_connection_close (f->activated);
1448 dbus_connection_unref (f->activated);
1449 f->activated = NULL;
1452 test_kill_pid (f->daemon_pid);
1453 g_spawn_close_pid (f->daemon_pid);
1455 test_main_context_unref (f->ctx);
1457 g_queue_foreach (&f->monitored, (GFunc) dbus_message_unref, NULL);
1458 g_queue_clear (&f->monitored);
1460 g_free (f->address);
1467 test_init (&argc, &argv);
1469 g_test_add ("/monitor/become", Fixture, &side_effects_config,
1470 setup, test_become_monitor, teardown);
1471 g_test_add ("/monitor/broadcast", Fixture, NULL,
1472 setup, test_broadcast, teardown);
1473 g_test_add ("/monitor/forbidden-broadcast", Fixture, &forbidding_config,
1474 setup, test_forbidden_broadcast, teardown);
1475 g_test_add ("/monitor/unicast-signal", Fixture, NULL,
1476 setup, test_unicast_signal, teardown);
1477 g_test_add ("/monitor/forbidden", Fixture, &forbidding_config,
1478 setup, test_forbidden, teardown);
1479 g_test_add ("/monitor/method-call", Fixture, NULL,
1480 setup, test_method_call, teardown);
1481 g_test_add ("/monitor/forbidden-method", Fixture, &forbidding_config,
1482 setup, test_forbidden_method_call, teardown);
1483 g_test_add ("/monitor/dbus-daemon", Fixture, NULL,
1484 setup, test_dbus_daemon, teardown);
1485 g_test_add ("/monitor/selective", Fixture, &selective_config,
1486 setup, test_selective, teardown);
1487 g_test_add ("/monitor/wildcard", Fixture, &wildcard_config,
1488 setup, test_unicast_signal, teardown);
1489 g_test_add ("/monitor/no-rule", Fixture, &no_rules_config,
1490 setup, test_unicast_signal, teardown);
1491 g_test_add ("/monitor/eavesdrop", Fixture, &eavesdrop_config,
1492 setup, test_unicast_signal, teardown);
1493 g_test_add ("/monitor/no-eavesdrop", Fixture, &no_eavesdrop_config,
1494 setup, test_unicast_signal, teardown);
1495 g_test_add ("/monitor/activation", Fixture, &fake_systemd_config,
1496 setup, test_activation, teardown);
1498 return g_test_run ();