tests: add --no-threads argument to disable threads
This is useful for Emscripten that can be built without threads support
This commit is contained in:
committed by
Anonymous Maarten
parent
3fccb77da6
commit
50f50df8b1
@@ -49,6 +49,8 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
SDL_Thread *thread;
|
||||
SDLTest_CommonState *state;
|
||||
int i;
|
||||
SDL_bool enable_threads = SDL_TRUE;
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, 0);
|
||||
@@ -60,8 +62,26 @@ int main(int argc, char *argv[])
|
||||
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
/* Parse commandline */
|
||||
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
|
||||
return 1;
|
||||
for (i = 1; i < argc;) {
|
||||
int consumed;
|
||||
|
||||
consumed = SDLTest_CommonArg(state, i);
|
||||
if (consumed == 0) {
|
||||
consumed = -1;
|
||||
if (SDL_strcasecmp(argv[i], "--no-threads") == 0) {
|
||||
enable_threads = SDL_FALSE;
|
||||
consumed = 1;
|
||||
}
|
||||
}
|
||||
if (consumed < 0) {
|
||||
static const char *options[] = {
|
||||
"[--no-threads]",
|
||||
NULL
|
||||
};
|
||||
SDLTest_CommonLogUsage(state, argv[0], options);
|
||||
return 1;
|
||||
}
|
||||
i += consumed;
|
||||
}
|
||||
|
||||
/* Load the SDL library */
|
||||
@@ -79,16 +99,18 @@ int main(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
alive = 1;
|
||||
thread = SDL_CreateThread(ThreadFunc, NULL, "#1");
|
||||
if (!thread) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError());
|
||||
quit(1);
|
||||
if (enable_threads) {
|
||||
alive = 1;
|
||||
thread = SDL_CreateThread(ThreadFunc, NULL, "#1");
|
||||
if (!thread) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError());
|
||||
quit(1);
|
||||
}
|
||||
SDL_Delay(5 * 1000);
|
||||
SDL_Log("Waiting for thread #1\n");
|
||||
alive = 0;
|
||||
SDL_WaitThread(thread, NULL);
|
||||
}
|
||||
SDL_Delay(5 * 1000);
|
||||
SDL_Log("Waiting for thread #1\n");
|
||||
alive = 0;
|
||||
SDL_WaitThread(thread, NULL);
|
||||
|
||||
SDL_Log("Main thread error string: %s\n", SDL_GetError());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user