Merge lp:~ted/dbus-test-runner/stop-premature-exiting into lp:dbus-test-runner/12.10

Proposed by Ted Gould
Status: Merged
Approved by: Charles Kerr
Approved revision: 50
Merged at revision: 46
Proposed branch: lp:~ted/dbus-test-runner/stop-premature-exiting
Merge into: lp:dbus-test-runner/12.10
Diff against target: 198 lines (+93/-1)
8 files modified
.bzrignore (+4/-0)
libdbustest/service.c (+1/-1)
libdbustest/task.c (+36/-0)
libdbustest/task.h (+2/-0)
src/dbus-test-runner.c (+18/-0)
tests/Makefile.am (+15/-0)
tests/test-wait-output.reference (+5/-0)
tests/test-wait-outputer (+12/-0)
To merge this branch: bzr merge lp:~ted/dbus-test-runner/stop-premature-exiting
Reviewer Review Type Date Requested Status
jenkins (community) continuous-integration Approve
Charles Kerr (community) Approve
Review via email: mp+127602@code.launchpad.net

Commit message

Add option to wait until task complete

Description of the change

Adding an option to wait until the task is complete even if we don't care about its return value.

To post a comment you must log in.
Revision history for this message
jenkins (martin-mrazik+qa) wrote :
review: Approve (continuous-integration)
Revision history for this message
Charles Kerr (charlesk) :
review: Approve
Revision history for this message
jenkins (martin-mrazik+qa) wrote :
review: Needs Fixing (continuous-integration)
50. By Ted Gould

Updating to trunk to resolve conflicts

