diff --git a/test_common/harness/parseParameters.cpp b/test_common/harness/parseParameters.cpp index 29499381..820814ec 100644 --- a/test_common/harness/parseParameters.cpp +++ b/test_common/harness/parseParameters.cpp @@ -35,6 +35,7 @@ std::string gCompilationProgram = DEFAULT_COMPILATION_PROGRAM; bool gDisableSPIRVValidation = false; std::string gSPIRVValidator = DEFAULT_SPIRV_VALIDATOR; unsigned gNumWorkerThreads; +bool gListTests = false; void helpInfo() { @@ -49,6 +50,8 @@ void helpInfo() spir-v Use SPIR-V offline compilation --num-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: --compilation-cache-mode @@ -104,6 +107,11 @@ int parseCustomParam(int argc, const char *argv[], const char *ignore) // option and print its own help. helpInfo(); } + else if (!strcmp(argv[i], "--list") || !strcmp(argv[i], "-list")) + { + delArg++; + gListTests = true; + } else if (!strcmp(argv[i], "--compilation-mode")) { delArg++; diff --git a/test_common/harness/parseParameters.h b/test_common/harness/parseParameters.h index 437e12f9..685aef21 100644 --- a/test_common/harness/parseParameters.h +++ b/test_common/harness/parseParameters.h @@ -40,6 +40,7 @@ extern std::string gCompilationCachePath; extern std::string gCompilationProgram; extern bool gDisableSPIRVValidation; extern std::string gSPIRVValidator; +extern bool gListTests; extern int parseCustomParam(int argc, const char *argv[], const char *ignore = 0); diff --git a/test_common/harness/testHarness.cpp b/test_common/harness/testHarness.cpp index 611d0b32..71430cd0 100644 --- a/test_common/harness/testHarness.cpp +++ b/test_common/harness/testHarness.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -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 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; } diff --git a/test_conformance/contractions/contractions.cpp b/test_conformance/contractions/contractions.cpp index 2fdf0323..0c868764 100644 --- a/test_conformance/contractions/contractions.cpp +++ b/test_conformance/contractions/contractions.cpp @@ -284,6 +284,11 @@ int main( int argc, const char **argv ) static int ParseArgs( int argc, const char **argv ) { + if (gListTests) + { + return 0; + } + gArgList = (const char **)calloc( argc, sizeof( char*) ); if( NULL == gArgList ) diff --git a/test_conformance/conversions/test_conversions.cpp b/test_conformance/conversions/test_conversions.cpp index 1712e099..5df5f0fd 100644 --- a/test_conformance/conversions/test_conversions.cpp +++ b/test_conformance/conversions/test_conversions.cpp @@ -112,6 +112,35 @@ int main(int argc, const char **argv) int error; 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) { return 1; diff --git a/test_conformance/half/main.cpp b/test_conformance/half/main.cpp index 743bc45c..9d9211c7 100644 --- a/test_conformance/half/main.cpp +++ b/test_conformance/half/main.cpp @@ -83,13 +83,6 @@ int main (int argc, const char **argv ) if( (error = ParseArgs( argc, argv )) ) goto exit; - if (gIsEmbedded) { - vlog( "\tProfile: Embedded\n" ); - }else - { - vlog( "\tProfile: Full\n" ); - } - fflush( stdout ); error = runTestHarnessWithCheck( argCount, argList, test_registry::getInstance().num_tests(), @@ -114,6 +107,10 @@ exit: static int ParseArgs( int argc, const char **argv ) { + if (gListTests) + { + return 0; + } int i; argList = (const char **)calloc(argc, sizeof(char *)); 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( "*** Wimpy Reduction Factor: %-27u ***\n\n", gWimpyReductionFactor); } + + if (gIsEmbedded) + { + vlog("\tProfile: Embedded\n"); + } + else + { + vlog("\tProfile: Full\n"); + } + return 0; } diff --git a/test_conformance/math_brute_force/main.cpp b/test_conformance/math_brute_force/main.cpp index 008ab307..519d8b12 100644 --- a/test_conformance/math_brute_force/main.cpp +++ b/test_conformance/math_brute_force/main.cpp @@ -384,21 +384,24 @@ int main(int argc, const char *argv[]) error = ParseArgs(argc, argv); if (error) return error; - // This takes a while, so prevent the machine from going to sleep. - PreventSleep(); - atexit(ResumeSleep); + if (!gListTests) + { + // This takes a while, so prevent the machine from going to sleep. + PreventSleep(); + atexit(ResumeSleep); - if (gSkipCorrectnessTesting) - vlog("*** Skipping correctness testing! ***\n\n"); - else if (gStopOnError) - vlog("Stopping at first error.\n"); + if (gSkipCorrectnessTesting) + vlog("*** Skipping correctness testing! ***\n\n"); + else if (gStopOnError) + vlog("Stopping at first error.\n"); - vlog(" \t "); - if (gWimpyMode) vlog(" "); - if (!gSkipCorrectnessTesting) vlog("\t max_ulps"); + vlog(" \t "); + if (gWimpyMode) vlog(" "); + if (!gSkipCorrectnessTesting) vlog("\t max_ulps"); - vlog("\n-------------------------------------------------------------------" - "----------------------------------------\n"); + vlog("\n---------------------------------------------------------------" + "--------------------------------------------\n"); + } gMTdata = MTdataHolder(gRandomSeed); @@ -425,6 +428,10 @@ int main(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 // line options defined by the harness cannot be used by the user. // To respect the implementation details of runTestHarnessWithCheck, diff --git a/test_conformance/mem_host_flags/main.cpp b/test_conformance/mem_host_flags/main.cpp index 0e9df56c..0b05ff16 100644 --- a/test_conformance/mem_host_flags/main.cpp +++ b/test_conformance/mem_host_flags/main.cpp @@ -31,7 +31,6 @@ int main(int argc, const char *argv[]) { - log_info("1st part, non gl-sharing objects...\n"); gTestRounding = true; return runTestHarness(argc, argv, test_registry::getInstance().num_tests(), test_registry::getInstance().definitions(), false, 0); diff --git a/test_conformance/printf/test_printf.cpp b/test_conformance/printf/test_printf.cpp index 38333175..9cd9db00 100644 --- a/test_conformance/printf/test_printf.cpp +++ b/test_conformance/printf/test_printf.cpp @@ -1101,20 +1101,19 @@ int main(int argc, const char* argv[]) argCount, argList, test_registry::getInstance().num_tests(), test_registry::getInstance().definitions(), true, 0, InitCL); - if(gQueue) + if (gQueue) { int error = clFinish(gQueue); - if (error) { + if (error) + { log_error("clFinish failed: %d\n", error); } + if (clReleaseCommandQueue(gQueue) != CL_SUCCESS) + log_error("clReleaseCommandQueue\n"); } - - if(clReleaseCommandQueue(gQueue)!=CL_SUCCESS) - log_error("clReleaseCommandQueue\n"); - if(clReleaseContext(gContext)!= CL_SUCCESS) + if (gContext && clReleaseContext(gContext) != CL_SUCCESS) log_error("clReleaseContext\n"); - free(argList); remove(gFileName); return err; diff --git a/test_conformance/select/test_select.cpp b/test_conformance/select/test_select.cpp index 20f5bd5e..490fa8bc 100644 --- a/test_conformance/select/test_select.cpp +++ b/test_conformance/select/test_select.cpp @@ -630,7 +630,8 @@ int main(int argc, const char* argv[]) s_wimpy_mode = true; } - if (s_wimpy_mode) { + if (s_wimpy_mode && !gListTests) + { log_info("\n"); log_info("*** WARNING: Testing in Wimpy mode! ***\n"); log_info("*** Wimpy mode is not sufficient to verify correctness. ***\n"); diff --git a/test_conformance/spir/main.cpp b/test_conformance/spir/main.cpp index 95e8c00f..322e71bc 100644 --- a/test_conformance/spir/main.cpp +++ b/test_conformance/spir/main.cpp @@ -6713,6 +6713,14 @@ cl_device_id get_platform_device (cl_device_type device_type, cl_uint choosen_de 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 @@ -6761,7 +6769,7 @@ static int ParseCommandLine (int argc, const char *argv[], /* Process the command line arguments */ /* 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 [] [pid] [id] [] [w32] [no-unzip]\n", argv[0] ); log_info( "\t\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( "\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++ ) - { - log_info( "\t\t%s\n", spir_suites[i].name ); - } + ListTests(); + return 0; + } + else if (!strcmp(argv[1], "--list") || !strcmp(argv[1], "-list")) + { + ListTests(); return 0; } diff --git a/test_conformance/spirv_new/main.cpp b/test_conformance/spirv_new/main.cpp index 98ce18e8..b5421f92 100644 --- a/test_conformance/spirv_new/main.cpp +++ b/test_conformance/spirv_new/main.cpp @@ -216,6 +216,7 @@ int main(int argc, const char *argv[]) { gReSeed = 1; bool modifiedSpvBinariesPath = false; + bool listTests = false; for (int i = 0; i < argc; ++i) { int argsRemoveNum = 0; if (argv[i] == spvBinariesPathArg) { @@ -241,9 +242,12 @@ int main(int argc, const char *argv[]) argc -= argsRemoveNum; --i; } + listTests |= (argv[i] == std::string("--list") + || argv[i] == std::string("-list")); } - if (modifiedSpvBinariesPath == false) { - printUsage(); + if (modifiedSpvBinariesPath == false && !listTests) + { + printUsage(); } return runTestHarnessWithCheck(