VirtualBox

Changeset 18569 in vbox for trunk/include/iprt


Ignore:
Timestamp:
Mar 31, 2009 1:07:20 PM (16 years ago)
Author:
vboxsync
Message:

RTTest: sub tests, more typical reporting of those.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/test.h

    r18366 r18569  
    5252#define NIL_RTTEST  ((RTTEST)0)
    5353
     54/**
     55 * Test message importance level.
     56 */
     57typedef 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
    5475
    5576/**
     
    121142 * @param   hTest       The test handle. If NIL_RTTEST we'll use the one
    122143 *                      associated with the calling thread.
     144 * @param   enmLevel    Message importance level.
    123145 * @param   pszFormat   The message.
    124146 * @param   va          Arguments.
    125147 */
    126 RTR3DECL(int) RTTestPrintfNlV(RTTEST hTest, const char *pszFormat, va_list va);
     148RTR3DECL(int) RTTestPrintfNlV(RTTEST hTest, RTTESTLVL enmLevel, const char *pszFormat, va_list va);
    127149
    128150/**
     
    132154 * @param   hTest       The test handle. If NIL_RTTEST we'll use the one
    133155 *                      associated with the calling thread.
     156 * @param   enmLevel    Message importance level.
    134157 * @param   pszFormat   The message.
    135158 * @param   ...         Arguments.
    136159 */
    137 RTR3DECL(int) RTTestPrintfNl(RTTEST hTest, const char *pszFormat, ...);
     160RTR3DECL(int) RTTestPrintfNl(RTTEST hTest, RTTESTLVL enmLevel, const char *pszFormat, ...);
    138161
    139162/**
     
    143166 * @param   hTest       The test handle. If NIL_RTTEST we'll use the one
    144167 *                      associated with the calling thread.
     168 * @param   enmLevel    Message importance level.
    145169 * @param   pszFormat   The message.
    146170 * @param   va          Arguments.
    147171 */
    148 RTR3DECL(int) RTTestPrintfV(RTTEST hTest, const char *pszFormat, va_list va);
     172RTR3DECL(int) RTTestPrintfV(RTTEST hTest, RTTESTLVL enmLevel, const char *pszFormat, va_list va);
    149173
    150174/**
     
    154178 * @param   hTest       The test handle. If NIL_RTTEST we'll use the one
    155179 *                      associated with the calling thread.
     180 * @param   enmLevel    Message importance level.
    156181 * @param   pszFormat   The message.
    157182 * @param   ...         Arguments.
    158183 */
    159 RTR3DECL(int) RTTestPrintf(RTTEST hTest, const char *pszFormat, ...);
     184RTR3DECL(int) RTTestPrintf(RTTEST hTest, RTTESTLVL enmLevel, const char *pszFormat, ...);
    160185
    161186/**
     
    176201 */
    177202RTR3DECL(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 */
     215RTR3DECL(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 */
     224RTR3DECL(int) RTTestSubDone(RTTEST hTest);
    178225
    179226/**
     
    220267    do { if (!(expr)) { RTTestFailed((hTest), "line %u: %s", __LINE__, #expr); } } while (0)
    221268
     269/** @def RTTEST_CHECK_MSG
     270 * Check whether a boolean expression holds true.
     271 *
     272 * If the expression is false, call RTTestFailed giving the line number and expression.
     273 *
     274 * @param   hTest           The test handle.
     275 * @param   expr            The expression to evaluate.
     276 * @param   TestPrintfArgs  Argument list for RTTestPrintf, including
     277 *                          parenthesis.
     278 */
     279#define RTTEST_CHECK_MSG(hTest, expr, TestPrintfArgs) \
     280    do { if (!(expr)) { \
     281            RTTestFailed((hTest), "line %u: %s", __LINE__, #expr); \
     282            RTTestPrintf TestPrintfArgs; \
     283         } \
     284    } while (0)
     285
     286
     287/**
     288 * Prints an extended PASSED message, optional.
     289 *
     290 * This does not conclude the sub-test, it could be used to report the passing
     291 * of a sub-sub-to-the-power-of-N-test.
     292 *
     293 * @returns IPRT status code.
     294 * @param   hTest       The test handle. If NIL_RTTEST we'll use the one
     295 *                      associated with the calling thread.
     296 * @param   pszFormat   The message. No trailing newline.
     297 * @param   va          The arguments.
     298 */
     299RTR3DECL(int) RTTestPassedV(RTTEST hTest, const char *pszFormat, va_list va);
     300
     301/**
     302 * Prints an extended PASSED message, optional.
     303 *
     304 * This does not conclude the sub-test, it could be used to report the passing
     305 * of a sub-sub-to-the-power-of-N-test.
     306 *
     307 * @returns IPRT status code.
     308 * @param   hTest       The test handle. If NIL_RTTEST we'll use the one
     309 *                      associated with the calling thread.
     310 * @param   pszFormat   The message. No trailing newline.
     311 * @param   ...         The arguments.
     312 */
     313RTR3DECL(int) RTTestPassed(RTTEST hTest, const char *pszFormat, ...);
     314
    222315
    223316/** @}  */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette