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