mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
Extended printf test with new strings cases (#1951)
According to work plan from issue #1058 Corrections to general test: -removed duplication of separate tests for each element of `PrintfTestType` vector, instead `doTest` procedure would iterate over vector related to specific `PrintfTestType` automaticaly -fixed procedure to assemble kernel source so it can accept only one parameter of the function ( eg. `printf("%%");` ) -incorporated important modifications from #1940 to avoid expected conflicts -warnings fixes, minor corrections, clang format Extension for string testing: -special symbols -nested symbols -all ascii characters -added new type of test `TYPE_FORMAT_STRING` to verify format string only (according to request from the issue)
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -55,6 +55,7 @@ enum PrintfTestType
|
||||
TYPE_HEXADEC,
|
||||
TYPE_CHAR,
|
||||
TYPE_STRING,
|
||||
TYPE_FORMAT_STRING,
|
||||
TYPE_VECTOR,
|
||||
TYPE_ADDRESS_SPACE,
|
||||
TYPE_COUNT
|
||||
|
||||
@@ -708,6 +708,7 @@ testCase testCaseChar = {
|
||||
// [string]format | [string] string-data representation |
|
||||
|
||||
//--------------------------------------------------------
|
||||
// clang-format off
|
||||
|
||||
std::vector<printDataGenParameters> printStringGenParameters = {
|
||||
|
||||
@@ -721,7 +722,32 @@ std::vector<printDataGenParameters> printStringGenParameters = {
|
||||
|
||||
//%% specification
|
||||
|
||||
{ { "%s" }, "\"%%\"" },
|
||||
{ {"%s"}, "\"%%\"" },
|
||||
|
||||
// special symbols
|
||||
// nested
|
||||
|
||||
{ {"%s"}, "\"\\\"%%\\\"\"" },
|
||||
|
||||
{ {"%s"}, "\"\\\'%%\\\'\"" },
|
||||
|
||||
// tabs
|
||||
|
||||
{ {"%s"}, "\"foo\\tfoo\"" },
|
||||
|
||||
// newlines
|
||||
|
||||
{ {"%s"}, "\"foo\\nfoo\"" },
|
||||
|
||||
// terminator
|
||||
{ {"%s"}, "\"foo\\0foo\"" },
|
||||
|
||||
// all ascii characters
|
||||
{ {"%s"},
|
||||
"\" "
|
||||
"!\\\"#$%&\'()*+,-./"
|
||||
"0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`"
|
||||
"abcdefghijklmnopqrstuvwxyz{|}~\"" }
|
||||
};
|
||||
|
||||
//---------------------------------------------------------
|
||||
@@ -737,8 +763,22 @@ std::vector<std::string> correctBufferString = {
|
||||
"f",
|
||||
|
||||
"%%",
|
||||
};
|
||||
|
||||
"\"%%\"",
|
||||
|
||||
"\'%%\'",
|
||||
|
||||
"foo\tfoo",
|
||||
|
||||
R"(foo
|
||||
foo)",
|
||||
|
||||
"foo",
|
||||
|
||||
" !\"#$%&\'()*+,-./"
|
||||
"0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`"
|
||||
"abcdefghijklmnopqrstuvwxyz{|}~"
|
||||
};
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
||||
@@ -760,7 +800,86 @@ testCase testCaseString = {
|
||||
|
||||
};
|
||||
|
||||
//--------------------------------------------------------
|
||||
|
||||
// [string]format |
|
||||
|
||||
//--------------------------------------------------------
|
||||
|
||||
std::vector<printDataGenParameters> printFormatStringGenParameters = {
|
||||
|
||||
//%% specification
|
||||
|
||||
{ {"%%"} },
|
||||
|
||||
// special symbols
|
||||
// nested
|
||||
|
||||
{ {"\\\"%%\\\""} },
|
||||
|
||||
{ {"\'%%\'"} },
|
||||
|
||||
// tabs
|
||||
|
||||
{ {"foo\\t\\t\\tfoo"} },
|
||||
|
||||
// newlines
|
||||
|
||||
{ {"foo\\nfoo"} },
|
||||
|
||||
// all ascii characters
|
||||
{ {
|
||||
" !\\\"#$%%&\'()*+,-./"
|
||||
"0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`"
|
||||
"abcdefghijklmnopqrstuvwxyz{|}~"
|
||||
} }
|
||||
};
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
||||
// Lookup table -[string] string-correct buffer |
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
||||
std::vector<std::string> correctBufferFormatString = {
|
||||
|
||||
"%",
|
||||
|
||||
"\"%\"",
|
||||
|
||||
"\'%\'",
|
||||
|
||||
"foo\t\t\tfoo",
|
||||
|
||||
R"(foo
|
||||
foo)",
|
||||
|
||||
" !\"#$%&\'()*+,-./"
|
||||
"0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`"
|
||||
"abcdefghijklmnopqrstuvwxyz{|}~"
|
||||
};
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
||||
//Test case for string |
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
||||
testCase testCaseFormatString = {
|
||||
|
||||
TYPE_FORMAT_STRING,
|
||||
|
||||
correctBufferFormatString,
|
||||
|
||||
printFormatStringGenParameters,
|
||||
|
||||
NULL,
|
||||
|
||||
kchar
|
||||
|
||||
};
|
||||
|
||||
// clang-format on
|
||||
|
||||
//=========================================================
|
||||
|
||||
@@ -968,10 +1087,11 @@ testCase testCaseAddrSpace = {
|
||||
//-------------------------------------------------------------------------------
|
||||
|
||||
std::vector<testCase*> allTestCase = {
|
||||
&testCaseInt, &testCaseHalf, &testCaseHalfLimits,
|
||||
&testCaseFloat, &testCaseFloatLimits, &testCaseOctal,
|
||||
&testCaseUnsigned, &testCaseHexadecimal, &testCaseChar,
|
||||
&testCaseString, &testCaseVector, &testCaseAddrSpace
|
||||
&testCaseInt, &testCaseHalf, &testCaseHalfLimits,
|
||||
&testCaseFloat, &testCaseFloatLimits, &testCaseOctal,
|
||||
&testCaseUnsigned, &testCaseHexadecimal, &testCaseChar,
|
||||
&testCaseString, &testCaseFormatString, &testCaseVector,
|
||||
&testCaseAddrSpace
|
||||
};
|
||||
|
||||
//-----------------------------------------
|
||||
@@ -996,14 +1116,14 @@ size_t verifyOutputBuffer(char *analysisBuffer,testCase* pTestCase,size_t testId
|
||||
if(pTestCase->_type == TYPE_ADDRESS_SPACE && strcmp(pTestCase->_genParameters[testId].addrSpacePAdd,""))
|
||||
|
||||
{
|
||||
char analysisBufferTmp[ANALYSIS_BUFFER_SIZE];
|
||||
char analysisBufferTmp[ANALYSIS_BUFFER_SIZE + 1];
|
||||
|
||||
if(strstr(analysisBuffer,"0x") == NULL)
|
||||
// Need to prepend 0x to ASCII number before calling strtol.
|
||||
strcpy(analysisBufferTmp,"0x");
|
||||
|
||||
else analysisBufferTmp[0]='\0';
|
||||
strcat(analysisBufferTmp,analysisBuffer);
|
||||
strncat(analysisBufferTmp, analysisBuffer, ANALYSIS_BUFFER_SIZE);
|
||||
if (sizeof(long) == 8) {
|
||||
if(strtoul(analysisBufferTmp,NULL,0) == pAddr) return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user