Reintegrated test/noinitwrongthread.c into the fold. Now to test.
This commit is contained in:
parent
f79a0892f2
commit
21a0550076
|
@ -4,9 +4,7 @@
|
||||||
|
|
||||||
allcallsCase(uiMain, /* no arguments */)
|
allcallsCase(uiMain, /* no arguments */)
|
||||||
allcallsCase(uiQuit, /* no arguments */)
|
allcallsCase(uiQuit, /* no arguments */)
|
||||||
#ifdef allcallsIncludeQueueMain
|
// uiQueueMain() is defined in all files explicitly since it isn't instantiated for all possible allcalls tests
|
||||||
allcallsCase(uiQueueMain, NULL, NULL)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
allcallsCase(uiControlType, /* no arguments */)
|
allcallsCase(uiControlType, /* no arguments */)
|
||||||
|
|
||||||
|
@ -17,4 +15,3 @@ allcallsCase(uiNewControl, 0, NULL)
|
||||||
allcallsCase(uiControlFree, NULL)
|
allcallsCase(uiControlFree, NULL)
|
||||||
allcallsCase(uiControlSetParent, NULL, NULL)
|
allcallsCase(uiControlSetParent, NULL, NULL)
|
||||||
allcallsCase(uiControlImplData, NULL)
|
allcallsCase(uiControlImplData, NULL)
|
||||||
allcallsCase(uiControlOnFree, /* no arguments */)
|
|
||||||
|
|
|
@ -3,7 +3,10 @@
|
||||||
# Using files() is the cleanest way to ensure the python script below gets the right filenames regardless of how meson sandboxes the command it's running.
|
# Using files() is the cleanest way to ensure the python script below gets the right filenames regardless of how meson sandboxes the command it's running.
|
||||||
libui_test_sources = files([
|
libui_test_sources = files([
|
||||||
'initmain.c',
|
'initmain.c',
|
||||||
# 'noinitwrongthread.c',
|
'noinitwrongthread.c',
|
||||||
|
])
|
||||||
|
libui_allcalls_headers = files([
|
||||||
|
'allcalls.h',
|
||||||
])
|
])
|
||||||
|
|
||||||
libui_test_sources_without_cases = [
|
libui_test_sources_without_cases = [
|
||||||
|
@ -46,7 +49,7 @@ libui_testlist_py = files(['testlist.py'])
|
||||||
|
|
||||||
libui_testlist_h = custom_target(
|
libui_testlist_h = custom_target(
|
||||||
'testlist.h',
|
'testlist.h',
|
||||||
input: libui_test_sources,
|
input: libui_test_sources + libui_allcalls_headers,
|
||||||
output: ['testlist.h'],
|
output: ['testlist.h'],
|
||||||
command: [python, libui_testlist_py, 'header', '@OUTPUT@', '@INPUT@'])
|
command: [python, libui_testlist_py, 'header', '@OUTPUT@', '@INPUT@'])
|
||||||
libui_testlist_c = custom_target(
|
libui_testlist_c = custom_target(
|
||||||
|
@ -63,7 +66,7 @@ libui_testparent = executable('testparent', libui_test_sources + libui_test_sour
|
||||||
gui_app: false,
|
gui_app: false,
|
||||||
install: false)
|
install: false)
|
||||||
|
|
||||||
runresult = run_command(python, libui_testlist_py + ['list'] + libui_test_sources)
|
runresult = run_command(python, libui_testlist_py + ['list'] + libui_test_sources + libui_allcalls_headers)
|
||||||
if runresult.returncode() != 0
|
if runresult.returncode() != 0
|
||||||
error('testlist.py failed; cannot compute list of test cases. Exit code @0@; stderr:\n@1@'.format(runresult.returncode(), runresult.stderr()))
|
error('testlist.py failed; cannot compute list of test cases. Exit code @0@; stderr:\n@1@'.format(runresult.returncode(), runresult.stderr()))
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -1,35 +1,52 @@
|
||||||
// 28 may 2019
|
// 28 may 2019
|
||||||
#include "test.h"
|
#include "test.h"
|
||||||
|
|
||||||
#define allcallsCaseFuncName(f) allcallsCaseFunc ## f
|
if match is not None:
|
||||||
#define allcallsCase(f, ...) static void allcallsCaseFuncName(f)(void) { f(__VA_ARGS__); }
|
f = match.group(1)
|
||||||
#define allcallsIncludeQueueMain
|
casenames.append('TestCallOnWrongThreadIsProgrammerError_' + f)
|
||||||
|
|
||||||
|
// TODO rename to FunctionsFailBeforeInit?
|
||||||
|
#define allcallsCase(f, ...) \
|
||||||
|
TestNoInit(CallBeforeInitIsProgrammerError_ ## f) \
|
||||||
|
{ \
|
||||||
|
void *ctx; \
|
||||||
|
ctx = beginCheckProgrammerError("atteTODOmpt to call " #f "() before uiInit()"); \
|
||||||
|
f(__VA_ARGS__); \
|
||||||
|
endCheckProgrammerError(ctx); \
|
||||||
|
}
|
||||||
#include "allcalls.h"
|
#include "allcalls.h"
|
||||||
#undef allcallsIncludeQueueMain
|
|
||||||
#undef allcallsCase
|
#undef allcallsCase
|
||||||
|
|
||||||
static const struct checkErrorCase beforeInitCases[] = {
|
TestNoInit(CallBeforeInitIsProgrammerError_uiQueueMain)
|
||||||
#define allcallsCase(f, ...) { #f "()", allcallsCaseFuncName(f), "attempt to call " #f "() before uiInit()" },
|
|
||||||
#define allcallsIncludeQueueMain
|
|
||||||
#include "allcalls.h"
|
|
||||||
#undef allcallsIncludeQueueMain
|
|
||||||
#undef allcallsCase
|
|
||||||
{ NULL, NULL, NULL },
|
|
||||||
};
|
|
||||||
|
|
||||||
TestNoInit(FunctionsFailBeforeInit)
|
|
||||||
{
|
{
|
||||||
checkProgrammerErrors(beforeInitCases);
|
void *ctx;
|
||||||
|
|
||||||
|
ctx = beginCheckProgrammerError("atteTODOmpt to call uiQueueMain() before uiInit()");
|
||||||
|
uiQueueMain(NULL, NULL);
|
||||||
|
endCheckProgrammerError(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct checkErrorCase wrongThreadCases[] = {
|
// TODO rename to FunctionsFailOnWrongThread?
|
||||||
#define allcallsCase(f, ...) { #f "()", allcallsCaseFuncName(f), "attempt to call " #f "() on a thread other than the GUI thread" },
|
#define allcallsCase(f, ...) \
|
||||||
|
static void threadTest ## f(void *data) \
|
||||||
|
{ \
|
||||||
|
f(__VA_ARGS__); \
|
||||||
|
} \
|
||||||
|
Test(CallOnWrongThreadIsProgrammerError_ ## f) \
|
||||||
|
{ \
|
||||||
|
threadThread *thread; \
|
||||||
|
threadSysError err; \
|
||||||
|
void *ctx; \
|
||||||
|
ctx = beginCheckProgrammerError("atteTODOmpt 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"
|
#include "allcalls.h"
|
||||||
#undef allcallsCase
|
#undef allcallsCase
|
||||||
{ NULL, NULL, NULL },
|
|
||||||
};
|
|
||||||
|
|
||||||
Test(FunctionsFailOnWrongThread)
|
// no uiQueueMain() test for the wrong thread; it's supposed to be callable from any thread
|
||||||
{
|
|
||||||
checkProgrammerErrorsInThread(wrongThreadCases);
|
|
||||||
}
|
|
||||||
|
|
|
@ -128,7 +128,8 @@ def usage():
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
r = re.compile('^(?:Test|TestNoInit)\(([A-Za-z0-9_]+)\)$')
|
rTest = re.compile('^(?:Test|TestNoInit)\(([A-Za-z0-9_]+)\)$')
|
||||||
|
rAllCalls = re.compile('^(?:allcallsCase)\(([A-Za-z0-9_]+),')
|
||||||
|
|
||||||
if len(sys.argv) < 2:
|
if len(sys.argv) < 2:
|
||||||
usage()
|
usage()
|
||||||
|
@ -151,9 +152,15 @@ def main():
|
||||||
|
|
||||||
casenames = []
|
casenames = []
|
||||||
for line in fileinput.input(files = files):
|
for line in fileinput.input(files = files):
|
||||||
match = r.match(line)
|
match = rTest.match(line)
|
||||||
if match is not None:
|
if match is not None:
|
||||||
casenames.append(match.group(1))
|
casenames.append(match.group(1))
|
||||||
|
match = rAllCalls.match(line)
|
||||||
|
if match is not None:
|
||||||
|
f = match.group(1)
|
||||||
|
# noinitwrongthread.c
|
||||||
|
casenames.append('TestCallBeforeInitIsProgrammerError_' + f)
|
||||||
|
casenames.append('TestCallOnWrongThreadIsProgrammerError_' + f)
|
||||||
cmd.run(sorted(casenames))
|
cmd.run(sorted(casenames))
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in New Issue