testautomation: add an option to list all test suites and tests

This commit is contained in:
Sylvain 2023-01-16 10:50:52 +01:00 committed by Sylvain Becker
parent 69253c542a
commit 80f51eeb1f
2 changed files with 21 additions and 2 deletions

View file

@ -37,6 +37,7 @@ int main(int argc, char *argv[])
char *filter = NULL; char *filter = NULL;
int i, done; int i, done;
SDL_Event event; SDL_Event event;
int list = 0;
/* Initialize test framework */ /* Initialize test framework */
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
@ -74,10 +75,13 @@ int main(int argc, char *argv[])
filter = SDL_strdup(argv[i + 1]); filter = SDL_strdup(argv[i + 1]);
consumed = 2; consumed = 2;
} }
} else if (SDL_strcasecmp(argv[i], "--list") == 0) {
consumed = 1;
list = 1;
} }
} }
if (consumed < 0) { if (consumed < 0) {
static const char *options[] = { "[--iterations #]", "[--execKey #]", "[--seed string]", "[--filter suite_name|test_name]", NULL }; static const char *options[] = { "[--iterations #]", "[--execKey #]", "[--seed string]", "[--filter suite_name|test_name]", "[--list]", NULL };
SDLTest_CommonLogUsage(state, argv[0], options); SDLTest_CommonLogUsage(state, argv[0], options);
quit(1); quit(1);
} }
@ -85,6 +89,21 @@ int main(int argc, char *argv[])
i += consumed; i += consumed;
} }
/* List all suites. */
if (list) {
int suiteCounter;
for (suiteCounter = 0; testSuites[suiteCounter]; ++suiteCounter) {
int testCounter;
SDLTest_TestSuiteReference *testSuite = testSuites[suiteCounter];
SDL_Log("Test suite: %s", testSuite->name);
for (testCounter = 0; testSuite->testCases[testCounter]; ++testCounter) {
const SDLTest_TestCaseReference *testCase = testSuite->testCases[testCounter];
SDL_Log(" test: %s", testCase->name);
}
}
return 0;
}
/* Initialize common state */ /* Initialize common state */
if (!SDLTest_CommonInit(state)) { if (!SDLTest_CommonInit(state)) {
quit(2); quit(2);

View file

@ -32,7 +32,7 @@ extern SDLTest_TestSuiteReference timerTestSuite;
extern SDLTest_TestSuiteReference videoTestSuite; extern SDLTest_TestSuiteReference videoTestSuite;
/* All test suites */ /* All test suites */
SDLTest_TestSuiteReference *testSuites[] = { static SDLTest_TestSuiteReference *testSuites[] = {
&audioTestSuite, &audioTestSuite,
&clipboardTestSuite, &clipboardTestSuite,
&eventsTestSuite, &eventsTestSuite,