Use a static array of testdata, to initialize stub pointer

Simplified function pointer parameter handling by introducing STUB_PARAMETER_POINTER_HANDLING_CONTENT for pointer tests
This commit is contained in:
2021-12-24 00:19:07 +01:00
parent d7f6efd0a6
commit 5782449388
2 changed files with 101 additions and 109 deletions

View File

@@ -181,7 +181,7 @@ STATIC void createVariableSpecificCheck(FILE *aFile, cfile_variable_t *aVariable
} }
} }
STATIC void createParameterSpecificCheck(FILE *aFile, cfunction_t *aFunction, cfunction_parameter_t *aParameter, char aParameterIndex) STATIC void createParameterSpecificCheck(char *aNoSuffix, FILE *aFile, cfunction_t *aFunction, cfunction_parameter_t *aParameter, char aParameterIndex)
{ {
// skip parameter without dataType // skip parameter without dataType
if (NULL == aParameter->dataType) if (NULL == aParameter->dataType)
@@ -195,69 +195,49 @@ STATIC void createParameterSpecificCheck(FILE *aFile, cfunction_t *aFunction, cf
fprintf(aFile, STUBINIT_PARAM_PARAMETER_S1", "STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_S1"]."STUBPARAMETER_PARAM_S1, aParameterIndex, aFunction->name, fprintf(aFile, STUBINIT_PARAM_PARAMETER_S1", "STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_S1"]."STUBPARAMETER_PARAM_S1, aParameterIndex, aFunction->name,
aFunction->name, aParameterIndex); aFunction->name, aParameterIndex);
fprintf(aFile, ");"NEWLINES); fprintf(aFile, ");"NEWLINES);
fprintf(aFile, "\t"STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_S1"]."STUBPARAMETER_PARAM_S1" = (%s) "STUBDEFAULT_VALUE_POINTER_S";" NEWLINES, aFunction->name, fprintf(aFile, "\t"STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_S1"]."STUBPARAMETER_PARAM_S1" = (%s) "STUBDEFAULT_VALUE_POINTER_S1";" NEWLINES, aFunction->name,
aFunction->name, aParameterIndex, aParameter->dataType); aFunction->name, aParameterIndex, aParameter->dataType, aNoSuffix);
} }
else if (NULL != strstr(aParameter->dataType, "*") // else if (NULL != strstr(aParameter->dataType, "*") || NULL != aParameter->array) //
&& NULL != strstr(aParameter->dataType, "char") // handle char* as strings
&& NULL == strstr(aParameter->dataType, "uchar")) // don't handle uchar (-> signed warning for strlen)
{ {
// char array with string comparison // char array with string comparison
fprintf(aFile, "\tif (" // fprintf(aFile, "\tif (" //
STUBPARAMETER_POINTERHANDLING_ADDRESS_S " == " STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_S1"]."STUBPARAMETER_POINTERHANDLING_S// STUBPARAMETER_POINTERHANDLING_ADDRESS_S " == " STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_S1"]."STUBPARAMETER_POINTERHANDLING_S//
")" NEWLINES "\t{" NEWLINES, aFunction->name, aFunction->name); ")" NEWLINES "\t{" NEWLINES, aFunction->name, aFunction->name);
// only assert if result should not be ignored (_size parameter) // only assert if result should not be ignored (_size parameter)
fprintf(aFile, "\t\tif ("STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_S1"]."STUBPARAMETER_PARAM_S1"_size)" NEWLINES, //
aFunction->name, aFunction->name, aParameterIndex);
fprintf(aFile, "\t\t\tCU_ASSERT_PTR_EQUAL(");
fprintf(aFile, STUBINIT_PARAM_PARAMETER_S1", "STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_S1"]."STUBPARAMETER_PARAM_S1");" NEWLINES, //
aParameterIndex, aFunction->name, aFunction->name, aParameterIndex);
fprintf(aFile, "\t}" NEWLINES);
// STUB_PARAMETER_POINTER_HANDLING_CONTENT
fprintf(aFile, "\telse if (" //
STUBPARAMETER_POINTERHANDLING_CONTENT_S " == " STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_S1"]."STUBPARAMETER_POINTERHANDLING_S//
")" NEWLINES "\t{" NEWLINES, aFunction->name, aFunction->name);
fprintf(aFile, "\t\tif ("STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_S1"]."STUBPARAMETER_PARAM_S1"_size)" NEWLINES, aFunction->name, aFunction->name, fprintf(aFile, "\t\tif ("STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_S1"]."STUBPARAMETER_PARAM_S1"_size)" NEWLINES, aFunction->name, aFunction->name,
aParameterIndex); aParameterIndex);
fprintf(aFile, "\t\t\tCU_ASSERT_MEMORY_CHECK(\"%s(%s)\", ", aFunction->name, aParameter->name); fprintf(aFile, "\t\t\tCU_ASSERT_MEMORY_CHECK(\"%s(%s)\", ", aFunction->name, aParameter->name);
fprintf(aFile, STUBINIT_PARAM_PARAMETER_S1", "STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_S1"]."STUBPARAMETER_PARAM_S1, aParameterIndex, aFunction->name, fprintf(aFile, STUBINIT_PARAM_PARAMETER_S1", "STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_S1"]."STUBPARAMETER_PARAM_S1, aParameterIndex, aFunction->name,
aFunction->name, aParameterIndex); aFunction->name, aParameterIndex);
fprintf(aFile, ", strlen("STUBINIT_PARAM_PARAMETER_S1"));"NEWLINES, aParameterIndex); fprintf(aFile, ", "STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_S1"]."STUBPARAMETER_PARAM_S1"_size);" NEWLINES, //
fprintf(aFile, "\t}" NEWLINES);
// injection only for non constant and non NULL parameter
if (NULL == strstr(aParameter->dataType, CPARS_ELEMENT_CONST))
{
fprintf(aFile, "\telse if (NULL != " STUBINIT_PARAM_PARAMETER_S1 ")" NEWLINES "\t{" NEWLINES, aParameterIndex);
fprintf(aFile, "\t\tmemcpy(" STUBINIT_PARAM_PARAMETER_S1 ", "STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_S1"]."STUBPARAMETER_PARAM_S1", " //
STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_S1"]."STUBPARAMETER_PARAM_S1"_size",//
aParameterIndex, aFunction->name, aFunction->name, aParameterIndex, aFunction->name, aFunction->name, aParameterIndex);
fprintf(aFile, ");" NEWLINES);
fprintf(aFile, "\t}" NEWLINES);
}
fprintf(aFile, "\t"STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_S1"]."STUBPARAMETER_PARAM_S1" = (%s) "STUBDEFAULT_VALUE_POINTER_S";" NEWLINES, aFunction->name,
aFunction->name, aParameterIndex, aParameter->dataType);
fprintf(aFile, "\t"STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_S1"]."STUBPARAMETER_PARAM_S1"_size = "STUBDEFAULT_VALUE_POINTERSIZE_S";" NEWLINES,
aFunction->name, aFunction->name, aParameterIndex); aFunction->name, aFunction->name, aParameterIndex);
}
else if (NULL != strstr(aParameter->dataType, "*") || NULL != aParameter->array)
{
// pointer
fprintf(aFile, "\tif (" //
STUBPARAMETER_POINTERHANDLING_ADDRESS_S " == " STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_S1"]."STUBPARAMETER_POINTERHANDLING_S//
")" NEWLINES "\t{" NEWLINES, aFunction->name, aFunction->name);
// only assert if result should not be ignored (_size parameter)
fprintf(aFile, "\t\tif ("STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_S1"]."STUBPARAMETER_PARAM_S1"_size)" NEWLINES, aFunction->name, aFunction->name,
aParameterIndex);
fprintf(aFile, "\t\t\tCU_ASSERT_PTR_EQUAL(");
fprintf(aFile, STUBINIT_PARAM_PARAMETER_S1", "STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_S1"]."STUBPARAMETER_PARAM_S1, aParameterIndex, aFunction->name,
aFunction->name, aParameterIndex);
fprintf(aFile, ");" NEWLINES);
fprintf(aFile, "\t}" NEWLINES); fprintf(aFile, "\t}" NEWLINES);
// injection only for non constant and non NULL parameter // injection only for non constant and non NULL parameter
if (NULL == strstr(aParameter->dataType, CPARS_ELEMENT_CONST)) if (NULL == strstr(aParameter->dataType, CPARS_ELEMENT_CONST))
{ {
fprintf(aFile, "\telse if (NULL != " STUBINIT_PARAM_PARAMETER_S1 ")" NEWLINES "\t{" NEWLINES, aParameterIndex); fprintf(aFile, "\telse if (NULL != " STUBINIT_PARAM_PARAMETER_S1 ")" NEWLINES "\t{" NEWLINES, aParameterIndex);
fprintf(aFile, "\t\tmemcpy(" STUBINIT_PARAM_PARAMETER_S1 ", "STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_S1"]."STUBPARAMETER_PARAM_S1", " // fprintf(aFile, "\t\tmemcpy(" STUBINIT_PARAM_PARAMETER_S1 ", "STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_S1"]."STUBPARAMETER_PARAM_S1", " //
STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_S1"]."STUBPARAMETER_PARAM_S1"_size",// STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_S1"]."STUBPARAMETER_PARAM_S1"_size);" NEWLINES,//
aParameterIndex, aFunction->name, aFunction->name, aParameterIndex, aFunction->name, aFunction->name, aParameterIndex); aParameterIndex, aFunction->name, aFunction->name, aParameterIndex, aFunction->name, aFunction->name, aParameterIndex);
fprintf(aFile, ");" NEWLINES);
fprintf(aFile, "\t}" NEWLINES); fprintf(aFile, "\t}" NEWLINES);
} }
fprintf(aFile, "\t"STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_S1"]."STUBPARAMETER_PARAM_S1" = (%s%s) "STUBDEFAULT_VALUE_POINTER_S";" NEWLINES, // fprintf(aFile, "\t"STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_S1"]."STUBPARAMETER_PARAM_S1" = (%s%s) "STUBDEFAULT_VALUE_POINTER_S1";" NEWLINES, //
aFunction->name, // STUBPARAMETER_STRUCT_S1 aFunction->name, // STUBPARAMETER_STRUCT_S1
aFunction->name, // STUBINSTANCE_S1 aFunction->name, // STUBINSTANCE_S1
aParameterIndex, // STUBPARAMETER_PARAM_S1, aParameterIndex, // STUBPARAMETER_PARAM_S1,
aParameter->dataType, (NULL == strstr(aParameter->dataType, "*") ? "*" : "")); // cast array only parameter to be pointer aParameter->dataType, (NULL == strstr(aParameter->dataType, "*") ? "*" : ""), // cast array only parameter to be pointer
aNoSuffix);
fprintf(aFile, "\t"STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_S1"]."STUBPARAMETER_PARAM_S1"_size = "STUBDEFAULT_VALUE_POINTERSIZE_S";" NEWLINES, fprintf(aFile, "\t"STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_S1"]."STUBPARAMETER_PARAM_S1"_size = "STUBDEFAULT_VALUE_POINTERSIZE_S";" NEWLINES,
aFunction->name, aFunction->name, aParameterIndex); aFunction->name, aFunction->name, aParameterIndex);
} }
@@ -414,14 +394,14 @@ STATIC int8_t createStubCheck(char *aNoSuffix, FILE *aFile, FILE *aHeader, cfile
return 0; return 0;
} }
STATIC int8_t createStubFunctionBlock(FILE *aFile, FILE *aHeader, cfunction_t *aFunction) STATIC int8_t createStubFunctionBlock(char *aNoSuffix, FILE *aFile, FILE *aHeader, cfunction_t *aFunction)
{ {
cfunction_parameter_t *parameter = NULL; cfunction_parameter_t *parameter = NULL;
char parameterIndex = STUBDEFAULT_PARAMETER_INDEX_CHAR; char parameterIndex = STUBDEFAULT_PARAMETER_INDEX_CHAR;
char *dataTypeTemp = NULL; char *dataTypeTemp = NULL;
bool pointerAvailable = false; bool pointerAvailable = false;
if (NULL == aFile || NULL == aHeader || NULL == aFunction) if (NULL == aNoSuffix || NULL == aFile || NULL == aHeader || NULL == aFunction)
{ {
return -1; return -1;
} }
@@ -556,10 +536,11 @@ STATIC int8_t createStubFunctionBlock(FILE *aFile, FILE *aHeader, cfunction_t *a
// initialize _size parameter to 1 (default to check addresses) // initialize _size parameter to 1 (default to check addresses)
if (CPARAMETER_TYPE_FUNCPTR != parameter->type && (parameter->array || NULL != strstr(parameter->dataType, "*"))) if (CPARAMETER_TYPE_FUNCPTR != parameter->type && (parameter->array || NULL != strstr(parameter->dataType, "*")))
{ {
fprintf(aFile, "\t[0 ... %u]."STUBPARAMETER_PARAM_S1" = (%s%s) "STUBDEFAULT_VALUE_POINTER_S"," NEWLINES, // fprintf(aFile, "\t[0 ... %u]."STUBPARAMETER_PARAM_S1" = (%s%s) "STUBDEFAULT_VALUE_POINTER_S1"," NEWLINES, //
STUB_INSTANCES_AMOUNT - 1, parameterIndex, //STUBDEFAULT_VALUE_POINTER_S STUB_INSTANCES_AMOUNT - 1, parameterIndex, //STUBDEFAULT_VALUE_POINTER_S
parameter->dataType, // parameter->dataType, //
(NULL == strstr(parameter->dataType, "*") ? "*" : "")); // cast array only parameter to be pointer (NULL == strstr(parameter->dataType, "*") ? "*" : ""), // cast array only parameter to be pointer
aNoSuffix);
fprintf(aFile, "\t[0 ... %u]."STUBPARAMETER_PARAM_S1"_size = 1," NEWLINES, STUB_INSTANCES_AMOUNT - 1, parameterIndex); fprintf(aFile, "\t[0 ... %u]."STUBPARAMETER_PARAM_S1"_size = 1," NEWLINES, STUB_INSTANCES_AMOUNT - 1, parameterIndex);
} }
else else
@@ -711,81 +692,85 @@ STATIC int8_t createStubFunctionBlock(FILE *aFile, FILE *aHeader, cfunction_t *a
fprintf(aFile, "\t"STUBPARAMETER_STRUCT_S1"["STUBINIT_PARAM_INSTANCE_S"]."STUBPARAMETER_CALLTEST_S" = "STUBINIT_PARAM_CALLTEST_S";" NEWLINES, fprintf(aFile, "\t"STUBPARAMETER_STRUCT_S1"["STUBINIT_PARAM_INSTANCE_S"]."STUBPARAMETER_CALLTEST_S" = "STUBINIT_PARAM_CALLTEST_S";" NEWLINES,
aFunction->name); aFunction->name);
// if STUB_CALL_PASS is requested init with parameter if (aFunction->parameter.amount)
fprintf(aFile, "\tif ( STUB_CALL_PASS == " STUBINIT_PARAM_CALLTEST_S ")" NEWLINES "\t{" NEWLINES);
if (pointerAvailable)
{ {
fprintf(aFile, // if STUB_CALL_PASS is requested init with parameter
"\t\t"STUBPARAMETER_STRUCT_S1"["STUBINIT_PARAM_INSTANCE_S"]."STUBPARAMETER_POINTERHANDLING_S" = "STUBINIT_PARAM_POINTERHANDLING_S";" NEWLINES, fprintf(aFile, "\tif ( STUB_CALL_PASS == " STUBINIT_PARAM_CALLTEST_S ")" NEWLINES "\t{" NEWLINES);
aFunction->name); if (pointerAvailable)
}
if (!isDatatypeVoid(aFunction->dataType))
{
fprintf(aFile, "\t\t"STUBPARAMETER_STRUCT_S1"["STUBINIT_PARAM_INSTANCE_S"]."STUBPARAMETER_RETURN_S" = "STUBINIT_PARAM_RETURN_S";" NEWLINES,
aFunction->name);
}
parameter = aFunction->parameter.head;
parameterIndex = STUBDEFAULT_PARAMETER_INDEX_CHAR;
while (parameter)
{
// skip parameter without dataType
if (NULL == parameter->dataType)
{
parameter = parameter->next;
continue;
}
fprintf(aFile, "\t\t"STUBPARAMETER_STRUCT_S1"["STUBINIT_PARAM_INSTANCE_S"]."STUBPARAMETER_PARAM_S1" = "STUBINIT_PARAM_PARAMETER_S1";" NEWLINES,
aFunction->name, parameterIndex, parameterIndex);
if ((NULL != strstr(parameter->dataType, "*") || parameter->array) && CPARAMETER_TYPE_FUNCPTR != parameter->type)
{ {
fprintf(aFile, fprintf(aFile,
"\t\t"STUBPARAMETER_STRUCT_S1"["STUBINIT_PARAM_INSTANCE_S"]."STUBPARAMETER_PARAM_S1"_size = "STUBINIT_PARAM_PARAMETER_S1"_size;" NEWLINES, "\t\t"STUBPARAMETER_STRUCT_S1"["STUBINIT_PARAM_INSTANCE_S"]."STUBPARAMETER_POINTERHANDLING_S" = "STUBINIT_PARAM_POINTERHANDLING_S";" NEWLINES,
aFunction->name);
}
if (!isDatatypeVoid(aFunction->dataType))
{
fprintf(aFile, "\t\t"STUBPARAMETER_STRUCT_S1"["STUBINIT_PARAM_INSTANCE_S"]."STUBPARAMETER_RETURN_S" = "STUBINIT_PARAM_RETURN_S";" NEWLINES,
aFunction->name);
}
parameter = aFunction->parameter.head;
parameterIndex = STUBDEFAULT_PARAMETER_INDEX_CHAR;
while (parameter)
{
// skip parameter without dataType
if (NULL == parameter->dataType)
{
parameter = parameter->next;
continue;
}
fprintf(aFile, "\t\t"STUBPARAMETER_STRUCT_S1"["STUBINIT_PARAM_INSTANCE_S"]."STUBPARAMETER_PARAM_S1" = "STUBINIT_PARAM_PARAMETER_S1";" NEWLINES,
aFunction->name, parameterIndex, parameterIndex); aFunction->name, parameterIndex, parameterIndex);
} if ((NULL != strstr(parameter->dataType, "*") || parameter->array) && CPARAMETER_TYPE_FUNCPTR != parameter->type)
++parameterIndex; {
parameter = parameter->next; fprintf(aFile,
} "\t\t"STUBPARAMETER_STRUCT_S1"["STUBINIT_PARAM_INSTANCE_S"]."STUBPARAMETER_PARAM_S1"_size = "STUBINIT_PARAM_PARAMETER_S1"_size;" NEWLINES,
fprintf(aFile, "\t}" NEWLINES); aFunction->name, parameterIndex, parameterIndex);
// if STUB_CALL_FAIL is requested init with default parameter }
fprintf(aFile, "\telse" NEWLINES "\t{" NEWLINES); ++parameterIndex;
if (pointerAvailable)
{
fprintf(aFile,
"\t\t"STUBPARAMETER_STRUCT_S1"["STUBINIT_PARAM_INSTANCE_S"]."STUBPARAMETER_POINTERHANDLING_S" = "STUBPARAMETER_POINTERHANDLING_ADDRESS_S";" NEWLINES,
aFunction->name);
}
parameter = aFunction->parameter.head;
parameterIndex = STUBDEFAULT_PARAMETER_INDEX_CHAR;
while (parameter)
{
// skip parameter without dataType
if (NULL == parameter->dataType)
{
parameter = parameter->next; parameter = parameter->next;
continue;
} }
// initialize _size parameter to 1 (default to check addresses) fprintf(aFile, "\t}" NEWLINES);
if (CPARAMETER_TYPE_FUNCPTR != parameter->type && (parameter->array || NULL != strstr(parameter->dataType, "*"))) // if STUB_CALL_FAIL is requested init with default parameter
fprintf(aFile, "\telse" NEWLINES "\t{" NEWLINES);
if (pointerAvailable)
{ {
fprintf(aFile, "\t\t"STUBPARAMETER_STRUCT_S1"["STUBINIT_PARAM_INSTANCE_S"]."STUBPARAMETER_PARAM_S1" = (%s%s) "STUBDEFAULT_VALUE_POINTER_S";" NEWLINES,
aFunction->name, parameterIndex, //
parameter->dataType,
(NULL == strstr(parameter->dataType, "*") ? "*" : "")); // cast array only parameter to be pointer
fprintf(aFile, fprintf(aFile,
"\t\t"STUBPARAMETER_STRUCT_S1"["STUBINIT_PARAM_INSTANCE_S"]."STUBPARAMETER_PARAM_S1"_size = "STUBDEFAULT_VALUE_POINTERSIZE_S";" NEWLINES, "\t\t"STUBPARAMETER_STRUCT_S1"["STUBINIT_PARAM_INSTANCE_S"]."STUBPARAMETER_POINTERHANDLING_S" = "STUBPARAMETER_POINTERHANDLING_ADDRESS_S";" NEWLINES,
aFunction->name, parameterIndex); aFunction->name);
} }
else parameter = aFunction->parameter.head;
parameterIndex = STUBDEFAULT_PARAMETER_INDEX_CHAR;
while (parameter)
{ {
fprintf(aFile, "\t\t"STUBPARAMETER_STRUCT_S1"["STUBINIT_PARAM_INSTANCE_S"]."STUBPARAMETER_PARAM_S1" = (%s) "STUBDEFAULT_VALUE_VARIABLE_S";" NEWLINES, // skip parameter without dataType
aFunction->name, parameterIndex, parameter->dataType); if (NULL == parameter->dataType)
{
parameter = parameter->next;
continue;
}
// initialize _size parameter to 1 (default to check addresses)
if (CPARAMETER_TYPE_FUNCPTR != parameter->type && (parameter->array || NULL != strstr(parameter->dataType, "*")))
{
fprintf(aFile,
"\t\t"STUBPARAMETER_STRUCT_S1"["STUBINIT_PARAM_INSTANCE_S"]."STUBPARAMETER_PARAM_S1" = (%s%s) "STUBDEFAULT_VALUE_POINTER_S1";" NEWLINES,
aFunction->name, parameterIndex, //
parameter->dataType, (NULL == strstr(parameter->dataType, "*") ? "*" : ""), // cast array only parameter to be pointer
aNoSuffix);
fprintf(aFile,
"\t\t"STUBPARAMETER_STRUCT_S1"["STUBINIT_PARAM_INSTANCE_S"]."STUBPARAMETER_PARAM_S1"_size = "STUBDEFAULT_VALUE_POINTERSIZE_S";" NEWLINES,
aFunction->name, parameterIndex);
}
else
{
fprintf(aFile,
"\t\t"STUBPARAMETER_STRUCT_S1"["STUBINIT_PARAM_INSTANCE_S"]."STUBPARAMETER_PARAM_S1" = (%s) "STUBDEFAULT_VALUE_VARIABLE_S";" NEWLINES,
aFunction->name, parameterIndex, parameter->dataType);
}
++parameterIndex;
parameter = parameter->next;
} }
fprintf(aFile, "\t}" NEWLINES);
++parameterIndex;
parameter = parameter->next;
} }
fprintf(aFile, "\t}" NEWLINES);
fprintf(aFile, "}" NEWLINES); fprintf(aFile, "}" NEWLINES);
NEWLINE(aFile); NEWLINE(aFile);
@@ -844,7 +829,7 @@ STATIC int8_t createStubFunctionBlock(FILE *aFile, FILE *aHeader, cfunction_t *a
parameter = parameter->next; parameter = parameter->next;
continue; continue;
} }
createParameterSpecificCheck(aFile, aFunction, parameter, parameterIndex); createParameterSpecificCheck(aNoSuffix, aFile, aFunction, parameter, parameterIndex);
++parameterIndex; ++parameterIndex;
parameter = parameter->next; parameter = parameter->next;
} }
@@ -1006,6 +991,12 @@ STATIC int8_t createStub(char *aOutput, char *aNoSuffix, cfile_t *aCfile)
fprintf(cfile, "#include \"stub_%s_user.h\""NEWLINES, aNoSuffix); fprintf(cfile, "#include \"stub_%s_user.h\""NEWLINES, aNoSuffix);
fprintf(cfile, "#include \"%s\""NEWLINES NEWLINES, gnu_basename(cHeaderName)); fprintf(cfile, "#include \"%s\""NEWLINES NEWLINES, gnu_basename(cHeaderName));
if (0 == cfile_hasPointerParameter(aCfile))
{
// Test data for stub pointer parameter to be initialized to.
fprintf(cfile, "static uint8_t "STUBDEFAULT_VALUE_POINTER_S1"[9] = { [0 ... 7] = 'A', [8] = '\\0' };" NEWLINES NEWLINES, aNoSuffix);
}
fprintf(cheader, "/*! @file %s"NEWLINES, gnu_basename(cHeaderName)); fprintf(cheader, "/*! @file %s"NEWLINES, gnu_basename(cHeaderName));
fprintf(cheader, " * @details"NEWLINES" * This is a stub header.\\n"NEWLINES); fprintf(cheader, " * @details"NEWLINES" * This is a stub header.\\n"NEWLINES);
fprintf(cheader, " * - generated by stubser -"NEWLINES" */" NEWLINES NEWLINES); fprintf(cheader, " * - generated by stubser -"NEWLINES" */" NEWLINES NEWLINES);
@@ -1020,7 +1011,7 @@ STATIC int8_t createStub(char *aOutput, char *aNoSuffix, cfile_t *aCfile)
function = aCfile->functions.head; function = aCfile->functions.head;
while (function) while (function)
{ {
(void) createStubFunctionBlock(cfile, cheader, function); (void) createStubFunctionBlock(aNoSuffix, cfile, cheader, function);
function = function->next; function = function->next;
} }

View File

@@ -34,6 +34,7 @@
#define STUBPARAMETER_POINTERHANDLING_S "stubPointerHandling" #define STUBPARAMETER_POINTERHANDLING_S "stubPointerHandling"
#define STUBPARAMETER_POINTERHANDLING_ENUM_S "stub_parameter_pointer_handling_t" #define STUBPARAMETER_POINTERHANDLING_ENUM_S "stub_parameter_pointer_handling_t"
#define STUBPARAMETER_POINTERHANDLING_ADDRESS_S "STUB_PARAMETER_POINTER_HANDLING_ADDRESS" #define STUBPARAMETER_POINTERHANDLING_ADDRESS_S "STUB_PARAMETER_POINTER_HANDLING_ADDRESS"
#define STUBPARAMETER_POINTERHANDLING_CONTENT_S "STUB_PARAMETER_POINTER_HANDLING_CONTENT"
#define STUBPARAMETER_POINTERHANDLING_INJECT_S "STUB_PARAMETER_POINTER_HANDLING_INJECT" #define STUBPARAMETER_POINTERHANDLING_INJECT_S "STUB_PARAMETER_POINTER_HANDLING_INJECT"
#define STUBPARAMETER_RETURN_S "returnValue" // "stubparameter_modulfunction_1".returnValue #define STUBPARAMETER_RETURN_S "returnValue" // "stubparameter_modulfunction_1".returnValue
#define STUBINSTANCE_S1 "stubInstance_%s" // stubInstance_modulfunction_1 #define STUBINSTANCE_S1 "stubInstance_%s" // stubInstance_modulfunction_1
@@ -46,7 +47,7 @@
#define STUBDEFAULT_PARAMETER_INDEX_CHAR 'a' #define STUBDEFAULT_PARAMETER_INDEX_CHAR 'a'
#define STUBDEFAULT_VALUE_FUNCTIONPOINTER_S "0xAA" #define STUBDEFAULT_VALUE_FUNCTIONPOINTER_S "0xAA"
#define STUBDEFAULT_VALUE_POINTER_S "0xAA" #define STUBDEFAULT_VALUE_POINTER_S1 "%s_testData" // stubfilename_testData
#define STUBDEFAULT_VALUE_POINTERSIZE_S "1" #define STUBDEFAULT_VALUE_POINTERSIZE_S "1"
#define STUBDEFAULT_VALUE_VARIABLE_S "0xAA" #define STUBDEFAULT_VALUE_VARIABLE_S "0xAA"