Return a non-zero exit-code when a sub-test fails (#951)

When running sub-tests explicitly on the command line and that sub-test
fails, the test harness returns `0` from `main()`. This is problematic
in automated testing environments as failed tests can be hidden.

This patch iterates over all the test results in the `resultTestList`
after all sub-tests have completed, if any of the tests failed a
non-zero value is returned from `parseAndCallCommandLineTests()` which
is then propagated up the call stack to `main()`.
This commit is contained in:
Kenneth Benzie
2020-10-20 07:08:40 +01:00
committed by GitHub
parent b165de7649
commit 8d44302935

View File

@@ -15,6 +15,7 @@
// //
#include "testHarness.h" #include "testHarness.h"
#include "compat.h" #include "compat.h"
#include <algorithm>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@@ -639,6 +640,19 @@ int parseAndCallCommandLineTests( int argc, const char *argv[], cl_device_id dev
} }
} }
if (std::any_of(resultTestList, resultTestList + testNum,
[](test_status result) {
switch (result)
{
case TEST_PASS:
case TEST_SKIP: return false;
case TEST_FAIL: return true;
};
}))
{
ret = EXIT_FAILURE;
}
free( selectedTestList ); free( selectedTestList );
free( resultTestList ); free( resultTestList );