Skip to content

Commit

Permalink
Extended printf test to verify length sub-specifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
shajder committed Sep 13, 2024
1 parent 9116bb7 commit 37c9625
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 1 deletion.
7 changes: 7 additions & 0 deletions test_conformance/printf/test_printf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,12 @@ int test_mixed_format_random(cl_device_id deviceID, cl_context context,
return doTest(gQueue, gContext, TYPE_MIXED_FORMAT_RANDOM, deviceID);
}

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

int test_buffer_size(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
{
Expand Down Expand Up @@ -1060,6 +1066,7 @@ test_definition test_list[] = {
ADD_TEST(address_space),
ADD_TEST(buffer_size),
ADD_TEST(mixed_format_random),
ADD_TEST(length_specifier),
};

const int test_num = ARRAY_SIZE( test_list );
Expand Down
1 change: 1 addition & 0 deletions test_conformance/printf/test_printf.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ enum PrintfTestType
TYPE_VECTOR,
TYPE_ADDRESS_SPACE,
TYPE_MIXED_FORMAT_RANDOM,
TYPE_LENGTH_SPECIFIER,
TYPE_COUNT
};

Expand Down
100 changes: 99 additions & 1 deletion test_conformance/printf/util_printf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1397,6 +1397,104 @@ testCase testCaseMixedFormat = { TYPE_MIXED_FORMAT_RANDOM,
correctBufferMixedFormat,
printMixedFormatGenParameters, NULL };


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

// length sub-specifier format

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

std::vector<printDataGenParameters> printLenSpecGenParameters = {

{ { "%hd" }, "32767" },

{ { "%hhd" }, "127" },

{ { "%ld" }, "9223372036854775807L" },

{ { "%hhd" }, "-128" },

{ { "%ld" }, "-9223372036854775807L" },

{ { "%hx" }, "32767" },

{ { "%hhx" }, "127" },

{ { "%lx" }, "9223372036854775807L" },

{ { "%hhx" }, "-128" },

{ { "%lx" }, "-9223372036854775807L" },

{ { "%ho" }, "32767" },

{ { "%hho" }, "127" },

{ { "%lo" }, "9223372036854775807L" },

{ { "%hho" }, "-128" },

{ { "%lo" }, "-9223372036854775807L" },
};

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

// Lookup table -[string] length specified correct buffer

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

std::vector<std::string> correctBufferLenSpec = {

"32767",

"127",

"9223372036854775807",

"-128",

"-9223372036854775807",

"7fff",

"7f",

"7fffffffffffffff",

"80",

"8000000000000001",

"77777",

"177",

"777777777777777777777",

"200",

"1000000000000000000001",
};


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

// Test case for length specified values

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

testCase testCaseLenSpec = {

TYPE_LENGTH_SPECIFIER,

correctBufferLenSpec,

printLenSpecGenParameters,

NULL

};

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

//All Test cases |
Expand All @@ -1409,7 +1507,7 @@ std::vector<testCase*> allTestCase = {
&testCaseDoubleLimits, &testCaseOctal, &testCaseUnsigned,
&testCaseHexadecimal, &testCaseChar, &testCaseString,
&testCaseFormatString, &testCaseVector, &testCaseAddrSpace,
&testCaseMixedFormat
&testCaseMixedFormat, &testCaseLenSpec
};

//-----------------------------------------
Expand Down

0 comments on commit 37c9625

Please sign in to comment.