Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added printf test for long type cases #2037

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions test_conformance/printf/test_printf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,13 @@ int doTest(cl_command_queue queue, cl_context context,
return TEST_SKIPPED_ITSELF;
}

if ((allTestCase[testId]->_type == TYPE_LONG) && !isLongSupported(device))
{
log_info("Skipping long because non-embeded test or cles_khr_int64 "
svenvh marked this conversation as resolved.
Show resolved Hide resolved
"extension is not supported.\n");
return TEST_SKIPPED_ITSELF;
}

auto& genParams = allTestCase[testId]->_genParameters;

auto fail_count = s_test_fail;
Expand Down Expand Up @@ -911,6 +918,12 @@ int test_int(cl_device_id deviceID, cl_context context, cl_command_queue queue,
return doTest(gQueue, gContext, TYPE_INT, deviceID);
}

int test_long(cl_device_id deviceID, cl_context context, cl_command_queue queue,
int num_elements)
{
return doTest(gQueue, gContext, TYPE_LONG, deviceID);
}

int test_half(cl_device_id deviceID, cl_context context, cl_command_queue queue,
int num_elements)
{
Expand Down Expand Up @@ -1015,21 +1028,14 @@ int test_buffer_size(cl_device_id deviceID, cl_context context,
}

test_definition test_list[] = {
ADD_TEST(int),
ADD_TEST(half),
ADD_TEST(half_limits),
ADD_TEST(float),
ADD_TEST(float_limits),
ADD_TEST(octal),
ADD_TEST(unsigned),
ADD_TEST(hexadecimal),
ADD_TEST(char),
ADD_TEST(string),
ADD_TEST(format_string),
ADD_TEST(vector),
ADD_TEST(address_space),
ADD_TEST(buffer_size),
ADD_TEST(mixed_format_random),
ADD_TEST(int), ADD_TEST(long),
ADD_TEST(half), ADD_TEST(half_limits),
ADD_TEST(float), ADD_TEST(float_limits),
ADD_TEST(octal), ADD_TEST(unsigned),
ADD_TEST(hexadecimal), ADD_TEST(char),
ADD_TEST(string), ADD_TEST(format_string),
ADD_TEST(vector), ADD_TEST(address_space),
ADD_TEST(buffer_size), ADD_TEST(mixed_format_random),
};

const int test_num = ARRAY_SIZE( test_list );
Expand Down
2 changes: 2 additions & 0 deletions test_conformance/printf/test_printf.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
enum PrintfTestType
{
TYPE_INT,
TYPE_LONG,
TYPE_HALF,
TYPE_HALF_LIMITS,
TYPE_FLOAT,
Expand Down Expand Up @@ -78,6 +79,7 @@ struct printDataGenParameters

// Reference results - filled out at run-time
static std::vector<std::string> correctBufferInt;
static std::vector<std::string> correctBufferLong;
static std::vector<std::string> correctBufferHalf;
static std::vector<std::string> correctBufferFloat;
static std::vector<std::string> correctBufferOctal;
Expand Down
85 changes: 80 additions & 5 deletions test_conformance/printf/util_printf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

// Helpers for generating runtime reference results
static void intRefBuilder(printDataGenParameters&, char*, const size_t);
static void longRefBuilder(printDataGenParameters&, char*, const size_t);
static void halfRefBuilder(printDataGenParameters&, char* rResult,
const size_t);
static void floatRefBuilder(printDataGenParameters&, char* rResult, const size_t);
Expand Down Expand Up @@ -105,6 +106,73 @@ testCase testCaseInt = {
};


//==================================

// long

//==================================

//------------------------------------------------------

// [string] format | [string] int-data representation |

//------------------------------------------------------

std::vector<printDataGenParameters> printLongGenParameters = {

//(Minimum) fifteen-wide,default(right)-justified

{ { "%5d" }, "10000000000L" },
svenvh marked this conversation as resolved.
Show resolved Hide resolved

//(Minimum) fifteen-wide,left-justified

{ { "%-15d" }, "-10000000000L" },

//(Minimum) fifteen-wide,default(right)-justified,zero-filled

{ { "%015d" }, "10000000000L" },

//(Minimum) fifteen-wide,default(right)-justified,with sign

{ { "%+15d" }, "-10000000000L" },

//(Minimum) fifteen-wide ,left-justified,with sign

{ { "%-+15d" }, "10000000000L" },

//(Minimum) fifteen-digit(zero-filled in absent
// digits),default(right)-justified

{ { "%.15i" }, "10000000000L" },

//(Minimum)Sixteen-wide, fifteen-digit(zero-filled in absent
// digits),default(right)-justified

{ { "%-+16.15i" }, "-10000000000L" },

};

//-----------------------------------------------

// test case for long |

//-----------------------------------------------

testCase testCaseLong = {

TYPE_LONG,

correctBufferLong,

printLongGenParameters,

longRefBuilder,

klong

};


//==============================================

// half
Expand Down Expand Up @@ -1134,11 +1202,11 @@ testCase testCaseMixedFormat = { TYPE_MIXED_FORMAT_RANDOM,
//-------------------------------------------------------------------------------

std::vector<testCase*> allTestCase = {
&testCaseInt, &testCaseHalf, &testCaseHalfLimits,
&testCaseFloat, &testCaseFloatLimits, &testCaseOctal,
&testCaseUnsigned, &testCaseHexadecimal, &testCaseChar,
&testCaseString, &testCaseFormatString, &testCaseVector,
&testCaseAddrSpace, &testCaseMixedFormat
&testCaseInt, &testCaseLong, &testCaseHalf,
&testCaseHalfLimits, &testCaseFloat, &testCaseFloatLimits,
&testCaseOctal, &testCaseUnsigned, &testCaseHexadecimal,
&testCaseChar, &testCaseString, &testCaseFormatString,
&testCaseVector, &testCaseAddrSpace, &testCaseMixedFormat
};

//-----------------------------------------
Expand Down Expand Up @@ -1255,6 +1323,13 @@ static void intRefBuilder(printDataGenParameters& params, char* refResult, const
atoi(params.dataRepresentation));
}

static void longRefBuilder(printDataGenParameters& params, char* refResult,
const size_t refSize)
{
snprintf(refResult, refSize, params.genericFormats.front().c_str(),
atoll(params.dataRepresentation));
}

static void halfRefBuilder(printDataGenParameters& params, char* refResult,
const size_t refSize)
{
Expand Down
Loading