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

@@ -35,6 +35,7 @@ std::string gCompilationProgram = DEFAULT_COMPILATION_PROGRAM;
bool gDisableSPIRVValidation = false; bool gDisableSPIRVValidation = false;
std::string gSPIRVValidator = DEFAULT_SPIRV_VALIDATOR; std::string gSPIRVValidator = DEFAULT_SPIRV_VALIDATOR;
unsigned gNumWorkerThreads; unsigned gNumWorkerThreads;
bool gListTests = false;
void helpInfo() void helpInfo()
{ {
@@ -49,6 +50,8 @@ void helpInfo()
spir-v Use SPIR-V offline compilation spir-v Use SPIR-V offline compilation
--num-worker-threads <num> --num-worker-threads <num>
Select parallel execution with the specified number of worker threads. Select parallel execution with the specified number of worker threads.
--list
List sub-tests
For offline compilation (binary and spir-v modes) only: For offline compilation (binary and spir-v modes) only:
--compilation-cache-mode <cache-mode> --compilation-cache-mode <cache-mode>
@@ -104,6 +107,11 @@ int parseCustomParam(int argc, const char *argv[], const char *ignore)
// option and print its own help. // option and print its own help.
helpInfo(); helpInfo();
} }
else if (!strcmp(argv[i], "--list") || !strcmp(argv[i], "-list"))
{
delArg++;
gListTests = true;
}
else if (!strcmp(argv[i], "--compilation-mode")) else if (!strcmp(argv[i], "--compilation-mode"))
{ {
delArg++; delArg++;

View File

@@ -40,6 +40,7 @@ extern std::string gCompilationCachePath;
extern std::string gCompilationProgram; extern std::string gCompilationProgram;
extern bool gDisableSPIRVValidation; extern bool gDisableSPIRVValidation;
extern std::string gSPIRVValidator; extern std::string gSPIRVValidator;
extern bool gListTests;
extern int parseCustomParam(int argc, const char *argv[], extern int parseCustomParam(int argc, const char *argv[],
const char *ignore = 0); const char *ignore = 0);

View File

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

View File

@@ -284,6 +284,11 @@ int main( int argc, const char **argv )
static int ParseArgs( int argc, const char **argv ) static int ParseArgs( int argc, const char **argv )
{ {
if (gListTests)
{
return 0;
}
gArgList = (const char **)calloc( argc, sizeof( char*) ); gArgList = (const char **)calloc( argc, sizeof( char*) );
if( NULL == gArgList ) if( NULL == gArgList )

View File

@@ -112,6 +112,35 @@ int main(int argc, const char **argv)
int error; int error;
argc = parseCustomParam(argc, argv); argc = parseCustomParam(argc, argv);
if (gListTests)
{
for (unsigned dst = 0; dst < kTypeCount; dst++)
{
for (unsigned src = 0; src < kTypeCount; src++)
{
for (unsigned sat = 0; sat < 2; sat++)
{
// skip illegal saturated conversions to float type
if (gSaturationNames[sat] == std::string("_sat")
&& (gTypeNames[dst] == std::string("float")
|| gTypeNames[dst] == std::string("half")
|| gTypeNames[dst] == std::string("double")))
{
continue;
}
for (unsigned rnd = 0; rnd < kRoundingModeCount; rnd++)
{
vlog("\t%s\n",
(std::string(gTypeNames[dst])
+ gSaturationNames[sat] + gRoundingModeNames[rnd]
+ "_" + gTypeNames[src])
.c_str());
}
}
}
}
return 0;
}
if (argc == -1) if (argc == -1)
{ {
return 1; return 1;

View File

@@ -83,13 +83,6 @@ int main (int argc, const char **argv )
if( (error = ParseArgs( argc, argv )) ) if( (error = ParseArgs( argc, argv )) )
goto exit; goto exit;
if (gIsEmbedded) {
vlog( "\tProfile: Embedded\n" );
}else
{
vlog( "\tProfile: Full\n" );
}
fflush( stdout ); fflush( stdout );
error = runTestHarnessWithCheck( error = runTestHarnessWithCheck(
argCount, argList, test_registry::getInstance().num_tests(), argCount, argList, test_registry::getInstance().num_tests(),
@@ -114,6 +107,10 @@ exit:
static int ParseArgs( int argc, const char **argv ) static int ParseArgs( int argc, const char **argv )
{ {
if (gListTests)
{
return 0;
}
int i; int i;
argList = (const char **)calloc(argc, sizeof(char *)); argList = (const char **)calloc(argc, sizeof(char *));
if( NULL == argList ) if( NULL == argList )
@@ -217,6 +214,16 @@ static int ParseArgs( int argc, const char **argv )
vlog( "*** It gives warm fuzzy feelings and then nevers calls. ***\n\n" ); vlog( "*** It gives warm fuzzy feelings and then nevers calls. ***\n\n" );
vlog( "*** Wimpy Reduction Factor: %-27u ***\n\n", gWimpyReductionFactor); vlog( "*** Wimpy Reduction Factor: %-27u ***\n\n", gWimpyReductionFactor);
} }
if (gIsEmbedded)
{
vlog("\tProfile: Embedded\n");
}
else
{
vlog("\tProfile: Full\n");
}
return 0; return 0;
} }

View File

@@ -384,21 +384,24 @@ int main(int argc, const char *argv[])
error = ParseArgs(argc, argv); error = ParseArgs(argc, argv);
if (error) return error; if (error) return error;
// This takes a while, so prevent the machine from going to sleep. if (!gListTests)
PreventSleep(); {
atexit(ResumeSleep); // This takes a while, so prevent the machine from going to sleep.
PreventSleep();
atexit(ResumeSleep);
if (gSkipCorrectnessTesting) if (gSkipCorrectnessTesting)
vlog("*** Skipping correctness testing! ***\n\n"); vlog("*** Skipping correctness testing! ***\n\n");
else if (gStopOnError) else if (gStopOnError)
vlog("Stopping at first error.\n"); vlog("Stopping at first error.\n");
vlog(" \t "); vlog(" \t ");
if (gWimpyMode) vlog(" "); if (gWimpyMode) vlog(" ");
if (!gSkipCorrectnessTesting) vlog("\t max_ulps"); if (!gSkipCorrectnessTesting) vlog("\t max_ulps");
vlog("\n-------------------------------------------------------------------" vlog("\n---------------------------------------------------------------"
"----------------------------------------\n"); "--------------------------------------------\n");
}
gMTdata = MTdataHolder(gRandomSeed); gMTdata = MTdataHolder(gRandomSeed);
@@ -425,6 +428,10 @@ int main(int argc, const char *argv[])
static int ParseArgs(int argc, const char **argv) static int ParseArgs(int argc, const char **argv)
{ {
if (gListTests)
{
return 0;
}
// We only pass test names to runTestHarnessWithCheck, hence global command // We only pass test names to runTestHarnessWithCheck, hence global command
// line options defined by the harness cannot be used by the user. // line options defined by the harness cannot be used by the user.
// To respect the implementation details of runTestHarnessWithCheck, // To respect the implementation details of runTestHarnessWithCheck,

View File

@@ -31,7 +31,6 @@
int main(int argc, const char *argv[]) int main(int argc, const char *argv[])
{ {
log_info("1st part, non gl-sharing objects...\n");
gTestRounding = true; gTestRounding = true;
return runTestHarness(argc, argv, test_registry::getInstance().num_tests(), return runTestHarness(argc, argv, test_registry::getInstance().num_tests(),
test_registry::getInstance().definitions(), false, 0); test_registry::getInstance().definitions(), false, 0);

View File

@@ -1101,20 +1101,19 @@ int main(int argc, const char* argv[])
argCount, argList, test_registry::getInstance().num_tests(), argCount, argList, test_registry::getInstance().num_tests(),
test_registry::getInstance().definitions(), true, 0, InitCL); test_registry::getInstance().definitions(), true, 0, InitCL);
if(gQueue) if (gQueue)
{ {
int error = clFinish(gQueue); int error = clFinish(gQueue);
if (error) { if (error)
{
log_error("clFinish failed: %d\n", error); log_error("clFinish failed: %d\n", error);
} }
if (clReleaseCommandQueue(gQueue) != CL_SUCCESS)
log_error("clReleaseCommandQueue\n");
} }
if (gContext && clReleaseContext(gContext) != CL_SUCCESS)
if(clReleaseCommandQueue(gQueue)!=CL_SUCCESS)
log_error("clReleaseCommandQueue\n");
if(clReleaseContext(gContext)!= CL_SUCCESS)
log_error("clReleaseContext\n"); log_error("clReleaseContext\n");
free(argList); free(argList);
remove(gFileName); remove(gFileName);
return err; return err;

View File

@@ -630,7 +630,8 @@ int main(int argc, const char* argv[])
s_wimpy_mode = true; s_wimpy_mode = true;
} }
if (s_wimpy_mode) { if (s_wimpy_mode && !gListTests)
{
log_info("\n"); log_info("\n");
log_info("*** WARNING: Testing in Wimpy mode! ***\n"); log_info("*** WARNING: Testing in Wimpy mode! ***\n");
log_info("*** Wimpy mode is not sufficient to verify correctness. ***\n"); log_info("*** Wimpy mode is not sufficient to verify correctness. ***\n");

View File

@@ -6713,6 +6713,14 @@ cl_device_id get_platform_device (cl_device_type device_type, cl_uint choosen_de
return devices[choosen_device_index]; return devices[choosen_device_index];
} }
static void ListTests()
{
for (unsigned int i = 0; i < (sizeof(spir_suites) / sizeof(sub_suite)); i++)
{
log_info("\t%s\n", spir_suites[i].name);
}
}
/** /**
Parses the command line parameters and set the Parses the command line parameters and set the
@@ -6761,7 +6769,7 @@ static int ParseCommandLine (int argc, const char *argv[],
/* Process the command line arguments */ /* Process the command line arguments */
/* Special case: just list the tests */ /* Special case: just list the tests */
if( ( argc > 1 ) && (!strcmp( argv[ 1 ], "-list" ) || !strcmp( argv[ 1 ], "-h" ) || !strcmp( argv[ 1 ], "--help" ))) if ((argc > 1) && (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")))
{ {
log_info( "Usage: %s [<suite name>] [pid<num>] [id<num>] [<device type>] [w32] [no-unzip]\n", argv[0] ); log_info( "Usage: %s [<suite name>] [pid<num>] [id<num>] [<device type>] [w32] [no-unzip]\n", argv[0] );
log_info( "\t<suite name>\tOne or more of: (default all)\n"); log_info( "\t<suite name>\tOne or more of: (default all)\n");
@@ -6771,10 +6779,12 @@ static int ParseCommandLine (int argc, const char *argv[],
log_info( "\tw32\t\tIndicates device address bits is 32.\n" ); log_info( "\tw32\t\tIndicates device address bits is 32.\n" );
log_info( "\tno-unzip\t\tDo not extract test files from Zip; use existing.\n" ); log_info( "\tno-unzip\t\tDo not extract test files from Zip; use existing.\n" );
for( unsigned int i = 0; i < (sizeof(spir_suites) / sizeof(sub_suite)); i++ ) ListTests();
{ return 0;
log_info( "\t\t%s\n", spir_suites[i].name ); }
} else if (!strcmp(argv[1], "--list") || !strcmp(argv[1], "-list"))
{
ListTests();
return 0; return 0;
} }

View File

@@ -216,6 +216,7 @@ int main(int argc, const char *argv[])
{ {
gReSeed = 1; gReSeed = 1;
bool modifiedSpvBinariesPath = false; bool modifiedSpvBinariesPath = false;
bool listTests = false;
for (int i = 0; i < argc; ++i) { for (int i = 0; i < argc; ++i) {
int argsRemoveNum = 0; int argsRemoveNum = 0;
if (argv[i] == spvBinariesPathArg) { if (argv[i] == spvBinariesPathArg) {
@@ -241,9 +242,12 @@ int main(int argc, const char *argv[])
argc -= argsRemoveNum; argc -= argsRemoveNum;
--i; --i;
} }
listTests |= (argv[i] == std::string("--list")
|| argv[i] == std::string("-list"));
} }
if (modifiedSpvBinariesPath == false) { if (modifiedSpvBinariesPath == false && !listTests)
printUsage(); {
printUsage();
} }
return runTestHarnessWithCheck( return runTestHarnessWithCheck(