Deduplicated noinitwrongthread.c and its OS-specific files.
This commit is contained in:
parent
80ddb4df8f
commit
eb1862afe1
|
@ -2,19 +2,8 @@
|
||||||
#include "test.h"
|
#include "test.h"
|
||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
|
|
||||||
// TODO split the macros in this file into its own file
|
#define allcallsHeader "allcalls.h"
|
||||||
|
#include "noinitwrongthreadimpl.h"
|
||||||
// TODO rename to FunctionsFailBeforeInit?
|
|
||||||
#define allcallsCase(f, ...) \
|
|
||||||
TestNoInit(CallBeforeInitIsProgrammerError_ ## f) \
|
|
||||||
{ \
|
|
||||||
void *ctx; \
|
|
||||||
ctx = beginCheckProgrammerError("attempt to call " #f "() before uiInit()"); \
|
|
||||||
f(__VA_ARGS__); \
|
|
||||||
endCheckProgrammerError(ctx); \
|
|
||||||
}
|
|
||||||
#include "allcalls.h"
|
|
||||||
#undef allcallsCase
|
|
||||||
|
|
||||||
TestNoInit(CallBeforeInitIsProgrammerError_uiQueueMain)
|
TestNoInit(CallBeforeInitIsProgrammerError_uiQueueMain)
|
||||||
{
|
{
|
||||||
|
@ -25,27 +14,4 @@ TestNoInit(CallBeforeInitIsProgrammerError_uiQueueMain)
|
||||||
endCheckProgrammerError(ctx);
|
endCheckProgrammerError(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO rename to FunctionsFailOnWrongThread?
|
|
||||||
#define allcallsCase(f, ...) \
|
|
||||||
static void threadTest ## f(void *data) \
|
|
||||||
{ \
|
|
||||||
f(__VA_ARGS__); \
|
|
||||||
} \
|
|
||||||
Test(CallOnWrongThreadIsProgrammerError_ ## f) \
|
|
||||||
{ \
|
|
||||||
threadThread *thread; \
|
|
||||||
threadSysError err; \
|
|
||||||
void *ctx; \
|
|
||||||
ctx = beginCheckProgrammerError("attempt to call " #f "() on a thread other than the GUI thread"); \
|
|
||||||
err = threadNewThread(threadTest ## f, NULL, &thread); \
|
|
||||||
if (err != 0) \
|
|
||||||
TestFatalf("error creating thread: " threadSysErrorFmt, threadSysErrorFmtArg(err)); \
|
|
||||||
err = threadThreadWaitAndFree(thread); \
|
|
||||||
if (err != 0) \
|
|
||||||
TestFatalf("error waiting for thread to finish: " threadSysErrorFmt, threadSysErrorFmtArg(err)); \
|
|
||||||
endCheckProgrammerError(ctx); \
|
|
||||||
}
|
|
||||||
#include "allcalls.h"
|
|
||||||
#undef allcallsCase
|
|
||||||
|
|
||||||
// no uiQueueMain() test for the wrong thread; it's supposed to be callable from any thread
|
// no uiQueueMain() test for the wrong thread; it's supposed to be callable from any thread
|
||||||
|
|
|
@ -2,37 +2,5 @@
|
||||||
#import "test_darwin.h"
|
#import "test_darwin.h"
|
||||||
#import "thread.h"
|
#import "thread.h"
|
||||||
|
|
||||||
// TODO rename to FunctionsFailBeforeInit?
|
#define allcallsHeader "allcalls_darwin.h"
|
||||||
#define allcallsCase(f, ...) \
|
#include "noinitwrongthreadimpl.h"
|
||||||
TestNoInit(CallBeforeInitIsProgrammerError_ ## f) \
|
|
||||||
{ \
|
|
||||||
void *ctx; \
|
|
||||||
ctx = beginCheckProgrammerError("attempt to call " #f "() before uiInit()"); \
|
|
||||||
f(__VA_ARGS__); \
|
|
||||||
endCheckProgrammerError(ctx); \
|
|
||||||
}
|
|
||||||
#include "allcalls_darwin.h"
|
|
||||||
#undef allcallsCase
|
|
||||||
|
|
||||||
// TODO rename to FunctionsFailOnWrongThread?
|
|
||||||
#define allcallsCase(f, ...) \
|
|
||||||
static void threadTest ## f(void *data) \
|
|
||||||
{ \
|
|
||||||
f(__VA_ARGS__); \
|
|
||||||
} \
|
|
||||||
Test(CallOnWrongThreadIsProgrammerError_ ## f) \
|
|
||||||
{ \
|
|
||||||
threadThread *thread; \
|
|
||||||
threadSysError err; \
|
|
||||||
void *ctx; \
|
|
||||||
ctx = beginCheckProgrammerError("attempt to call " #f "() on a thread other than the GUI thread"); \
|
|
||||||
err = threadNewThread(threadTest ## f, NULL, &thread); \
|
|
||||||
if (err != 0) \
|
|
||||||
TestFatalf("error creating thread: " threadSysErrorFmt, threadSysErrorFmtArg(err)); \
|
|
||||||
err = threadThreadWaitAndFree(thread); \
|
|
||||||
if (err != 0) \
|
|
||||||
TestFatalf("error waiting for thread to finish: " threadSysErrorFmt, threadSysErrorFmtArg(err)); \
|
|
||||||
endCheckProgrammerError(ctx); \
|
|
||||||
}
|
|
||||||
#include "allcalls_darwin.h"
|
|
||||||
#undef allcallsCase
|
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
// 28 may 2019
|
||||||
|
// define allcallsHeader and include test.h and thread.h before including this
|
||||||
|
|
||||||
|
// TODO rename to FunctionsFailBeforeInit?
|
||||||
|
#define allcallsCase(f, ...) \
|
||||||
|
TestNoInit(CallBeforeInitIsProgrammerError_ ## f) \
|
||||||
|
{ \
|
||||||
|
void *ctx; \
|
||||||
|
ctx = beginCheckProgrammerError("attempt to call " #f "() before uiInit()"); \
|
||||||
|
f(__VA_ARGS__); \
|
||||||
|
endCheckProgrammerError(ctx); \
|
||||||
|
}
|
||||||
|
#include allcallsHeader
|
||||||
|
#undef allcallsCase
|
||||||
|
|
||||||
|
// TODO rename to FunctionsFailOnWrongThread?
|
||||||
|
#define allcallsCase(f, ...) \
|
||||||
|
static void threadTest ## f(void *data) \
|
||||||
|
{ \
|
||||||
|
f(__VA_ARGS__); \
|
||||||
|
} \
|
||||||
|
Test(CallOnWrongThreadIsProgrammerError_ ## f) \
|
||||||
|
{ \
|
||||||
|
threadThread *thread; \
|
||||||
|
threadSysError err; \
|
||||||
|
void *ctx; \
|
||||||
|
ctx = beginCheckProgrammerError("attempt to call " #f "() on a thread other than the GUI thread"); \
|
||||||
|
err = threadNewThread(threadTest ## f, NULL, &thread); \
|
||||||
|
if (err != 0) \
|
||||||
|
TestFatalf("error creating thread: " threadSysErrorFmt, threadSysErrorFmtArg(err)); \
|
||||||
|
err = threadThreadWaitAndFree(thread); \
|
||||||
|
if (err != 0) \
|
||||||
|
TestFatalf("error waiting for thread to finish: " threadSysErrorFmt, threadSysErrorFmtArg(err)); \
|
||||||
|
endCheckProgrammerError(ctx); \
|
||||||
|
}
|
||||||
|
#include allcallsHeader
|
||||||
|
#undef allcallsCase
|
Loading…
Reference in New Issue