Piped the actual file/line through to testingRunWithTimeout().
This commit is contained in:
parent
64478bd5b0
commit
e03021a350
|
@ -1,18 +1,11 @@
|
|||
// 10 april 2019
|
||||
#include "test.h"
|
||||
|
||||
static void timeoutMain(testingT *t, void *data)
|
||||
void timeoutMain(testingT *t, void *data)
|
||||
{
|
||||
uiMain();
|
||||
}
|
||||
|
||||
void timeout_uiMain(testingT *t, int64_t timeout, int failNowOnError)
|
||||
{
|
||||
testingRunWithTimeout(t, timeout,
|
||||
timeoutMain, NULL,
|
||||
"uiMain()", failNowOnError);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
return testingMain();
|
||||
|
|
|
@ -3,4 +3,8 @@
|
|||
#include "testing.h"
|
||||
|
||||
// main.c
|
||||
extern void timeout_uiMain(testingT *t, int64_t timeout, int failNowOnError);
|
||||
extern void timeoutMain(testingT *t, void *data);
|
||||
#define timeout_uiMain(t, timeout, failNowOnError) \
|
||||
testingRunWithTimeout(t, timeout, \
|
||||
timeoutMain, NULL, \
|
||||
"uiMain()", failNowOnError);
|
||||
|
|
|
@ -78,7 +78,8 @@ extern int64_t testingTimerNsec(testingTimer *t);
|
|||
extern char *testingNsecString(int64_t nsec);
|
||||
extern void testingFreeNsecString(char *s);
|
||||
|
||||
extern void testingRunWithTimeout(testingT *t, int64_t timeout, void (*f)(testingT *t, void *data), void *data, const char *comment, int failNowOnError);
|
||||
#define testingRunWithTimeout(t, timeout, f, data, comment, failNowOnError) \
|
||||
testingprivRunWithTimeout(t, __FILE__, __LINE__, timeout, f, data, comment, failNowOnError)
|
||||
|
||||
extern void testingprivRegisterTest(const char *, void (*)(testingT *), const char *, long);
|
||||
extern void testingprivRegisterTestBefore(const char *, void (*)(testingT *), const char *, long);
|
||||
|
@ -89,3 +90,4 @@ extern void testingprivRegisterTestAfter(const char *, void (*)(testingT *), con
|
|||
#define testingprivTLogvfThen(then, t, format, ap) ((testingprivTLogvfFull(t, __FILE__, __LINE__, format, ap)), (then(t)))
|
||||
extern void testingprivTLogfFull(testingT *, const char *, long, const char *, ...);
|
||||
extern void testingprivTLogvfFull(testingT *, const char *, long, const char *, va_list);
|
||||
extern void testingprivRunWithTimeout(testingT *, const char *, long, int64_t, void (*)(testingT *, void *), void *, const char *, int);
|
||||
|
|
|
@ -14,7 +14,7 @@ static void onTimeout(int sig)
|
|||
longjmp(timeout_ret, 1);
|
||||
}
|
||||
|
||||
void testingRunWithTimeout(testingT *t, int64_t timeout, void (*f)(testingT *t, void *data), void *data, const char *comment, int failNowOnError)
|
||||
void testingprivRunWithTimeout(testingT *t, const char *file, long line, int64_t timeout, void (*f)(testingT *t, void *data), void *data, const char *comment, int failNowOnError)
|
||||
{
|
||||
char *timeoutstr;
|
||||
sig_t prevsig;
|
||||
|
@ -30,15 +30,18 @@ void testingRunWithTimeout(testingT *t, int64_t timeout, void (*f)(testingT *t,
|
|||
timer.it_value.tv_usec = (timeout % testingNsecPerSec) / testingNsecPerUsec;
|
||||
if (setitimer(ITIMER_REAL, &timer, &prevtimer) != 0) {
|
||||
setitimerError = errno;
|
||||
testingTErrorf(t, "error applying %s timeout: %s", comment, strerror(setitimerError));
|
||||
testingprivTLogfFull(t, file, line, "error applying %s timeout: %s", comment, strerror(setitimerError));
|
||||
testingTFail(t);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (setjmp(timeout_ret) == 0) {
|
||||
(*f)(t, data);
|
||||
failNowOnError = 0; // we succeeded
|
||||
} else
|
||||
testingTErrorf(t, "%s timeout passed (%s)", comment, timeoutstr);
|
||||
} else {
|
||||
testingprivTLogfFull(t, file, line, "%s timeout passed (%s)", comment, timeoutstr);
|
||||
testingTFail(t);
|
||||
}
|
||||
|
||||
out:
|
||||
if (setitimerError == 0)
|
||||
|
|
Loading…
Reference in New Issue