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
1=== modified file 'c/include/subunit/child.h'
2--- c/include/subunit/child.h 2009-10-02 22:26:44 +0000
3+++ c/include/subunit/child.h 2010-09-28 20:32:46 +0000
4@@ -74,6 +74,23 @@
5 char const * const reason);
6
7
8+enum subunit_progress_whence {
9+ SUBUNIT_PROGRESS_SET,
10+ SUBUNIT_PROGRESS_CUR,
11+ SUBUNIT_PROGRESS_POP,
12+ SUBUNIT_PROGRESS_PUSH,
13+};
14+
15+/**
16+ * subunit_progress:
17+ *
18+ * Report the progress of a test run.
19+ * @whence: The type of progress update to report.
20+ * @offset: Offset of the progress (only for SUBUNIT_PROGRESS_SET
21+ * and SUBUNIT_PROGRESS_CUR).
22+ */
23+extern void subunit_progress(enum subunit_progress_whence whence, int offset);
24+
25 #ifdef __cplusplus
26 }
27 #endif
28
29=== modified file 'c/lib/child.c'
30--- c/lib/child.c 2009-10-02 22:26:44 +0000
31+++ c/lib/child.c 2010-09-28 20:32:46 +0000
32@@ -80,3 +80,25 @@
33 {
34 subunit_send_event("skip", name, reason);
35 }
36+
37+void
38+subunit_progress(enum subunit_progress_whence whence, int offset)
39+{
40+ switch (whence) {
41+ case SUBUNIT_PROGRESS_SET:
42+ printf("progress: %d\n", offset);
43+ break;
44+ case SUBUNIT_PROGRESS_CUR:
45+ printf("progress: %+-d\n", offset);
46+ break;
47+ case SUBUNIT_PROGRESS_POP:
48+ printf("progress: pop\n");
49+ break;
50+ case SUBUNIT_PROGRESS_PUSH:
51+ printf("progress: push\n");
52+ break;
53+ default:
54+ fprintf(stderr, "Invalid whence %d in subunit_progress()\n", whence);
55+ break;
56+ }
57+}
58
59=== modified file 'c/tests/test_child.c'
60--- c/tests/test_child.c 2009-10-02 22:26:44 +0000
61+++ c/tests/test_child.c 2010-09-28 20:32:46 +0000
62@@ -164,6 +164,44 @@
63 }
64 END_TEST
65
66+
67+static void
68+call_test_progress_pop(void)
69+{
70+ subunit_progress(SUBUNIT_PROGRESS_POP, 0);
71+}
72+
73+static void
74+call_test_progress_set(void)
75+{
76+ subunit_progress(SUBUNIT_PROGRESS_SET, 5);
77+}
78+
79+static void
80+call_test_progress_push(void)
81+{
82+ subunit_progress(SUBUNIT_PROGRESS_PUSH, 0);
83+}
84+
85+static void
86+call_test_progress_cur(void)
87+{
88+ subunit_progress(SUBUNIT_PROGRESS_CUR, -6);
89+}
90+
91+START_TEST (test_progress)
92+{
93+ test_stdout_function("progress: pop\n",
94+ call_test_progress_pop);
95+ test_stdout_function("progress: push\n",
96+ call_test_progress_push);
97+ test_stdout_function("progress: 5\n",
98+ call_test_progress_set);
99+ test_stdout_function("progress: -6\n",
100+ call_test_progress_cur);
101+}
102+END_TEST
103+
104 static Suite *
105 child_suite(void)
106 {
107@@ -175,6 +213,7 @@
108 tcase_add_test (tc_core, test_fail);
109 tcase_add_test (tc_core, test_error);
110 tcase_add_test (tc_core, test_skip);
111+ tcase_add_test (tc_core, test_progress);
112 return s;
113 }
114

Subscribers

People subscribed via source and target branches