diff options
author | Martin Pitt <martin.pitt@ubuntu.com> | 2011-04-20 00:43:59 +0200 |
---|---|---|
committer | Martin Pitt <martin.pitt@ubuntu.com> | 2011-04-26 11:50:36 +0200 |
commit | eddcf0ef3d0b8445618e368328d7e110a83b69b3 (patch) | |
tree | 937533db5a23c50d32b8b6d46d2f493557ed310a /src/up-main.c | |
parent | f65aa4dbf2721a660300d14fc3a582d3be3c3072 (diff) | |
download | upower-eddcf0ef3d0b8445618e368328d7e110a83b69b3.tar.gz |
Add option to run daemon on the session bus for testing
Add a daemon option --test which will run upowerd on the session bus. This
allows us to run tests without interfering with the system instance. This also
avoids any root privileges entirely, which permits running integration tests as
part of a package build.
Diffstat (limited to 'src/up-main.c')
-rw-r--r-- | src/up-main.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/up-main.c b/src/up-main.c index d116487..cfebe8e 100644 --- a/src/up-main.c +++ b/src/up-main.c @@ -133,6 +133,7 @@ main (gint argc, gchar **argv) gint retval = 1; gboolean timed_exit = FALSE; gboolean immediate_exit = FALSE; + gboolean session_bus = FALSE; guint timer_id = 0; const GOptionEntry options[] = { @@ -142,6 +143,8 @@ main (gint argc, gchar **argv) { "immediate-exit", '\0', 0, G_OPTION_ARG_NONE, &immediate_exit, /* TRANSLATORS: exit straight away, used for automatic profiling */ _("Exit after the engine has loaded"), NULL }, + { "test", '\0', 0, G_OPTION_ARG_NONE, &session_bus, + _("Run on the session bus (only for testing)"), NULL }, { NULL} }; @@ -153,7 +156,9 @@ main (gint argc, gchar **argv) g_option_context_free (context); /* get bus connection */ - bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); + if (session_bus) + up_daemon_set_bus_type (DBUS_BUS_SESSION); + bus = dbus_g_bus_get (up_daemon_get_bus_type (), &error); if (bus == NULL) { g_warning ("Couldn't connect to system bus: %s", error->message); g_error_free (error); |