From 80f51eeb1fc2d4637ade4dc9020623649ed38562 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Mon, 16 Jan 2023 10:50:52 +0100 Subject: [PATCH] testautomation: add an option to list all test suites and tests --- test/testautomation.c | 21 ++++++++++++++++++++- test/testautomation_suites.h | 2 +- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/test/testautomation.c b/test/testautomation.c index c07ffdc16..60697040b 100644 --- a/test/testautomation.c +++ b/test/testautomation.c @@ -37,6 +37,7 @@ int main(int argc, char *argv[]) char *filter = NULL; int i, done; SDL_Event event; + int list = 0; /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); @@ -74,10 +75,13 @@ int main(int argc, char *argv[]) filter = SDL_strdup(argv[i + 1]); consumed = 2; } + } else if (SDL_strcasecmp(argv[i], "--list") == 0) { + consumed = 1; + list = 1; } } 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); quit(1); } @@ -85,6 +89,21 @@ int main(int argc, char *argv[]) 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 */ if (!SDLTest_CommonInit(state)) { quit(2); diff --git a/test/testautomation_suites.h b/test/testautomation_suites.h index 48f6d49db..ab0e86b68 100644 --- a/test/testautomation_suites.h +++ b/test/testautomation_suites.h @@ -32,7 +32,7 @@ extern SDLTest_TestSuiteReference timerTestSuite; extern SDLTest_TestSuiteReference videoTestSuite; /* All test suites */ -SDLTest_TestSuiteReference *testSuites[] = { +static SDLTest_TestSuiteReference *testSuites[] = { &audioTestSuite, &clipboardTestSuite, &eventsTestSuite,