Merge lp:~jelmer/subunit/c-progress into lp:~subunit/subunit/trunk

Proposed by Jelmer Vernooij
Status: Merged
Merged at revision: 133
Proposed branch: lp:~jelmer/subunit/c-progress
Merge into: lp:~subunit/subunit/trunk
Diff against target: 113 lines (+78/-0)
3 files modified
c/include/subunit/child.h (+17/-0)
c/lib/child.c (+22/-0)
c/tests/test_child.c (+39/-0)
To merge this branch: bzr merge lp:~jelmer/subunit/c-progress
Reviewer Review Type Date Requested Status
Subunit Developers code Pending
Review via email: mp+36851@code.launchpad.net

Description of the change

This adds a subunit_progress() function. We already have this in Samba's libtorture, but it seems to make more sense for it to be upstream.

To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) wrote :

Thanks for this; I'd like you to split the different test calls up so
there is no ambiguity that each call produces separate output.

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

On Tue, 2010-09-28 at 20:18 +0000, Robert Collins wrote:
> Thanks for this; I'd like you to split the different test calls up so
> there is no ambiguity that each call produces separate output.
I've pushed a new version.

lp:~jelmer/subunit/c-progress updated
134. By Jelmer Vernooij

Split up progress tests.

Revision history for this message
Robert Collins (lifeless) wrote :

Land It!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'c/include/subunit/child.h'
--- c/include/subunit/child.h 2009-10-02 22:26:44 +0000
+++ c/include/subunit/child.h 2010-09-28 20:32:46 +0000
@@ -74,6 +74,23 @@
74 char const * const reason);74 char const * const reason);
7575
7676
77enum subunit_progress_whence {
78 SUBUNIT_PROGRESS_SET,
79 SUBUNIT_PROGRESS_CUR,
80 SUBUNIT_PROGRESS_POP,
81 SUBUNIT_PROGRESS_PUSH,
82};
83
84/**
85 * subunit_progress:
86 *
87 * Report the progress of a test run.
88 * @whence: The type of progress update to report.
89 * @offset: Offset of the progress (only for SUBUNIT_PROGRESS_SET
90 * and SUBUNIT_PROGRESS_CUR).
91 */
92extern void subunit_progress(enum subunit_progress_whence whence, int offset);
93
77#ifdef __cplusplus94#ifdef __cplusplus
78}95}
79#endif96#endif
8097
=== modified file 'c/lib/child.c'
--- c/lib/child.c 2009-10-02 22:26:44 +0000
+++ c/lib/child.c 2010-09-28 20:32:46 +0000
@@ -80,3 +80,25 @@
80{80{
81 subunit_send_event("skip", name, reason);81 subunit_send_event("skip", name, reason);
82}82}
83
84void
85subunit_progress(enum subunit_progress_whence whence, int offset)
86{
87 switch (whence) {
88 case SUBUNIT_PROGRESS_SET:
89 printf("progress: %d\n", offset);
90 break;
91 case SUBUNIT_PROGRESS_CUR:
92 printf("progress: %+-d\n", offset);
93 break;
94 case SUBUNIT_PROGRESS_POP:
95 printf("progress: pop\n");
96 break;
97 case SUBUNIT_PROGRESS_PUSH:
98 printf("progress: push\n");
99 break;
100 default:
101 fprintf(stderr, "Invalid whence %d in subunit_progress()\n", whence);
102 break;
103 }
104}
83105
=== modified file 'c/tests/test_child.c'
--- c/tests/test_child.c 2009-10-02 22:26:44 +0000
+++ c/tests/test_child.c 2010-09-28 20:32:46 +0000
@@ -164,6 +164,44 @@
164}164}
165END_TEST165END_TEST
166166
167
168static void
169call_test_progress_pop(void)
170{
171 subunit_progress(SUBUNIT_PROGRESS_POP, 0);
172}
173
174static void
175call_test_progress_set(void)
176{
177 subunit_progress(SUBUNIT_PROGRESS_SET, 5);
178}
179
180static void
181call_test_progress_push(void)
182{
183 subunit_progress(SUBUNIT_PROGRESS_PUSH, 0);
184}
185
186static void
187call_test_progress_cur(void)
188{
189 subunit_progress(SUBUNIT_PROGRESS_CUR, -6);
190}
191
192START_TEST (test_progress)
193{
194 test_stdout_function("progress: pop\n",
195 call_test_progress_pop);
196 test_stdout_function("progress: push\n",
197 call_test_progress_push);
198 test_stdout_function("progress: 5\n",
199 call_test_progress_set);
200 test_stdout_function("progress: -6\n",
201 call_test_progress_cur);
202}
203END_TEST
204
167static Suite *205static Suite *
168child_suite(void)206child_suite(void)
169{207{
@@ -175,6 +213,7 @@
175 tcase_add_test (tc_core, test_fail);213 tcase_add_test (tc_core, test_fail);
176 tcase_add_test (tc_core, test_error);214 tcase_add_test (tc_core, test_error);
177 tcase_add_test (tc_core, test_skip);215 tcase_add_test (tc_core, test_skip);
216 tcase_add_test (tc_core, test_progress);
178 return s;217 return s;
179}218}
180219

Subscribers

People subscribed via source and target branches