Improved the main QueueMain test.

This commit is contained in:
Pietro Gagliardi 2020-05-09 16:54:18 -04:00
parent c39bd66d38
commit 73afdaaeb2
1 changed files with 25 additions and 19 deletions

View File

@ -138,41 +138,45 @@ TestNoInit(InitIncorrectlyAfterIncorrectInitialization)
endCheckProgrammerError(ctx); endCheckProgrammerError(ctx);
} }
// TODOTODOTODOTODOTODOTODOTODOTODOTODOTODO struct testQueueMainParams {
unsigned int n;
struct testParams {
uint32_t flag;
threadSysError err; threadSysError err;
}; };
/*
TODO if I remove the uiQuit() from this test on Windows, I will occasionally get
=== RUN TestQueueMain_DifferentThread
../test/initmain.c:161: uiMain() timed out (5s)
--- FAIL: TestQueueMain_DifferentThread (4.9989539s)
TODO see if this is still relevant
*/
static void queued(void *data) static void queued(void *data)
{ {
struct testParams *p = (struct testParams *) data; struct testQueueMainParams *p = (struct testQueueMainParams *) data;
p->flag = 1; p->n++;
if (p->n > 2)
p->n = 2;
uiQuit(); uiQuit();
} }
Test(QueueMain) Test(QueueMain)
{ {
struct testParams p; struct testQueueMainParams p;
memset(&p, 0, sizeof (struct testParams)); memset(&p, 0, sizeof (struct testQueueMainParams));
p.flag = 0; p.n = 0;
uiQueueMain(queued, &p); uiQueueMain(queued, &p);
uiMain(); uiMain();
if (p.flag != 1) switch (p.n) {
TestErrorf("uiQueueMain() didn't set flag properly:" diff("%d"), case 0:
p.flag, 1); TestErrorf("uiQueueMain() function was not called");
break;
case 1:
// do nothing; this is the expected case
break;
default:
TestErrorf("uiQueueMain() called more than once");
}
} }
// TODOTODOTODOTODOTODOTODOTODOTODOTODOTODO
#if 0
// TODO there has to be a way to do this that absolutely will not possibly go in the wrong order... or produce a false positive // TODO there has to be a way to do this that absolutely will not possibly go in the wrong order... or produce a false positive
#define queueOp(name, expr) \ #define queueOp(name, expr) \
static void name(void *data) \ static void name(void *data) \
@ -313,3 +317,5 @@ testingTest(Timer)
{ {
} }
#endif #endif
#endif