2019-04-10 13:42:17 -05:00
|
|
|
// 10 april 2019
|
2019-04-28 12:12:40 -05:00
|
|
|
#include "test.h"
|
|
|
|
|
2019-05-03 09:32:31 -05:00
|
|
|
void timeoutMain(void *data)
|
2019-04-28 12:12:40 -05:00
|
|
|
{
|
|
|
|
uiMain();
|
|
|
|
}
|
|
|
|
|
2019-05-26 19:19:02 -05:00
|
|
|
struct errorParams errorParams;
|
|
|
|
|
|
|
|
void catchProgrammerError(const char *prefix, const char *msg, const char *suffix, bool internal)
|
|
|
|
{
|
|
|
|
errorParams.caught = true;
|
|
|
|
if (strstr(prefix, "programmer error") == NULL)
|
2019-06-02 00:36:53 -05:00
|
|
|
testingTErrorfFull(errorParams.t, errorParams.file, errorParams.line, "%s prefix string doesn't contain \"programmer error\": %s", errorParams.exprstr, prefix);
|
2019-05-26 19:19:02 -05:00
|
|
|
if (internal)
|
2019-06-02 00:36:53 -05:00
|
|
|
testingTErrorfFull(errorParams.t, errorParams.file, errorParams.line, "%s error is marked internal; should not have been", errorParams.exprstr);
|
2019-05-26 19:19:02 -05:00
|
|
|
if (strstr(msg, errorParams.msgWant) == NULL)
|
2019-06-02 00:51:40 -05:00
|
|
|
testingTErrorf(errorParams.t, errorParams.file, errorParams.line, "%s: message doesn't contain expected substring:" diffx("%s"),
|
|
|
|
errorParams.exprstr, msg, errorParams.msgWant);
|
2019-05-26 19:19:02 -05:00
|
|
|
}
|
|
|
|
|
2019-05-30 09:33:39 -05:00
|
|
|
static void runSetORingResults(testingSet *set, const struct testingOptions *options, bool *anyRun, bool *anyFailed)
|
2019-05-10 20:16:29 -05:00
|
|
|
{
|
2019-05-30 09:33:39 -05:00
|
|
|
bool ar, af;
|
2019-05-10 20:16:29 -05:00
|
|
|
|
|
|
|
testingSetRun(set, options, &ar, &af);
|
|
|
|
if (ar)
|
2019-05-30 09:33:39 -05:00
|
|
|
*anyRun = true;
|
2019-05-10 20:16:29 -05:00
|
|
|
if (af)
|
2019-05-30 09:33:39 -05:00
|
|
|
*anyFailed = true;
|
2019-05-10 20:16:29 -05:00
|
|
|
}
|
|
|
|
|
2019-05-05 14:59:59 -05:00
|
|
|
int main(int argc, char *argv[])
|
2019-04-10 13:42:17 -05:00
|
|
|
{
|
2019-05-05 14:59:59 -05:00
|
|
|
testingOptions opts;
|
2019-05-30 09:33:39 -05:00
|
|
|
bool anyRun = false, anyFailed = false;
|
2019-05-10 20:16:29 -05:00
|
|
|
uiInitError err;
|
2019-05-05 14:59:59 -05:00
|
|
|
|
|
|
|
memset(&opts, 0, sizeof (testingOptions));
|
|
|
|
if (argc == 2 && strcmp(argv[1], "-v") == 0)
|
2019-05-30 21:09:45 -05:00
|
|
|
opts.Verbose = true;
|
2019-05-05 14:59:59 -05:00
|
|
|
else if (argc != 1) {
|
|
|
|
fprintf(stderr, "usage: %s [-v]\n", argv[0]);
|
|
|
|
return 1;
|
|
|
|
}
|
2019-05-10 20:16:29 -05:00
|
|
|
|
|
|
|
runSetORingResults(beforeTests, &opts, &anyRun, &anyFailed);
|
|
|
|
memset(&err, 0, sizeof (uiInitError));
|
|
|
|
err.Size = sizeof (uiInitError);
|
2019-05-30 21:09:45 -05:00
|
|
|
if (!uiInit(NULL, &err)) {
|
2019-05-10 20:36:38 -05:00
|
|
|
fprintf(stderr, "uiInit() failed: %s; can't continue\n", err.Message);
|
2019-05-10 20:16:29 -05:00
|
|
|
printf("FAIL\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
runSetORingResults(NULL, &opts, &anyRun, &anyFailed);
|
|
|
|
|
|
|
|
if (!anyRun)
|
|
|
|
fprintf(stderr, "warning: no tests to run\n");
|
|
|
|
if (anyFailed) {
|
|
|
|
printf("FAIL\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
printf("PASS\n");
|
2019-05-31 21:07:51 -05:00
|
|
|
fflush(stdout); // AddressSanitizer can chop the tail end of the output for whatever reason
|
2019-05-10 20:16:29 -05:00
|
|
|
return 0;
|
2019-04-10 13:42:17 -05:00
|
|
|
}
|