Update '-list' option (#2457)

'-list' option is used to print all sub-tests. But some test do not
support it at all. And all test do not display it the same way, making
it quite complicated for external tools to extract them.

That CL clean the usage so that tests:
- Print the sub-tests list with either '-list' (to prevent breaking
legacy usage) or '--list' (to match other options)
- Do not print anything else when the option is used
This commit is contained in:
Romaric Jodin
2025-08-19 18:48:03 +02:00
committed by GitHub
parent 7f01a861d8
commit cef3ef6b59
12 changed files with 127 additions and 43 deletions

View File

@@ -22,6 +22,7 @@
#include <cassert>
#include <deque>
#include <mutex>
#include <set>
#include <stdexcept>
#include <thread>
#include <vector>
@@ -169,6 +170,19 @@ void version_expected_info(const char *test_name, const char *api_name,
"reports %s version %s)\n",
test_name, api_name, expected_version, api_name, device_version);
}
static void list_tests(int testNum, test_definition testList[])
{
std::set<std::string> names;
for (int i = 0; i < testNum; i++)
{
names.insert(testList[i].name);
}
for (const auto &name : names)
{
log_info("\t%s\n", name.c_str());
}
}
int runTestHarnessWithCheck(int argc, const char *argv[], int testNum,
test_definition testList[],
int forceNoContextCreation,
@@ -258,10 +272,13 @@ int runTestHarnessWithCheck(int argc, const char *argv[], int testNum,
return EXIT_FAILURE;
}
/* Special case: just list the tests */
if ((argc > 1)
&& (!strcmp(argv[1], "-list") || !strcmp(argv[1], "-h")
|| !strcmp(argv[1], "--help")))
if (gListTests)
{
list_tests(testNum, testList);
return EXIT_SUCCESS;
}
if ((argc > 1) && (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")))
{
char *fileName = getenv("CL_CONFORMANCE_RESULTS_FILENAME");
@@ -284,10 +301,7 @@ int runTestHarnessWithCheck(int argc, const char *argv[], int testNum,
log_info("\n");
log_info("Test names:\n");
for (int i = 0; i < testNum; i++)
{
log_info("\t%s\n", testList[i].name);
}
list_tests(testNum, testList);
return EXIT_SUCCESS;
}