1 | /** @file
|
---|
2 | * IPRT - Testcase Framework.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2009 Sun Microsystems, Inc.
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License (GPL) as published by the Free Software
|
---|
12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | *
|
---|
16 | * The contents of this file may alternatively be used under the terms
|
---|
17 | * of the Common Development and Distribution License Version 1.0
|
---|
18 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
19 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
20 | * CDDL are applicable instead of those of the GPL.
|
---|
21 | *
|
---|
22 | * You may elect to license modified versions of this file under the
|
---|
23 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
24 | *
|
---|
25 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
26 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
27 | * additional information or have any questions.
|
---|
28 | */
|
---|
29 |
|
---|
30 | #ifndef ___iprt_test_h
|
---|
31 | #define ___iprt_test_h
|
---|
32 |
|
---|
33 | #include <iprt/cdefs.h>
|
---|
34 | #include <iprt/types.h>
|
---|
35 | #include <iprt/stdarg.h>
|
---|
36 |
|
---|
37 | __BEGIN_DECLS
|
---|
38 |
|
---|
39 | /** @defgroup grp_rt_test RTTest - Testcase Framework.
|
---|
40 | * @ingroup grp_rt
|
---|
41 | * @{
|
---|
42 | */
|
---|
43 |
|
---|
44 | /** A test handle. */
|
---|
45 | typedef struct RTTESTINT *RTTEST;
|
---|
46 | /** A pointer to a test handle. */
|
---|
47 | typedef RTTEST *PRTTEST;
|
---|
48 | /** A const pointer to a test handle. */
|
---|
49 | typedef RTTEST const *PCRTTEST;
|
---|
50 |
|
---|
51 | /** A NIL Test handle. */
|
---|
52 | #define NIL_RTTEST ((RTTEST)0)
|
---|
53 |
|
---|
54 | /**
|
---|
55 | * Test message importance level.
|
---|
56 | */
|
---|
57 | typedef enum RTTESTLVL
|
---|
58 | {
|
---|
59 | /** Invalid 0. */
|
---|
60 | RTTESTLVL_INVALID = 0,
|
---|
61 | /** Message should always be printed. */
|
---|
62 | RTTESTLVL_ALWAYS,
|
---|
63 | /** Failure message. */
|
---|
64 | RTTESTLVL_FAILURE,
|
---|
65 | /** Sub-test banner. */
|
---|
66 | RTTESTLVL_SUB_TEST,
|
---|
67 | /** Info message. */
|
---|
68 | RTTESTLVL_INFO,
|
---|
69 | /** Debug message. */
|
---|
70 | RTTESTLVL_DEBUG,
|
---|
71 | /** The last (invalid). */
|
---|
72 | RTTESTLVL_END
|
---|
73 | } RTTESTLVL;
|
---|
74 |
|
---|
75 |
|
---|
76 | /**
|
---|
77 | * Creates a test instance.
|
---|
78 | *
|
---|
79 | * @returns IPRT status code.
|
---|
80 | * @param pszTest The test name.
|
---|
81 | * @param phTest Where to store the test instance handle.
|
---|
82 | */
|
---|
83 | RTR3DECL(int) RTTestCreate(const char *pszTest, PRTTEST phTest);
|
---|
84 |
|
---|
85 | /**
|
---|
86 | * Destroys a test instance previously created by RTTestCreate.
|
---|
87 | *
|
---|
88 | * @returns IPRT status code.
|
---|
89 | * @param hTest The test handle. NIL_RTTEST is ignored.
|
---|
90 | */
|
---|
91 | RTR3DECL(int) RTTestDestroy(RTTEST hTest);
|
---|
92 |
|
---|
93 | /**
|
---|
94 | * Allocate a block of guarded memory.
|
---|
95 | *
|
---|
96 | * @returns IPRT status code.
|
---|
97 | * @param hTest The test handle. If NIL_RTTEST we'll use the one
|
---|
98 | * associated with the calling thread.
|
---|
99 | * @param cb The amount of memory to allocate.
|
---|
100 | * @param cbAlign The alignment of the returned block.
|
---|
101 | * @param fHead Head or tail optimized guard.
|
---|
102 | * @param ppvUser Where to return the pointer to the block.
|
---|
103 | */
|
---|
104 | RTR3DECL(int) RTTestGuardedAlloc(RTTEST hTest, size_t cb, uint32_t cbAlign, bool fHead, void **ppvUser);
|
---|
105 |
|
---|
106 | /**
|
---|
107 | * Allocates a block of guarded memory where the guarded is immediately after
|
---|
108 | * the user memory.
|
---|
109 | *
|
---|
110 | * @returns Pointer to the allocated memory. NULL on failure.
|
---|
111 | * @param hTest The test handle. If NIL_RTTEST we'll use the one
|
---|
112 | * associated with the calling thread.
|
---|
113 | * @param cb The amount of memory to allocate.
|
---|
114 | */
|
---|
115 | RTR3DECL(void *) RTTestGuardedAllocTail(RTTEST hTest, size_t cb);
|
---|
116 |
|
---|
117 | /**
|
---|
118 | * Allocates a block of guarded memory where the guarded is right in front of
|
---|
119 | * the user memory.
|
---|
120 | *
|
---|
121 | * @returns Pointer to the allocated memory. NULL on failure.
|
---|
122 | * @param hTest The test handle. If NIL_RTTEST we'll use the one
|
---|
123 | * associated with the calling thread.
|
---|
124 | * @param cb The amount of memory to allocate.
|
---|
125 | */
|
---|
126 | RTR3DECL(void *) RTTestGuardedAllocHead(RTTEST hTest, size_t cb);
|
---|
127 |
|
---|
128 | /**
|
---|
129 | * Frees a block of guarded memory.
|
---|
130 | *
|
---|
131 | * @returns IPRT status code.
|
---|
132 | * @param hTest The test handle. If NIL_RTTEST we'll use the one
|
---|
133 | * associated with the calling thread.
|
---|
134 | * @param pv The memory. NULL is ignored.
|
---|
135 | */
|
---|
136 | RTR3DECL(int) RTTestGuardedFree(RTTEST hTest, void *pv);
|
---|
137 |
|
---|
138 | /**
|
---|
139 | * Test vprintf making sure the output starts on a new line.
|
---|
140 | *
|
---|
141 | * @returns Number of chars printed.
|
---|
142 | * @param hTest The test handle. If NIL_RTTEST we'll use the one
|
---|
143 | * associated with the calling thread.
|
---|
144 | * @param enmLevel Message importance level.
|
---|
145 | * @param pszFormat The message.
|
---|
146 | * @param va Arguments.
|
---|
147 | */
|
---|
148 | RTR3DECL(int) RTTestPrintfNlV(RTTEST hTest, RTTESTLVL enmLevel, const char *pszFormat, va_list va);
|
---|
149 |
|
---|
150 | /**
|
---|
151 | * Test printf making sure the output starts on a new line.
|
---|
152 | *
|
---|
153 | * @returns Number of chars printed.
|
---|
154 | * @param hTest The test handle. If NIL_RTTEST we'll use the one
|
---|
155 | * associated with the calling thread.
|
---|
156 | * @param enmLevel Message importance level.
|
---|
157 | * @param pszFormat The message.
|
---|
158 | * @param ... Arguments.
|
---|
159 | */
|
---|
160 | RTR3DECL(int) RTTestPrintfNl(RTTEST hTest, RTTESTLVL enmLevel, const char *pszFormat, ...);
|
---|
161 |
|
---|
162 | /**
|
---|
163 | * Test vprintf, makes sure lines are prefixed and so forth.
|
---|
164 | *
|
---|
165 | * @returns Number of chars printed.
|
---|
166 | * @param hTest The test handle. If NIL_RTTEST we'll use the one
|
---|
167 | * associated with the calling thread.
|
---|
168 | * @param enmLevel Message importance level.
|
---|
169 | * @param pszFormat The message.
|
---|
170 | * @param va Arguments.
|
---|
171 | */
|
---|
172 | RTR3DECL(int) RTTestPrintfV(RTTEST hTest, RTTESTLVL enmLevel, const char *pszFormat, va_list va);
|
---|
173 |
|
---|
174 | /**
|
---|
175 | * Test printf, makes sure lines are prefixed and so forth.
|
---|
176 | *
|
---|
177 | * @returns Number of chars printed.
|
---|
178 | * @param hTest The test handle. If NIL_RTTEST we'll use the one
|
---|
179 | * associated with the calling thread.
|
---|
180 | * @param enmLevel Message importance level.
|
---|
181 | * @param pszFormat The message.
|
---|
182 | * @param ... Arguments.
|
---|
183 | */
|
---|
184 | RTR3DECL(int) RTTestPrintf(RTTEST hTest, RTTESTLVL enmLevel, const char *pszFormat, ...);
|
---|
185 |
|
---|
186 | /**
|
---|
187 | * Prints the test banner.
|
---|
188 | *
|
---|
189 | * @returns Number of chars printed.
|
---|
190 | * @param hTest The test handle. If NIL_RTTEST we'll use the one
|
---|
191 | * associated with the calling thread.
|
---|
192 | */
|
---|
193 | RTR3DECL(int) RTTestBanner(RTTEST hTest);
|
---|
194 |
|
---|
195 | /**
|
---|
196 | * Summaries the test, destroys the test instance and return an exit code.
|
---|
197 | *
|
---|
198 | * @returns Test program exit code.
|
---|
199 | * @param hTest The test handle. If NIL_RTTEST we'll use the one
|
---|
200 | * associated with the calling thread.
|
---|
201 | */
|
---|
202 | RTR3DECL(int) RTTestSummaryAndDestroy(RTTEST hTest);
|
---|
203 |
|
---|
204 | /**
|
---|
205 | * Starts a sub-test.
|
---|
206 | *
|
---|
207 | * This will perform an implicit RTTestSubDone() call if that has not been done
|
---|
208 | * since the last RTTestSub call.
|
---|
209 | *
|
---|
210 | * @returns Number of chars printed.
|
---|
211 | * @param hTest The test handle. If NIL_RTTEST we'll use the one
|
---|
212 | * associated with the calling thread.
|
---|
213 | * @param pszSubTest The sub-test name
|
---|
214 | */
|
---|
215 | RTR3DECL(int) RTTestSub(RTTEST hTest, const char *pszSubTest);
|
---|
216 |
|
---|
217 | /**
|
---|
218 | * Completes a sub-test.
|
---|
219 | *
|
---|
220 | * @returns Number of chars printed.
|
---|
221 | * @param hTest The test handle. If NIL_RTTEST we'll use the one
|
---|
222 | * associated with the calling thread.
|
---|
223 | */
|
---|
224 | RTR3DECL(int) RTTestSubDone(RTTEST hTest);
|
---|
225 |
|
---|
226 | /**
|
---|
227 | * Prints an extended PASSED message, optional.
|
---|
228 | *
|
---|
229 | * This does not conclude the sub-test, it could be used to report the passing
|
---|
230 | * of a sub-sub-to-the-power-of-N-test.
|
---|
231 | *
|
---|
232 | * @returns IPRT status code.
|
---|
233 | * @param hTest The test handle. If NIL_RTTEST we'll use the one
|
---|
234 | * associated with the calling thread.
|
---|
235 | * @param pszFormat The message. No trailing newline.
|
---|
236 | * @param va The arguments.
|
---|
237 | */
|
---|
238 | RTR3DECL(int) RTTestPassedV(RTTEST hTest, const char *pszFormat, va_list va);
|
---|
239 |
|
---|
240 | /**
|
---|
241 | * Prints an extended PASSED message, optional.
|
---|
242 | *
|
---|
243 | * This does not conclude the sub-test, it could be used to report the passing
|
---|
244 | * of a sub-sub-to-the-power-of-N-test.
|
---|
245 | *
|
---|
246 | * @returns IPRT status code.
|
---|
247 | * @param hTest The test handle. If NIL_RTTEST we'll use the one
|
---|
248 | * associated with the calling thread.
|
---|
249 | * @param pszFormat The message. No trailing newline.
|
---|
250 | * @param ... The arguments.
|
---|
251 | */
|
---|
252 | RTR3DECL(int) RTTestPassed(RTTEST hTest, const char *pszFormat, ...);
|
---|
253 |
|
---|
254 |
|
---|
255 | /**
|
---|
256 | * Increments the error counter.
|
---|
257 | *
|
---|
258 | * @returns IPRT status code.
|
---|
259 | * @param hTest The test handle. If NIL_RTTEST we'll use the one
|
---|
260 | * associated with the calling thread.
|
---|
261 | */
|
---|
262 | RTR3DECL(int) RTTestErrorInc(RTTEST hTest);
|
---|
263 |
|
---|
264 | /**
|
---|
265 | * Increments the error counter and prints a failure message.
|
---|
266 | *
|
---|
267 | * @returns IPRT status code.
|
---|
268 | * @param hTest The test handle. If NIL_RTTEST we'll use the one
|
---|
269 | * associated with the calling thread.
|
---|
270 | * @param pszFormat The message. No trailing newline.
|
---|
271 | * @param va The arguments.
|
---|
272 | */
|
---|
273 | RTR3DECL(int) RTTestFailedV(RTTEST hTest, const char *pszFormat, va_list va);
|
---|
274 |
|
---|
275 | /**
|
---|
276 | * Increments the error counter and prints a failure message.
|
---|
277 | *
|
---|
278 | * @returns IPRT status code.
|
---|
279 | * @param hTest The test handle. If NIL_RTTEST we'll use the one
|
---|
280 | * associated with the calling thread.
|
---|
281 | * @param pszFormat The message. No trailing newline.
|
---|
282 | * @param ... The arguments.
|
---|
283 | */
|
---|
284 | RTR3DECL(int) RTTestFailed(RTTEST hTest, const char *pszFormat, ...);
|
---|
285 |
|
---|
286 | /**
|
---|
287 | * Same as RTTestPrintfV with RTTESTLVL_FAILURE.
|
---|
288 | *
|
---|
289 | * @returns Number of chars printed.
|
---|
290 | * @param hTest The test handle. If NIL_RTTEST we'll use the one
|
---|
291 | * associated with the calling thread.
|
---|
292 | * @param enmLevel Message importance level.
|
---|
293 | * @param pszFormat The message.
|
---|
294 | * @param va Arguments.
|
---|
295 | */
|
---|
296 | RTR3DECL(int) RTTestFailureDetailsV(RTTEST hTest, const char *pszFormat, va_list va);
|
---|
297 |
|
---|
298 | /**
|
---|
299 | * Same as RTTestPrintf with RTTESTLVL_FAILURE.
|
---|
300 | *
|
---|
301 | * @returns Number of chars printed.
|
---|
302 | * @param hTest The test handle. If NIL_RTTEST we'll use the one
|
---|
303 | * associated with the calling thread.
|
---|
304 | * @param enmLevel Message importance level.
|
---|
305 | * @param pszFormat The message.
|
---|
306 | * @param ... Arguments.
|
---|
307 | */
|
---|
308 | RTR3DECL(int) RTTestFailureDetails(RTTEST hTest, const char *pszFormat, ...);
|
---|
309 |
|
---|
310 |
|
---|
311 | /** @def RTTEST_CHECK
|
---|
312 | * Check whether a boolean expression holds true.
|
---|
313 | *
|
---|
314 | * If the expression is false, call RTTestFailed giving the line number and expression.
|
---|
315 | *
|
---|
316 | * @param hTest The test handle.
|
---|
317 | * @param expr The expression to evaluate.
|
---|
318 | */
|
---|
319 | #define RTTEST_CHECK(hTest, expr) \
|
---|
320 | do { if (!(expr)) { \
|
---|
321 | RTTestFailed((hTest), "line %u: %s", __LINE__, #expr); \
|
---|
322 | } \
|
---|
323 | } while (0)
|
---|
324 |
|
---|
325 | /** @def RTTEST_CHECK_MSG
|
---|
326 | * Check whether a boolean expression holds true.
|
---|
327 | *
|
---|
328 | * If the expression is false, call RTTestFailed giving the line number and expression.
|
---|
329 | *
|
---|
330 | * @param hTest The test handle.
|
---|
331 | * @param expr The expression to evaluate.
|
---|
332 | * @param DetailsArgs Argument list for RTTestFailureDetails, including
|
---|
333 | * parenthesis.
|
---|
334 | */
|
---|
335 | #define RTTEST_CHECK_MSG(hTest, expr, DetailsArgs) \
|
---|
336 | do { if (!(expr)) { \
|
---|
337 | RTTestFailed((hTest), "line %u: %s", __LINE__, #expr); \
|
---|
338 | RTTestFailureDetails DetailsArgs; \
|
---|
339 | } \
|
---|
340 | } while (0)
|
---|
341 |
|
---|
342 | /** @def RTTEST_CHECK_RET
|
---|
343 | * Check whether a boolean expression holds true, returns on false.
|
---|
344 | *
|
---|
345 | * If the expression is false, call RTTestFailed giving the line number and expression.
|
---|
346 | *
|
---|
347 | * @param hTest The test handle.
|
---|
348 | * @param expr The expression to evaluate.
|
---|
349 | * @param rcRet What to return on failure.
|
---|
350 | */
|
---|
351 | #define RTTEST_CHECK_RET(hTest, expr, rc) \
|
---|
352 | do { if (!(expr)) { \
|
---|
353 | RTTestFailed((hTest), "line %u: %s", __LINE__, #expr); \
|
---|
354 | return (rcRet); \
|
---|
355 | } \
|
---|
356 | } while (0)
|
---|
357 |
|
---|
358 | /** @def RTTEST_CHECK_MSG_RET
|
---|
359 | * Check whether a boolean expression holds true, returns on false.
|
---|
360 | *
|
---|
361 | * If the expression is false, call RTTestFailed giving the line number and expression.
|
---|
362 | *
|
---|
363 | * @param hTest The test handle.
|
---|
364 | * @param expr The expression to evaluate.
|
---|
365 | * @param DetailsArgs Argument list for RTTestFailureDetails, including
|
---|
366 | * parenthesis.
|
---|
367 | * @param rcRet What to return on failure.
|
---|
368 | */
|
---|
369 | #define RTTEST_CHECK_MSG_RET(hTest, expr, DetailsArgs, rcRet) \
|
---|
370 | do { if (!(expr)) { \
|
---|
371 | RTTestFailed((hTest), "line %u: %s", __LINE__, #expr); \
|
---|
372 | RTTestFailureDetails DetailsArgs; \
|
---|
373 | return (rcRet); \
|
---|
374 | } \
|
---|
375 | } while (0)
|
---|
376 |
|
---|
377 | /** @def RTTEST_CHECK_RETV
|
---|
378 | * Check whether a boolean expression holds true, returns void on false.
|
---|
379 | *
|
---|
380 | * If the expression is false, call RTTestFailed giving the line number and expression.
|
---|
381 | *
|
---|
382 | * @param hTest The test handle.
|
---|
383 | * @param expr The expression to evaluate.
|
---|
384 | */
|
---|
385 | #define RTTEST_CHECK_RETV(hTest, expr) \
|
---|
386 | do { if (!(expr)) { \
|
---|
387 | RTTestFailed((hTest), "line %u: %s", __LINE__, #expr); \
|
---|
388 | return; \
|
---|
389 | } \
|
---|
390 | } while (0)
|
---|
391 |
|
---|
392 | /** @def RTTEST_CHECK_MSG_RET
|
---|
393 | * Check whether a boolean expression holds true, returns void on false.
|
---|
394 | *
|
---|
395 | * If the expression is false, call RTTestFailed giving the line number and expression.
|
---|
396 | *
|
---|
397 | * @param hTest The test handle.
|
---|
398 | * @param expr The expression to evaluate.
|
---|
399 | * @param DetailsArgs Argument list for RTTestFailureDetails, including
|
---|
400 | * parenthesis.
|
---|
401 | */
|
---|
402 | #define RTTEST_CHECK_MSG_RETV(hTest, expr, DetailsArgs) \
|
---|
403 | do { if (!(expr)) { \
|
---|
404 | RTTestFailed((hTest), "line %u: %s", __LINE__, #expr); \
|
---|
405 | RTTestFailureDetails DetailsArgs; \
|
---|
406 | return; \
|
---|
407 | } \
|
---|
408 | } while (0)
|
---|
409 |
|
---|
410 |
|
---|
411 |
|
---|
412 |
|
---|
413 | /** @name Implicit Test Handle API Variation
|
---|
414 | * The test handle is retrieved from the test TLS entry of the calling thread.
|
---|
415 | * @{
|
---|
416 | */
|
---|
417 |
|
---|
418 | /**
|
---|
419 | * Test vprintf, makes sure lines are prefixed and so forth.
|
---|
420 | *
|
---|
421 | * @returns Number of chars printed.
|
---|
422 | * @param enmLevel Message importance level.
|
---|
423 | * @param pszFormat The message.
|
---|
424 | * @param va Arguments.
|
---|
425 | */
|
---|
426 | RTR3DECL(int) RTTestIPrintfV(RTTESTLVL enmLevel, const char *pszFormat, va_list va);
|
---|
427 |
|
---|
428 | /**
|
---|
429 | * Test printf, makes sure lines are prefixed and so forth.
|
---|
430 | *
|
---|
431 | * @returns Number of chars printed.
|
---|
432 | * @param enmLevel Message importance level.
|
---|
433 | * @param pszFormat The message.
|
---|
434 | * @param ... Arguments.
|
---|
435 | */
|
---|
436 | RTR3DECL(int) RTTestIPrintf(RTTESTLVL enmLevel, const char *pszFormat, ...);
|
---|
437 |
|
---|
438 | /**
|
---|
439 | * Prints an extended PASSED message, optional.
|
---|
440 | *
|
---|
441 | * This does not conclude the sub-test, it could be used to report the passing
|
---|
442 | * of a sub-sub-to-the-power-of-N-test.
|
---|
443 | *
|
---|
444 | * @returns IPRT status code.
|
---|
445 | * @param pszFormat The message. No trailing newline.
|
---|
446 | * @param va The arguments.
|
---|
447 | */
|
---|
448 | RTR3DECL(int) RTTestIPassedV(const char *pszFormat, va_list va);
|
---|
449 |
|
---|
450 | /**
|
---|
451 | * Prints an extended PASSED message, optional.
|
---|
452 | *
|
---|
453 | * This does not conclude the sub-test, it could be used to report the passing
|
---|
454 | * of a sub-sub-to-the-power-of-N-test.
|
---|
455 | *
|
---|
456 | * @returns IPRT status code.
|
---|
457 | * @param pszFormat The message. No trailing newline.
|
---|
458 | * @param ... The arguments.
|
---|
459 | */
|
---|
460 | RTR3DECL(int) RTTestIPassed(const char *pszFormat, ...);
|
---|
461 |
|
---|
462 | /**
|
---|
463 | * Increments the error counter.
|
---|
464 | *
|
---|
465 | * @returns IPRT status code.
|
---|
466 | */
|
---|
467 | RTR3DECL(int) RTTestIErrorInc(void);
|
---|
468 |
|
---|
469 | /**
|
---|
470 | * Increments the error counter and prints a failure message.
|
---|
471 | *
|
---|
472 | * @returns IPRT status code.
|
---|
473 | * @param pszFormat The message. No trailing newline.
|
---|
474 | * @param va The arguments.
|
---|
475 | */
|
---|
476 | RTR3DECL(int) RTTestIFailedV(const char *pszFormat, va_list va);
|
---|
477 |
|
---|
478 | /**
|
---|
479 | * Increments the error counter and prints a failure message.
|
---|
480 | *
|
---|
481 | * @returns IPRT status code.
|
---|
482 | * @param pszFormat The message. No trailing newline.
|
---|
483 | * @param ... The arguments.
|
---|
484 | */
|
---|
485 | RTR3DECL(int) RTTestIFailed(const char *pszFormat, ...);
|
---|
486 |
|
---|
487 | /**
|
---|
488 | * Same as RTTestIPrintfV with RTTESTLVL_FAILURE.
|
---|
489 | *
|
---|
490 | * @returns Number of chars printed.
|
---|
491 | * @param pszFormat The message.
|
---|
492 | * @param va Arguments.
|
---|
493 | */
|
---|
494 | RTR3DECL(int) RTTestIFailureDetailsV(const char *pszFormat, va_list va);
|
---|
495 |
|
---|
496 | /**
|
---|
497 | * Same as RTTestIPrintf with RTTESTLVL_FAILURE.
|
---|
498 | *
|
---|
499 | * @returns Number of chars printed.
|
---|
500 | * @param pszFormat The message.
|
---|
501 | * @param ... Arguments.
|
---|
502 | */
|
---|
503 | RTR3DECL(int) RTTestIFailureDetails(const char *pszFormat, ...);
|
---|
504 |
|
---|
505 |
|
---|
506 | /** @def RTTESTI_CHECK
|
---|
507 | * Check whether a boolean expression holds true.
|
---|
508 | *
|
---|
509 | * If the expression is false, call RTTestIFailed giving the line number and
|
---|
510 | * expression.
|
---|
511 | *
|
---|
512 | * @param expr The expression to evaluate.
|
---|
513 | */
|
---|
514 | #define RTTESTI_CHECK(expr) \
|
---|
515 | do { if (!(expr)) { \
|
---|
516 | RTTestIFailed("line %u: %s", __LINE__, #expr); \
|
---|
517 | } \
|
---|
518 | } while (0)
|
---|
519 |
|
---|
520 | /** @def RTTESTI_CHECK_MSG
|
---|
521 | * Check whether a boolean expression holds true.
|
---|
522 | *
|
---|
523 | * If the expression is false, call RTTestIFailed giving the line number and
|
---|
524 | * expression.
|
---|
525 | *
|
---|
526 | * @param expr The expression to evaluate.
|
---|
527 | * @param DetailsArgs Argument list for RTTestIFailureDetails, including
|
---|
528 | * parenthesis.
|
---|
529 | */
|
---|
530 | #define RTTESTI_CHECK_MSG(expr, DetailsArgs) \
|
---|
531 | do { if (!(expr)) { \
|
---|
532 | RTTestIFailed("line %u: %s", __LINE__, #expr); \
|
---|
533 | RTTestIFailureDetails DetailsArgs; \
|
---|
534 | } \
|
---|
535 | } while (0)
|
---|
536 |
|
---|
537 | /** @def RTTESTI_CHECK_RET
|
---|
538 | * Check whether a boolean expression holds true, returns on false.
|
---|
539 | *
|
---|
540 | * If the expression is false, call RTTestIFailed giving the line number and
|
---|
541 | * expression.
|
---|
542 | *
|
---|
543 | * @param expr The expression to evaluate.
|
---|
544 | * @param rcRet What to return on failure.
|
---|
545 | */
|
---|
546 | #define RTTESTI_CHECK_RET(expr, rc) \
|
---|
547 | do { if (!(expr)) { \
|
---|
548 | RTTestIFailed("line %u: %s", __LINE__, #expr); \
|
---|
549 | return (rcRet); \
|
---|
550 | } \
|
---|
551 | } while (0)
|
---|
552 |
|
---|
553 | /** @def RTTESTI_CHECK_MSG_RET
|
---|
554 | * Check whether a boolean expression holds true, returns on false.
|
---|
555 | *
|
---|
556 | * If the expression is false, call RTTestIFailed giving the line number and
|
---|
557 | * expression.
|
---|
558 | *
|
---|
559 | * @param expr The expression to evaluate.
|
---|
560 | * @param DetailsArgs Argument list for RTTestIFailureDetails, including
|
---|
561 | * parenthesis.
|
---|
562 | * @param rcRet What to return on failure.
|
---|
563 | */
|
---|
564 | #define RTTESTI_CHECK_MSG_RET(expr, DetailsArgs, rcRet) \
|
---|
565 | do { if (!(expr)) { \
|
---|
566 | RTTestIFailed("line %u: %s", __LINE__, #expr); \
|
---|
567 | RTTestIFailureDetails DetailsArgs; \
|
---|
568 | return (rcRet); \
|
---|
569 | } \
|
---|
570 | } while (0)
|
---|
571 |
|
---|
572 | /** @def RTTESTI_CHECK_RETV
|
---|
573 | * Check whether a boolean expression holds true, returns void on false.
|
---|
574 | *
|
---|
575 | * If the expression is false, call RTTestIFailed giving the line number and
|
---|
576 | * expression.
|
---|
577 | *
|
---|
578 | * @param expr The expression to evaluate.
|
---|
579 | */
|
---|
580 | #define RTTESTI_CHECK_RETV(expr) \
|
---|
581 | do { if (!(expr)) { \
|
---|
582 | RTTestIFailed("line %u: %s", __LINE__, #expr); \
|
---|
583 | return; \
|
---|
584 | } \
|
---|
585 | } while (0)
|
---|
586 |
|
---|
587 | /** @def RTTESTI_CHECK_MSG_RET
|
---|
588 | * Check whether a boolean expression holds true, returns void on false.
|
---|
589 | *
|
---|
590 | * If the expression is false, call RTTestIFailed giving the line number and
|
---|
591 | * expression.
|
---|
592 | *
|
---|
593 | * @param expr The expression to evaluate.
|
---|
594 | * @param DetailsArgs Argument list for RTTestIFailureDetails, including
|
---|
595 | * parenthesis.
|
---|
596 | */
|
---|
597 | #define RTTESTI_CHECK_MSG_RETV(expr, DetailsArgs) \
|
---|
598 | do { if (!(expr)) { \
|
---|
599 | RTTestIFailed("line %u: %s", __LINE__, #expr); \
|
---|
600 | RTTestIFailureDetails DetailsArgs; \
|
---|
601 | return; \
|
---|
602 | } \
|
---|
603 | } while (0)
|
---|
604 |
|
---|
605 |
|
---|
606 | /** @} */
|
---|
607 |
|
---|
608 |
|
---|
609 | /** @} */
|
---|
610 |
|
---|
611 | __END_DECLS
|
---|
612 |
|
---|
613 | #endif
|
---|
614 |
|
---|