- Timestamp:
- Mar 29, 2021 12:59:22 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/mangling.h
r87647 r88311 2397 2397 # define RTTestDestroy RT_MANGLER(RTTestDestroy) 2398 2398 # define RTTestDisableAssertions RT_MANGLER(RTTestDisableAssertions) 2399 # define RTTestErrContext RT_MANGLER(RTTestErrContext) 2400 # define RTTestErrContextV RT_MANGLER(RTTestErrContextV) 2399 2401 # define RTTestErrorCount RT_MANGLER(RTTestErrorCount) 2400 2402 # define RTTestErrorInc RT_MANGLER(RTTestErrorInc) … … 2408 2410 # define RTTestGuardedFree RT_MANGLER(RTTestGuardedFree) 2409 2411 # define RTTestIDisableAssertions RT_MANGLER(RTTestIDisableAssertions) 2412 # define RTTestIErrContext RT_MANGLER(RTTestIErrContext) 2413 # define RTTestIErrContextV RT_MANGLER(RTTestIErrContextV) 2410 2414 # define RTTestIErrorCount RT_MANGLER(RTTestIErrorCount) 2411 2415 # define RTTestIErrorInc RT_MANGLER(RTTestIErrorInc) -
trunk/include/iprt/test.h
r86534 r88311 639 639 640 640 /** 641 * Sets error context info to be printed with the first failure. 642 * 643 * @returns IPRT status code. 644 * @param hTest The test handle. If NIL_RTTEST we'll use the one 645 * associated with the calling thread. 646 * @param pszFormat The message, no trailing newline. NULL to clear the 647 * context message. 648 * @param va The arguments. 649 */ 650 RTR3DECL(int) RTTestErrContextV(RTTEST hTest, const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(2, 0); 651 652 /** 653 * Sets error context info to be printed with the first failure. 654 * 655 * @returns IPRT status code. 656 * @param hTest The test handle. If NIL_RTTEST we'll use the one 657 * associated with the calling thread. 658 * @param pszFormat The message, no trailing newline. NULL to clear the 659 * context message. 660 * @param ... The arguments. 661 */ 662 RTR3DECL(int) RTTestErrContext(RTTEST hTest, const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(2, 3); 663 664 /** 641 665 * Disables and shuts up assertions. 642 666 * … … 1115 1139 */ 1116 1140 RTR3DECL(int) RTTestIFailureDetails(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2); 1141 1142 /** 1143 * Sets error context info to be printed with the first failure. 1144 * 1145 * @returns IPRT status code. 1146 * @param pszFormat The message, no trailing newline. NULL to clear the 1147 * context message. 1148 * @param va The arguments. 1149 */ 1150 RTR3DECL(int) RTTestIErrContextV(const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(1, 0); 1151 1152 /** 1153 * Sets error context info to be printed with the first failure. 1154 * 1155 * @returns IPRT status code. 1156 * @param pszFormat The message, no trailing newline. NULL to clear the 1157 * context message. 1158 * @param ... The arguments. 1159 */ 1160 RTR3DECL(int) RTTestIErrContext(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2); 1117 1161 1118 1162 /** -
trunk/src/VBox/Runtime/r3/test.cpp
r82968 r88311 125 125 /** The number of sub tests that failed. */ 126 126 uint32_t cSubTestsFailed; 127 128 /** Error context message. */ 129 char *pszErrCtx; 127 130 128 131 /** Set if XML output is enabled. */ … … 520 523 RTStrFree((char *)pTest->pszTest); 521 524 pTest->pszTest = NULL; 525 RTStrFree(pTest->pszErrCtx); 526 pTest->pszErrCtx = NULL; 522 527 RTMemFree(pTest); 523 528 return VINF_SUCCESS; … … 1259 1264 pTest->fSubTestReported = true; 1260 1265 } 1266 RTStrFree(pTest->pszErrCtx); 1267 pTest->pszErrCtx = NULL; 1261 1268 return cch; 1262 1269 } … … 1711 1718 RTCritSectEnter(&pTest->OutputLock); 1712 1719 cch += rtTestPrintf(pTest, fHasNewLine ? "%N" : "%N\n", pszFormat, &va2); 1720 if (pTest->pszErrCtx) 1721 { 1722 cch += rtTestPrintf(pTest, "context: %s\n", pTest->pszErrCtx); 1723 RTStrFree(pTest->pszErrCtx); 1724 pTest->pszErrCtx = NULL; 1725 } 1713 1726 RTCritSectLeave(&pTest->OutputLock); 1714 1727 … … 1775 1788 1776 1789 1790 RTR3DECL(int) RTTestErrContextV(RTTEST hTest, const char *pszFormat, va_list va) 1791 { 1792 PRTTESTINT pTest = hTest; 1793 RTTEST_GET_VALID_RETURN(pTest); 1794 1795 RTStrFree(pTest->pszErrCtx); 1796 pTest->pszErrCtx = NULL; 1797 1798 if (pszFormat && *pszFormat) 1799 { 1800 pTest->pszErrCtx = RTStrAPrintf2V(pszFormat, va); 1801 AssertReturn(pTest->pszErrCtx, VERR_NO_STR_MEMORY); 1802 RTStrStripR(pTest->pszErrCtx); 1803 } 1804 1805 return VINF_SUCCESS; 1806 } 1807 1808 1809 RTR3DECL(int) RTTestErrContext(RTTEST hTest, const char *pszFormat, ...) 1810 { 1811 va_list va; 1812 va_start(va, pszFormat); 1813 int rc = RTTestErrContextV(hTest, pszFormat, va); 1814 va_end(va); 1815 return rc; 1816 } 1817 1818 1777 1819 RTR3DECL(int) RTTestDisableAssertions(RTTEST hTest) 1778 1820 { -
trunk/src/VBox/Runtime/r3/testi.cpp
r82968 r88311 176 176 177 177 178 RTR3DECL(int) RTTestIErrContextV(const char *pszFormat, va_list va) 179 { 180 return RTTestErrContextV(NIL_RTTEST, pszFormat, va); 181 } 182 183 184 RTR3DECL(int) RTTestErrContext(const char *pszFormat, ...) 185 { 186 va_list va; 187 va_start(va, pszFormat); 188 int rc = RTTestIErrContextV(pszFormat, va); 189 va_end(va); 190 return rc; 191 } 192 193 178 194 RTR3DECL(int) RTTestIDisableAssertions(void) 179 195 {
Note:
See TracChangeset
for help on using the changeset viewer.