And finished adjusting the tests accordingly. Now to test.
This commit is contained in:
parent
e2baa5bb5c
commit
dbfea28313
|
@ -61,7 +61,7 @@ testingTest(QueueMain)
|
||||||
int flag = 0;
|
int flag = 0;
|
||||||
|
|
||||||
uiQueueMain(queued, &flag);
|
uiQueueMain(queued, &flag);
|
||||||
timeout_uiMain(t, 5 * timerSecond, 0);
|
timeout_uiMain(t, 5 * timerSecond);
|
||||||
if (flag != 1)
|
if (flag != 1)
|
||||||
testingTErrorf(t, "uiQueueMain() didn't set flag properly: got %d, want 1", flag);
|
testingTErrorf(t, "uiQueueMain() didn't set flag properly: got %d, want 1", flag);
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ testingTest(QueueMain_Sequence)
|
||||||
uint32_t flag;
|
uint32_t flag;
|
||||||
|
|
||||||
queueOrder(&flag);
|
queueOrder(&flag);
|
||||||
timeout_uiMain(t, 5 * timerSecond, 0);
|
timeout_uiMain(t, 5 * timerSecond);
|
||||||
checkOrder(t, flag);
|
checkOrder(t, flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ testingTest(QueueMain_DifferentThread)
|
||||||
int flag = 0;
|
int flag = 0;
|
||||||
|
|
||||||
thread = testingNewThread(queueThread, &flag);
|
thread = testingNewThread(queueThread, &flag);
|
||||||
timeout_uiMain(t, 5 * timerSecond, 0);
|
timeout_uiMain(t, 5 * timerSecond);
|
||||||
testingThreadWaitAndFree(thread);
|
testingThreadWaitAndFree(thread);
|
||||||
if (flag != 1)
|
if (flag != 1)
|
||||||
testingTErrorf(t, "uiQueueMain() didn't set flag properly: got %d, want 1", flag);
|
testingTErrorf(t, "uiQueueMain() didn't set flag properly: got %d, want 1", flag);
|
||||||
|
@ -162,7 +162,7 @@ testingTest(QueueMain_DifferentThreadSequence)
|
||||||
uint32_t flag = 1; // make sure it's initialized just in case
|
uint32_t flag = 1; // make sure it's initialized just in case
|
||||||
|
|
||||||
thread = testingNewThread(queueOrderThread, &flag);
|
thread = testingNewThread(queueOrderThread, &flag);
|
||||||
timeout_uiMain(t, 5 * timerSecond, 0);
|
timeout_uiMain(t, 5 * timerSecond);
|
||||||
testingThreadWaitAndFree(thread);
|
testingThreadWaitAndFree(thread);
|
||||||
checkOrder(t, flag);
|
checkOrder(t, flag);
|
||||||
}
|
}
|
||||||
|
|
16
test/test.h
16
test/test.h
|
@ -5,7 +5,15 @@
|
||||||
|
|
||||||
// main.c
|
// main.c
|
||||||
extern void timeoutMain(testingT *t, void *data);
|
extern void timeoutMain(testingT *t, void *data);
|
||||||
#define timeout_uiMain(t, timeout, failNowOnError) \
|
#define timeout_uiMain(t, d) { \
|
||||||
testingRunWithTimeout(t, timeout, \
|
timerSysError err; \
|
||||||
timeoutMain, NULL, \
|
int timedOut; \
|
||||||
"uiMain()", failNowOnError);
|
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); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
|
@ -21,11 +21,11 @@ extern void timerDurationString(timerDuration d, char buf[timerDurationStringLen
|
||||||
typedef uint64_t timerSysError;
|
typedef uint64_t timerSysError;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define timerSysErrorFmt "0x%08I32X"
|
#define timerSysErrorFmt "0x%08I32X"
|
||||||
#define timerSysErrorArg(x) ((uint32_t) x)
|
#define timerSysErrorFmtArg(x) ((uint32_t) x)
|
||||||
#else
|
#else
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#define timerSysErrorFmt "%s (%d)"
|
#define timerSysErrorFmt "%s (%d)"
|
||||||
#define timerSysErrorArg(x) strerror((int) x), ((int) x)
|
#define timerSysErrorFmtArg(x) strerror((int) x), ((int) x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern timerSysError timerRunWithTimeout(timerDuration d, void (*f)(void *data), void *data, int *timedOut);
|
extern timerSysError timerRunWithTimeout(timerDuration d, void (*f)(void *data), void *data, int *timedOut);
|
||||||
|
|
|
@ -357,7 +357,6 @@ static unsigned __stdcall timerThreadProc(void *data)
|
||||||
timerSysError timerRunWithTimeout(timerDuration d, void (*f)(void *data), void *data, int *timedOut)
|
timerSysError timerRunWithTimeout(timerDuration d, void (*f)(void *data), void *data, int *timedOut)
|
||||||
{
|
{
|
||||||
volatile struct timeoutParams p;
|
volatile struct timeoutParams p;
|
||||||
char timeoutstr[timerDurationStringLen];
|
|
||||||
MSG msg;
|
MSG msg;
|
||||||
volatile uintptr_t timerThreadValue = 0;
|
volatile uintptr_t timerThreadValue = 0;
|
||||||
volatile HANDLE timerThread = NULL;
|
volatile HANDLE timerThread = NULL;
|
||||||
|
@ -366,7 +365,6 @@ timerSysError timerRunWithTimeout(timerDuration d, void (*f)(void *data), void *
|
||||||
|
|
||||||
*timedOut = 0;
|
*timedOut = 0;
|
||||||
ZeroMemory(&p, sizeof (struct timeoutParams));
|
ZeroMemory(&p, sizeof (struct timeoutParams));
|
||||||
timerDurationString(d, timeoutstr);
|
|
||||||
|
|
||||||
hr = setupNonReentrance(&p);
|
hr = setupNonReentrance(&p);
|
||||||
if (hr != S_OK)
|
if (hr != S_OK)
|
||||||
|
|
Loading…
Reference in New Issue