Merge lp:~charlesk/dbus-test-runner/support-gtestdbus-and-dbusmock-templates into lp:dbus-test-runner/15.10
- support-gtestdbus-and-dbusmock-templates
- Merge into trunk.15.10
Status: | Needs review |
---|---|
Proposed branch: | lp:~charlesk/dbus-test-runner/support-gtestdbus-and-dbusmock-templates |
Merge into: | lp:dbus-test-runner/15.10 |
Diff against target: |
1683 lines (+389/-560) 21 files modified
Makefile.am (+0/-1) configure.ac (+0/-1) data/Makefile.am (+0/-5) data/session.conf (+0/-42) data/system.conf (+0/-42) debian/libdbustest1.symbols (+2/-3) libdbustest/Makefile.am (+2/-4) libdbustest/bustle.c (+4/-4) libdbustest/dbus-mock.c (+66/-16) libdbustest/dbus-mock.h (+1/-0) libdbustest/process.c (+7/-7) libdbustest/service.c (+293/-379) libdbustest/service.h (+3/-7) libdbustest/task.c (+2/-2) libdbustest/watchdog.c (+2/-2) po/Makefile.in.in (+5/-6) src/Makefile.am (+0/-1) src/dbus-test-runner.c (+0/-16) tests/Makefile.am (+2/-2) tests/test-libdbustest-mock.c (+0/-14) tests/test-libdbustest.c (+0/-6) |
To merge this branch: | bzr merge lp:~charlesk/dbus-test-runner/support-gtestdbus-and-dbusmock-templates |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Needs Fixing | |
Ted Gould | Pending | ||
Review via email: mp+271834@code.launchpad.net |
Commit message
Add support for dbusmock templates and for working with externally-managed DBuses and GTestDBuses.
Description of the change
Add support for dbusmock templates and for working with externally-managed DBuses and GTestDBuses.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:112
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 113. By Charles Kerr
-
we're removing some public functions and adding others, so bump both ABI and API
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:113
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Unmerged revisions
- 113. By Charles Kerr
-
we're removing some public functions and adding others, so bump both ABI and API
- 112. By Charles Kerr
-
copyediting: tidy up the new comments a little
- 111. By Charles Kerr
-
remove unused macro
- 110. By Charles Kerr
-
and while we're in the neighborhood, update DbusTestService to use G_DEFINE_
TYPE_WITH_ PRIVATE - 109. By Charles Kerr
-
revert dbus_test_
service_ new() to take an address argument, as with the current ABI - 108. By Charles Kerr
-
in libdbustest/, get the mock class working with the new template property
- 107. By Charles Kerr
-
in debian/
libdbustest1. symbols, add dbus_test_ dbus_mock_ new_from_ template( ) - 106. By Charles Kerr
-
in libdbustest, add new method dbus_test_
dbus_mock_ new_from_ template( ) - 105. By Charles Kerr
-
in libdbustest/
service. c, copyediting -- make whitespace of new code more consistent with existing code - 104. By Charles Kerr
-
remove now-unused method dbus_test_
service_ set_keep_ environment( )
Preview Diff
1 | === modified file 'Makefile.am' | |||
2 | --- Makefile.am 2012-04-23 15:45:16 +0000 | |||
3 | +++ Makefile.am 2015-09-21 17:10:37 +0000 | |||
4 | @@ -1,5 +1,4 @@ | |||
5 | 1 | SUBDIRS = \ | 1 | SUBDIRS = \ |
6 | 2 | data \ | ||
7 | 3 | libdbustest \ | 2 | libdbustest \ |
8 | 4 | src \ | 3 | src \ |
9 | 5 | tests \ | 4 | tests \ |
10 | 6 | 5 | ||
11 | === modified file 'configure.ac' | |||
12 | --- configure.ac 2015-01-20 22:26:38 +0000 | |||
13 | +++ configure.ac 2015-09-21 17:10:37 +0000 | |||
14 | @@ -76,7 +76,6 @@ | |||
15 | 76 | po/Makefile.in | 76 | po/Makefile.in |
16 | 77 | libdbustest/Makefile | 77 | libdbustest/Makefile |
17 | 78 | src/Makefile | 78 | src/Makefile |
18 | 79 | data/Makefile | ||
19 | 80 | tests/Makefile | 79 | tests/Makefile |
20 | 81 | ]) | 80 | ]) |
21 | 82 | 81 | ||
22 | 83 | 82 | ||
23 | === removed directory 'data' | |||
24 | === removed file 'data/Makefile.am' | |||
25 | --- data/Makefile.am 2014-11-06 19:48:03 +0000 | |||
26 | +++ data/Makefile.am 1970-01-01 00:00:00 +0000 | |||
27 | @@ -1,5 +0,0 @@ | |||
28 | 1 | |||
29 | 2 | sessionconfdir = $(datadir)/dbus-test-runner/ | ||
30 | 3 | sessionconf_DATA = session.conf system.conf | ||
31 | 4 | |||
32 | 5 | EXTRA_DIST = session.conf system.conf | ||
33 | 6 | 0 | ||
34 | === removed file 'data/session.conf' | |||
35 | --- data/session.conf 2012-02-20 18:24:44 +0000 | |||
36 | +++ data/session.conf 1970-01-01 00:00:00 +0000 | |||
37 | @@ -1,42 +0,0 @@ | |||
38 | 1 | <!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN" | ||
39 | 2 | "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> | ||
40 | 3 | <busconfig> | ||
41 | 4 | <!-- If we fork, keep the user's original umask to avoid affecting | ||
42 | 5 | the behavior of child processes. --> | ||
43 | 6 | <keep_umask/> | ||
44 | 7 | |||
45 | 8 | <type>session</type> | ||
46 | 9 | |||
47 | 10 | <listen>unix:tmpdir=/tmp</listen> | ||
48 | 11 | |||
49 | 12 | <standard_session_servicedirs /> | ||
50 | 13 | |||
51 | 14 | <policy context="default"> | ||
52 | 15 | <!-- Allow everything to be sent --> | ||
53 | 16 | <allow send_destination="*" eavesdrop="true"/> | ||
54 | 17 | <!-- Allow everything to be received --> | ||
55 | 18 | <allow eavesdrop="true"/> | ||
56 | 19 | <!-- Allow anyone to own anything --> | ||
57 | 20 | <allow own="*"/> | ||
58 | 21 | </policy> | ||
59 | 22 | |||
60 | 23 | <!-- raise the service start timeout to 40 seconds as it can timeout | ||
61 | 24 | on the live cd on slow machines --> | ||
62 | 25 | <limit name="service_start_timeout">60000</limit> | ||
63 | 26 | |||
64 | 27 | <!-- the memory limits are 1G instead of say 4G because they can't exceed 32-bit signed int max --> | ||
65 | 28 | <limit name="max_incoming_bytes">1000000000</limit> | ||
66 | 29 | <limit name="max_outgoing_bytes">1000000000</limit> | ||
67 | 30 | <limit name="max_message_size">1000000000</limit> | ||
68 | 31 | <limit name="service_start_timeout">120000</limit> | ||
69 | 32 | <limit name="auth_timeout">240000</limit> | ||
70 | 33 | <limit name="max_completed_connections">100000</limit> | ||
71 | 34 | <limit name="max_incomplete_connections">10000</limit> | ||
72 | 35 | <limit name="max_connections_per_user">100000</limit> | ||
73 | 36 | <limit name="max_pending_service_starts">10000</limit> | ||
74 | 37 | <limit name="max_names_per_connection">50000</limit> | ||
75 | 38 | <limit name="max_match_rules_per_connection">50000</limit> | ||
76 | 39 | <limit name="max_replies_per_connection">50000</limit> | ||
77 | 40 | <limit name="reply_timeout">300000</limit> | ||
78 | 41 | |||
79 | 42 | </busconfig> | ||
80 | 43 | 0 | ||
81 | === removed file 'data/system.conf' | |||
82 | --- data/system.conf 2014-11-06 19:54:27 +0000 | |||
83 | +++ data/system.conf 1970-01-01 00:00:00 +0000 | |||
84 | @@ -1,42 +0,0 @@ | |||
85 | 1 | <!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN" | ||
86 | 2 | "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> | ||
87 | 3 | <busconfig> | ||
88 | 4 | <!-- If we fork, keep the user's original umask to avoid affecting | ||
89 | 5 | the behavior of child processes. --> | ||
90 | 6 | <keep_umask/> | ||
91 | 7 | |||
92 | 8 | <type>system</type> | ||
93 | 9 | |||
94 | 10 | <listen>unix:tmpdir=/tmp</listen> | ||
95 | 11 | |||
96 | 12 | <standard_session_servicedirs /> | ||
97 | 13 | |||
98 | 14 | <policy context="default"> | ||
99 | 15 | <!-- Allow everything to be sent --> | ||
100 | 16 | <allow send_destination="*" eavesdrop="true"/> | ||
101 | 17 | <!-- Allow everything to be received --> | ||
102 | 18 | <allow eavesdrop="true"/> | ||
103 | 19 | <!-- Allow anyone to own anything --> | ||
104 | 20 | <allow own="*"/> | ||
105 | 21 | </policy> | ||
106 | 22 | |||
107 | 23 | <!-- raise the service start timeout to 40 seconds as it can timeout | ||
108 | 24 | on the live cd on slow machines --> | ||
109 | 25 | <limit name="service_start_timeout">60000</limit> | ||
110 | 26 | |||
111 | 27 | <!-- the memory limits are 1G instead of say 4G because they can't exceed 32-bit signed int max --> | ||
112 | 28 | <limit name="max_incoming_bytes">1000000000</limit> | ||
113 | 29 | <limit name="max_outgoing_bytes">1000000000</limit> | ||
114 | 30 | <limit name="max_message_size">1000000000</limit> | ||
115 | 31 | <limit name="service_start_timeout">120000</limit> | ||
116 | 32 | <limit name="auth_timeout">240000</limit> | ||
117 | 33 | <limit name="max_completed_connections">100000</limit> | ||
118 | 34 | <limit name="max_incomplete_connections">10000</limit> | ||
119 | 35 | <limit name="max_connections_per_user">100000</limit> | ||
120 | 36 | <limit name="max_pending_service_starts">10000</limit> | ||
121 | 37 | <limit name="max_names_per_connection">50000</limit> | ||
122 | 38 | <limit name="max_match_rules_per_connection">50000</limit> | ||
123 | 39 | <limit name="max_replies_per_connection">50000</limit> | ||
124 | 40 | <limit name="reply_timeout">300000</limit> | ||
125 | 41 | |||
126 | 42 | </busconfig> | ||
127 | 43 | 0 | ||
128 | === modified file 'debian/libdbustest1.symbols' | |||
129 | --- debian/libdbustest1.symbols 2015-02-18 03:44:59 +0000 | |||
130 | +++ debian/libdbustest1.symbols 2015-09-21 17:10:37 +0000 | |||
131 | @@ -5,6 +5,7 @@ | |||
132 | 5 | dbus_test_dbus_mock_get_object@Base 15.04.0+15.04.20141209 | 5 | dbus_test_dbus_mock_get_object@Base 15.04.0+15.04.20141209 |
133 | 6 | dbus_test_dbus_mock_get_type@Base 15.04.0+15.04.20141209 | 6 | dbus_test_dbus_mock_get_type@Base 15.04.0+15.04.20141209 |
134 | 7 | dbus_test_dbus_mock_new@Base 15.04.0+15.04.20141209 | 7 | dbus_test_dbus_mock_new@Base 15.04.0+15.04.20141209 |
135 | 8 | dbus_test_dbus_mock_new_from_template@Base 0replaceme | ||
136 | 8 | dbus_test_dbus_mock_object_add_method@Base 15.04.0+15.04.20141209 | 9 | dbus_test_dbus_mock_object_add_method@Base 15.04.0+15.04.20141209 |
137 | 9 | dbus_test_dbus_mock_object_add_property@Base 15.04.0+15.04.20141209 | 10 | dbus_test_dbus_mock_object_add_property@Base 15.04.0+15.04.20141209 |
138 | 10 | dbus_test_dbus_mock_object_check_method_call@Base 15.04.0+15.04.20141209 | 11 | dbus_test_dbus_mock_object_check_method_call@Base 15.04.0+15.04.20141209 |
139 | @@ -20,12 +21,10 @@ | |||
140 | 20 | dbus_test_service_add_task_with_priority@Base 15.04.0+15.04.20141209 | 21 | dbus_test_service_add_task_with_priority@Base 15.04.0+15.04.20141209 |
141 | 21 | dbus_test_service_get_type@Base 15.04.0+15.04.20141209 | 22 | dbus_test_service_get_type@Base 15.04.0+15.04.20141209 |
142 | 22 | dbus_test_service_new@Base 15.04.0+15.04.20141209 | 23 | dbus_test_service_new@Base 15.04.0+15.04.20141209 |
143 | 24 | dbus_test_service_new_with_test_bus@ 0replaceme | ||
144 | 23 | dbus_test_service_remove_task@Base 15.04.0+15.04.20150218 | 25 | dbus_test_service_remove_task@Base 15.04.0+15.04.20150218 |
145 | 24 | dbus_test_service_run@Base 15.04.0+15.04.20141209 | 26 | dbus_test_service_run@Base 15.04.0+15.04.20141209 |
146 | 25 | dbus_test_service_set_bus@Base 15.04.0+15.04.20141209 | 27 | dbus_test_service_set_bus@Base 15.04.0+15.04.20141209 |
147 | 26 | dbus_test_service_set_conf_file@Base 15.04.0+15.04.20141209 | ||
148 | 27 | dbus_test_service_set_daemon@Base 15.04.0+15.04.20141209 | ||
149 | 28 | dbus_test_service_set_keep_environment@Base 15.04.0+15.04.20141209 | ||
150 | 29 | dbus_test_service_start_tasks@Base 15.04.0+15.04.20141209 | 28 | dbus_test_service_start_tasks@Base 15.04.0+15.04.20141209 |
151 | 30 | dbus_test_service_stop@Base 15.04.0+15.04.20141209 | 29 | dbus_test_service_stop@Base 15.04.0+15.04.20141209 |
152 | 31 | dbus_test_task_get_bus@Base 15.04.0+15.04.20141209 | 30 | dbus_test_task_get_bus@Base 15.04.0+15.04.20141209 |
153 | 32 | 31 | ||
154 | === modified file 'libdbustest/Makefile.am' | |||
155 | --- libdbustest/Makefile.am 2014-11-06 19:51:07 +0000 | |||
156 | +++ libdbustest/Makefile.am 2015-09-21 17:10:37 +0000 | |||
157 | @@ -1,8 +1,8 @@ | |||
158 | 1 | 1 | ||
159 | 2 | lib_LTLIBRARIES = libdbustest.la | 2 | lib_LTLIBRARIES = libdbustest.la |
160 | 3 | 3 | ||
163 | 4 | ABI_VERSION = 1 | 4 | ABI_VERSION = 2 |
164 | 5 | API_VERSION = 1 | 5 | API_VERSION = 2 |
165 | 6 | 6 | ||
166 | 7 | AM_CFLAGS = -Wall | 7 | AM_CFLAGS = -Wall |
167 | 8 | 8 | ||
168 | @@ -35,8 +35,6 @@ | |||
169 | 35 | $(COVERAGE_CFLAGS) \ | 35 | $(COVERAGE_CFLAGS) \ |
170 | 36 | -I$(top_srcdir) \ | 36 | -I$(top_srcdir) \ |
171 | 37 | -I$(builddir) \ | 37 | -I$(builddir) \ |
172 | 38 | -DDEFAULT_SESSION_CONF="\"$(datadir)/dbus-test-runner/session.conf\"" \ | ||
173 | 39 | -DDEFAULT_SYSTEM_CONF="\"$(datadir)/dbus-test-runner/system.conf\"" \ | ||
174 | 40 | -DBUSTLE_DUAL_MONITOR="\"$(pkgdatadir)/dbus-test-bustle-handler\"" \ | 38 | -DBUSTLE_DUAL_MONITOR="\"$(pkgdatadir)/dbus-test-bustle-handler\"" \ |
175 | 41 | -DWATCHDOG="\"$(pkglibexecdir)/dbus-test-watchdog\"" \ | 39 | -DWATCHDOG="\"$(pkglibexecdir)/dbus-test-watchdog\"" \ |
176 | 42 | -DG_LOG_DOMAIN=\"libdbustest\" \ | 40 | -DG_LOG_DOMAIN=\"libdbustest\" \ |
177 | 43 | 41 | ||
178 | === modified file 'libdbustest/bustle.c' | |||
179 | --- libdbustest/bustle.c 2013-12-06 10:04:57 +0000 | |||
180 | +++ libdbustest/bustle.c 2015-09-21 17:10:37 +0000 | |||
181 | @@ -51,7 +51,7 @@ | |||
182 | 51 | GIOCondition condition, | 51 | GIOCondition condition, |
183 | 52 | gpointer data); | 52 | gpointer data); |
184 | 53 | 53 | ||
186 | 54 | G_DEFINE_TYPE (DbusTestBustle, dbus_test_bustle, DBUS_TEST_TYPE_TASK); | 54 | G_DEFINE_TYPE (DbusTestBustle, dbus_test_bustle, DBUS_TEST_TYPE_TASK) |
187 | 55 | 55 | ||
188 | 56 | static void | 56 | static void |
189 | 57 | dbus_test_bustle_class_init (DbusTestBustleClass *klass) | 57 | dbus_test_bustle_class_init (DbusTestBustleClass *klass) |
190 | @@ -114,7 +114,7 @@ | |||
191 | 114 | 114 | ||
192 | 115 | if (bustler->priv->stderr != NULL) { | 115 | if (bustler->priv->stderr != NULL) { |
193 | 116 | while (G_IO_IN & g_io_channel_get_buffer_condition(bustler->priv->stderr)) { | 116 | while (G_IO_IN & g_io_channel_get_buffer_condition(bustler->priv->stderr)) { |
195 | 117 | bustle_write_error(bustler->priv->stderr, 0 /* unused */, bustler); | 117 | bustle_write_error(bustler->priv->stderr, (GIOCondition)0 /* unused */, bustler); |
196 | 118 | } | 118 | } |
197 | 119 | 119 | ||
198 | 120 | g_clear_pointer(&bustler->priv->stderr, g_io_channel_unref); | 120 | g_clear_pointer(&bustler->priv->stderr, g_io_channel_unref); |
199 | @@ -248,7 +248,7 @@ | |||
200 | 248 | bustle_monitor, /* argv */ | 248 | bustle_monitor, /* argv */ |
201 | 249 | NULL, /* envp */ | 249 | NULL, /* envp */ |
202 | 250 | /* G_SPAWN_SEARCH_PATH | G_SPAWN_STDERR_TO_DEV_NULL, */ /* flags */ | 250 | /* G_SPAWN_SEARCH_PATH | G_SPAWN_STDERR_TO_DEV_NULL, */ /* flags */ |
204 | 251 | G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD, /* flags */ | 251 | (GSpawnFlags)(G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD), /* flags */ |
205 | 252 | NULL, /* child setup func */ | 252 | NULL, /* child setup func */ |
206 | 253 | NULL, /* child setup data */ | 253 | NULL, /* child setup data */ |
207 | 254 | &bustler->priv->pid, /* PID */ | 254 | &bustler->priv->pid, /* PID */ |
208 | @@ -279,7 +279,7 @@ | |||
209 | 279 | 279 | ||
210 | 280 | bustler->priv->stderr = g_io_channel_unix_new(bustle_stderr_num); | 280 | bustler->priv->stderr = g_io_channel_unix_new(bustle_stderr_num); |
211 | 281 | g_io_add_watch(bustler->priv->stderr, | 281 | g_io_add_watch(bustler->priv->stderr, |
213 | 282 | G_IO_IN | G_IO_HUP | G_IO_ERR, /* conditions */ | 282 | (GIOCondition)(G_IO_IN | G_IO_HUP | G_IO_ERR), /* conditions */ |
214 | 283 | bustle_write_error, /* func */ | 283 | bustle_write_error, /* func */ |
215 | 284 | bustler); /* func data */ | 284 | bustler); /* func data */ |
216 | 285 | 285 | ||
217 | 286 | 286 | ||
218 | === modified file 'libdbustest/dbus-mock.c' | |||
219 | --- libdbustest/dbus-mock.c 2015-01-30 02:43:44 +0000 | |||
220 | +++ libdbustest/dbus-mock.c 2015-09-21 17:10:37 +0000 | |||
221 | @@ -30,6 +30,7 @@ | |||
222 | 30 | 30 | ||
223 | 31 | struct _DbusTestDbusMockPrivate { | 31 | struct _DbusTestDbusMockPrivate { |
224 | 32 | gchar * name; | 32 | gchar * name; |
225 | 33 | gchar * template_pathname; | ||
226 | 33 | _DbusMockIfaceOrgFreedesktopDBusMock * proxy; | 34 | _DbusMockIfaceOrgFreedesktopDBusMock * proxy; |
227 | 34 | /* Entries of DbusTestDbusMockObject */ | 35 | /* Entries of DbusTestDbusMockObject */ |
228 | 35 | GList * objects; | 36 | GList * objects; |
229 | @@ -65,9 +66,12 @@ | |||
230 | 65 | enum { | 66 | enum { |
231 | 66 | PROP_0, | 67 | PROP_0, |
232 | 67 | PROP_DBUS_NAME, | 68 | PROP_DBUS_NAME, |
233 | 69 | PROP_TEMPLATE_PATHNAME, | ||
234 | 68 | NUM_PROPS | 70 | NUM_PROPS |
235 | 69 | }; | 71 | }; |
236 | 70 | 72 | ||
237 | 73 | static GParamSpec * properties[NUM_PROPS]; | ||
238 | 74 | |||
239 | 71 | enum { | 75 | enum { |
240 | 72 | ERROR_METHOD_NOT_FOUND, | 76 | ERROR_METHOD_NOT_FOUND, |
241 | 73 | NUM_ERRORS | 77 | NUM_ERRORS |
242 | @@ -96,8 +100,8 @@ | |||
243 | 96 | static void method_free (gpointer data); | 100 | static void method_free (gpointer data); |
244 | 97 | static void property_free (gpointer data); | 101 | static void property_free (gpointer data); |
245 | 98 | 102 | ||
248 | 99 | G_DEFINE_TYPE (DbusTestDbusMock, dbus_test_dbus_mock, DBUS_TEST_TYPE_PROCESS); | 103 | G_DEFINE_TYPE (DbusTestDbusMock, dbus_test_dbus_mock, DBUS_TEST_TYPE_PROCESS) |
249 | 100 | G_DEFINE_QUARK("dbus-test-dbus-mock", _dbus_mock); | 104 | G_DEFINE_QUARK("dbus-test-dbus-mock", _dbus_mock) |
250 | 101 | 105 | ||
251 | 102 | /* Initialize Class */ | 106 | /* Initialize Class */ |
252 | 103 | static void | 107 | static void |
253 | @@ -113,12 +117,23 @@ | |||
254 | 113 | object_class->set_property = set_property; | 117 | object_class->set_property = set_property; |
255 | 114 | object_class->constructed = constructed; | 118 | object_class->constructed = constructed; |
256 | 115 | 119 | ||
263 | 116 | g_object_class_install_property (object_class, PROP_DBUS_NAME, | 120 | properties[PROP_0] = NULL; |
264 | 117 | g_param_spec_string("dbus-name", | 121 | |
265 | 118 | "DBus Name", | 122 | properties[PROP_DBUS_NAME] = g_param_spec_string( |
266 | 119 | "The well known name for dbusmock on the session bus", | 123 | "dbus-name", |
267 | 120 | "com.canonical.DBusTestRunner.DBusMock", /* default */ | 124 | "DBus Name", |
268 | 121 | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)); | 125 | "The well known name for dbusmock on the session bus", |
269 | 126 | "com.canonical.DBusTestRunner.DBusMock", /* default */ | ||
270 | 127 | (GParamFlags)(G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)); | ||
271 | 128 | |||
272 | 129 | properties[PROP_TEMPLATE_PATHNAME] = g_param_spec_string( | ||
273 | 130 | "template-pathname", | ||
274 | 131 | "Template Pathname", | ||
275 | 132 | "If using a dbusmock template, the full pathname for its file", | ||
276 | 133 | NULL, /* default */ | ||
277 | 134 | (GParamFlags)(G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)); | ||
278 | 135 | |||
279 | 136 | g_object_class_install_properties (object_class, NUM_PROPS, properties); | ||
280 | 122 | 137 | ||
281 | 123 | DbusTestTaskClass * tclass = DBUS_TEST_TASK_CLASS(klass); | 138 | DbusTestTaskClass * tclass = DBUS_TEST_TASK_CLASS(klass); |
282 | 124 | 139 | ||
283 | @@ -202,6 +217,9 @@ | |||
284 | 202 | case PROP_DBUS_NAME: | 217 | case PROP_DBUS_NAME: |
285 | 203 | g_value_set_string(value, self->priv->name); | 218 | g_value_set_string(value, self->priv->name); |
286 | 204 | break; | 219 | break; |
287 | 220 | case PROP_TEMPLATE_PATHNAME: | ||
288 | 221 | g_value_set_string(value, self->priv->template_pathname); | ||
289 | 222 | break; | ||
290 | 205 | default: | 223 | default: |
291 | 206 | G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); | 224 | G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); |
292 | 207 | } | 225 | } |
293 | @@ -220,6 +238,10 @@ | |||
294 | 220 | g_free(self->priv->name); | 238 | g_free(self->priv->name); |
295 | 221 | self->priv->name = g_value_dup_string(value); | 239 | self->priv->name = g_value_dup_string(value); |
296 | 222 | break; | 240 | break; |
297 | 241 | case PROP_TEMPLATE_PATHNAME: | ||
298 | 242 | g_free(self->priv->template_pathname); | ||
299 | 243 | self->priv->template_pathname = g_value_dup_string(value); | ||
300 | 244 | break; | ||
301 | 223 | default: | 245 | default: |
302 | 224 | G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); | 246 | G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); |
303 | 225 | } | 247 | } |
304 | @@ -350,7 +372,7 @@ | |||
305 | 350 | 372 | ||
306 | 351 | if (add_object) { | 373 | if (add_object) { |
307 | 352 | proxy = _dbus_mock_iface_org_freedesktop_dbus_mock_proxy_new_sync(mock->priv->bus, | 374 | proxy = _dbus_mock_iface_org_freedesktop_dbus_mock_proxy_new_sync(mock->priv->bus, |
309 | 353 | G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, | 375 | (GDBusProxyFlags)(G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START), |
310 | 354 | mock->priv->name, | 376 | mock->priv->name, |
311 | 355 | object->object_path, /* path */ | 377 | object->object_path, /* path */ |
312 | 356 | mock->priv->cancel, | 378 | mock->priv->cancel, |
313 | @@ -442,9 +464,14 @@ | |||
314 | 442 | paramval = "--system"; g_array_append_val(params, paramval); | 464 | paramval = "--system"; g_array_append_val(params, paramval); |
315 | 443 | } | 465 | } |
316 | 444 | 466 | ||
320 | 445 | g_array_append_val(params, self->priv->name); | 467 | if (self->priv->template_pathname != NULL) { |
321 | 446 | paramval = "/"; g_array_append_val(params, paramval); | 468 | paramval = "--template"; g_array_append_val(params, paramval); |
322 | 447 | paramval = "com.canonical.DbusTest.DbusMock"; g_array_append_val(params, paramval); | 469 | paramval = self->priv->template_pathname; g_array_append_val(params, paramval); |
323 | 470 | } else { | ||
324 | 471 | g_array_append_val(params, self->priv->name); | ||
325 | 472 | paramval = "/"; g_array_append_val(params, paramval); | ||
326 | 473 | paramval = "com.canonical.DbusTest.DbusMock"; g_array_append_val(params, paramval); | ||
327 | 474 | } | ||
328 | 448 | 475 | ||
329 | 449 | g_object_set(G_OBJECT(self), "parameters", params, NULL); | 476 | g_object_set(G_OBJECT(self), "parameters", params, NULL); |
330 | 450 | g_array_unref(params); | 477 | g_array_unref(params); |
331 | @@ -478,7 +505,7 @@ | |||
332 | 478 | 505 | ||
333 | 479 | /* Zero, Setup the proxy */ | 506 | /* Zero, Setup the proxy */ |
334 | 480 | self->priv->proxy = _dbus_mock_iface_org_freedesktop_dbus_mock_proxy_new_sync(self->priv->bus, | 507 | self->priv->proxy = _dbus_mock_iface_org_freedesktop_dbus_mock_proxy_new_sync(self->priv->bus, |
336 | 481 | G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, | 508 | (GDBusProxyFlags)(G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START), |
337 | 482 | self->priv->name, | 509 | self->priv->name, |
338 | 483 | "/", /* path */ | 510 | "/", /* path */ |
339 | 484 | self->priv->cancel, | 511 | self->priv->cancel, |
340 | @@ -517,7 +544,6 @@ | |||
341 | 517 | /* Second, Install Objects */ | 544 | /* Second, Install Objects */ |
342 | 518 | GList * lobj = self->priv->objects; | 545 | GList * lobj = self->priv->objects; |
343 | 519 | for (lobj = self->priv->objects; lobj != NULL; lobj = g_list_next(lobj)) { | 546 | for (lobj = self->priv->objects; lobj != NULL; lobj = g_list_next(lobj)) { |
344 | 520 | GError * error = NULL; | ||
345 | 521 | 547 | ||
346 | 522 | DbusTestDbusMockObject * obj = (DbusTestDbusMockObject *)lobj->data; | 548 | DbusTestDbusMockObject * obj = (DbusTestDbusMockObject *)lobj->data; |
347 | 523 | install_object(self, obj, &error); | 549 | install_object(self, obj, &error); |
348 | @@ -554,6 +580,30 @@ | |||
349 | 554 | } | 580 | } |
350 | 555 | 581 | ||
351 | 556 | /** | 582 | /** |
352 | 583 | * dbus_test_dbus_mock_new: | ||
353 | 584 | * @bus_name: The name dbus mock should get on the bus | ||
354 | 585 | * | ||
355 | 586 | * Creates a new dbus mock process with the given dbusmock template. | ||
356 | 587 | * As with dbus_test_dbus_mock_new(), this function doesn't start | ||
357 | 588 | * the process -- it queues up a mock to be started when the DBusTest | ||
358 | 589 | * framework is run. | ||
359 | 590 | * | ||
360 | 591 | * Return value: A new dbus mock instance | ||
361 | 592 | */ | ||
362 | 593 | DbusTestDbusMock * | ||
363 | 594 | dbus_test_dbus_mock_new_from_template (const gchar * template_pathname) | ||
364 | 595 | { | ||
365 | 596 | g_return_val_if_fail(template_pathname != NULL, NULL); | ||
366 | 597 | g_return_val_if_fail(*template_pathname != '\0', NULL); | ||
367 | 598 | |||
368 | 599 | DbusTestDbusMock * mock = g_object_new(DBUS_TEST_TYPE_DBUS_MOCK, | ||
369 | 600 | "template-pathname", template_pathname, | ||
370 | 601 | NULL); | ||
371 | 602 | |||
372 | 603 | return mock; | ||
373 | 604 | } | ||
374 | 605 | |||
375 | 606 | /** | ||
376 | 557 | * dbus_test_dbus_mock_get_object: | 607 | * dbus_test_dbus_mock_get_object: |
377 | 558 | * @mock: A #DbusTestDbusMock instance | 608 | * @mock: A #DbusTestDbusMock instance |
378 | 559 | * @path: DBus path of the object | 609 | * @path: DBus path of the object |
379 | @@ -666,7 +716,7 @@ | |||
380 | 666 | * Return value: Whether it was registered successfully | 716 | * Return value: Whether it was registered successfully |
381 | 667 | */ | 717 | */ |
382 | 668 | gboolean | 718 | gboolean |
384 | 669 | dbus_test_dbus_mock_object_add_method (DbusTestDbusMock * mock, DbusTestDbusMockObject * obj, const gchar * method, const GVariantType * inparams, const GVariantType * outparams, const gchar * python_code, G_GNUC_UNUSED GError ** error) | 719 | dbus_test_dbus_mock_object_add_method (DbusTestDbusMock * mock, DbusTestDbusMockObject * obj, const gchar * method, const GVariantType * inparams, const GVariantType * outparams, const gchar * python_code, GError ** error) |
385 | 670 | { | 720 | { |
386 | 671 | g_return_val_if_fail(DBUS_TEST_IS_DBUS_MOCK(mock), FALSE); | 721 | g_return_val_if_fail(DBUS_TEST_IS_DBUS_MOCK(mock), FALSE); |
387 | 672 | g_return_val_if_fail(obj != NULL, FALSE); | 722 | g_return_val_if_fail(obj != NULL, FALSE); |
388 | @@ -942,7 +992,7 @@ | |||
389 | 942 | * Return value: Whether it was added | 992 | * Return value: Whether it was added |
390 | 943 | */ | 993 | */ |
391 | 944 | gboolean | 994 | gboolean |
393 | 945 | dbus_test_dbus_mock_object_add_property (DbusTestDbusMock * mock, DbusTestDbusMockObject * obj, const gchar * name, const GVariantType * type, GVariant * value, G_GNUC_UNUSED GError ** error) | 995 | dbus_test_dbus_mock_object_add_property (DbusTestDbusMock * mock, DbusTestDbusMockObject * obj, const gchar * name, const GVariantType * type, GVariant * value, GError ** error) |
394 | 946 | { | 996 | { |
395 | 947 | g_return_val_if_fail(DBUS_TEST_IS_DBUS_MOCK(mock), FALSE); | 997 | g_return_val_if_fail(DBUS_TEST_IS_DBUS_MOCK(mock), FALSE); |
396 | 948 | g_return_val_if_fail(obj != NULL, FALSE); | 998 | g_return_val_if_fail(obj != NULL, FALSE); |
397 | 949 | 999 | ||
398 | === modified file 'libdbustest/dbus-mock.h' | |||
399 | --- libdbustest/dbus-mock.h 2013-11-01 01:16:08 +0000 | |||
400 | +++ libdbustest/dbus-mock.h 2015-09-21 17:10:37 +0000 | |||
401 | @@ -61,6 +61,7 @@ | |||
402 | 61 | 61 | ||
403 | 62 | DbusTestDbusMock * dbus_test_dbus_mock_new (const gchar * bus_name); | 62 | DbusTestDbusMock * dbus_test_dbus_mock_new (const gchar * bus_name); |
404 | 63 | 63 | ||
405 | 64 | DbusTestDbusMock * dbus_test_dbus_mock_new_from_template (const char * template_pathname); | ||
406 | 64 | 65 | ||
407 | 65 | /* Object stuff */ | 66 | /* Object stuff */ |
408 | 66 | 67 | ||
409 | 67 | 68 | ||
410 | === modified file 'libdbustest/process.c' | |||
411 | --- libdbustest/process.c 2013-12-20 21:49:44 +0000 | |||
412 | +++ libdbustest/process.c 2015-09-21 17:10:37 +0000 | |||
413 | @@ -64,7 +64,7 @@ | |||
414 | 64 | const GValue * value, | 64 | const GValue * value, |
415 | 65 | GParamSpec * pspec); | 65 | GParamSpec * pspec); |
416 | 66 | 66 | ||
418 | 67 | G_DEFINE_TYPE (DbusTestProcess, dbus_test_process, DBUS_TEST_TYPE_TASK); | 67 | G_DEFINE_TYPE (DbusTestProcess, dbus_test_process, DBUS_TEST_TYPE_TASK) |
419 | 68 | 68 | ||
420 | 69 | static void | 69 | static void |
421 | 70 | dbus_test_process_class_init (DbusTestProcessClass *klass) | 70 | dbus_test_process_class_init (DbusTestProcessClass *klass) |
422 | @@ -83,13 +83,13 @@ | |||
423 | 83 | "Executable Name", | 83 | "Executable Name", |
424 | 84 | "The executable being run by the process object", | 84 | "The executable being run by the process object", |
425 | 85 | "", /* default */ | 85 | "", /* default */ |
427 | 86 | G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE)); | 86 | (GParamFlags)(G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE))); |
428 | 87 | g_object_class_install_property (object_class, PROP_PARAMETERS, | 87 | g_object_class_install_property (object_class, PROP_PARAMETERS, |
429 | 88 | g_param_spec_boxed("parameters", | 88 | g_param_spec_boxed("parameters", |
430 | 89 | "Parameters", | 89 | "Parameters", |
431 | 90 | "Parameters to pass to the executable", | 90 | "Parameters to pass to the executable", |
432 | 91 | G_TYPE_ARRAY, | 91 | G_TYPE_ARRAY, |
434 | 92 | G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE)); | 92 | (GParamFlags)(G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE))); |
435 | 93 | 93 | ||
436 | 94 | DbusTestTaskClass * task_class = DBUS_TEST_TASK_CLASS(klass); | 94 | DbusTestTaskClass * task_class = DBUS_TEST_TASK_CLASS(klass); |
437 | 95 | 95 | ||
438 | @@ -194,7 +194,7 @@ | |||
439 | 194 | 194 | ||
440 | 195 | /* Get a property */ | 195 | /* Get a property */ |
441 | 196 | static void | 196 | static void |
443 | 197 | get_property (GObject * object, guint property_id, G_GNUC_UNUSED GValue * value, GParamSpec * pspec) | 197 | get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) |
444 | 198 | { | 198 | { |
445 | 199 | DbusTestProcess * self = DBUS_TEST_PROCESS(object); | 199 | DbusTestProcess * self = DBUS_TEST_PROCESS(object); |
446 | 200 | 200 | ||
447 | @@ -214,7 +214,7 @@ | |||
448 | 214 | 214 | ||
449 | 215 | /* Set a property */ | 215 | /* Set a property */ |
450 | 216 | static void | 216 | static void |
452 | 217 | set_property (GObject * object, guint property_id, G_GNUC_UNUSED const GValue * value, GParamSpec * pspec) | 217 | set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) |
453 | 218 | { | 218 | { |
454 | 219 | if (get_state(DBUS_TEST_TASK(object)) == DBUS_TEST_TASK_STATE_RUNNING) { | 219 | if (get_state(DBUS_TEST_TASK(object)) == DBUS_TEST_TASK_STATE_RUNNING) { |
455 | 220 | g_warning("Can't set properties on a running process"); | 220 | g_warning("Can't set properties on a running process"); |
456 | @@ -324,7 +324,7 @@ | |||
457 | 324 | g_spawn_async_with_pipes(current_dir, | 324 | g_spawn_async_with_pipes(current_dir, |
458 | 325 | argv, /* argv */ | 325 | argv, /* argv */ |
459 | 326 | NULL, /* envp */ | 326 | NULL, /* envp */ |
461 | 327 | G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD, /* flags */ | 327 | (GSpawnFlags)(G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD), /* flags */ |
462 | 328 | NULL, /* child setup func */ | 328 | NULL, /* child setup func */ |
463 | 329 | NULL, /* child setup data */ | 329 | NULL, /* child setup data */ |
464 | 330 | &(process->priv->pid), /* PID */ | 330 | &(process->priv->pid), /* PID */ |
465 | @@ -352,7 +352,7 @@ | |||
466 | 352 | process->priv->io_chan = g_io_channel_unix_new(proc_stdout); | 352 | process->priv->io_chan = g_io_channel_unix_new(proc_stdout); |
467 | 353 | g_io_channel_set_buffer_size(process->priv->io_chan, 10 * 1024 * 1024); /* 10 MB should be enough for anyone */ | 353 | g_io_channel_set_buffer_size(process->priv->io_chan, 10 * 1024 * 1024); /* 10 MB should be enough for anyone */ |
468 | 354 | process->priv->io_watch = g_io_add_watch(process->priv->io_chan, | 354 | process->priv->io_watch = g_io_add_watch(process->priv->io_chan, |
470 | 355 | G_IO_IN | G_IO_HUP | G_IO_ERR, /* conditions */ | 355 | (GIOCondition)(G_IO_IN | G_IO_HUP | G_IO_ERR), /* conditions */ |
471 | 356 | proc_writes, /* func */ | 356 | proc_writes, /* func */ |
472 | 357 | process); /* func data */ | 357 | process); /* func data */ |
473 | 358 | 358 | ||
474 | 359 | 359 | ||
475 | === modified file 'libdbustest/service.c' | |||
476 | --- libdbustest/service.c 2015-02-13 17:19:17 +0000 | |||
477 | +++ libdbustest/service.c 2015-09-21 17:10:37 +0000 | |||
478 | @@ -29,21 +29,27 @@ | |||
479 | 29 | #include "glib-compat.h" | 29 | #include "glib-compat.h" |
480 | 30 | 30 | ||
481 | 31 | #include "dbus-test.h" | 31 | #include "dbus-test.h" |
486 | 32 | #include "watchdog.h" | 32 | |
487 | 33 | 33 | enum { | |
488 | 34 | typedef enum _ServiceState ServiceState; | 34 | PROP_0, |
489 | 35 | enum _ServiceState { | 35 | PROP_ADDRESS, |
490 | 36 | PROP_TEST_DBUS, | ||
491 | 37 | PROP_LAST | ||
492 | 38 | }; | ||
493 | 39 | |||
494 | 40 | static GParamSpec * properties[PROP_LAST]; | ||
495 | 41 | |||
496 | 42 | typedef enum _ServiceState { | ||
497 | 36 | STATE_INIT, | 43 | STATE_INIT, |
501 | 37 | STATE_DAEMON_STARTING, | 44 | STATE_BUS_STARTED, |
499 | 38 | STATE_DAEMON_STARTED, | ||
500 | 39 | STATE_DAEMON_FAILED, | ||
502 | 40 | STATE_STARTING, | 45 | STATE_STARTING, |
503 | 41 | STATE_STARTED, | 46 | STATE_STARTED, |
504 | 42 | STATE_RUNNING, | 47 | STATE_RUNNING, |
505 | 43 | STATE_FINISHED | 48 | STATE_FINISHED |
507 | 44 | }; | 49 | } |
508 | 50 | ServiceState; | ||
509 | 45 | 51 | ||
511 | 46 | struct _DbusTestServicePrivate { | 52 | typedef struct DbusTestServicePrivate { |
512 | 47 | GQueue tasks_first; | 53 | GQueue tasks_first; |
513 | 48 | GQueue tasks_normal; | 54 | GQueue tasks_normal; |
514 | 49 | GQueue tasks_last; | 55 | GQueue tasks_last; |
515 | @@ -51,36 +57,28 @@ | |||
516 | 51 | GMainLoop * mainloop; | 57 | GMainLoop * mainloop; |
517 | 52 | ServiceState state; | 58 | ServiceState state; |
518 | 53 | 59 | ||
533 | 54 | gboolean daemon_crashed; | 60 | gchar * external_bus_address; |
534 | 55 | 61 | ||
535 | 56 | GPid dbus; | 62 | GTestDBus * test_dbus; |
536 | 57 | guint dbus_watch; | 63 | gboolean test_dbus_started_here; |
523 | 58 | GIOChannel * dbus_io; | ||
524 | 59 | guint dbus_io_watch; | ||
525 | 60 | gchar * dbus_daemon; | ||
526 | 61 | gchar * dbus_configfile; | ||
527 | 62 | |||
528 | 63 | gboolean first_time; | ||
529 | 64 | gboolean keep_env; | ||
530 | 65 | |||
531 | 66 | DbusTestWatchdog * watchdog; | ||
532 | 67 | guint watchdog_source; | ||
537 | 68 | 64 | ||
538 | 69 | DbusTestServiceBus bus_type; | 65 | DbusTestServiceBus bus_type; |
540 | 70 | }; | 66 | } |
541 | 67 | DbusTestServicePrivate; | ||
542 | 71 | 68 | ||
543 | 72 | #define SERVICE_CHANGE_HANDLER "dbus-test-service-change-handler" | 69 | #define SERVICE_CHANGE_HANDLER "dbus-test-service-change-handler" |
544 | 73 | 70 | ||
545 | 74 | #define DBUS_TEST_SERVICE_GET_PRIVATE(o) \ | ||
546 | 75 | (G_TYPE_INSTANCE_GET_PRIVATE ((o), DBUS_TEST_TYPE_SERVICE, DbusTestServicePrivate)) | ||
547 | 76 | |||
548 | 77 | static void dbus_test_service_class_init (DbusTestServiceClass *klass); | 71 | static void dbus_test_service_class_init (DbusTestServiceClass *klass); |
549 | 78 | static void dbus_test_service_init (DbusTestService *self); | 72 | static void dbus_test_service_init (DbusTestService *self); |
550 | 79 | static void dbus_test_service_dispose (GObject *object); | 73 | static void dbus_test_service_dispose (GObject *object); |
551 | 80 | static void dbus_test_service_finalize (GObject *object); | 74 | static void dbus_test_service_finalize (GObject *object); |
555 | 81 | static gboolean watchdog_ping (gpointer user_data); | 75 | static void dbus_test_service_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec); |
556 | 82 | 76 | static void dbus_test_service_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec); | |
557 | 83 | G_DEFINE_TYPE (DbusTestService, dbus_test_service, G_TYPE_OBJECT); | 77 | |
558 | 78 | G_DEFINE_TYPE_WITH_PRIVATE(DbusTestService, dbus_test_service, G_TYPE_OBJECT) | ||
559 | 79 | |||
560 | 80 | #define get_priv(service) ((DbusTestServicePrivate*)dbus_test_service_get_instance_private(service)) | ||
561 | 81 | |||
562 | 84 | 82 | ||
563 | 85 | static void | 83 | static void |
564 | 86 | dbus_test_service_class_init (DbusTestServiceClass *klass) | 84 | dbus_test_service_class_init (DbusTestServiceClass *klass) |
565 | @@ -91,6 +89,30 @@ | |||
566 | 91 | 89 | ||
567 | 92 | object_class->dispose = dbus_test_service_dispose; | 90 | object_class->dispose = dbus_test_service_dispose; |
568 | 93 | object_class->finalize = dbus_test_service_finalize; | 91 | object_class->finalize = dbus_test_service_finalize; |
569 | 92 | object_class->get_property = dbus_test_service_get_property; | ||
570 | 93 | object_class->set_property = dbus_test_service_set_property; | ||
571 | 94 | |||
572 | 95 | properties[PROP_0] = NULL; | ||
573 | 96 | |||
574 | 97 | properties[PROP_TEST_DBUS] = g_param_spec_object ( | ||
575 | 98 | "test-dbus", | ||
576 | 99 | "Test DBus", | ||
577 | 100 | "Externally-owned test dbus. (Optional)", | ||
578 | 101 | G_TYPE_TEST_DBUS, | ||
579 | 102 | (GParamFlags)(G_PARAM_READWRITE | | ||
580 | 103 | G_PARAM_CONSTRUCT_ONLY | | ||
581 | 104 | G_PARAM_STATIC_STRINGS)); | ||
582 | 105 | |||
583 | 106 | properties[PROP_ADDRESS] = g_param_spec_string ( | ||
584 | 107 | "external-bus-address", | ||
585 | 108 | "External Bus Address", | ||
586 | 109 | "Address of externally-managed DBus for service to run on. (Optional)", | ||
587 | 110 | NULL, | ||
588 | 111 | (GParamFlags)(G_PARAM_READWRITE | | ||
589 | 112 | G_PARAM_CONSTRUCT_ONLY | | ||
590 | 113 | G_PARAM_STATIC_STRINGS)); | ||
591 | 114 | |||
592 | 115 | g_object_class_install_properties (object_class, PROP_LAST, properties); | ||
593 | 94 | 116 | ||
594 | 95 | return; | 117 | return; |
595 | 96 | } | 118 | } |
596 | @@ -98,35 +120,16 @@ | |||
597 | 98 | static void | 120 | static void |
598 | 99 | dbus_test_service_init (DbusTestService *self) | 121 | dbus_test_service_init (DbusTestService *self) |
599 | 100 | { | 122 | { |
629 | 101 | self->priv = DBUS_TEST_SERVICE_GET_PRIVATE(self); | 123 | DbusTestServicePrivate * priv = get_priv(self); |
630 | 102 | 124 | ||
631 | 103 | g_queue_init(&self->priv->tasks_first); | 125 | g_queue_init(&priv->tasks_first); |
632 | 104 | g_queue_init(&self->priv->tasks_normal); | 126 | g_queue_init(&priv->tasks_normal); |
633 | 105 | g_queue_init(&self->priv->tasks_last); | 127 | g_queue_init(&priv->tasks_last); |
634 | 106 | 128 | ||
635 | 107 | self->priv->mainloop = g_main_loop_new(NULL, FALSE); | 129 | priv->mainloop = g_main_loop_new(NULL, FALSE); |
636 | 108 | self->priv->state = STATE_INIT; | 130 | priv->state = STATE_INIT; |
637 | 109 | 131 | ||
638 | 110 | self->priv->daemon_crashed = FALSE; | 132 | priv->bus_type = DBUS_TEST_SERVICE_BUS_SESSION; |
610 | 111 | |||
611 | 112 | self->priv->dbus = 0; | ||
612 | 113 | self->priv->dbus_watch = 0; | ||
613 | 114 | self->priv->dbus_io = NULL; | ||
614 | 115 | self->priv->dbus_io_watch = 0; | ||
615 | 116 | self->priv->dbus_daemon = g_strdup("dbus-daemon"); | ||
616 | 117 | self->priv->dbus_configfile = g_strdup(DEFAULT_SESSION_CONF); | ||
617 | 118 | |||
618 | 119 | self->priv->first_time = TRUE; | ||
619 | 120 | self->priv->keep_env = FALSE; | ||
620 | 121 | |||
621 | 122 | self->priv->watchdog = g_object_new(DBUS_TEST_TYPE_WATCHDOG, NULL); | ||
622 | 123 | self->priv->watchdog_source = g_timeout_add_seconds_full(G_PRIORITY_DEFAULT, | ||
623 | 124 | 5, | ||
624 | 125 | watchdog_ping, | ||
625 | 126 | g_object_ref(self->priv->watchdog), | ||
626 | 127 | g_object_unref); | ||
627 | 128 | |||
628 | 129 | self->priv->bus_type = DBUS_TEST_SERVICE_BUS_SESSION; | ||
639 | 130 | 133 | ||
640 | 131 | return; | 134 | return; |
641 | 132 | } | 135 | } |
642 | @@ -145,64 +148,36 @@ | |||
643 | 145 | return; | 148 | return; |
644 | 146 | } | 149 | } |
645 | 147 | 150 | ||
646 | 151 | |||
647 | 148 | static void | 152 | static void |
648 | 149 | dbus_test_service_dispose (GObject *object) | 153 | dbus_test_service_dispose (GObject *object) |
649 | 150 | { | 154 | { |
650 | 151 | g_return_if_fail(DBUS_TEST_IS_SERVICE(object)); | 155 | g_return_if_fail(DBUS_TEST_IS_SERVICE(object)); |
705 | 152 | DbusTestService * self = DBUS_TEST_SERVICE(object); | 156 | DbusTestServicePrivate * priv = get_priv(DBUS_TEST_SERVICE(object)); |
706 | 153 | 157 | ||
707 | 154 | if (!g_queue_is_empty(&self->priv->tasks_last)) { | 158 | if (!g_queue_is_empty(&priv->tasks_last)) { |
708 | 155 | g_queue_foreach(&self->priv->tasks_last, task_unref, NULL); | 159 | g_queue_foreach(&priv->tasks_last, task_unref, NULL); |
709 | 156 | g_queue_clear(&self->priv->tasks_last); | 160 | g_queue_clear(&priv->tasks_last); |
710 | 157 | } | 161 | } |
711 | 158 | 162 | ||
712 | 159 | if (!g_queue_is_empty(&self->priv->tasks_normal)) { | 163 | if (!g_queue_is_empty(&priv->tasks_normal)) { |
713 | 160 | g_queue_foreach(&self->priv->tasks_normal, task_unref, NULL); | 164 | g_queue_foreach(&priv->tasks_normal, task_unref, NULL); |
714 | 161 | g_queue_clear(&self->priv->tasks_normal); | 165 | g_queue_clear(&priv->tasks_normal); |
715 | 162 | } | 166 | } |
716 | 163 | 167 | ||
717 | 164 | if (!g_queue_is_empty(&self->priv->tasks_first)) { | 168 | if (!g_queue_is_empty(&priv->tasks_first)) { |
718 | 165 | g_queue_foreach(&self->priv->tasks_first, task_unref, NULL); | 169 | g_queue_foreach(&priv->tasks_first, task_unref, NULL); |
719 | 166 | g_queue_clear(&self->priv->tasks_first); | 170 | g_queue_clear(&priv->tasks_first); |
720 | 167 | } | 171 | } |
721 | 168 | 172 | ||
722 | 169 | if (self->priv->dbus_watch != 0) { | 173 | if (priv->test_dbus_started_here) { |
723 | 170 | g_source_remove(self->priv->dbus_watch); | 174 | priv->test_dbus_started_here = FALSE; |
724 | 171 | self->priv->dbus_watch = 0; | 175 | g_test_dbus_down (priv->test_dbus); |
725 | 172 | } | 176 | } |
726 | 173 | 177 | ||
727 | 174 | if (self->priv->dbus_io_watch != 0) { | 178 | g_clear_object(&priv->test_dbus); |
728 | 175 | g_source_remove(self->priv->dbus_io_watch); | 179 | |
729 | 176 | self->priv->dbus_io_watch = 0; | 180 | g_clear_pointer(&priv->mainloop, g_main_loop_unref); |
676 | 177 | } | ||
677 | 178 | |||
678 | 179 | if (self->priv->dbus_io != NULL) { | ||
679 | 180 | g_io_channel_shutdown(self->priv->dbus_io, TRUE, NULL); | ||
680 | 181 | g_io_channel_unref(self->priv->dbus_io); | ||
681 | 182 | self->priv->dbus_io = NULL; | ||
682 | 183 | } | ||
683 | 184 | |||
684 | 185 | g_print("DBus daemon: Shutdown\n"); | ||
685 | 186 | if (self->priv->dbus != 0) { | ||
686 | 187 | gchar * cmd = g_strdup_printf("kill -9 %d", self->priv->dbus); | ||
687 | 188 | g_spawn_command_line_async(cmd, NULL); | ||
688 | 189 | g_free(cmd); | ||
689 | 190 | |||
690 | 191 | g_spawn_close_pid(self->priv->dbus); | ||
691 | 192 | self->priv->dbus = 0; | ||
692 | 193 | } | ||
693 | 194 | |||
694 | 195 | if (self->priv->mainloop != NULL) { | ||
695 | 196 | g_main_loop_unref(self->priv->mainloop); | ||
696 | 197 | self->priv->mainloop = NULL; | ||
697 | 198 | } | ||
698 | 199 | |||
699 | 200 | g_clear_object(&self->priv->watchdog); | ||
700 | 201 | |||
701 | 202 | if (self->priv->watchdog_source != 0) { | ||
702 | 203 | g_source_remove(self->priv->watchdog_source); | ||
703 | 204 | self->priv->watchdog_source = 0; | ||
704 | 205 | } | ||
730 | 206 | 181 | ||
731 | 207 | G_OBJECT_CLASS (dbus_test_service_parent_class)->dispose (object); | 182 | G_OBJECT_CLASS (dbus_test_service_parent_class)->dispose (object); |
732 | 208 | return; | 183 | return; |
733 | @@ -212,38 +187,100 @@ | |||
734 | 212 | dbus_test_service_finalize (GObject *object) | 187 | dbus_test_service_finalize (GObject *object) |
735 | 213 | { | 188 | { |
736 | 214 | g_return_if_fail(DBUS_TEST_IS_SERVICE(object)); | 189 | g_return_if_fail(DBUS_TEST_IS_SERVICE(object)); |
769 | 215 | DbusTestService * self = DBUS_TEST_SERVICE(object); | 190 | DbusTestServicePrivate * priv = get_priv(DBUS_TEST_SERVICE(object)); |
770 | 216 | 191 | ||
771 | 217 | g_free(self->priv->dbus_daemon); | 192 | g_clear_pointer(&priv->external_bus_address, g_free); |
772 | 218 | self->priv->dbus_daemon = NULL; | 193 | } |
773 | 219 | g_free(self->priv->dbus_configfile); | 194 | |
774 | 220 | self->priv->dbus_configfile = NULL; | 195 | static void |
775 | 221 | 196 | dbus_test_service_get_property (GObject *o, guint property_id, GValue *value, GParamSpec *pspec) | |
776 | 222 | G_OBJECT_CLASS (dbus_test_service_parent_class)->finalize (object); | 197 | { |
777 | 223 | return; | 198 | DbusTestServicePrivate * priv = get_priv(DBUS_TEST_SERVICE(o)); |
778 | 224 | } | 199 | |
779 | 225 | 200 | switch (property_id) { | |
780 | 226 | DbusTestService * | 201 | case PROP_ADDRESS: |
781 | 227 | dbus_test_service_new (G_GNUC_UNUSED const gchar * address) | 202 | g_value_set_string (value, priv->external_bus_address); |
782 | 228 | { | 203 | break; |
783 | 229 | DbusTestService * service = g_object_new(DBUS_TEST_TYPE_SERVICE, | 204 | |
784 | 230 | NULL); | 205 | case PROP_TEST_DBUS: |
785 | 231 | 206 | g_value_set_object (value, priv->test_dbus); | |
786 | 232 | /* TODO: Use the address */ | 207 | break; |
787 | 233 | 208 | ||
788 | 234 | return service; | 209 | default: |
789 | 235 | } | 210 | G_OBJECT_WARN_INVALID_PROPERTY_ID (o, property_id, pspec); |
790 | 236 | 211 | } | |
791 | 237 | /* Ping the watchdog so that it knows we're still alive */ | 212 | } |
792 | 238 | static gboolean | 213 | |
793 | 239 | watchdog_ping (gpointer user_data) | 214 | static void |
794 | 240 | { | 215 | dbus_test_service_set_property (GObject *o, guint property_id, const GValue *value, GParamSpec *pspec) |
795 | 241 | DbusTestWatchdog * watchdog = DBUS_TEST_WATCHDOG(user_data); | 216 | { |
796 | 242 | 217 | DbusTestServicePrivate * priv = get_priv(DBUS_TEST_SERVICE(o)); | |
797 | 243 | dbus_test_watchdog_ping(watchdog); | 218 | |
798 | 244 | 219 | switch (property_id) { | |
799 | 245 | return TRUE; | 220 | case PROP_ADDRESS: |
800 | 246 | } | 221 | g_free(priv->external_bus_address); |
801 | 222 | priv->external_bus_address = g_value_dup_string(value); | ||
802 | 223 | break; | ||
803 | 224 | |||
804 | 225 | case PROP_TEST_DBUS: | ||
805 | 226 | g_warn_if_fail(priv->test_dbus == NULL); | ||
806 | 227 | priv->test_dbus = g_value_dup_object(value); | ||
807 | 228 | break; | ||
808 | 229 | |||
809 | 230 | default: | ||
810 | 231 | G_OBJECT_WARN_INVALID_PROPERTY_ID (o, property_id, pspec); | ||
811 | 232 | } | ||
812 | 233 | } | ||
813 | 234 | |||
814 | 235 | /** | ||
815 | 236 | * dbus_test_service_new: | ||
816 | 237 | * @mock: A #DbusTestDbusMock instance | ||
817 | 238 | * @external_bus_address: Address of an externally-managed bus, or NULL | ||
818 | 239 | * | ||
819 | 240 | * Creates a new DbusTestService. | ||
820 | 241 | * | ||
821 | 242 | * The most common use case is for DbusTestService to create and manage | ||
822 | 243 | * its own test bus. To use an externally-managed bus instead, pass its | ||
823 | 244 | * address in the external_bus_address agument. | ||
824 | 245 | * | ||
825 | 246 | * Return Value: (transfer full): A new DbusTestService | ||
826 | 247 | */ | ||
827 | 248 | DbusTestService * | ||
828 | 249 | dbus_test_service_new (const gchar* external_bus_address) | ||
829 | 250 | { | ||
830 | 251 | DbusTestService * service; | ||
831 | 252 | |||
832 | 253 | if (external_bus_address && *external_bus_address) | ||
833 | 254 | service = g_object_new(DBUS_TEST_TYPE_SERVICE, "external-bus-address", external_bus_address, NULL); | ||
834 | 255 | else | ||
835 | 256 | service = g_object_new(DBUS_TEST_TYPE_SERVICE, NULL); | ||
836 | 257 | |||
837 | 258 | return service; | ||
838 | 259 | } | ||
839 | 260 | |||
840 | 261 | /** | ||
841 | 262 | * dbus_test_service_new_test_bus: | ||
842 | 263 | * @mock: A #DbusTestDbusMock instance | ||
843 | 264 | * @test_bus: An externally-owned GTestDBus | ||
844 | 265 | * | ||
845 | 266 | * Creates a new DbusTestService with uses the specified GTestDBus. | ||
846 | 267 | * | ||
847 | 268 | * Return Value: (transfer full): A new DbusTestService | ||
848 | 269 | */ | ||
849 | 270 | DbusTestService * | ||
850 | 271 | dbus_test_service_new_with_test_bus (GTestDBus * test_dbus) | ||
851 | 272 | { | ||
852 | 273 | g_return_val_if_fail(test_dbus != NULL, NULL); | ||
853 | 274 | g_return_val_if_fail(G_IS_TEST_DBUS(test_dbus), NULL); | ||
854 | 275 | |||
855 | 276 | DbusTestService * service = g_object_new(DBUS_TEST_TYPE_SERVICE, "test-dbus", test_dbus, NULL); | ||
856 | 277 | |||
857 | 278 | return service; | ||
858 | 279 | } | ||
859 | 280 | |||
860 | 281 | /*** | ||
861 | 282 | **** | ||
862 | 283 | ***/ | ||
863 | 247 | 284 | ||
864 | 248 | static gboolean | 285 | static gboolean |
865 | 249 | all_tasks_finished_helper (G_GNUC_UNUSED DbusTestService * service, DbusTestTask * task, G_GNUC_UNUSED gpointer user_data) | 286 | all_tasks_finished_helper (G_GNUC_UNUSED DbusTestService * service, DbusTestTask * task, G_GNUC_UNUSED gpointer user_data) |
866 | @@ -273,9 +310,11 @@ | |||
867 | 273 | static gboolean | 310 | static gboolean |
868 | 274 | all_tasks_bus_match (DbusTestService * service, DbusTestTask * task, G_GNUC_UNUSED gpointer user_data) | 311 | all_tasks_bus_match (DbusTestService * service, DbusTestTask * task, G_GNUC_UNUSED gpointer user_data) |
869 | 275 | { | 312 | { |
871 | 276 | return service->priv->bus_type == DBUS_TEST_SERVICE_BUS_BOTH || | 313 | DbusTestServicePrivate * priv = get_priv(service); |
872 | 314 | |||
873 | 315 | return priv->bus_type == DBUS_TEST_SERVICE_BUS_BOTH || | ||
874 | 277 | dbus_test_task_get_bus(task) == DBUS_TEST_SERVICE_BUS_BOTH || | 316 | dbus_test_task_get_bus(task) == DBUS_TEST_SERVICE_BUS_BOTH || |
876 | 278 | dbus_test_task_get_bus(task) == service->priv->bus_type; | 317 | dbus_test_task_get_bus(task) == priv->bus_type; |
877 | 279 | } | 318 | } |
878 | 280 | 319 | ||
879 | 281 | typedef struct { | 320 | typedef struct { |
880 | @@ -301,6 +340,8 @@ | |||
881 | 301 | static gboolean | 340 | static gboolean |
882 | 302 | all_tasks (DbusTestService * service, gboolean (*helper) (DbusTestService * service, DbusTestTask * task, gpointer user_data), gpointer user_data) | 341 | all_tasks (DbusTestService * service, gboolean (*helper) (DbusTestService * service, DbusTestTask * task, gpointer user_data), gpointer user_data) |
883 | 303 | { | 342 | { |
884 | 343 | DbusTestServicePrivate * priv = get_priv(service); | ||
885 | 344 | |||
886 | 304 | all_tasks_helper_data_t data = { | 345 | all_tasks_helper_data_t data = { |
887 | 305 | .passing = TRUE, | 346 | .passing = TRUE, |
888 | 306 | .service = service, | 347 | .service = service, |
889 | @@ -308,17 +349,17 @@ | |||
890 | 308 | .user_data = user_data | 349 | .user_data = user_data |
891 | 309 | }; | 350 | }; |
892 | 310 | 351 | ||
904 | 311 | g_queue_foreach(&service->priv->tasks_first, all_tasks_helper, &data); | 352 | g_queue_foreach(&priv->tasks_first, all_tasks_helper, &data); |
905 | 312 | if (!data.passing) { | 353 | if (!data.passing) { |
906 | 313 | return FALSE; | 354 | return FALSE; |
907 | 314 | } | 355 | } |
908 | 315 | 356 | ||
909 | 316 | g_queue_foreach(&service->priv->tasks_normal, all_tasks_helper, &data); | 357 | g_queue_foreach(&priv->tasks_normal, all_tasks_helper, &data); |
910 | 317 | if (!data.passing) { | 358 | if (!data.passing) { |
911 | 318 | return FALSE; | 359 | return FALSE; |
912 | 319 | } | 360 | } |
913 | 320 | 361 | ||
914 | 321 | g_queue_foreach(&service->priv->tasks_last, all_tasks_helper, &data); | 362 | g_queue_foreach(&priv->tasks_last, all_tasks_helper, &data); |
915 | 322 | if (!data.passing) { | 363 | if (!data.passing) { |
916 | 323 | return FALSE; | 364 | return FALSE; |
917 | 324 | } | 365 | } |
918 | @@ -354,15 +395,16 @@ | |||
919 | 354 | static void | 395 | static void |
920 | 355 | normalize_name_lengths (DbusTestService * service) | 396 | normalize_name_lengths (DbusTestService * service) |
921 | 356 | { | 397 | { |
922 | 398 | DbusTestServicePrivate * priv = get_priv(service); | ||
923 | 357 | glong length = 0; | 399 | glong length = 0; |
924 | 358 | 400 | ||
928 | 359 | g_queue_foreach(&service->priv->tasks_first, task_get_name_length, &length); | 401 | g_queue_foreach(&priv->tasks_first, task_get_name_length, &length); |
929 | 360 | g_queue_foreach(&service->priv->tasks_normal, task_get_name_length, &length); | 402 | g_queue_foreach(&priv->tasks_normal, task_get_name_length, &length); |
930 | 361 | g_queue_foreach(&service->priv->tasks_last, task_get_name_length, &length); | 403 | g_queue_foreach(&priv->tasks_last, task_get_name_length, &length); |
931 | 362 | 404 | ||
935 | 363 | g_queue_foreach(&service->priv->tasks_first, task_set_name_length, &length); | 405 | g_queue_foreach(&priv->tasks_first, task_set_name_length, &length); |
936 | 364 | g_queue_foreach(&service->priv->tasks_normal, task_set_name_length, &length); | 406 | g_queue_foreach(&priv->tasks_normal, task_set_name_length, &length); |
937 | 365 | g_queue_foreach(&service->priv->tasks_last, task_set_name_length, &length); | 407 | g_queue_foreach(&priv->tasks_last, task_set_name_length, &length); |
938 | 366 | 408 | ||
939 | 367 | return; | 409 | return; |
940 | 368 | } | 410 | } |
941 | @@ -377,198 +419,97 @@ | |||
942 | 377 | return; | 419 | return; |
943 | 378 | } | 420 | } |
944 | 379 | 421 | ||
947 | 380 | static gboolean | 422 | static void |
948 | 381 | dbus_writes (GIOChannel * channel, GIOCondition condition, gpointer data) | 423 | ensure_bus_is_up (DbusTestService * service) |
949 | 382 | { | 424 | { |
955 | 383 | DbusTestService * service = DBUS_TEST_SERVICE(data); | 425 | const gchar* address = NULL; |
956 | 384 | 426 | DbusTestServicePrivate * priv = get_priv(service); | |
957 | 385 | if (condition & G_IO_ERR) { | 427 | |
958 | 386 | g_critical("DBus writing failure!"); | 428 | if (priv->external_bus_address != NULL) { |
959 | 387 | return FALSE; | 429 | /* if the client specified an externally-managed bus, |
960 | 430 | we don't have to start anything here... */ | ||
961 | 431 | address = priv->external_bus_address; | ||
962 | 432 | } else { | ||
963 | 433 | /* if the client didn't provide a GTestDBus, create our own */ | ||
964 | 434 | if (priv->test_dbus == NULL) | ||
965 | 435 | priv->test_dbus = g_test_dbus_new (G_TEST_DBUS_NONE); | ||
966 | 436 | |||
967 | 437 | /* start the test dbus */ | ||
968 | 438 | const gboolean bus_is_up = g_test_dbus_get_bus_address(priv->test_dbus) != NULL; | ||
969 | 439 | if (!bus_is_up) { | ||
970 | 440 | g_test_dbus_up (priv->test_dbus); | ||
971 | 441 | priv->test_dbus_started_here = TRUE; | ||
972 | 442 | } | ||
973 | 443 | |||
974 | 444 | address = g_test_dbus_get_bus_address(priv->test_dbus); | ||
975 | 388 | } | 445 | } |
976 | 389 | 446 | ||
991 | 390 | gchar * line; | 447 | /* set the environment variables */ |
992 | 391 | gsize termloc; | 448 | g_setenv("DBUS_STARTER_ADDRESS", address, TRUE); |
993 | 392 | GIOStatus status = g_io_channel_read_line (channel, &line, NULL, &termloc, NULL); | 449 | switch (priv->bus_type) { |
980 | 393 | g_return_val_if_fail(status == G_IO_STATUS_NORMAL, FALSE); | ||
981 | 394 | line[termloc] = '\0'; | ||
982 | 395 | |||
983 | 396 | g_print("DBus daemon: %s\n", line); | ||
984 | 397 | |||
985 | 398 | if (service->priv->first_time) { | ||
986 | 399 | service->priv->first_time = FALSE; | ||
987 | 400 | |||
988 | 401 | g_setenv("DBUS_STARTER_ADDRESS", line, TRUE); | ||
989 | 402 | |||
990 | 403 | switch (service->priv->bus_type) { | ||
994 | 404 | case DBUS_TEST_SERVICE_BUS_SESSION: | 450 | case DBUS_TEST_SERVICE_BUS_SESSION: |
996 | 405 | g_setenv("DBUS_SESSION_BUS_ADDRESS", line, TRUE); | 451 | g_setenv("DBUS_SESSION_BUS_ADDRESS", address, TRUE); |
997 | 406 | g_setenv("DBUS_STARTER_BUS_TYPE", "session", TRUE); | 452 | g_setenv("DBUS_STARTER_BUS_TYPE", "session", TRUE); |
998 | 407 | break; | 453 | break; |
999 | 408 | case DBUS_TEST_SERVICE_BUS_SYSTEM: | 454 | case DBUS_TEST_SERVICE_BUS_SYSTEM: |
1001 | 409 | g_setenv("DBUS_SYSTEM_BUS_ADDRESS", line, TRUE); | 455 | g_setenv("DBUS_SYSTEM_BUS_ADDRESS", address, TRUE); |
1002 | 410 | g_setenv("DBUS_STARTER_BUS_TYPE", "system", TRUE); | 456 | g_setenv("DBUS_STARTER_BUS_TYPE", "system", TRUE); |
1003 | 411 | break; | 457 | break; |
1004 | 412 | case DBUS_TEST_SERVICE_BUS_BOTH: | 458 | case DBUS_TEST_SERVICE_BUS_BOTH: |
1007 | 413 | g_setenv("DBUS_SESSION_BUS_ADDRESS", line, TRUE); | 459 | g_setenv("DBUS_SESSION_BUS_ADDRESS", address, TRUE); |
1008 | 414 | g_setenv("DBUS_SYSTEM_BUS_ADDRESS", line, TRUE); | 460 | g_setenv("DBUS_SYSTEM_BUS_ADDRESS", address, TRUE); |
1009 | 415 | g_setenv("DBUS_STARTER_BUS_TYPE", "session", TRUE); | 461 | g_setenv("DBUS_STARTER_BUS_TYPE", "session", TRUE); |
1010 | 416 | break; | 462 | break; |
1120 | 417 | } | 463 | } |
1121 | 418 | 464 | ||
1122 | 419 | if (service->priv->state == STATE_DAEMON_STARTING) { | 465 | priv->state = STATE_BUS_STARTED; |
1123 | 420 | g_main_loop_quit(service->priv->mainloop); | 466 | |
1015 | 421 | } | ||
1016 | 422 | } | ||
1017 | 423 | |||
1018 | 424 | g_free(line); | ||
1019 | 425 | |||
1020 | 426 | return TRUE; | ||
1021 | 427 | } | ||
1022 | 428 | |||
1023 | 429 | static void | ||
1024 | 430 | dbus_watcher (GPid pid, G_GNUC_UNUSED gint status, gpointer data) | ||
1025 | 431 | { | ||
1026 | 432 | DbusTestService * service = DBUS_TEST_SERVICE(data); | ||
1027 | 433 | g_critical("DBus Daemon exited abruptly!"); | ||
1028 | 434 | |||
1029 | 435 | service->priv->daemon_crashed = TRUE; | ||
1030 | 436 | g_main_loop_quit(DBUS_TEST_SERVICE(data)->priv->mainloop); | ||
1031 | 437 | |||
1032 | 438 | if (pid != 0) { | ||
1033 | 439 | g_spawn_close_pid(pid); | ||
1034 | 440 | } | ||
1035 | 441 | |||
1036 | 442 | return; | ||
1037 | 443 | } | ||
1038 | 444 | |||
1039 | 445 | static void | ||
1040 | 446 | dbus_child_setup () | ||
1041 | 447 | { | ||
1042 | 448 | setpgrp(); | ||
1043 | 449 | } | ||
1044 | 450 | |||
1045 | 451 | static void | ||
1046 | 452 | start_daemon (DbusTestService * service) | ||
1047 | 453 | { | ||
1048 | 454 | if (service->priv->dbus != 0) { | ||
1049 | 455 | return; | ||
1050 | 456 | } | ||
1051 | 457 | |||
1052 | 458 | service->priv->state = STATE_DAEMON_STARTING; | ||
1053 | 459 | |||
1054 | 460 | gint dbus_stdout = 0; | ||
1055 | 461 | GError * error = NULL; | ||
1056 | 462 | gchar * blank[1] = {NULL}; | ||
1057 | 463 | gchar * current_dir = g_get_current_dir(); | ||
1058 | 464 | gchar * dbus_startup[] = {service->priv->dbus_daemon, "--config-file", service->priv->dbus_configfile, "--print-address", NULL}; | ||
1059 | 465 | g_spawn_async_with_pipes(current_dir, | ||
1060 | 466 | dbus_startup, /* argv */ | ||
1061 | 467 | service->priv->keep_env ? NULL : blank, /* envp */ | ||
1062 | 468 | G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD, /* flags */ | ||
1063 | 469 | (GSpawnChildSetupFunc) dbus_child_setup, /* child setup func */ | ||
1064 | 470 | NULL, /* child setup data */ | ||
1065 | 471 | &service->priv->dbus, /* PID */ | ||
1066 | 472 | NULL, /* stdin */ | ||
1067 | 473 | &dbus_stdout, /* stdout */ | ||
1068 | 474 | NULL, /* stderr */ | ||
1069 | 475 | &error); /* error */ | ||
1070 | 476 | |||
1071 | 477 | g_free (current_dir); | ||
1072 | 478 | |||
1073 | 479 | if (error != NULL) { | ||
1074 | 480 | g_critical("Unable to start dbus daemon: %s", error->message); | ||
1075 | 481 | g_error_free(error); | ||
1076 | 482 | service->priv->daemon_crashed = TRUE; | ||
1077 | 483 | return; | ||
1078 | 484 | } | ||
1079 | 485 | |||
1080 | 486 | dbus_test_watchdog_add_pid(service->priv->watchdog, service->priv->dbus); | ||
1081 | 487 | |||
1082 | 488 | service->priv->dbus_watch = g_child_watch_add(service->priv->dbus, dbus_watcher, service); | ||
1083 | 489 | |||
1084 | 490 | service->priv->dbus_io = g_io_channel_unix_new(dbus_stdout); | ||
1085 | 491 | service->priv->dbus_io_watch = g_io_add_watch(service->priv->dbus_io, | ||
1086 | 492 | G_IO_IN | G_IO_HUP | G_IO_ERR, /* conditions */ | ||
1087 | 493 | dbus_writes, /* func */ | ||
1088 | 494 | service); /* func data */ | ||
1089 | 495 | |||
1090 | 496 | g_main_loop_run(service->priv->mainloop); | ||
1091 | 497 | |||
1092 | 498 | /* we should have a usable connection now, let's check */ | ||
1093 | 499 | const gchar * bus_address = NULL; | ||
1094 | 500 | if (service->priv->bus_type == DBUS_TEST_SERVICE_BUS_SYSTEM) { | ||
1095 | 501 | bus_address = g_getenv("DBUS_SYSTEM_BUS_ADDRESS"); | ||
1096 | 502 | } else { | ||
1097 | 503 | bus_address = g_getenv("DBUS_SESSION_BUS_ADDRESS"); | ||
1098 | 504 | } | ||
1099 | 505 | g_return_if_fail(bus_address != NULL); | ||
1100 | 506 | gchar **tokens = g_strsplit (bus_address, ",", 0); | ||
1101 | 507 | |||
1102 | 508 | guint i; | ||
1103 | 509 | gboolean is_valid = FALSE; | ||
1104 | 510 | for (i = 0; i < g_strv_length (tokens); i++) { | ||
1105 | 511 | if (strlen (tokens[i]) && g_dbus_is_supported_address (tokens[i], NULL)) { | ||
1106 | 512 | is_valid = TRUE; | ||
1107 | 513 | break; | ||
1108 | 514 | } | ||
1109 | 515 | } | ||
1110 | 516 | g_strfreev(tokens); | ||
1111 | 517 | |||
1112 | 518 | if (!is_valid) { | ||
1113 | 519 | service->priv->state = STATE_DAEMON_FAILED; | ||
1114 | 520 | g_critical ("DBus daemon failed: Bus address is not supported"); | ||
1115 | 521 | g_error_free (error); | ||
1116 | 522 | return; | ||
1117 | 523 | } | ||
1118 | 524 | |||
1119 | 525 | service->priv->state = STATE_DAEMON_STARTED; | ||
1124 | 526 | return; | 467 | return; |
1125 | 527 | } | 468 | } |
1126 | 528 | 469 | ||
1127 | 529 | void | 470 | void |
1128 | 530 | dbus_test_service_start_tasks (DbusTestService * service) | 471 | dbus_test_service_start_tasks (DbusTestService * service) |
1129 | 531 | { | 472 | { |
1131 | 532 | g_return_if_fail(DBUS_TEST_SERVICE(service)); | 473 | g_return_if_fail(DBUS_TEST_IS_SERVICE(service)); |
1132 | 533 | g_return_if_fail(all_tasks(service, all_tasks_bus_match, NULL)); | 474 | g_return_if_fail(all_tasks(service, all_tasks_bus_match, NULL)); |
1133 | 534 | 475 | ||
1138 | 535 | start_daemon(service); | 476 | DbusTestServicePrivate * priv = get_priv(service); |
1139 | 536 | g_return_if_fail(g_getenv("DBUS_SESSION_BUS_ADDRESS") != NULL || | 477 | |
1140 | 537 | g_getenv("DBUS_SYSTEM_BUS_ADDRESS") != NULL); | 478 | ensure_bus_is_up(service); |
1141 | 538 | g_return_if_fail(service->priv->state != STATE_DAEMON_FAILED); | 479 | g_return_if_fail(g_getenv("DBUS_STARTER_ADDRESS") != NULL); |
1142 | 539 | 480 | ||
1143 | 540 | if (all_tasks(service, all_tasks_started_helper, NULL)) { | 481 | if (all_tasks(service, all_tasks_started_helper, NULL)) { |
1144 | 541 | /* If we have all started we can mark it as such as long | 482 | /* If we have all started we can mark it as such as long |
1145 | 542 | as we understand where we could hit this case */ | 483 | as we understand where we could hit this case */ |
1148 | 543 | if (service->priv->state == STATE_INIT || service->priv->state == STATE_DAEMON_STARTED) { | 484 | if (priv->state == STATE_INIT || priv->state == STATE_BUS_STARTED) { |
1149 | 544 | service->priv->state = STATE_STARTED; | 485 | priv->state = STATE_STARTED; |
1150 | 545 | } | 486 | } |
1151 | 546 | return; | 487 | return; |
1152 | 547 | } | 488 | } |
1153 | 548 | 489 | ||
1154 | 549 | normalize_name_lengths(service); | 490 | normalize_name_lengths(service); |
1155 | 550 | 491 | ||
1167 | 551 | g_queue_foreach(&service->priv->tasks_first, task_starter, NULL); | 492 | g_queue_foreach(&priv->tasks_first, task_starter, NULL); |
1168 | 552 | if (!g_queue_is_empty(&service->priv->tasks_first)) { | 493 | if (!g_queue_is_empty(&priv->tasks_first)) { |
1169 | 553 | g_usleep(100000); | 494 | g_usleep(100000); |
1170 | 554 | } | 495 | } |
1171 | 555 | 496 | ||
1172 | 556 | g_queue_foreach(&service->priv->tasks_normal, task_starter, NULL); | 497 | g_queue_foreach(&priv->tasks_normal, task_starter, NULL); |
1173 | 557 | 498 | ||
1174 | 558 | if (!g_queue_is_empty(&service->priv->tasks_last)) { | 499 | if (!g_queue_is_empty(&priv->tasks_last)) { |
1175 | 559 | g_usleep(100000); | 500 | g_usleep(100000); |
1176 | 560 | } | 501 | } |
1177 | 561 | g_queue_foreach(&service->priv->tasks_last, task_starter, NULL); | 502 | g_queue_foreach(&priv->tasks_last, task_starter, NULL); |
1178 | 562 | 503 | ||
1179 | 563 | if (!all_tasks(service, all_tasks_started_helper, NULL)) { | 504 | if (!all_tasks(service, all_tasks_started_helper, NULL)) { |
1182 | 564 | service->priv->state = STATE_STARTING; | 505 | priv->state = STATE_STARTING; |
1183 | 565 | g_main_loop_run(service->priv->mainloop); | 506 | g_main_loop_run(priv->mainloop); |
1184 | 566 | 507 | ||
1185 | 567 | /* This should never happen, but let's be sure */ | 508 | /* This should never happen, but let's be sure */ |
1186 | 568 | g_return_if_fail(all_tasks(service, all_tasks_started_helper, NULL)); | 509 | g_return_if_fail(all_tasks(service, all_tasks_started_helper, NULL)); |
1187 | 569 | } | 510 | } |
1188 | 570 | 511 | ||
1190 | 571 | service->priv->state = STATE_STARTED; | 512 | priv->state = STATE_STARTED; |
1191 | 572 | 513 | ||
1192 | 573 | return; | 514 | return; |
1193 | 574 | } | 515 | } |
1194 | @@ -582,10 +523,6 @@ | |||
1195 | 582 | static int | 523 | static int |
1196 | 583 | get_status (DbusTestService * service) | 524 | get_status (DbusTestService * service) |
1197 | 584 | { | 525 | { |
1198 | 585 | if (service->priv->daemon_crashed || service->priv->state == STATE_DAEMON_FAILED) { | ||
1199 | 586 | return -1; | ||
1200 | 587 | } | ||
1201 | 588 | |||
1202 | 589 | if (all_tasks(service, all_tasks_passed_helper, NULL)) { | 526 | if (all_tasks(service, all_tasks_passed_helper, NULL)) { |
1203 | 590 | return 0; | 527 | return 0; |
1204 | 591 | } else { | 528 | } else { |
1205 | @@ -596,38 +533,41 @@ | |||
1206 | 596 | int | 533 | int |
1207 | 597 | dbus_test_service_run (DbusTestService * service) | 534 | dbus_test_service_run (DbusTestService * service) |
1208 | 598 | { | 535 | { |
1210 | 599 | g_return_val_if_fail(DBUS_TEST_SERVICE(service), -1); | 536 | g_return_val_if_fail(DBUS_TEST_IS_SERVICE(service), -1); |
1211 | 537 | |||
1212 | 538 | DbusTestServicePrivate * priv = get_priv(service); | ||
1213 | 600 | 539 | ||
1214 | 601 | dbus_test_service_start_tasks(service); | 540 | dbus_test_service_start_tasks(service); |
1216 | 602 | g_return_val_if_fail(service->priv->state == STATE_STARTED, get_status(service)); | 541 | g_return_val_if_fail(priv->state == STATE_STARTED, get_status(service)); |
1217 | 603 | 542 | ||
1218 | 604 | if (all_tasks(service, all_tasks_finished_helper, NULL)) { | 543 | if (all_tasks(service, all_tasks_finished_helper, NULL)) { |
1219 | 605 | return get_status(service); | 544 | return get_status(service); |
1220 | 606 | } | 545 | } |
1221 | 607 | 546 | ||
1224 | 608 | service->priv->state = STATE_RUNNING; | 547 | priv->state = STATE_RUNNING; |
1225 | 609 | g_main_loop_run(service->priv->mainloop); | 548 | g_main_loop_run(priv->mainloop); |
1226 | 610 | 549 | ||
1227 | 611 | /* This should never happen, but let's be sure */ | 550 | /* This should never happen, but let's be sure */ |
1228 | 612 | g_return_val_if_fail(all_tasks(service, all_tasks_finished_helper, NULL), -1); | 551 | g_return_val_if_fail(all_tasks(service, all_tasks_finished_helper, NULL), -1); |
1230 | 613 | service->priv->state = STATE_FINISHED; | 552 | priv->state = STATE_FINISHED; |
1231 | 614 | 553 | ||
1232 | 615 | return get_status(service); | 554 | return get_status(service); |
1233 | 616 | } | 555 | } |
1234 | 617 | 556 | ||
1235 | 618 | static void | 557 | static void |
1237 | 619 | task_state_changed (G_GNUC_UNUSED DbusTestTask * task, G_GNUC_UNUSED DbusTestTaskState state, gpointer user_data) | 558 | task_state_changed (G_GNUC_UNUSED DbusTestTask * task, G_GNUC_UNUSED DbusTestTaskState state, gpointer gservice) |
1238 | 620 | { | 559 | { |
1241 | 621 | g_return_if_fail(DBUS_TEST_IS_SERVICE(user_data)); | 560 | g_return_if_fail(DBUS_TEST_IS_SERVICE(gservice)); |
1242 | 622 | DbusTestService * service = DBUS_TEST_SERVICE(user_data); | 561 | DbusTestService * service = DBUS_TEST_SERVICE(gservice); |
1243 | 562 | DbusTestServicePrivate * priv = get_priv(service); | ||
1244 | 623 | 563 | ||
1247 | 624 | if (service->priv->state == STATE_STARTING && all_tasks(service, all_tasks_started_helper, NULL)) { | 564 | if (priv->state == STATE_STARTING && all_tasks(service, all_tasks_started_helper, NULL)) { |
1248 | 625 | g_main_loop_quit(service->priv->mainloop); | 565 | g_main_loop_quit(priv->mainloop); |
1249 | 626 | return; | 566 | return; |
1250 | 627 | } | 567 | } |
1251 | 628 | 568 | ||
1254 | 629 | if (service->priv->state == STATE_RUNNING && all_tasks(service, all_tasks_finished_helper, NULL)) { | 569 | if (priv->state == STATE_RUNNING && all_tasks(service, all_tasks_finished_helper, NULL)) { |
1255 | 630 | g_main_loop_quit(service->priv->mainloop); | 570 | g_main_loop_quit(priv->mainloop); |
1256 | 631 | return; | 571 | return; |
1257 | 632 | } | 572 | } |
1258 | 633 | 573 | ||
1259 | @@ -637,7 +577,7 @@ | |||
1260 | 637 | void | 577 | void |
1261 | 638 | dbus_test_service_add_task (DbusTestService * service, DbusTestTask * task) | 578 | dbus_test_service_add_task (DbusTestService * service, DbusTestTask * task) |
1262 | 639 | { | 579 | { |
1264 | 640 | return dbus_test_service_add_task_with_priority(service, task, DBUS_TEST_SERVICE_PRIORITY_NORMAL); | 580 | dbus_test_service_add_task_with_priority(service, task, DBUS_TEST_SERVICE_PRIORITY_NORMAL); |
1265 | 641 | } | 581 | } |
1266 | 642 | 582 | ||
1267 | 643 | void | 583 | void |
1268 | @@ -650,17 +590,18 @@ | |||
1269 | 650 | goals for busness. Fail early. */ | 590 | goals for busness. Fail early. */ |
1270 | 651 | g_return_if_fail(all_tasks_bus_match(service, task, NULL)); | 591 | g_return_if_fail(all_tasks_bus_match(service, task, NULL)); |
1271 | 652 | 592 | ||
1272 | 593 | DbusTestServicePrivate * priv = get_priv(service); | ||
1273 | 653 | GQueue * queue = NULL; | 594 | GQueue * queue = NULL; |
1274 | 654 | 595 | ||
1275 | 655 | switch (prio) { | 596 | switch (prio) { |
1276 | 656 | case DBUS_TEST_SERVICE_PRIORITY_FIRST: | 597 | case DBUS_TEST_SERVICE_PRIORITY_FIRST: |
1278 | 657 | queue = &service->priv->tasks_first; | 598 | queue = &priv->tasks_first; |
1279 | 658 | break; | 599 | break; |
1280 | 659 | case DBUS_TEST_SERVICE_PRIORITY_NORMAL: | 600 | case DBUS_TEST_SERVICE_PRIORITY_NORMAL: |
1282 | 660 | queue = &service->priv->tasks_normal; | 601 | queue = &priv->tasks_normal; |
1283 | 661 | break; | 602 | break; |
1284 | 662 | case DBUS_TEST_SERVICE_PRIORITY_LAST: | 603 | case DBUS_TEST_SERVICE_PRIORITY_LAST: |
1286 | 663 | queue = &service->priv->tasks_last; | 604 | queue = &priv->tasks_last; |
1287 | 664 | break; | 605 | break; |
1288 | 665 | default: | 606 | default: |
1289 | 666 | g_assert_not_reached(); | 607 | g_assert_not_reached(); |
1290 | @@ -690,10 +631,12 @@ | |||
1291 | 690 | g_return_val_if_fail(DBUS_TEST_IS_SERVICE(service), FALSE); | 631 | g_return_val_if_fail(DBUS_TEST_IS_SERVICE(service), FALSE); |
1292 | 691 | g_return_val_if_fail(DBUS_TEST_IS_TASK(task), FALSE); | 632 | g_return_val_if_fail(DBUS_TEST_IS_TASK(task), FALSE); |
1293 | 692 | 633 | ||
1294 | 634 | DbusTestServicePrivate * priv = get_priv(service); | ||
1295 | 635 | |||
1296 | 693 | guint count = 0; | 636 | guint count = 0; |
1300 | 694 | count += g_queue_remove_all(&service->priv->tasks_first, task); | 637 | count += g_queue_remove_all(&priv->tasks_first, task); |
1301 | 695 | count += g_queue_remove_all(&service->priv->tasks_normal, task); | 638 | count += g_queue_remove_all(&priv->tasks_normal, task); |
1302 | 696 | count += g_queue_remove_all(&service->priv->tasks_last, task); | 639 | count += g_queue_remove_all(&priv->tasks_last, task); |
1303 | 697 | 640 | ||
1304 | 698 | /* Checking the count here so that we can generate a warning. Guessing that | 641 | /* Checking the count here so that we can generate a warning. Guessing that |
1305 | 699 | this actually never happens, but it's easy to check */ | 642 | this actually never happens, but it's easy to check */ |
1306 | @@ -715,56 +658,27 @@ | |||
1307 | 715 | } | 658 | } |
1308 | 716 | 659 | ||
1309 | 717 | void | 660 | void |
1310 | 718 | dbus_test_service_set_daemon (DbusTestService * service, const gchar * daemon) | ||
1311 | 719 | { | ||
1312 | 720 | g_return_if_fail(DBUS_TEST_IS_SERVICE(service)); | ||
1313 | 721 | g_free(service->priv->dbus_daemon); | ||
1314 | 722 | service->priv->dbus_daemon = g_strdup(daemon); | ||
1315 | 723 | return; | ||
1316 | 724 | } | ||
1317 | 725 | |||
1318 | 726 | void | ||
1319 | 727 | dbus_test_service_set_conf_file (DbusTestService * service, const gchar * conffile) | ||
1320 | 728 | { | ||
1321 | 729 | g_return_if_fail(DBUS_TEST_IS_SERVICE(service)); | ||
1322 | 730 | g_free(service->priv->dbus_configfile); | ||
1323 | 731 | service->priv->dbus_configfile = g_strdup(conffile); | ||
1324 | 732 | return; | ||
1325 | 733 | } | ||
1326 | 734 | |||
1327 | 735 | void | ||
1328 | 736 | dbus_test_service_set_keep_environment (DbusTestService * service, gboolean keep_env) | ||
1329 | 737 | { | ||
1330 | 738 | g_return_if_fail(DBUS_TEST_IS_SERVICE(service)); | ||
1331 | 739 | service->priv->keep_env = keep_env; | ||
1332 | 740 | } | ||
1333 | 741 | |||
1334 | 742 | void | ||
1335 | 743 | dbus_test_service_stop (DbusTestService * service) | 661 | dbus_test_service_stop (DbusTestService * service) |
1336 | 744 | { | 662 | { |
1337 | 745 | g_return_if_fail(DBUS_TEST_IS_SERVICE(service)); | 663 | g_return_if_fail(DBUS_TEST_IS_SERVICE(service)); |
1339 | 746 | g_main_loop_quit(service->priv->mainloop); | 664 | |
1340 | 665 | DbusTestServicePrivate * priv = get_priv(service); | ||
1341 | 666 | g_main_loop_quit(priv->mainloop); | ||
1342 | 667 | |||
1343 | 747 | return; | 668 | return; |
1344 | 748 | } | 669 | } |
1345 | 749 | 670 | ||
1346 | 750 | void dbus_test_service_set_bus (DbusTestService * service, DbusTestServiceBus bus) | 671 | void dbus_test_service_set_bus (DbusTestService * service, DbusTestServiceBus bus) |
1347 | 751 | { | 672 | { |
1348 | 752 | g_return_if_fail(DBUS_TEST_IS_SERVICE(service)); | 673 | g_return_if_fail(DBUS_TEST_IS_SERVICE(service)); |
1350 | 753 | g_return_if_fail(service->priv->dbus == 0); /* we can't change after we're running */ | 674 | |
1351 | 675 | DbusTestServicePrivate * priv = get_priv(service); | ||
1352 | 676 | g_return_if_fail(priv->state < STATE_BUS_STARTED); /* we can't change after the bus is started */ | ||
1353 | 754 | 677 | ||
1354 | 755 | if (bus == DBUS_TEST_SERVICE_BUS_BOTH) { | 678 | if (bus == DBUS_TEST_SERVICE_BUS_BOTH) { |
1355 | 756 | g_warning("Setting bus to BOTH, which is typically only used as a default value."); | 679 | g_warning("Setting bus to BOTH, which is typically only used as a default value."); |
1356 | 757 | } | 680 | } |
1357 | 758 | 681 | ||
1359 | 759 | service->priv->bus_type = bus; | 682 | priv->bus_type = bus; |
1360 | 760 | g_warn_if_fail(all_tasks(service, all_tasks_bus_match, NULL)); | 683 | g_warn_if_fail(all_tasks(service, all_tasks_bus_match, NULL)); |
1361 | 761 | |||
1362 | 762 | if (bus == DBUS_TEST_SERVICE_BUS_SYSTEM) { | ||
1363 | 763 | g_free(service->priv->dbus_configfile); | ||
1364 | 764 | service->priv->dbus_configfile = g_strdup(DEFAULT_SYSTEM_CONF); | ||
1365 | 765 | } else { | ||
1366 | 766 | /* BOTH and SESSION get the session config — for backwards compatibility there */ | ||
1367 | 767 | g_free(service->priv->dbus_configfile); | ||
1368 | 768 | service->priv->dbus_configfile = g_strdup(DEFAULT_SESSION_CONF); | ||
1369 | 769 | } | ||
1370 | 770 | } | 684 | } |
1371 | 771 | 685 | ||
1372 | === modified file 'libdbustest/service.h' | |||
1373 | --- libdbustest/service.h 2015-02-13 17:19:17 +0000 | |||
1374 | +++ libdbustest/service.h 2015-09-21 17:10:37 +0000 | |||
1375 | @@ -24,7 +24,7 @@ | |||
1376 | 24 | #error "Please include #include <libdbustest/dbus-test.h> only" | 24 | #error "Please include #include <libdbustest/dbus-test.h> only" |
1377 | 25 | #endif | 25 | #endif |
1378 | 26 | 26 | ||
1380 | 27 | #include <glib-object.h> | 27 | #include <gio/gio.h> |
1381 | 28 | 28 | ||
1382 | 29 | #include "task.h" | 29 | #include "task.h" |
1383 | 30 | 30 | ||
1384 | @@ -39,7 +39,6 @@ | |||
1385 | 39 | 39 | ||
1386 | 40 | typedef struct _DbusTestService DbusTestService; | 40 | typedef struct _DbusTestService DbusTestService; |
1387 | 41 | typedef struct _DbusTestServiceClass DbusTestServiceClass; | 41 | typedef struct _DbusTestServiceClass DbusTestServiceClass; |
1388 | 42 | typedef struct _DbusTestServicePrivate DbusTestServicePrivate; | ||
1389 | 43 | 42 | ||
1390 | 44 | struct _DbusTestServiceClass { | 43 | struct _DbusTestServiceClass { |
1391 | 45 | GObjectClass parent_class; | 44 | GObjectClass parent_class; |
1392 | @@ -47,7 +46,6 @@ | |||
1393 | 47 | 46 | ||
1394 | 48 | struct _DbusTestService { | 47 | struct _DbusTestService { |
1395 | 49 | GObject parent; | 48 | GObject parent; |
1396 | 50 | DbusTestServicePrivate * priv; | ||
1397 | 51 | }; | 49 | }; |
1398 | 52 | 50 | ||
1399 | 53 | typedef enum | 51 | typedef enum |
1400 | @@ -65,7 +63,8 @@ | |||
1401 | 65 | } DbusTestServiceBus; | 63 | } DbusTestServiceBus; |
1402 | 66 | 64 | ||
1403 | 67 | GType dbus_test_service_get_type (void); | 65 | GType dbus_test_service_get_type (void); |
1405 | 68 | DbusTestService * dbus_test_service_new (const gchar * address); | 66 | DbusTestService * dbus_test_service_new (const char* external_bus_addr); |
1406 | 67 | DbusTestService * dbus_test_service_new_with_test_bus(GTestDBus * test_bus); | ||
1407 | 69 | void dbus_test_service_start_tasks (DbusTestService * service); | 68 | void dbus_test_service_start_tasks (DbusTestService * service); |
1408 | 70 | int dbus_test_service_run (DbusTestService * service); | 69 | int dbus_test_service_run (DbusTestService * service); |
1409 | 71 | void dbus_test_service_stop (DbusTestService * service); | 70 | void dbus_test_service_stop (DbusTestService * service); |
1410 | @@ -74,9 +73,6 @@ | |||
1411 | 74 | void dbus_test_service_add_task_with_priority (DbusTestService * service, DbusTestTask * task, DbusTestServicePriority prio); | 73 | void dbus_test_service_add_task_with_priority (DbusTestService * service, DbusTestTask * task, DbusTestServicePriority prio); |
1412 | 75 | gboolean dbus_test_service_remove_task (DbusTestService * service, DbusTestTask * task); | 74 | gboolean dbus_test_service_remove_task (DbusTestService * service, DbusTestTask * task); |
1413 | 76 | 75 | ||
1414 | 77 | void dbus_test_service_set_daemon (DbusTestService * service, const gchar * daemon); | ||
1415 | 78 | void dbus_test_service_set_conf_file (DbusTestService * service, const gchar * conffile); | ||
1416 | 79 | void dbus_test_service_set_keep_environment (DbusTestService * service, gboolean keep_env); | ||
1417 | 80 | void dbus_test_service_set_bus (DbusTestService * service, DbusTestServiceBus bus); | 76 | void dbus_test_service_set_bus (DbusTestService * service, DbusTestServiceBus bus); |
1418 | 81 | 77 | ||
1419 | 82 | G_END_DECLS | 78 | G_END_DECLS |
1420 | 83 | 79 | ||
1421 | === modified file 'libdbustest/task.c' | |||
1422 | --- libdbustest/task.c 2015-01-30 02:36:45 +0000 | |||
1423 | +++ libdbustest/task.c 2015-09-21 17:10:37 +0000 | |||
1424 | @@ -55,7 +55,7 @@ | |||
1425 | 55 | static void dbus_test_task_dispose (GObject *object); | 55 | static void dbus_test_task_dispose (GObject *object); |
1426 | 56 | static void dbus_test_task_finalize (GObject *object); | 56 | static void dbus_test_task_finalize (GObject *object); |
1427 | 57 | 57 | ||
1429 | 58 | G_DEFINE_TYPE (DbusTestTask, dbus_test_task, G_TYPE_OBJECT); | 58 | G_DEFINE_TYPE (DbusTestTask, dbus_test_task, G_TYPE_OBJECT) |
1430 | 59 | 59 | ||
1431 | 60 | static guint signals[LAST_SIGNAL] = {0}; | 60 | static guint signals[LAST_SIGNAL] = {0}; |
1432 | 61 | 61 | ||
1433 | @@ -192,7 +192,7 @@ | |||
1434 | 192 | void | 192 | void |
1435 | 193 | dbus_test_task_set_wait_for (DbusTestTask * task, const gchar * dbus_name) | 193 | dbus_test_task_set_wait_for (DbusTestTask * task, const gchar * dbus_name) |
1436 | 194 | { | 194 | { |
1438 | 195 | return dbus_test_task_set_wait_for_bus(task, dbus_name, DBUS_TEST_SERVICE_BUS_BOTH); | 195 | dbus_test_task_set_wait_for_bus(task, dbus_name, DBUS_TEST_SERVICE_BUS_BOTH); |
1439 | 196 | } | 196 | } |
1440 | 197 | 197 | ||
1441 | 198 | void | 198 | void |
1442 | 199 | 199 | ||
1443 | === modified file 'libdbustest/watchdog.c' | |||
1444 | --- libdbustest/watchdog.c 2013-01-29 19:38:21 +0000 | |||
1445 | +++ libdbustest/watchdog.c 2015-09-21 17:10:37 +0000 | |||
1446 | @@ -15,7 +15,7 @@ | |||
1447 | 15 | static void dbus_test_watchdog_init (DbusTestWatchdog *self); | 15 | static void dbus_test_watchdog_init (DbusTestWatchdog *self); |
1448 | 16 | static void dbus_test_watchdog_finalize (GObject *object); | 16 | static void dbus_test_watchdog_finalize (GObject *object); |
1449 | 17 | 17 | ||
1451 | 18 | G_DEFINE_TYPE (DbusTestWatchdog, dbus_test_watchdog, G_TYPE_OBJECT); | 18 | G_DEFINE_TYPE (DbusTestWatchdog, dbus_test_watchdog, G_TYPE_OBJECT) |
1452 | 19 | 19 | ||
1453 | 20 | /* Initialize class */ | 20 | /* Initialize class */ |
1454 | 21 | static void | 21 | static void |
1455 | @@ -32,7 +32,7 @@ | |||
1456 | 32 | 32 | ||
1457 | 33 | /* Initialize instance data */ | 33 | /* Initialize instance data */ |
1458 | 34 | static void | 34 | static void |
1460 | 35 | dbus_test_watchdog_init (G_GNUC_UNUSED DbusTestWatchdog *self) | 35 | dbus_test_watchdog_init (DbusTestWatchdog *self) |
1461 | 36 | { | 36 | { |
1462 | 37 | self->priv = DBUS_TEST_WATCHDOG_GET_PRIVATE(self); | 37 | self->priv = DBUS_TEST_WATCHDOG_GET_PRIVATE(self); |
1463 | 38 | 38 | ||
1464 | 39 | 39 | ||
1465 | === modified file 'po/Makefile.in.in' | |||
1466 | --- po/Makefile.in.in 2012-07-12 15:56:53 +0000 | |||
1467 | +++ po/Makefile.in.in 2015-09-21 17:10:37 +0000 | |||
1468 | @@ -33,8 +33,7 @@ | |||
1469 | 33 | datadir = @datadir@ | 33 | datadir = @datadir@ |
1470 | 34 | datarootdir = @datarootdir@ | 34 | datarootdir = @datarootdir@ |
1471 | 35 | libdir = @libdir@ | 35 | libdir = @libdir@ |
1474 | 36 | DATADIRNAME = @DATADIRNAME@ | 36 | localedir = @localedir@ |
1473 | 37 | itlocaledir = $(prefix)/$(DATADIRNAME)/locale | ||
1475 | 38 | subdir = po | 37 | subdir = po |
1476 | 39 | install_sh = @install_sh@ | 38 | install_sh = @install_sh@ |
1477 | 40 | # Automake >= 1.8 provides @mkdir_p@. | 39 | # Automake >= 1.8 provides @mkdir_p@. |
1478 | @@ -80,7 +79,7 @@ | |||
1479 | 80 | 79 | ||
1480 | 81 | .po.pox: | 80 | .po.pox: |
1481 | 82 | $(MAKE) $(GETTEXT_PACKAGE).pot | 81 | $(MAKE) $(GETTEXT_PACKAGE).pot |
1483 | 83 | $(MSGMERGE) $< $(GETTEXT_PACKAGE).pot -o $*.pox | 82 | $(MSGMERGE) $* $(GETTEXT_PACKAGE).pot -o $*.pox |
1484 | 84 | 83 | ||
1485 | 85 | .po.mo: | 84 | .po.mo: |
1486 | 86 | $(INTLTOOL_V_MSGFMT)$(MSGFMT) -o $@ $< | 85 | $(INTLTOOL_V_MSGFMT)$(MSGFMT) -o $@ $< |
1487 | @@ -108,7 +107,7 @@ | |||
1488 | 108 | install-data-yes: all | 107 | install-data-yes: all |
1489 | 109 | linguas="$(USE_LINGUAS)"; \ | 108 | linguas="$(USE_LINGUAS)"; \ |
1490 | 110 | for lang in $$linguas; do \ | 109 | for lang in $$linguas; do \ |
1492 | 111 | dir=$(DESTDIR)$(itlocaledir)/$$lang/LC_MESSAGES; \ | 110 | dir=$(DESTDIR)$(localedir)/$$lang/LC_MESSAGES; \ |
1493 | 112 | $(mkdir_p) $$dir; \ | 111 | $(mkdir_p) $$dir; \ |
1494 | 113 | if test -r $$lang.gmo; then \ | 112 | if test -r $$lang.gmo; then \ |
1495 | 114 | $(INSTALL_DATA) $$lang.gmo $$dir/$(GETTEXT_PACKAGE).mo; \ | 113 | $(INSTALL_DATA) $$lang.gmo $$dir/$(GETTEXT_PACKAGE).mo; \ |
1496 | @@ -142,8 +141,8 @@ | |||
1497 | 142 | uninstall: | 141 | uninstall: |
1498 | 143 | linguas="$(USE_LINGUAS)"; \ | 142 | linguas="$(USE_LINGUAS)"; \ |
1499 | 144 | for lang in $$linguas; do \ | 143 | for lang in $$linguas; do \ |
1502 | 145 | rm -f $(DESTDIR)$(itlocaledir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE).mo; \ | 144 | rm -f $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE).mo; \ |
1503 | 146 | rm -f $(DESTDIR)$(itlocaledir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE).mo.m; \ | 145 | rm -f $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE).mo.m; \ |
1504 | 147 | done | 146 | done |
1505 | 148 | 147 | ||
1506 | 149 | check: all $(GETTEXT_PACKAGE).pot | 148 | check: all $(GETTEXT_PACKAGE).pot |
1507 | 150 | 149 | ||
1508 | === modified file 'src/Makefile.am' | |||
1509 | --- src/Makefile.am 2012-10-02 03:15:57 +0000 | |||
1510 | +++ src/Makefile.am 2015-09-21 17:10:37 +0000 | |||
1511 | @@ -5,7 +5,6 @@ | |||
1512 | 5 | dbus_test_runner_CFLAGS = $(DBUS_TEST_RUNNER_CFLAGS) \ | 5 | dbus_test_runner_CFLAGS = $(DBUS_TEST_RUNNER_CFLAGS) \ |
1513 | 6 | $(COVERAGE_CFLAGS) \ | 6 | $(COVERAGE_CFLAGS) \ |
1514 | 7 | -I$(top_srcdir) \ | 7 | -I$(top_srcdir) \ |
1515 | 8 | -DDEFAULT_SESSION_CONF="\"$(datadir)/dbus-test-runner/session.conf\"" \ | ||
1516 | 9 | -Wall -Werror -Wextra | 8 | -Wall -Werror -Wextra |
1517 | 10 | dbus_test_runner_LDADD = $(DBUS_TEST_RUNNER_LIBS) \ | 9 | dbus_test_runner_LDADD = $(DBUS_TEST_RUNNER_LIBS) \ |
1518 | 11 | $(top_builddir)/libdbustest/libdbustest.la | 10 | $(top_builddir)/libdbustest/libdbustest.la |
1519 | 12 | 11 | ||
1520 | === modified file 'src/dbus-test-runner.c' | |||
1521 | --- src/dbus-test-runner.c 2014-12-09 22:24:27 +0000 | |||
1522 | +++ src/dbus-test-runner.c 2015-09-21 17:10:37 +0000 | |||
1523 | @@ -25,7 +25,6 @@ | |||
1524 | 25 | 25 | ||
1525 | 26 | static DbusTestServiceBus bus_type = DBUS_TEST_SERVICE_BUS_SESSION; | 26 | static DbusTestServiceBus bus_type = DBUS_TEST_SERVICE_BUS_SESSION; |
1526 | 27 | static gint max_wait = 30; | 27 | static gint max_wait = 30; |
1527 | 28 | static gboolean keep_env = FALSE; | ||
1528 | 29 | static DbusTestProcess * last_task = NULL; | 28 | static DbusTestProcess * last_task = NULL; |
1529 | 30 | static DbusTestService * service = NULL; | 29 | static DbusTestService * service = NULL; |
1530 | 31 | static gboolean timeout = FALSE; | 30 | static gboolean timeout = FALSE; |
1531 | @@ -194,18 +193,13 @@ | |||
1532 | 194 | return FALSE; | 193 | return FALSE; |
1533 | 195 | } | 194 | } |
1534 | 196 | 195 | ||
1535 | 197 | static gchar * dbus_configfile = NULL; | ||
1536 | 198 | static gchar * dbus_daemon = NULL; | ||
1537 | 199 | static gchar * bustle_cmd = NULL; | 196 | static gchar * bustle_cmd = NULL; |
1538 | 200 | static gchar * bustle_datafile = NULL; | 197 | static gchar * bustle_datafile = NULL; |
1539 | 201 | 198 | ||
1540 | 202 | static GOptionEntry general_options[] = { | 199 | static GOptionEntry general_options[] = { |
1541 | 203 | {"dbus-daemon", 0, 0, G_OPTION_ARG_FILENAME, &dbus_daemon, "Path to the DBus deamon to use. Defaults to 'dbus-daemon'.", "executable"}, | ||
1542 | 204 | {"dbus-config", 'd', 0, G_OPTION_ARG_FILENAME, &dbus_configfile, "Configuration file for newly created DBus server. Defaults to '" DEFAULT_SESSION_CONF "'.", "config_file"}, | ||
1543 | 205 | {"bustle-monitor", 0, 0, G_OPTION_ARG_FILENAME, &bustle_cmd, "Path to the Bustle DBus Monitor to use. Defaults to 'bustle-dbus-monitor'.", "executable"}, | 200 | {"bustle-monitor", 0, 0, G_OPTION_ARG_FILENAME, &bustle_cmd, "Path to the Bustle DBus Monitor to use. Defaults to 'bustle-dbus-monitor'.", "executable"}, |
1544 | 206 | {"bustle-data", 'b', 0, G_OPTION_ARG_FILENAME, &bustle_datafile, "A file to write out data from the bustle logger to.", "data_file"}, | 201 | {"bustle-data", 'b', 0, G_OPTION_ARG_FILENAME, &bustle_datafile, "A file to write out data from the bustle logger to.", "data_file"}, |
1545 | 207 | {"max-wait", 'm', 0, G_OPTION_ARG_INT, &max_wait, "The maximum amount of time the test runner will wait for the test to complete. Default is 30 seconds.", "seconds"}, | 202 | {"max-wait", 'm', 0, G_OPTION_ARG_INT, &max_wait, "The maximum amount of time the test runner will wait for the test to complete. Default is 30 seconds.", "seconds"}, |
1546 | 208 | {"keep-env", 0, 0, G_OPTION_ARG_NONE, &keep_env, "Whether to propagate the execution environment to the dbus-server and all the services activated by it. By default the environment is cleared.", NULL }, | ||
1547 | 209 | {"bus-type", 0, 0, G_OPTION_ARG_CALLBACK, option_bus_type, "Configures which buses are represented by the tool to the tasks. Default: session", "{session|system|both}" }, | 203 | {"bus-type", 0, 0, G_OPTION_ARG_CALLBACK, option_bus_type, "Configures which buses are represented by the tool to the tasks. Default: session", "{session|system|both}" }, |
1548 | 210 | { NULL, 0, 0, 0, NULL, NULL, NULL } | 204 | { NULL, 0, 0, 0, NULL, NULL, NULL } |
1549 | 211 | }; | 205 | }; |
1550 | @@ -250,14 +244,6 @@ | |||
1551 | 250 | 244 | ||
1552 | 251 | dbus_test_service_set_bus(service, bus_type); | 245 | dbus_test_service_set_bus(service, bus_type); |
1553 | 252 | 246 | ||
1554 | 253 | if (dbus_daemon != NULL) { | ||
1555 | 254 | dbus_test_service_set_daemon(service, dbus_daemon); | ||
1556 | 255 | } | ||
1557 | 256 | |||
1558 | 257 | if (dbus_configfile != NULL) { | ||
1559 | 258 | dbus_test_service_set_conf_file(service, dbus_configfile); | ||
1560 | 259 | } | ||
1561 | 260 | |||
1562 | 261 | if (bustle_datafile != NULL) { | 247 | if (bustle_datafile != NULL) { |
1563 | 262 | DbusTestBustle * bustler = dbus_test_bustle_new(bustle_datafile); | 248 | DbusTestBustle * bustler = dbus_test_bustle_new(bustle_datafile); |
1564 | 263 | /* We want to ensure that bustle captures all the data so start it first */ | 249 | /* We want to ensure that bustle captures all the data so start it first */ |
1565 | @@ -274,8 +260,6 @@ | |||
1566 | 274 | g_timeout_add_seconds(max_wait, max_wait_hit, NULL); | 260 | g_timeout_add_seconds(max_wait, max_wait_hit, NULL); |
1567 | 275 | } | 261 | } |
1568 | 276 | 262 | ||
1569 | 277 | dbus_test_service_set_keep_environment(service, keep_env); | ||
1570 | 278 | |||
1571 | 279 | /* These should all be in the service now */ | 263 | /* These should all be in the service now */ |
1572 | 280 | if (last_task != NULL) { | 264 | if (last_task != NULL) { |
1573 | 281 | g_object_unref(last_task); | 265 | g_object_unref(last_task); |
1574 | 282 | 266 | ||
1575 | === modified file 'tests/Makefile.am' | |||
1576 | --- tests/Makefile.am 2015-01-30 17:10:47 +0000 | |||
1577 | +++ tests/Makefile.am 2015-09-21 17:10:37 +0000 | |||
1578 | @@ -1,6 +1,6 @@ | |||
1579 | 1 | 1 | ||
1582 | 2 | DBUS_RUNNER=$(top_builddir)/src/dbus-test-runner --dbus-config $(srcdir)/../data/session.conf | 2 | DBUS_RUNNER=$(top_builddir)/src/dbus-test-runner |
1583 | 3 | DBUS_RUNNER_SYSTEM=$(top_builddir)/src/dbus-test-runner --dbus-config $(srcdir)/../data/system.conf | 3 | DBUS_RUNNER_SYSTEM=$(top_builddir)/src/dbus-test-runner |
1584 | 4 | TESTS = | 4 | TESTS = |
1585 | 5 | DISTCLEANFILES = $(TESTS) | 5 | DISTCLEANFILES = $(TESTS) |
1586 | 6 | XFAIL_TESTS = | 6 | XFAIL_TESTS = |
1587 | 7 | 7 | ||
1588 | === modified file 'tests/test-libdbustest-mock.c' | |||
1589 | --- tests/test-libdbustest-mock.c 2015-02-02 15:52:49 +0000 | |||
1590 | +++ tests/test-libdbustest-mock.c 2015-09-21 17:10:37 +0000 | |||
1591 | @@ -58,8 +58,6 @@ | |||
1592 | 58 | DbusTestService * service = dbus_test_service_new(NULL); | 58 | DbusTestService * service = dbus_test_service_new(NULL); |
1593 | 59 | g_assert(service != NULL); | 59 | g_assert(service != NULL); |
1594 | 60 | 60 | ||
1595 | 61 | dbus_test_service_set_conf_file(service, SESSION_CONF); | ||
1596 | 62 | |||
1597 | 63 | DbusTestDbusMock * mock = dbus_test_dbus_mock_new("foo.test"); | 61 | DbusTestDbusMock * mock = dbus_test_dbus_mock_new("foo.test"); |
1598 | 64 | g_assert(mock != NULL); | 62 | g_assert(mock != NULL); |
1599 | 65 | 63 | ||
1600 | @@ -103,8 +101,6 @@ | |||
1601 | 103 | DbusTestService * service = dbus_test_service_new(NULL); | 101 | DbusTestService * service = dbus_test_service_new(NULL); |
1602 | 104 | g_assert(service != NULL); | 102 | g_assert(service != NULL); |
1603 | 105 | 103 | ||
1604 | 106 | dbus_test_service_set_conf_file(service, SESSION_CONF); | ||
1605 | 107 | |||
1606 | 108 | DbusTestDbusMock * mock = dbus_test_dbus_mock_new("foo.test"); | 104 | DbusTestDbusMock * mock = dbus_test_dbus_mock_new("foo.test"); |
1607 | 109 | g_assert(mock != NULL); | 105 | g_assert(mock != NULL); |
1608 | 110 | 106 | ||
1609 | @@ -275,8 +271,6 @@ | |||
1610 | 275 | DbusTestService * service = dbus_test_service_new(NULL); | 271 | DbusTestService * service = dbus_test_service_new(NULL); |
1611 | 276 | g_assert(service != NULL); | 272 | g_assert(service != NULL); |
1612 | 277 | 273 | ||
1613 | 278 | dbus_test_service_set_conf_file(service, SESSION_CONF); | ||
1614 | 279 | |||
1615 | 280 | DbusTestDbusMock * mock = dbus_test_dbus_mock_new("foo.test"); | 274 | DbusTestDbusMock * mock = dbus_test_dbus_mock_new("foo.test"); |
1616 | 281 | g_assert(mock != NULL); | 275 | g_assert(mock != NULL); |
1617 | 282 | 276 | ||
1618 | @@ -359,8 +353,6 @@ | |||
1619 | 359 | DbusTestService * service = dbus_test_service_new(NULL); | 353 | DbusTestService * service = dbus_test_service_new(NULL); |
1620 | 360 | g_assert(service != NULL); | 354 | g_assert(service != NULL); |
1621 | 361 | 355 | ||
1622 | 362 | dbus_test_service_set_conf_file(service, SESSION_CONF); | ||
1623 | 363 | |||
1624 | 364 | DbusTestDbusMock * mock = dbus_test_dbus_mock_new("foo.test"); | 356 | DbusTestDbusMock * mock = dbus_test_dbus_mock_new("foo.test"); |
1625 | 365 | g_assert(mock != NULL); | 357 | g_assert(mock != NULL); |
1626 | 366 | 358 | ||
1627 | @@ -430,8 +422,6 @@ | |||
1628 | 430 | DbusTestService * service = dbus_test_service_new(NULL); | 422 | DbusTestService * service = dbus_test_service_new(NULL); |
1629 | 431 | g_assert(service != NULL); | 423 | g_assert(service != NULL); |
1630 | 432 | 424 | ||
1631 | 433 | dbus_test_service_set_conf_file(service, SESSION_CONF); | ||
1632 | 434 | |||
1633 | 435 | DbusTestDbusMock * mock = dbus_test_dbus_mock_new("foo.test"); | 425 | DbusTestDbusMock * mock = dbus_test_dbus_mock_new("foo.test"); |
1634 | 436 | g_assert(mock != NULL); | 426 | g_assert(mock != NULL); |
1635 | 437 | 427 | ||
1636 | @@ -530,8 +520,6 @@ | |||
1637 | 530 | g_assert(service != NULL); | 520 | g_assert(service != NULL); |
1638 | 531 | dbus_test_service_set_bus(service, DBUS_TEST_SERVICE_BUS_SYSTEM); | 521 | dbus_test_service_set_bus(service, DBUS_TEST_SERVICE_BUS_SYSTEM); |
1639 | 532 | 522 | ||
1640 | 533 | dbus_test_service_set_conf_file(service, SESSION_CONF); | ||
1641 | 534 | |||
1642 | 535 | DbusTestDbusMock * mock = dbus_test_dbus_mock_new("foo.test"); | 523 | DbusTestDbusMock * mock = dbus_test_dbus_mock_new("foo.test"); |
1643 | 536 | g_assert(mock != NULL); | 524 | g_assert(mock != NULL); |
1644 | 537 | dbus_test_task_set_bus(DBUS_TEST_TASK(mock), DBUS_TEST_SERVICE_BUS_SYSTEM); | 525 | dbus_test_task_set_bus(DBUS_TEST_TASK(mock), DBUS_TEST_SERVICE_BUS_SYSTEM); |
1645 | @@ -598,8 +586,6 @@ | |||
1646 | 598 | DbusTestService * service = dbus_test_service_new(NULL); | 586 | DbusTestService * service = dbus_test_service_new(NULL); |
1647 | 599 | g_assert(service != NULL); | 587 | g_assert(service != NULL); |
1648 | 600 | 588 | ||
1649 | 601 | dbus_test_service_set_conf_file(service, SESSION_CONF); | ||
1650 | 602 | |||
1651 | 603 | DbusTestDbusMock * mock = dbus_test_dbus_mock_new("foo.test"); | 589 | DbusTestDbusMock * mock = dbus_test_dbus_mock_new("foo.test"); |
1652 | 604 | g_assert(mock != NULL); | 590 | g_assert(mock != NULL); |
1653 | 605 | 591 | ||
1654 | 606 | 592 | ||
1655 | === modified file 'tests/test-libdbustest.c' | |||
1656 | --- tests/test-libdbustest.c 2013-01-29 20:32:11 +0000 | |||
1657 | +++ tests/test-libdbustest.c 2015-09-21 17:10:37 +0000 | |||
1658 | @@ -8,8 +8,6 @@ | |||
1659 | 8 | DbusTestService * service = dbus_test_service_new(NULL); | 8 | DbusTestService * service = dbus_test_service_new(NULL); |
1660 | 9 | g_assert(service != NULL); | 9 | g_assert(service != NULL); |
1661 | 10 | 10 | ||
1662 | 11 | dbus_test_service_set_conf_file(service, SESSION_CONF); | ||
1663 | 12 | |||
1664 | 13 | g_unsetenv("DBUS_SESSION_BUS_ADDRESS"); | 11 | g_unsetenv("DBUS_SESSION_BUS_ADDRESS"); |
1665 | 14 | dbus_test_service_start_tasks(service); | 12 | dbus_test_service_start_tasks(service); |
1666 | 15 | g_assert(g_getenv("DBUS_SESSION_BUS_ADDRESS") != NULL); | 13 | g_assert(g_getenv("DBUS_SESSION_BUS_ADDRESS") != NULL); |
1667 | @@ -24,8 +22,6 @@ | |||
1668 | 24 | DbusTestService * service = dbus_test_service_new(NULL); | 22 | DbusTestService * service = dbus_test_service_new(NULL); |
1669 | 25 | g_assert(service != NULL); | 23 | g_assert(service != NULL); |
1670 | 26 | 24 | ||
1671 | 27 | dbus_test_service_set_conf_file(service, SESSION_CONF); | ||
1672 | 28 | |||
1673 | 29 | DbusTestTask * task = dbus_test_task_new(); | 25 | DbusTestTask * task = dbus_test_task_new(); |
1674 | 30 | g_assert(task != NULL); | 26 | g_assert(task != NULL); |
1675 | 31 | 27 | ||
1676 | @@ -46,8 +42,6 @@ | |||
1677 | 46 | DbusTestService * service = dbus_test_service_new(NULL); | 42 | DbusTestService * service = dbus_test_service_new(NULL); |
1678 | 47 | g_assert(service != NULL); | 43 | g_assert(service != NULL); |
1679 | 48 | 44 | ||
1680 | 49 | dbus_test_service_set_conf_file(service, SESSION_CONF); | ||
1681 | 50 | |||
1682 | 51 | DbusTestTask * task = dbus_test_task_new(); | 45 | DbusTestTask * task = dbus_test_task_new(); |
1683 | 52 | g_assert(task != NULL); | 46 | g_assert(task != NULL); |
1684 | 53 | 47 |
Quick review, some comments below