Move printing sub-test information into test harness (#421)

This removes all the duplicated code from each test, and moves it to
test harness so that we have single place where this information is
printed.

Signed-off-by: Radek Szymanski <radek.szymanski@arm.com>
This commit is contained in:
Radek Szymanski
2019-08-05 15:16:12 +01:00
committed by Kévin Petit
parent 19951a2a14
commit 03650057bb
26 changed files with 87 additions and 184 deletions

View File

@@ -22,8 +22,6 @@
#include <malloc.h>
#endif
int gTestCount = 0;
int gTestFailure = 0;
RoundingMode gFloatToHalfRoundingMode = kDefaultRoundingMode;
static cl_ushort float2half_rte( float f );
@@ -3719,8 +3717,6 @@ bool check_minimum_supported( cl_image_format *formatList, unsigned int numForma
{
log_error( "ERROR: Format required by OpenCL 1.0 is not supported: " );
print_header( &formatsToTest[ i ], true );
gTestCount++;
gTestFailure++;
passed = false;
}
}

View File

@@ -40,8 +40,6 @@
#include "rounding_mode.h"
#include "clImageHelper.h"
extern int gTestCount;
extern int gTestFailure;
extern cl_device_type gDeviceType;
// Number of iterations per image format to test if not testing max images, rounding, or small images

View File

@@ -40,6 +40,8 @@
int gTestsPassed = 0;
int gTestsFailed = 0;
int gFailCount;
int gTestCount;
cl_uint gRandomSeed = 0;
cl_uint gReSeed = 0;
@@ -568,6 +570,37 @@ static int saveResultsToJson( const char *fileName, const char *suiteName, test_
return ret;
}
static void print_results( int failed, int count, const char* name )
{
if( count < failed )
{
count = failed;
}
if( failed == 0 )
{
if( count > 1 )
{
log_info( "PASSED %d of %d %ss.\n", count, count, name );
}
else
{
log_info( "PASSED %s.\n", name );
}
}
else if( failed > 0 )
{
if( count > 1 )
{
log_error( "FAILED %d of %d %ss.\n", failed, count, name );
}
else
{
log_error( "FAILED %s.\n", name );
}
}
}
int parseAndCallCommandLineTests( int argc, const char *argv[], cl_device_id device, int testNum,
test_definition testList[], int forceNoContextCreation,
cl_command_queue_properties queueProps, int num_elements )
@@ -617,28 +650,8 @@ int parseAndCallCommandLineTests( int argc, const char *argv[], cl_device_id dev
callTestFunctions( testList, selectedTestList, resultTestList, testNum, device,
forceNoContextCreation, num_elements, queueProps );
if( gTestsFailed == 0 )
{
if( gTestsPassed > 1 )
{
log_info("PASSED %d of %d tests.\n", gTestsPassed, gTestsPassed);
}
else if( gTestsPassed > 0 )
{
log_info("PASSED test.\n");
}
}
else if( gTestsFailed > 0 )
{
if( gTestsFailed+gTestsPassed > 1 )
{
log_error("FAILED %d of %d tests.\n", gTestsFailed, gTestsFailed+gTestsPassed);
}
else
{
log_error("FAILED test.\n");
}
}
print_results( gFailCount, gTestCount, "sub-test" );
print_results( gTestsFailed, gTestsFailed + gTestsPassed, "test" );
char *filename = getenv( "CL_CONFORMANCE_RESULTS_FILENAME" );
if( filename != NULL )

View File

@@ -69,6 +69,8 @@ typedef enum test_status
TEST_SKIP = 2,
} test_status;
extern int gFailCount;
extern int gTestCount;
extern cl_uint gReSeed;
extern cl_uint gRandomSeed;