2019-04-28 12:12:40 -05:00
|
|
|
// 28 april 2019
|
|
|
|
#include "../ui.h"
|
2019-05-26 14:41:22 -05:00
|
|
|
#include "../common/testhooks.h"
|
2019-05-04 15:53:54 -05:00
|
|
|
#include "lib/testing.h"
|
|
|
|
#include "lib/timer.h"
|
2019-04-28 12:12:40 -05:00
|
|
|
|
2019-05-04 20:13:47 -05:00
|
|
|
#define diff(t, clause, fmt, got, want) testingTErrorf(t, "%s:\ngot " fmt "\nwant " fmt, clause, got, want)
|
2019-05-18 20:21:35 -05:00
|
|
|
#define diff_2str(t, clause, clause2, fmt, got, want) testingTErrorf(t, "%s %s:\ngot " fmt "\nwant " fmt, clause, clause2, got, want)
|
2019-05-04 20:13:47 -05:00
|
|
|
#define diff2(t, clause, fmts, got1, got2, want1, want2) testingTErrorf(t, "%s:\ngot " fmts "\nwant " fmts, clause, got1, got2, want1, want2)
|
|
|
|
#define diffFatal(t, clause, fmt, got, want) testingTFatalf(t, "%s:\ngot " fmt "\nwant " fmt, clause, got, want)
|
|
|
|
#define diff2Fatal(t, clause, fmts, got1, got2, want1, want2) testingTFatalf(t, "%s:\ngot " fmts "\nwant " fmts, clause, got1, got2, want1, want2)
|
|
|
|
|
2019-04-28 12:12:40 -05:00
|
|
|
// main.c
|
2019-05-03 09:32:31 -05:00
|
|
|
extern void timeoutMain(void *data);
|
2019-05-03 01:02:20 -05:00
|
|
|
#define timeout_uiMain(t, d) { \
|
|
|
|
timerSysError err; \
|
2019-05-30 21:09:45 -05:00
|
|
|
bool timedOut; \
|
2019-05-03 01:02:20 -05:00
|
|
|
err = timerRunWithTimeout(d, timeoutMain, NULL, &timedOut); \
|
|
|
|
if (err != 0) \
|
|
|
|
testingTErrorf(t, "error running uiMain() in timeout: " timerSysErrorFmt, timerSysErrorFmtArg(err)); \
|
|
|
|
if (timedOut) { \
|
|
|
|
char timeoutstr[timerDurationStringLen]; \
|
|
|
|
timerDurationString(d, timeoutstr); \
|
|
|
|
testingTErrorf(t, "uiMain() timed out (%s)", timeoutstr); \
|
|
|
|
} \
|
|
|
|
}
|
2019-05-26 19:19:02 -05:00
|
|
|
struct errorParams {
|
|
|
|
testingT *t;
|
|
|
|
// TODO this shouldn't have a colon in it but the diff() macros above necessitate it
|
|
|
|
const char *exprstr;
|
|
|
|
const char *msgWant;
|
|
|
|
bool caught;
|
|
|
|
};
|
|
|
|
extern struct errorParams errorParams;
|
|
|
|
extern void catchProgrammerError(const char *prefix, const char *msg, const char *suffix, bool internal);
|
|
|
|
#define testProgrammerError(tt, expr, mw) { \
|
|
|
|
testingTLogf(t, "*** %s", #expr); \
|
|
|
|
uiprivTestHookReportProgrammerError(catchProgrammerError); \
|
|
|
|
errorParams.t = tt; \
|
|
|
|
errorParams.exprstr = #expr ":"; \
|
|
|
|
errorParams.msgWant = mw; \
|
|
|
|
errorParams.caught = false; \
|
|
|
|
expr; \
|
|
|
|
if (!errorParams.caught) \
|
|
|
|
testingTErrorf(t, "%s did not throw a programmer error; should have", #expr); \
|
|
|
|
uiprivTestHookReportProgrammerError(NULL); \
|
|
|
|
}
|
2019-05-10 20:16:29 -05:00
|
|
|
|
|
|
|
// init.c
|
|
|
|
extern testingSet *beforeTests;
|