Merge lp:~brianaker/gearmand/formatters into lp:gearmand
- formatters
- Merge into 1.2
Proposed by
Brian Aker
Status: | Merged |
---|---|
Merged at revision: | 797 |
Proposed branch: | lp:~brianaker/gearmand/formatters |
Merge into: | lp:gearmand |
Diff against target: |
1093 lines (+542/-290) 8 files modified
libtest/collection.cc (+106/-35) libtest/collection.h (+27/-15) libtest/formatter.cc (+186/-106) libtest/formatter.hpp (+59/-33) libtest/framework.cc (+30/-52) libtest/framework.h (+26/-20) libtest/main.cc (+28/-29) libtest/test.h (+80/-0) |
To merge this branch: | bzr merge lp:~brianaker/gearmand/formatters |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Tangent Trunk | Pending | ||
Review via email: mp+172640@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'libtest/collection.cc' | |||
2 | --- libtest/collection.cc 2013-05-03 08:41:20 +0000 | |||
3 | +++ libtest/collection.cc 2013-07-02 18:24:29 +0000 | |||
4 | @@ -38,9 +38,11 @@ | |||
5 | 38 | 38 | ||
6 | 39 | #include <libtest/common.h> | 39 | #include <libtest/common.h> |
7 | 40 | 40 | ||
8 | 41 | #include <algorithm> | ||
9 | 42 | |||
10 | 41 | // @todo possibly have this code fork off so if it fails nothing goes bad | 43 | // @todo possibly have this code fork off so if it fails nothing goes bad |
11 | 42 | static test_return_t runner_code(libtest::Framework* frame, | 44 | static test_return_t runner_code(libtest::Framework* frame, |
13 | 43 | test_st* run, | 45 | const struct test_st* run, |
14 | 44 | libtest::Timer& _timer) | 46 | libtest::Timer& _timer) |
15 | 45 | { // Runner Code | 47 | { // Runner Code |
16 | 46 | 48 | ||
17 | @@ -84,46 +86,119 @@ | |||
18 | 84 | 86 | ||
19 | 85 | namespace libtest { | 87 | namespace libtest { |
20 | 86 | 88 | ||
28 | 87 | Collection::Collection(Framework* frame_arg, | 89 | Collection::Collection(Framework* frame_, |
29 | 88 | collection_st* arg) : | 90 | collection_st* tests_) : |
30 | 89 | _name(arg->name), | 91 | _name(tests_->name), |
31 | 90 | _pre(arg->pre), | 92 | _ret(TEST_SKIPPED), |
32 | 91 | _post(arg->post), | 93 | _pre(tests_->pre), |
33 | 92 | _tests(arg->tests), | 94 | _post(tests_->post), |
34 | 93 | _frame(frame_arg), | 95 | _tests(tests_->tests), |
35 | 96 | _frame(frame_), | ||
36 | 94 | _success(0), | 97 | _success(0), |
37 | 95 | _skipped(0), | 98 | _skipped(0), |
38 | 96 | _failed(0), | 99 | _failed(0), |
43 | 97 | _total(0), | 100 | _formatter(frame_->formatter()) |
44 | 98 | _formatter(frame_arg->name(), _name) | 101 | { |
45 | 99 | { | 102 | fatal_assert(tests_); |
46 | 100 | fatal_assert(arg); | 103 | for (const test_st *run= _tests; run->name; run++) |
47 | 104 | { | ||
48 | 105 | push_testcase(run); | ||
49 | 106 | } | ||
50 | 107 | |||
51 | 108 | case_iter= _testcases.begin(); | ||
52 | 109 | } | ||
53 | 110 | |||
54 | 111 | Collection::~Collection() | ||
55 | 112 | { | ||
56 | 113 | std::for_each(_testcases.begin(), _testcases.end(), DeleteFromVector()); | ||
57 | 114 | _testcases.clear(); | ||
58 | 115 | |||
59 | 116 | std::for_each(_formatter.begin(), _formatter.end(), DeleteFromVector()); | ||
60 | 117 | _formatter.clear(); | ||
61 | 118 | } | ||
62 | 119 | |||
63 | 120 | void Collection::push_testcase(const test_st* test_) | ||
64 | 121 | { | ||
65 | 122 | TestCase* _current_testcase= new TestCase(test_); | ||
66 | 123 | _testcases.push_back(_current_testcase); | ||
67 | 124 | } | ||
68 | 125 | |||
69 | 126 | void Collection::format() | ||
70 | 127 | { | ||
71 | 128 | for (Formatters::iterator format_iter= _formatter.begin(); | ||
72 | 129 | format_iter != _formatter.end(); | ||
73 | 130 | ++format_iter) | ||
74 | 131 | { | ||
75 | 132 | (*format_iter)->report((*case_iter), std::distance(_testcases.begin(), case_iter)); | ||
76 | 133 | } | ||
77 | 134 | } | ||
78 | 135 | |||
79 | 136 | void Collection::plan() | ||
80 | 137 | { | ||
81 | 138 | for (Formatters::iterator format_iter= _formatter.begin(); | ||
82 | 139 | format_iter != _formatter.end(); | ||
83 | 140 | ++format_iter) | ||
84 | 141 | { | ||
85 | 142 | (*format_iter)->plan(this); | ||
86 | 143 | } | ||
87 | 144 | } | ||
88 | 145 | |||
89 | 146 | void Collection::complete() | ||
90 | 147 | { | ||
91 | 148 | for (Formatters::iterator format_iter= _formatter.begin(); | ||
92 | 149 | format_iter != _formatter.end(); | ||
93 | 150 | ++format_iter) | ||
94 | 151 | { | ||
95 | 152 | (*format_iter)->complete(); | ||
96 | 153 | } | ||
97 | 154 | } | ||
98 | 155 | |||
99 | 156 | void Collection::succeess() | ||
100 | 157 | { | ||
101 | 158 | _success++; | ||
102 | 159 | (*case_iter)->success(_timer); | ||
103 | 160 | format(); | ||
104 | 161 | } | ||
105 | 162 | |||
106 | 163 | void Collection::skip() | ||
107 | 164 | { | ||
108 | 165 | _skipped++; | ||
109 | 166 | (*case_iter)->skipped(); | ||
110 | 167 | format(); | ||
111 | 168 | } | ||
112 | 169 | |||
113 | 170 | void Collection::fail() | ||
114 | 171 | { | ||
115 | 172 | _failed++; | ||
116 | 173 | (*case_iter)->failed(); | ||
117 | 174 | format(); | ||
118 | 101 | } | 175 | } |
119 | 102 | 176 | ||
120 | 103 | test_return_t Collection::exec() | 177 | test_return_t Collection::exec() |
121 | 104 | { | 178 | { |
122 | 179 | // Write out any headers required by formatting. | ||
123 | 180 | plan(); | ||
124 | 181 | |||
125 | 105 | if (test_success(_frame->runner()->setup(_pre, _frame->creators_ptr()))) | 182 | if (test_success(_frame->runner()->setup(_pre, _frame->creators_ptr()))) |
126 | 106 | { | 183 | { |
128 | 107 | for (test_st *run= _tests; run->name; run++) | 184 | for (; case_iter != _testcases.end(); |
129 | 185 | ++case_iter) | ||
130 | 108 | { | 186 | { |
133 | 109 | formatter()->push_testcase(run->name); | 187 | if (_frame->match((*case_iter)->name())) |
132 | 110 | if (_frame->match(run->name)) | ||
134 | 111 | { | 188 | { |
136 | 112 | formatter()->skipped(); | 189 | skip(); |
137 | 113 | continue; | 190 | continue; |
138 | 114 | } | 191 | } |
139 | 115 | _total++; | ||
140 | 116 | 192 | ||
141 | 117 | test_return_t return_code; | 193 | test_return_t return_code; |
142 | 118 | try | 194 | try |
143 | 119 | { | 195 | { |
145 | 120 | if (run->requires_flush) | 196 | if ((*case_iter)->requires_flush()) |
146 | 121 | { | 197 | { |
147 | 122 | if (test_failed(_frame->runner()->flush(_frame->creators_ptr()))) | 198 | if (test_failed(_frame->runner()->flush(_frame->creators_ptr()))) |
148 | 123 | { | 199 | { |
149 | 124 | Error << "frame->runner()->flush(creators_ptr)"; | 200 | Error << "frame->runner()->flush(creators_ptr)"; |
152 | 125 | _skipped++; | 201 | skip(); |
151 | 126 | formatter()->skipped(); | ||
153 | 127 | continue; | 202 | continue; |
154 | 128 | } | 203 | } |
155 | 129 | } | 204 | } |
156 | @@ -132,7 +207,7 @@ | |||
157 | 132 | 207 | ||
158 | 133 | try | 208 | try |
159 | 134 | { | 209 | { |
161 | 135 | return_code= runner_code(_frame, run, _timer); | 210 | return_code= runner_code(_frame, (*case_iter)->test(), _timer); |
162 | 136 | } | 211 | } |
163 | 137 | catch (...) | 212 | catch (...) |
164 | 138 | { | 213 | { |
165 | @@ -145,26 +220,22 @@ | |||
166 | 145 | catch (const libtest::fatal& e) | 220 | catch (const libtest::fatal& e) |
167 | 146 | { | 221 | { |
168 | 147 | stream::cerr(e.file(), e.line(), e.func()) << e.what(); | 222 | stream::cerr(e.file(), e.line(), e.func()) << e.what(); |
171 | 148 | _failed++; | 223 | fail(); |
170 | 149 | formatter()->failed(); | ||
172 | 150 | throw; | 224 | throw; |
173 | 151 | } | 225 | } |
174 | 152 | 226 | ||
175 | 153 | switch (return_code) | 227 | switch (return_code) |
176 | 154 | { | 228 | { |
177 | 155 | case TEST_SUCCESS: | 229 | case TEST_SUCCESS: |
180 | 156 | _success++; | 230 | succeess(); |
179 | 157 | formatter()->success(_timer); | ||
181 | 158 | break; | 231 | break; |
182 | 159 | 232 | ||
183 | 160 | case TEST_FAILURE: | 233 | case TEST_FAILURE: |
186 | 161 | _failed++; | 234 | fail(); |
185 | 162 | formatter()->failed(); | ||
187 | 163 | break; | 235 | break; |
188 | 164 | 236 | ||
189 | 165 | case TEST_SKIPPED: | 237 | case TEST_SKIPPED: |
192 | 166 | _skipped++; | 238 | skip(); |
191 | 167 | formatter()->skipped(); | ||
193 | 168 | break; | 239 | break; |
194 | 169 | 240 | ||
195 | 170 | default: | 241 | default: |
196 | @@ -180,17 +251,17 @@ | |||
197 | 180 | 251 | ||
198 | 181 | if (_failed == 0 and _skipped == 0 and _success) | 252 | if (_failed == 0 and _skipped == 0 and _success) |
199 | 182 | { | 253 | { |
201 | 183 | return TEST_SUCCESS; | 254 | _ret= TEST_SUCCESS; |
202 | 184 | } | 255 | } |
205 | 185 | 256 | else if (_failed) | |
204 | 186 | if (_failed) | ||
206 | 187 | { | 257 | { |
208 | 188 | return TEST_FAILURE; | 258 | _ret= TEST_FAILURE; |
209 | 189 | } | 259 | } |
210 | 190 | 260 | ||
212 | 191 | fatal_assert(_skipped or _success == 0); | 261 | // Complete any headers required by formatting. |
213 | 262 | complete(); | ||
214 | 192 | 263 | ||
216 | 193 | return TEST_SKIPPED; | 264 | return _ret; |
217 | 194 | } | 265 | } |
218 | 195 | 266 | ||
219 | 196 | } // namespace libtest | 267 | } // namespace libtest |
220 | 197 | 268 | ||
221 | === modified file 'libtest/collection.h' | |||
222 | --- libtest/collection.h 2013-01-10 12:05:49 +0000 | |||
223 | +++ libtest/collection.h 2013-07-02 18:24:29 +0000 | |||
224 | @@ -58,41 +58,52 @@ | |||
225 | 58 | class Collection { | 58 | class Collection { |
226 | 59 | public: | 59 | public: |
227 | 60 | Collection(libtest::Framework*, collection_st*); | 60 | Collection(libtest::Framework*, collection_st*); |
228 | 61 | ~Collection(); | ||
229 | 61 | 62 | ||
230 | 62 | test_return_t exec(); | 63 | test_return_t exec(); |
231 | 63 | 64 | ||
233 | 64 | const char* name() | 65 | const char* name() const |
234 | 65 | { | 66 | { |
235 | 66 | return _name.c_str(); | 67 | return _name.c_str(); |
236 | 67 | } | 68 | } |
237 | 68 | 69 | ||
239 | 69 | uint32_t success() | 70 | void succeess(); |
240 | 71 | |||
241 | 72 | void skip(); | ||
242 | 73 | |||
243 | 74 | void fail(); | ||
244 | 75 | |||
245 | 76 | uint32_t succeeded() const | ||
246 | 70 | { | 77 | { |
247 | 71 | return _success; | 78 | return _success; |
248 | 72 | } | 79 | } |
249 | 73 | 80 | ||
251 | 74 | uint32_t skipped() | 81 | uint32_t skipped() const |
252 | 75 | { | 82 | { |
253 | 76 | return _skipped; | 83 | return _skipped; |
254 | 77 | } | 84 | } |
255 | 78 | 85 | ||
257 | 79 | uint32_t failed() | 86 | uint32_t failed() const |
258 | 80 | { | 87 | { |
259 | 81 | return _failed; | 88 | return _failed; |
260 | 82 | } | 89 | } |
261 | 83 | 90 | ||
271 | 84 | uint32_t total() | 91 | void format(); |
272 | 85 | { | 92 | |
273 | 86 | return _total; | 93 | size_t total() const |
274 | 87 | } | 94 | { |
275 | 88 | 95 | return _testcases.size(); | |
276 | 89 | libtest::Formatter* formatter() | 96 | } |
277 | 90 | { | 97 | |
278 | 91 | return &_formatter; | 98 | void plan(); |
279 | 92 | } | 99 | void complete(); |
280 | 100 | |||
281 | 101 | private: | ||
282 | 102 | void push_testcase(const test_st* test_); | ||
283 | 93 | 103 | ||
284 | 94 | private: | 104 | private: |
285 | 95 | std::string _name; | 105 | std::string _name; |
286 | 106 | test_return_t _ret; | ||
287 | 96 | test_callback_fn *_pre; | 107 | test_callback_fn *_pre; |
288 | 97 | test_callback_fn *_post; | 108 | test_callback_fn *_post; |
289 | 98 | struct test_st *_tests; | 109 | struct test_st *_tests; |
290 | @@ -100,9 +111,10 @@ | |||
291 | 100 | uint32_t _success; | 111 | uint32_t _success; |
292 | 101 | uint32_t _skipped; | 112 | uint32_t _skipped; |
293 | 102 | uint32_t _failed; | 113 | uint32_t _failed; |
294 | 103 | uint32_t _total; | ||
295 | 104 | libtest::Timer _timer; | 114 | libtest::Timer _timer; |
297 | 105 | libtest::Formatter _formatter; | 115 | libtest::Formatters& _formatter; |
298 | 116 | TestCases _testcases; | ||
299 | 117 | TestCases::iterator case_iter; | ||
300 | 106 | 118 | ||
301 | 107 | private: | 119 | private: |
302 | 108 | Collection( const Collection& ); | 120 | Collection( const Collection& ); |
303 | 109 | 121 | ||
304 | === modified file 'libtest/formatter.cc' | |||
305 | --- libtest/formatter.cc 2013-01-04 00:19:53 +0000 | |||
306 | +++ libtest/formatter.cc 2013-07-02 18:24:29 +0000 | |||
307 | @@ -44,101 +44,190 @@ | |||
308 | 44 | 44 | ||
309 | 45 | namespace libtest { | 45 | namespace libtest { |
310 | 46 | 46 | ||
406 | 47 | class TestCase { | 47 | Formatter::Formatter(const Framework* frame_, std::ostream& output_): |
407 | 48 | public: | 48 | _frame(frame_), |
408 | 49 | TestCase(const std::string& arg): | 49 | _output(output_) |
409 | 50 | _name(arg), | 50 | { |
410 | 51 | _result(TEST_FAILURE) | 51 | } |
411 | 52 | { | 52 | |
412 | 53 | } | 53 | const std::string& Formatter::name() const |
413 | 54 | 54 | { | |
414 | 55 | const std::string& name() const | 55 | return _frame->name(); |
415 | 56 | { | 56 | } |
416 | 57 | return _name; | 57 | |
417 | 58 | } | 58 | Legacy::Legacy(const Framework* frame_, std::ostream& output_): |
418 | 59 | 59 | Formatter(frame_, output_), | |
419 | 60 | test_return_t result() const | 60 | _collection(NULL) |
420 | 61 | { | 61 | { |
421 | 62 | return _result; | 62 | } |
422 | 63 | } | 63 | |
423 | 64 | 64 | ||
424 | 65 | void result(test_return_t arg) | 65 | Legacy::~Legacy() |
425 | 66 | { | 66 | { |
426 | 67 | _result= arg; | 67 | if (getenv("YATL_SUMMARY")) |
427 | 68 | } | 68 | { |
428 | 69 | 69 | Outn(); | |
429 | 70 | void result(test_return_t arg, const libtest::Timer& timer_) | 70 | Out << "Tests\t\t\t\t\t" << _frame->total(); |
430 | 71 | { | 71 | Out << "\tFailed\t\t\t\t\t" << _frame->failed(); |
431 | 72 | _result= arg; | 72 | Out << "\tSkipped\t\t\t\t\t" << _frame->skipped(); |
432 | 73 | _timer= timer_; | 73 | Out << "\tSucceeded\t\t\t\t" << _frame->success(); |
433 | 74 | } | 74 | } |
434 | 75 | 75 | } | |
435 | 76 | const libtest::Timer& timer() const | 76 | |
436 | 77 | { | 77 | void Legacy::plan(const Collection* collection) |
437 | 78 | return _timer; | 78 | { |
438 | 79 | } | 79 | _collection= collection; |
439 | 80 | 80 | } | |
440 | 81 | void timer(libtest::Timer& arg) | 81 | |
441 | 82 | { | 82 | void Legacy::report(const libtest::TestCase* test, size_t) const |
442 | 83 | _timer= arg; | 83 | { |
443 | 84 | } | 84 | switch (test->result()) |
444 | 85 | 85 | { | |
445 | 86 | private: | 86 | case TEST_SUCCESS: |
446 | 87 | std::string _name; | 87 | Out << name() << "." |
447 | 88 | test_return_t _result; | 88 | << _collection->name() << "." |
448 | 89 | libtest::Timer _timer; | 89 | << test->name() |
449 | 90 | }; | 90 | << "\t\t\t\t\t" |
450 | 91 | 91 | << test->timer() | |
451 | 92 | Formatter::Formatter(const std::string& frame_name, const std::string& arg) | 92 | << " [ " << test_strerror(test->result()) << " ]"; |
452 | 93 | { | 93 | break; |
453 | 94 | _suite_name= frame_name; | 94 | |
454 | 95 | _suite_name+= "."; | 95 | case TEST_FAILURE: |
455 | 96 | _suite_name+= arg; | 96 | Out << name() << "." |
456 | 97 | } | 97 | << _collection->name() << "." |
457 | 98 | 98 | << test->name() | |
458 | 99 | Formatter::~Formatter() | 99 | << "\t\t\t\t\t" << "[ " << test_strerror(test->result()) << " ]"; |
459 | 100 | { | 100 | break; |
460 | 101 | std::for_each(_testcases.begin(), _testcases.end(), DeleteFromVector()); | 101 | |
461 | 102 | _testcases.clear(); | 102 | case TEST_SKIPPED: |
462 | 103 | } | 103 | Out << name() << "." |
463 | 104 | 104 | << _collection->name() << "." | |
464 | 105 | TestCase* Formatter::current() | 105 | << test->name() |
465 | 106 | { | 106 | << "\t\t\t\t\t" << "[ " << test_strerror(test->result()) << " ]"; |
466 | 107 | return _testcases.back(); | 107 | break; |
467 | 108 | } | 108 | } |
468 | 109 | 109 | } | |
469 | 110 | void Formatter::skipped() | 110 | |
470 | 111 | { | 111 | Junit::Junit(const Framework* frame_, std::ostream& output_): |
471 | 112 | current()->result(TEST_SKIPPED); | 112 | Formatter(frame_, output_) |
472 | 113 | Out << name() << "." << current()->name() << "\t\t\t\t\t" << "[ " << test_strerror(current()->result()) << " ]"; | 113 | { |
473 | 114 | 114 | _output << "<testsuites name=\"" << name() << "\">" << std::endl; | |
474 | 115 | reset(); | 115 | } |
475 | 116 | } | 116 | |
476 | 117 | 117 | Junit::~Junit() | |
477 | 118 | void Formatter::failed() | 118 | { |
478 | 119 | { | 119 | _output << "</testsuites>" << std::endl; |
479 | 120 | assert(current()); | 120 | } |
480 | 121 | current()->result(TEST_FAILURE); | 121 | |
481 | 122 | 122 | void Junit::report(const libtest::TestCase* test, size_t) const | |
482 | 123 | Out << name() << "." << current()->name() << "\t\t\t\t\t" << "[ " << test_strerror(current()->result()) << " ]"; | 123 | { |
483 | 124 | 124 | _output << "\t\t<testcase name=\"" | |
484 | 125 | reset(); | 125 | << test->name() |
485 | 126 | } | 126 | << "\" time=\"" |
486 | 127 | 127 | << test->timer().elapsed_milliseconds() | |
487 | 128 | void Formatter::success(const libtest::Timer& timer_) | 128 | << "\">" |
488 | 129 | { | 129 | << std::endl; |
489 | 130 | assert(current()); | 130 | |
490 | 131 | current()->result(TEST_SUCCESS, timer_); | 131 | switch (test->result()) |
491 | 132 | 132 | { | |
492 | 133 | Out << name() << "." | 133 | case TEST_SKIPPED: |
493 | 134 | << current()->name() | 134 | _output << "\t\t <skipped/>" << std::endl; |
494 | 135 | << "\t\t\t\t\t" | 135 | break; |
495 | 136 | << current()->timer() | 136 | |
496 | 137 | << " [ " << test_strerror(current()->result()) << " ]"; | 137 | case TEST_FAILURE: |
497 | 138 | 138 | _output << "\t\t <failure message=\"\" type=\"\"/>"<< std::endl; | |
498 | 139 | reset(); | 139 | break; |
499 | 140 | } | 140 | |
500 | 141 | 141 | case TEST_SUCCESS: | |
501 | 142 | break; | ||
502 | 143 | } | ||
503 | 144 | _output << "\t\t</testcase>" << std::endl; | ||
504 | 145 | } | ||
505 | 146 | |||
506 | 147 | void Junit::plan(const Collection* collection) | ||
507 | 148 | { | ||
508 | 149 | _output << "\t<testsuite name=\"" << collection->name() << "\" classname=\"\" package=\"\">" << std::endl; | ||
509 | 150 | } | ||
510 | 151 | |||
511 | 152 | void Junit::complete() | ||
512 | 153 | { | ||
513 | 154 | _output << "\t</testsuite>" << std::endl; | ||
514 | 155 | } | ||
515 | 156 | |||
516 | 157 | TAP::TAP(const Framework* frame_, std::ostream& output_): | ||
517 | 158 | Formatter(frame_, output_) | ||
518 | 159 | { | ||
519 | 160 | } | ||
520 | 161 | |||
521 | 162 | TAP::~TAP() | ||
522 | 163 | { | ||
523 | 164 | } | ||
524 | 165 | |||
525 | 166 | void TAP::report(const libtest::TestCase* test, size_t position) const | ||
526 | 167 | { | ||
527 | 168 | assert(test); | ||
528 | 169 | switch (test->result()) | ||
529 | 170 | { | ||
530 | 171 | case TEST_SUCCESS: | ||
531 | 172 | _output << "ok " << position << " - " << test->name() << " # "; | ||
532 | 173 | _output << test->timer().elapsed_milliseconds(); | ||
533 | 174 | break; | ||
534 | 175 | |||
535 | 176 | case TEST_FAILURE: | ||
536 | 177 | _output << "not ok " << position << " - " << test->name() << " # "; | ||
537 | 178 | break; | ||
538 | 179 | |||
539 | 180 | case TEST_SKIPPED: | ||
540 | 181 | _output << "ok " << position << " - # SKIP "; | ||
541 | 182 | break; | ||
542 | 183 | } | ||
543 | 184 | |||
544 | 185 | _output << std::endl; | ||
545 | 186 | } | ||
546 | 187 | |||
547 | 188 | void TAP::plan(const Collection* collection) | ||
548 | 189 | { | ||
549 | 190 | _output << "0.." << collection->total() << std::endl; | ||
550 | 191 | } | ||
551 | 192 | |||
552 | 193 | #if 0 | ||
553 | 194 | void Formatter::tap(libtest::Framework& framework_, std::ofstream& output) | ||
554 | 195 | { | ||
555 | 196 | for (Suites::iterator framework_iter= framework_.suites().begin(); | ||
556 | 197 | framework_iter != framework_.suites().end(); | ||
557 | 198 | ++framework_iter) | ||
558 | 199 | { | ||
559 | 200 | output << "1.." << (*framework_iter)->formatter()->testcases().size() << " # " << (*framework_iter)->name() << std::endl; | ||
560 | 201 | |||
561 | 202 | size_t test_count= 1; | ||
562 | 203 | for (TestCases::iterator case_iter= (*framework_iter)->formatter()->testcases().begin(); | ||
563 | 204 | case_iter != (*framework_iter)->formatter()->testcases().end(); | ||
564 | 205 | ++case_iter) | ||
565 | 206 | { | ||
566 | 207 | switch ((*case_iter)->result()) | ||
567 | 208 | { | ||
568 | 209 | case TEST_SKIPPED: | ||
569 | 210 | output << "ok " << test_count << " - # SKIP "; | ||
570 | 211 | break; | ||
571 | 212 | |||
572 | 213 | case TEST_FAILURE: | ||
573 | 214 | output << "not ok " << test_count << " - " << (*case_iter)->name() << " # "; | ||
574 | 215 | break; | ||
575 | 216 | |||
576 | 217 | case TEST_SUCCESS: | ||
577 | 218 | output << "ok " << test_count << " - " << (*case_iter)->name() << " # "; | ||
578 | 219 | break; | ||
579 | 220 | } | ||
580 | 221 | |||
581 | 222 | output | ||
582 | 223 | << (*case_iter)->timer().elapsed_milliseconds() | ||
583 | 224 | << std::endl; | ||
584 | 225 | } | ||
585 | 226 | } | ||
586 | 227 | } | ||
587 | 228 | #endif | ||
588 | 229 | |||
589 | 230 | #if 0 | ||
590 | 142 | void Formatter::xml(libtest::Framework& framework_, std::ofstream& output) | 231 | void Formatter::xml(libtest::Framework& framework_, std::ofstream& output) |
591 | 143 | { | 232 | { |
592 | 144 | output << "<testsuites name=\"" << framework_.name() << "\">" << std::endl; | 233 | output << "<testsuites name=\"" << framework_.name() << "\">" << std::endl; |
593 | @@ -178,15 +267,6 @@ | |||
594 | 178 | } | 267 | } |
595 | 179 | output << "</testsuites>" << std::endl; | 268 | output << "</testsuites>" << std::endl; |
596 | 180 | } | 269 | } |
608 | 181 | 270 | #endif | |
609 | 182 | void Formatter::push_testcase(const std::string& arg) | 271 | |
599 | 183 | { | ||
600 | 184 | assert(_suite_name.empty() == false); | ||
601 | 185 | TestCase* _current_testcase= new TestCase(arg); | ||
602 | 186 | _testcases.push_back(_current_testcase); | ||
603 | 187 | } | ||
604 | 188 | |||
605 | 189 | void Formatter::reset() | ||
606 | 190 | { | ||
607 | 191 | } | ||
610 | 192 | } // namespace libtest | 272 | } // namespace libtest |
611 | 193 | 273 | ||
612 | === modified file 'libtest/formatter.hpp' | |||
613 | --- libtest/formatter.hpp 2012-12-10 09:06:07 +0000 | |||
614 | +++ libtest/formatter.hpp 2013-07-02 18:24:29 +0000 | |||
615 | @@ -43,43 +43,69 @@ | |||
616 | 43 | 43 | ||
617 | 44 | namespace libtest { | 44 | namespace libtest { |
618 | 45 | 45 | ||
621 | 46 | class TestCase; | 46 | class Collection; |
622 | 47 | typedef std::vector<libtest::TestCase*> TestCases; | 47 | |
623 | 48 | class Formatter; | ||
624 | 49 | typedef std::vector<libtest::Formatter*> Formatters; | ||
625 | 48 | 50 | ||
626 | 49 | class Formatter { | 51 | class Formatter { |
627 | 50 | public: | 52 | public: |
650 | 51 | Formatter(const std::string& frame_name, const std::string& arg); | 53 | Formatter(const Framework* frame_, std::ostream&); |
651 | 52 | 54 | ||
652 | 53 | ~Formatter(); | 55 | virtual ~Formatter() {} |
653 | 54 | 56 | ||
654 | 55 | void skipped(); | 57 | virtual void plan(const libtest::Collection*) {} |
655 | 56 | 58 | virtual void report(const libtest::TestCase*, size_t) const {} | |
656 | 57 | void failed(); | 59 | virtual void complete() {} |
657 | 58 | 60 | ||
658 | 59 | void success(const libtest::Timer&); | 61 | protected: |
659 | 60 | 62 | const std::string& name() const; | |
660 | 61 | void push_testcase(const std::string&); | 63 | |
661 | 62 | 64 | #if 0 | |
640 | 63 | const std::string& name() const | ||
641 | 64 | { | ||
642 | 65 | return _suite_name; | ||
643 | 66 | } | ||
644 | 67 | |||
645 | 68 | TestCases& testcases() | ||
646 | 69 | { | ||
647 | 70 | return _testcases; | ||
648 | 71 | } | ||
649 | 72 | |||
662 | 73 | static void xml(libtest::Framework&, std::ofstream&); | 65 | static void xml(libtest::Framework&, std::ofstream&); |
672 | 74 | 66 | static void tap(libtest::Framework&, std::ofstream&); | |
673 | 75 | private: | 67 | #endif |
674 | 76 | void reset(); | 68 | |
675 | 77 | 69 | protected: | |
676 | 78 | TestCase* current(); | 70 | const Framework* _frame; |
677 | 79 | 71 | ||
678 | 80 | private: | 72 | protected: |
679 | 81 | std::string _suite_name; | 73 | std::ostream& _output; |
680 | 82 | TestCases _testcases; | 74 | }; |
681 | 75 | |||
682 | 76 | class Junit : public Formatter | ||
683 | 77 | { | ||
684 | 78 | public: | ||
685 | 79 | Junit(const Framework*, std::ostream&); | ||
686 | 80 | ~Junit(); | ||
687 | 81 | |||
688 | 82 | void report(const libtest::TestCase*, size_t position) const; | ||
689 | 83 | |||
690 | 84 | void plan(const libtest::Collection*); | ||
691 | 85 | void complete(); | ||
692 | 86 | }; | ||
693 | 87 | |||
694 | 88 | class TAP : public Formatter | ||
695 | 89 | { | ||
696 | 90 | public: | ||
697 | 91 | TAP(const Framework*, std::ostream&); | ||
698 | 92 | ~TAP(); | ||
699 | 93 | |||
700 | 94 | void plan(const libtest::Collection*); | ||
701 | 95 | void report(const libtest::TestCase*, size_t position) const; | ||
702 | 96 | }; | ||
703 | 97 | |||
704 | 98 | class Legacy : public Formatter | ||
705 | 99 | { | ||
706 | 100 | public: | ||
707 | 101 | Legacy(const Framework*, std::ostream&); | ||
708 | 102 | ~Legacy(); | ||
709 | 103 | |||
710 | 104 | void plan(const libtest::Collection*); | ||
711 | 105 | void report(const libtest::TestCase*, size_t position) const; | ||
712 | 106 | |||
713 | 107 | private: | ||
714 | 108 | const libtest::Collection* _collection; | ||
715 | 83 | }; | 109 | }; |
716 | 84 | 110 | ||
717 | 85 | } // namespace libtest | 111 | } // namespace libtest |
718 | 86 | 112 | ||
719 | === modified file 'libtest/framework.cc' | |||
720 | --- libtest/framework.cc 2013-05-03 08:41:20 +0000 | |||
721 | +++ libtest/framework.cc 2013-07-02 18:24:29 +0000 | |||
722 | @@ -125,6 +125,33 @@ | |||
723 | 125 | _name(name_) | 125 | _name(name_) |
724 | 126 | { | 126 | { |
725 | 127 | get_world(this); | 127 | get_world(this); |
726 | 128 | |||
727 | 129 | { | ||
728 | 130 | std::string file_name; | ||
729 | 131 | if (getenv("WORKSPACE")) | ||
730 | 132 | { | ||
731 | 133 | file_name.append(getenv("WORKSPACE")); | ||
732 | 134 | file_name.append("/"); | ||
733 | 135 | } | ||
734 | 136 | file_name.append(name()); | ||
735 | 137 | file_name.append(".xml"); | ||
736 | 138 | xml_file.open(file_name.c_str(), std::ios::trunc); | ||
737 | 139 | _formatter.push_back(new libtest::Junit(this, xml_file)); | ||
738 | 140 | } | ||
739 | 141 | |||
740 | 142 | { | ||
741 | 143 | std::string file_name; | ||
742 | 144 | if (getenv("WORKSPACE")) | ||
743 | 145 | { | ||
744 | 146 | file_name.append(getenv("WORKSPACE")); | ||
745 | 147 | file_name.append("/"); | ||
746 | 148 | } | ||
747 | 149 | file_name.append(name()); | ||
748 | 150 | file_name.append(".tap"); | ||
749 | 151 | tap_file.open(file_name.c_str(), std::ios::trunc); | ||
750 | 152 | _formatter.push_back(new libtest::TAP(this, tap_file)); | ||
751 | 153 | } | ||
752 | 154 | _formatter.push_back(new libtest::Legacy(this, std::cout)); | ||
753 | 128 | } | 155 | } |
754 | 129 | 156 | ||
755 | 130 | void Framework::collections(collection_st collections_[]) | 157 | void Framework::collections(collection_st collections_[]) |
756 | @@ -148,6 +175,9 @@ | |||
757 | 148 | 175 | ||
758 | 149 | std::for_each(_collection.begin(), _collection.end(), DeleteFromVector()); | 176 | std::for_each(_collection.begin(), _collection.end(), DeleteFromVector()); |
759 | 150 | _collection.clear(); | 177 | _collection.clear(); |
760 | 178 | |||
761 | 179 | std::for_each(_formatter.begin(), _formatter.end(), DeleteFromVector()); | ||
762 | 180 | _formatter.clear(); | ||
763 | 151 | } | 181 | } |
764 | 152 | 182 | ||
765 | 153 | bool Framework::match(const char* arg) | 183 | bool Framework::match(const char* arg) |
766 | @@ -232,58 +262,6 @@ | |||
767 | 232 | } | 262 | } |
768 | 233 | } | 263 | } |
769 | 234 | 264 | ||
770 | 235 | uint32_t Framework::sum_total() | ||
771 | 236 | { | ||
772 | 237 | uint32_t count= 0; | ||
773 | 238 | for (std::vector<Collection*>::iterator iter= _collection.begin(); | ||
774 | 239 | iter != _collection.end(); | ||
775 | 240 | ++iter) | ||
776 | 241 | { | ||
777 | 242 | count+= (*iter)->total(); | ||
778 | 243 | } | ||
779 | 244 | |||
780 | 245 | return count; | ||
781 | 246 | } | ||
782 | 247 | |||
783 | 248 | uint32_t Framework::sum_success() | ||
784 | 249 | { | ||
785 | 250 | uint32_t count= 0; | ||
786 | 251 | for (std::vector<Collection*>::iterator iter= _collection.begin(); | ||
787 | 252 | iter != _collection.end(); | ||
788 | 253 | ++iter) | ||
789 | 254 | { | ||
790 | 255 | count+= (*iter)->success(); | ||
791 | 256 | } | ||
792 | 257 | |||
793 | 258 | return count; | ||
794 | 259 | } | ||
795 | 260 | |||
796 | 261 | uint32_t Framework::sum_skipped() | ||
797 | 262 | { | ||
798 | 263 | uint32_t count= 0; | ||
799 | 264 | for (std::vector<Collection*>::iterator iter= _collection.begin(); | ||
800 | 265 | iter != _collection.end(); | ||
801 | 266 | ++iter) | ||
802 | 267 | { | ||
803 | 268 | count+= (*iter)->skipped(); | ||
804 | 269 | } | ||
805 | 270 | |||
806 | 271 | return count; | ||
807 | 272 | } | ||
808 | 273 | |||
809 | 274 | uint32_t Framework::sum_failed() | ||
810 | 275 | { | ||
811 | 276 | uint32_t count= 0; | ||
812 | 277 | for (std::vector<Collection*>::iterator iter= _collection.begin(); | ||
813 | 278 | iter != _collection.end(); | ||
814 | 279 | ++iter) | ||
815 | 280 | { | ||
816 | 281 | count+= (*iter)->failed(); | ||
817 | 282 | } | ||
818 | 283 | |||
819 | 284 | return count; | ||
820 | 285 | } | ||
821 | 286 | |||
822 | 287 | libtest::Runner *Framework::runner() | 265 | libtest::Runner *Framework::runner() |
823 | 288 | { | 266 | { |
824 | 289 | if (_runner == NULL) | 267 | if (_runner == NULL) |
825 | 290 | 268 | ||
826 | === modified file 'libtest/framework.h' | |||
827 | --- libtest/framework.h 2013-05-03 06:03:28 +0000 | |||
828 | +++ libtest/framework.h 2013-07-02 18:24:29 +0000 | |||
829 | @@ -2,7 +2,7 @@ | |||
830 | 2 | * | 2 | * |
831 | 3 | * Data Differential YATL (i.e. libtest) library | 3 | * Data Differential YATL (i.e. libtest) library |
832 | 4 | * | 4 | * |
834 | 5 | * Copyright (C) 2012 Data Differential, http://datadifferential.com/ | 5 | * Copyright (C) 2012-2013 Data Differential, http://datadifferential.com/ |
835 | 6 | * | 6 | * |
836 | 7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without |
837 | 8 | * modification, are permitted provided that the following conditions are | 8 | * modification, are permitted provided that the following conditions are |
838 | @@ -45,6 +45,7 @@ | |||
839 | 45 | */ | 45 | */ |
840 | 46 | 46 | ||
841 | 47 | #include <vector> | 47 | #include <vector> |
842 | 48 | #include <fstream> | ||
843 | 48 | 49 | ||
844 | 49 | namespace { class Collection; } | 50 | namespace { class Collection; } |
845 | 50 | typedef std::vector<libtest::Collection*> Suites; | 51 | typedef std::vector<libtest::Collection*> Suites; |
846 | @@ -126,47 +127,48 @@ | |||
847 | 126 | return _signal; | 127 | return _signal; |
848 | 127 | } | 128 | } |
849 | 128 | 129 | ||
850 | 129 | uint32_t sum_total(); | ||
851 | 130 | uint32_t sum_success(); | ||
852 | 131 | uint32_t sum_skipped(); | ||
853 | 132 | uint32_t sum_failed(); | ||
854 | 133 | |||
855 | 134 | size_t size() | 130 | size_t size() |
856 | 135 | { | 131 | { |
857 | 136 | return _collection.size(); | 132 | return _collection.size(); |
858 | 137 | } | 133 | } |
859 | 138 | 134 | ||
861 | 139 | uint32_t total() const | 135 | Suites& suites() |
862 | 136 | { | ||
863 | 137 | return _collection; | ||
864 | 138 | } | ||
865 | 139 | |||
866 | 140 | libtest::Formatters& formatter() | ||
867 | 141 | { | ||
868 | 142 | return _formatter; | ||
869 | 143 | } | ||
870 | 144 | |||
871 | 145 | size_t total() const | ||
872 | 140 | { | 146 | { |
873 | 141 | return _total; | 147 | return _total; |
874 | 142 | } | 148 | } |
875 | 143 | 149 | ||
877 | 144 | uint32_t success() const | 150 | size_t success() const |
878 | 145 | { | 151 | { |
879 | 146 | return _success; | 152 | return _success; |
880 | 147 | } | 153 | } |
881 | 148 | 154 | ||
883 | 149 | uint32_t skipped() const | 155 | size_t skipped() const |
884 | 150 | { | 156 | { |
885 | 151 | return _skipped; | 157 | return _skipped; |
886 | 152 | } | 158 | } |
887 | 153 | 159 | ||
889 | 154 | uint32_t failed() const | 160 | size_t failed() const |
890 | 155 | { | 161 | { |
891 | 156 | return _failed; | 162 | return _failed; |
892 | 157 | } | 163 | } |
893 | 158 | 164 | ||
894 | 159 | Suites& suites() | ||
895 | 160 | { | ||
896 | 161 | return _collection; | ||
897 | 162 | } | ||
898 | 163 | |||
899 | 164 | private: | 165 | private: |
905 | 165 | uint32_t _total; | 166 | // Sums |
906 | 166 | uint32_t _success; | 167 | size_t _total; |
907 | 167 | uint32_t _skipped; | 168 | size_t _success; |
908 | 168 | uint32_t _failed; | 169 | size_t _skipped; |
909 | 169 | 170 | size_t _failed; | |
910 | 171 | |||
911 | 170 | /* These methods are called outside of any collection call. */ | 172 | /* These methods are called outside of any collection call. */ |
912 | 171 | test_callback_create_fn *_create; | 173 | test_callback_create_fn *_create; |
913 | 172 | test_callback_destroy_fn *_destroy; | 174 | test_callback_destroy_fn *_destroy; |
914 | @@ -195,6 +197,10 @@ | |||
915 | 195 | private: | 197 | private: |
916 | 196 | Framework( const Framework& ); | 198 | Framework( const Framework& ); |
917 | 197 | const Framework& operator=( const Framework& ); | 199 | const Framework& operator=( const Framework& ); |
918 | 200 | libtest::Formatters _formatter; | ||
919 | 201 | std::ofstream xml_file; | ||
920 | 202 | std::ofstream tap_file; | ||
921 | 203 | |||
922 | 198 | }; | 204 | }; |
923 | 199 | 205 | ||
924 | 200 | } // namespace libtest | 206 | } // namespace libtest |
925 | 201 | 207 | ||
926 | === modified file 'libtest/main.cc' | |||
927 | --- libtest/main.cc 2013-06-28 19:13:48 +0000 | |||
928 | +++ libtest/main.cc 2013-07-02 18:24:29 +0000 | |||
929 | @@ -60,25 +60,6 @@ | |||
930 | 60 | 60 | ||
931 | 61 | using namespace libtest; | 61 | using namespace libtest; |
932 | 62 | 62 | ||
933 | 63 | static void stats_print(libtest::Framework *frame) | ||
934 | 64 | { | ||
935 | 65 | if (frame->failed() == 0 and frame->success() == 0) | ||
936 | 66 | { | ||
937 | 67 | return; | ||
938 | 68 | } | ||
939 | 69 | |||
940 | 70 | Outn(); | ||
941 | 71 | Out << "Collections\t\t\t\t\t" << frame->total(); | ||
942 | 72 | Out << "\tFailed\t\t\t\t\t" << frame->failed(); | ||
943 | 73 | Out << "\tSkipped\t\t\t\t\t" << frame->skipped(); | ||
944 | 74 | Out << "\tSucceeded\t\t\t\t" << frame->success(); | ||
945 | 75 | Outn(); | ||
946 | 76 | Out << "Tests\t\t\t\t\t" << frame->sum_total(); | ||
947 | 77 | Out << "\tFailed\t\t\t\t" << frame->sum_failed(); | ||
948 | 78 | Out << "\tSkipped\t\t\t\t" << frame->sum_skipped(); | ||
949 | 79 | Out << "\tSucceeded\t\t\t" << frame->sum_success(); | ||
950 | 80 | } | ||
951 | 81 | |||
952 | 82 | #include <getopt.h> | 63 | #include <getopt.h> |
953 | 83 | #include <unistd.h> | 64 | #include <unistd.h> |
954 | 84 | 65 | ||
955 | @@ -380,19 +361,37 @@ | |||
956 | 380 | Out << "All tests completed successfully."; | 361 | Out << "All tests completed successfully."; |
957 | 381 | } | 362 | } |
958 | 382 | 363 | ||
960 | 383 | stats_print(frame.get()); | 364 | #if 0 |
961 | 365 | { | ||
962 | 366 | std::ofstream xml_file; | ||
963 | 367 | std::string file_name; | ||
964 | 368 | if (getenv("WORKSPACE")) | ||
965 | 369 | { | ||
966 | 370 | file_name.append(getenv("WORKSPACE")); | ||
967 | 371 | file_name.append("/"); | ||
968 | 372 | } | ||
969 | 373 | file_name.append(frame->name()); | ||
970 | 374 | file_name.append(".xml"); | ||
971 | 375 | xml_file.open(file_name.c_str(), std::ios::trunc); | ||
972 | 376 | libtest::Formatter::xml(*frame, xml_file); | ||
973 | 377 | } | ||
974 | 378 | #endif | ||
975 | 384 | 379 | ||
979 | 385 | std::ofstream xml_file; | 380 | #if 0 |
977 | 386 | std::string file_name; | ||
978 | 387 | if (getenv("WORKSPACE")) | ||
980 | 388 | { | 381 | { |
983 | 389 | file_name.append(getenv("WORKSPACE")); | 382 | std::ofstream tap_file; |
984 | 390 | file_name.append("/"); | 383 | std::string file_name; |
985 | 384 | if (getenv("WORKSPACE")) | ||
986 | 385 | { | ||
987 | 386 | file_name.append(getenv("WORKSPACE")); | ||
988 | 387 | file_name.append("/"); | ||
989 | 388 | } | ||
990 | 389 | file_name.append(frame->name()); | ||
991 | 390 | file_name.append(".tap"); | ||
992 | 391 | tap_file.open(file_name.c_str(), std::ios::trunc); | ||
993 | 392 | libtest::Formatter::tap(*frame, tap_file); | ||
994 | 391 | } | 393 | } |
999 | 392 | file_name.append(frame->name()); | 394 | #endif |
996 | 393 | file_name.append(".xml"); | ||
997 | 394 | xml_file.open(file_name.c_str(), std::ios::trunc); | ||
998 | 395 | libtest::Formatter::xml(*frame, xml_file); | ||
1000 | 396 | 395 | ||
1001 | 397 | Outn(); // Generate a blank to break up the messages if make check/test has been run | 396 | Outn(); // Generate a blank to break up the messages if make check/test has been run |
1002 | 398 | } while (exit_code == EXIT_SUCCESS and --opt_repeat); | 397 | } while (exit_code == EXIT_SUCCESS and --opt_repeat); |
1003 | 399 | 398 | ||
1004 | === modified file 'libtest/test.h' | |||
1005 | --- libtest/test.h 2012-12-31 11:03:44 +0000 | |||
1006 | +++ libtest/test.h 2013-07-02 18:24:29 +0000 | |||
1007 | @@ -51,6 +51,86 @@ | |||
1008 | 51 | test_callback_fn *test_fn; | 51 | test_callback_fn *test_fn; |
1009 | 52 | }; | 52 | }; |
1010 | 53 | 53 | ||
1011 | 54 | namespace libtest { | ||
1012 | 55 | |||
1013 | 56 | class TestCase; | ||
1014 | 57 | typedef std::vector<libtest::TestCase*> TestCases; | ||
1015 | 58 | |||
1016 | 59 | class TestCase { | ||
1017 | 60 | public: | ||
1018 | 61 | TestCase(const struct test_st* test_): | ||
1019 | 62 | _result(TEST_FAILURE) | ||
1020 | 63 | { | ||
1021 | 64 | _test.name= test_->name; | ||
1022 | 65 | _test.requires_flush= test_->requires_flush; | ||
1023 | 66 | _test.test_fn= test_->test_fn; | ||
1024 | 67 | } | ||
1025 | 68 | |||
1026 | 69 | const char* name() const | ||
1027 | 70 | { | ||
1028 | 71 | return _test.name; | ||
1029 | 72 | } | ||
1030 | 73 | |||
1031 | 74 | test_return_t result() const | ||
1032 | 75 | { | ||
1033 | 76 | return _result; | ||
1034 | 77 | } | ||
1035 | 78 | |||
1036 | 79 | void result(test_return_t result_) | ||
1037 | 80 | { | ||
1038 | 81 | _result= result_; | ||
1039 | 82 | } | ||
1040 | 83 | |||
1041 | 84 | void result(test_return_t result_, const libtest::Timer& timer_) | ||
1042 | 85 | { | ||
1043 | 86 | _result= result_; | ||
1044 | 87 | _timer= timer_; | ||
1045 | 88 | } | ||
1046 | 89 | |||
1047 | 90 | const libtest::Timer& timer() const | ||
1048 | 91 | { | ||
1049 | 92 | return _timer; | ||
1050 | 93 | } | ||
1051 | 94 | |||
1052 | 95 | void timer(libtest::Timer& timer_) | ||
1053 | 96 | { | ||
1054 | 97 | _timer= timer_; | ||
1055 | 98 | } | ||
1056 | 99 | |||
1057 | 100 | void skipped() | ||
1058 | 101 | { | ||
1059 | 102 | _result= TEST_SKIPPED; | ||
1060 | 103 | } | ||
1061 | 104 | |||
1062 | 105 | void failed() | ||
1063 | 106 | { | ||
1064 | 107 | _result= TEST_FAILURE; | ||
1065 | 108 | } | ||
1066 | 109 | |||
1067 | 110 | void success(const libtest::Timer& timer_) | ||
1068 | 111 | { | ||
1069 | 112 | _result= TEST_SUCCESS; | ||
1070 | 113 | _timer= timer_; | ||
1071 | 114 | } | ||
1072 | 115 | |||
1073 | 116 | |||
1074 | 117 | const struct test_st* test() const | ||
1075 | 118 | { | ||
1076 | 119 | return &_test; | ||
1077 | 120 | } | ||
1078 | 121 | |||
1079 | 122 | bool requires_flush() const | ||
1080 | 123 | { | ||
1081 | 124 | return _test.requires_flush; | ||
1082 | 125 | } | ||
1083 | 126 | |||
1084 | 127 | private: | ||
1085 | 128 | struct test_st _test; | ||
1086 | 129 | test_return_t _result; | ||
1087 | 130 | libtest::Timer _timer; | ||
1088 | 131 | }; | ||
1089 | 132 | } // namespace libtest | ||
1090 | 133 | |||
1091 | 54 | #define test_assert_errno(A) \ | 134 | #define test_assert_errno(A) \ |
1092 | 55 | do \ | 135 | do \ |
1093 | 56 | { \ | 136 | { \ |