mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-05-11 14:38:24 +02:00
SDL_test: move argument parsing into SDL_test
This commit is contained in:
committed by
Anonymous Maarten
parent
09af4a8086
commit
102b3b480b
@@ -19,6 +19,7 @@
|
||||
#include "testautomation_suites.h"
|
||||
|
||||
static SDLTest_CommonState *state;
|
||||
static SDLTest_TestSuiteRunner *runner;
|
||||
|
||||
/* All test suites */
|
||||
static SDLTest_TestSuiteReference *testSuites[] = {
|
||||
@@ -55,6 +56,7 @@ static SDLTest_TestSuiteReference *testSuites[] = {
|
||||
static void
|
||||
quit(int rc)
|
||||
{
|
||||
SDLTest_DestroyTestSuiteRunner(runner);
|
||||
SDLTest_CommonQuit(state);
|
||||
/* Let 'main()' return normally */
|
||||
if (rc != 0) {
|
||||
@@ -65,14 +67,9 @@ quit(int rc)
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int result;
|
||||
int testIterations = 1;
|
||||
Uint64 userExecKey = 0;
|
||||
char *userRunSeed = NULL;
|
||||
char *filter = NULL;
|
||||
int i, done;
|
||||
SDL_Event event;
|
||||
int list = 0;
|
||||
SDL_bool randomOrder = SDL_FALSE;
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO | SDL_INIT_AUDIO);
|
||||
@@ -83,6 +80,8 @@ int main(int argc, char *argv[])
|
||||
/* No need of windows (or update testautomation_mouse.c:mouse_getMouseFocus() */
|
||||
state->num_windows = 0;
|
||||
|
||||
runner = SDLTest_CreateTestSuiteRunner(state, testSuites);
|
||||
|
||||
/* Parse commandline */
|
||||
for (i = 1; i < argc;) {
|
||||
int consumed;
|
||||
@@ -90,46 +89,15 @@ int main(int argc, char *argv[])
|
||||
consumed = SDLTest_CommonArg(state, i);
|
||||
if (consumed == 0) {
|
||||
consumed = -1;
|
||||
if (SDL_strcasecmp(argv[i], "--iterations") == 0) {
|
||||
if (argv[i + 1]) {
|
||||
testIterations = SDL_atoi(argv[i + 1]);
|
||||
if (testIterations < 1) {
|
||||
testIterations = 1;
|
||||
}
|
||||
consumed = 2;
|
||||
}
|
||||
} else if (SDL_strcasecmp(argv[i], "--execKey") == 0) {
|
||||
if (argv[i + 1]) {
|
||||
(void)SDL_sscanf(argv[i + 1], "%" SDL_PRIu64, &userExecKey);
|
||||
consumed = 2;
|
||||
}
|
||||
} else if (SDL_strcasecmp(argv[i], "--seed") == 0) {
|
||||
if (argv[i + 1]) {
|
||||
userRunSeed = SDL_strdup(argv[i + 1]);
|
||||
consumed = 2;
|
||||
}
|
||||
} else if (SDL_strcasecmp(argv[i], "--filter") == 0) {
|
||||
if (argv[i + 1]) {
|
||||
filter = SDL_strdup(argv[i + 1]);
|
||||
consumed = 2;
|
||||
}
|
||||
} else if (SDL_strcasecmp(argv[i], "--list") == 0) {
|
||||
|
||||
if (SDL_strcasecmp(argv[i], "--list") == 0) {
|
||||
consumed = 1;
|
||||
list = 1;
|
||||
} else if (SDL_strcasecmp(argv[i], "--random-order") == 0) {
|
||||
consumed = 1;
|
||||
randomOrder = SDL_TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
if (consumed < 0) {
|
||||
static const char *options[] = {
|
||||
"[--iterations #]",
|
||||
"[--execKey #]",
|
||||
"[--seed string]",
|
||||
"[--filter suite_name|test_name]",
|
||||
"[--list]",
|
||||
"[--random-order]",
|
||||
NULL };
|
||||
SDLTest_CommonLogUsage(state, argv[0], options);
|
||||
quit(1);
|
||||
@@ -166,7 +134,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
/* Call Harness */
|
||||
result = SDLTest_RunSuites(testSuites, userRunSeed, userExecKey, filter, testIterations, randomOrder);
|
||||
result = SDLTest_ExecuteTestSuiteRunner(runner);
|
||||
|
||||
/* Empty event queue */
|
||||
done = 0;
|
||||
@@ -177,10 +145,6 @@ int main(int argc, char *argv[])
|
||||
SDL_Delay(10);
|
||||
}
|
||||
|
||||
/* Clean up */
|
||||
SDL_free(userRunSeed);
|
||||
SDL_free(filter);
|
||||
|
||||
/* Shutdown everything */
|
||||
quit(0);
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user