Revision history for this message
jenkins (martin-mrazik+qa) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2011-11-28 22:21:06 +0000
3+++ .bzrignore 2012-10-03 03:18:18 +0000
4@@ -24,3 +24,7 @@
5 test-check-name
6 test-own-name
7 test-wait-for
8+test-wait-output.filtered
9+test-wait-output.output
10+test-wait-output
11+test-wait-output.output-only
12
13=== modified file 'libdbustest/service.c'
14--- libdbustest/service.c 2012-10-02 03:11:56 +0000
15+++ libdbustest/service.c 2012-10-03 03:18:18 +0000
16@@ -209,7 +209,7 @@
17 DbusTestTaskState state = dbus_test_task_get_state(task);
18 DbusTestTaskReturn ret = dbus_test_task_get_return(task);
19
20- if (state != DBUS_TEST_TASK_STATE_FINISHED && ret != DBUS_TEST_TASK_RETURN_IGNORE) {
21+ if (state != DBUS_TEST_TASK_STATE_FINISHED && (ret != DBUS_TEST_TASK_RETURN_IGNORE || dbus_test_task_get_wait_finished(task))) {
22 *all_finished = FALSE;
23 }
24
25
26=== modified file 'libdbustest/task.c'
27--- libdbustest/task.c 2012-10-02 03:11:56 +0000
28+++ libdbustest/task.c 2012-10-03 03:18:18 +0000
29@@ -35,6 +35,7 @@
30 glong padding_cnt;
31
32 gboolean been_run;
33+ gboolean wait_until_complete;
34 };
35
36 /* Signals */
37@@ -97,6 +98,7 @@
38 self->priv->padding_cnt = 0;
39
40 self->priv->been_run = FALSE;
41+ self->priv->wait_until_complete = FALSE;
42
43 return;
44 }
45@@ -346,3 +348,37 @@
46
47 return task->priv->wait_for;
48 }
49+
50+/**
51+ * dbus_test_task_set_wait_finished:
52+ * @task: Task to adjust the value on
53+ * @wait_till_complete: Set this task to wait until complete
54+ * even if we don't care about the return value.
55+ *
56+ * If this task has the value of its return set to ignore this
57+ * means we won't exit early.
58+ */
59+void
60+dbus_test_task_set_wait_finished (DbusTestTask * task, gboolean wait_till_complete)
61+{
62+ g_return_if_fail(DBUS_TEST_IS_TASK(task));
63+
64+ task->priv->wait_until_complete = wait_till_complete;
65+
66+ return;
67+}
68+
69+/**
70+ * dbus_test_task_set_wait_finished:
71+ * @task: Task to get the value from
72+ *
73+ * Check to see if we should wait on this taks irregardless
74+ * of whether we care about the return value.
75+ */
76+gboolean
77+dbus_test_task_get_wait_finished (DbusTestTask * task)
78+{
79+ g_return_val_if_fail(DBUS_TEST_IS_TASK(task), FALSE);
80+
81+ return task->priv->wait_until_complete;
82+}
83
84=== modified file 'libdbustest/task.h'
85--- libdbustest/task.h 2012-04-22 18:22:22 +0000
86+++ libdbustest/task.h 2012-10-03 03:18:18 +0000
87@@ -81,6 +81,7 @@
88 void dbus_test_task_set_name_spacing (DbusTestTask * task, glong chars);
89 void dbus_test_task_set_wait_for (DbusTestTask * task, const gchar * dbus_name);
90 void dbus_test_task_set_return (DbusTestTask * task, DbusTestTaskReturn ret);
91+void dbus_test_task_set_wait_finished (DbusTestTask * task, gboolean wait_till_complete);
92
93 void dbus_test_task_print (DbusTestTask * task, const gchar * message);
94
95@@ -88,6 +89,7 @@
96 DbusTestTaskReturn dbus_test_task_get_return (DbusTestTask * task);
97 const gchar * dbus_test_task_get_name (DbusTestTask * task);
98 const gchar * dbus_test_task_get_wait_for (DbusTestTask * task);
99+gboolean dbus_test_task_get_wait_finished (DbusTestTask * task);
100
101 void dbus_test_task_run (DbusTestTask * task);
102
103
104=== modified file 'src/dbus-test-runner.c'
105--- src/dbus-test-runner.c 2012-10-02 03:15:57 +0000
106+++ src/dbus-test-runner.c 2012-10-03 03:18:18 +0000
107@@ -62,6 +62,23 @@
108 }
109
110 static gboolean
111+option_complete (G_GNUC_UNUSED const gchar * arg, G_GNUC_UNUSED const gchar * value, G_GNUC_UNUSED gpointer data, GError ** error)
112+{
113+ if (last_task == NULL) {
114+ g_set_error(error, G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE, "No task to put adjust return on.");
115+ return FALSE;
116+ }
117+
118+ if (dbus_test_task_get_wait_finished(DBUS_TEST_TASK(last_task))) {
119+ g_set_error(error, G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE, "Task has already be setup to wait until finished.");
120+ return FALSE;
121+ }
122+
123+ dbus_test_task_set_wait_finished(DBUS_TEST_TASK(last_task), TRUE);
124+ return TRUE;
125+}
126+
127+static gboolean
128 option_noreturn (G_GNUC_UNUSED const gchar * arg, G_GNUC_UNUSED const gchar * value, G_GNUC_UNUSED gpointer data, GError ** error)
129 {
130 if (last_task == NULL) {
131@@ -154,6 +171,7 @@
132 {"invert-return", 'i', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, option_invert, "Invert the return value of the task before calculating whether the test passes or fails.", NULL},
133 {"parameter", 'p', 0, G_OPTION_ARG_CALLBACK, option_param, "Add a parameter to the call of this utility. May be called as many times as you'd like.", NULL},
134 {"wait-for", 'f', 0, G_OPTION_ARG_CALLBACK, option_wait, "A dbus-name that should appear on the bus before this task is started", "dbus-name"},
135+ {"wait-until-complete", 'c', G_OPTION_FLAG_NO_ARG,G_OPTION_ARG_CALLBACK, option_complete, "Signal that we should wait until this task exits even if we don't need the return value", NULL},
136 {NULL}
137 };
138
139
140=== modified file 'tests/Makefile.am'
141--- tests/Makefile.am 2012-10-01 21:45:55 +0000
142+++ tests/Makefile.am 2012-10-03 03:18:18 +0000
143@@ -266,6 +266,19 @@
144 XFAIL_TESTS += test-daemon-junk
145 DISTCLEANFILES += test-daemon-junk-spitter
146
147+TESTS += test-wait-output
148+test-wait-output: Makefile.am test-wait-outputer
149+ @echo "#!/bin/sh" > $@
150+ @echo $(DBUS_RUNNER) --task "$(srcdir)/test-wait-outputer" --task-name output --ignore-return --wait-until-complete \| tee $(builddir)/test-wait-output.output >> $@
151+ @echo "grep ^output: $(builddir)/test-wait-output.output | tail -n +2 > $(builddir)/test-wait-output.output-only" >> $@
152+ @echo "sed -e s/output:\\ //g $(builddir)/test-wait-output.output-only > $(builddir)/test-wait-output.filtered" >> $@
153+ @echo diff test-wait-output.reference test-wait-output.filtered >> $@
154+ @chmod +x $@
155+DISTCLEANFILES += \
156+ test-wait-output.output \
157+ test-wait-output.output-only \
158+ test-wait-output.filtered
159+
160 ###########################
161 # libdbustest
162 ###########################
163@@ -306,6 +319,8 @@
164 DISTCLEANFILES += $(LIBDBUSTEST_XML_REPORT)
165
166 EXTRA_DIST = \
167+ test-wait-outputer \
168+ test-wait-output.reference \
169 delayrm.sh \
170 test-bustle.reference \
171 test-bustle-data-check.sh \
172
173=== added file 'tests/test-wait-output.reference'
174--- tests/test-wait-output.reference 1970-01-01 00:00:00 +0000
175+++ tests/test-wait-output.reference 2012-10-03 03:18:18 +0000
176@@ -0,0 +1,5 @@
177+One
178+Two
179+Three
180+Four
181+Five
182
183=== added file 'tests/test-wait-outputer'
184--- tests/test-wait-outputer 1970-01-01 00:00:00 +0000
185+++ tests/test-wait-outputer 2012-10-03 03:18:18 +0000
186@@ -0,0 +1,12 @@
187+#!/bin/bash
188+
189+sleep 1
190+echo "One"
191+sleep 1
192+echo "Two"
193+sleep 1
194+echo "Three"
195+sleep 1
196+echo "Four"
197+sleep 1
198+echo "Five"

Subscribers

People subscribed via source and target branches