Using _size parameter = 0 to also disable address detection selectively
Code comment enhancements for stubser and resulting stubs
This commit is contained in:
@@ -255,7 +255,7 @@ STATIC int8_t matchPrefix(void *aElement, celement_type_t aElementType, char *aS
|
||||
* @param [in] *aBlockStart Terminated string defining the start of a block
|
||||
* @param [in] *aBlockEnd Terminated string defining the end of a block
|
||||
* @param [in] *aLine Terminated line (e.g. read from a file getline())
|
||||
* @param [out] **aPosition Pointing to found block string (realted to \ref aRemove) / NULL for CFILE_BLOCK_DETECT_NONE or CFILE_BLOCK_DETECT_ERROR
|
||||
* @param [out] **aPosition Pointing to found block string (related to \ref aRemove) / NULL for CFILE_BLOCK_DETECT_NONE or CFILE_BLOCK_DETECT_ERROR
|
||||
* @param [in] aRemove false - remove only content of block; true - also remove block strings
|
||||
* @return cfile_block_return_t
|
||||
* @retval CFILE_BLOCK_DETECT_START Start found
|
||||
|
@@ -171,14 +171,19 @@ STATIC void createParameterSpecificCheck(FILE *aFile, cfunction_t *aFunction, cf
|
||||
}
|
||||
else if (NULL != strstr(aParameter->dataType, "*") && NULL != strstr(aParameter->dataType, "char"))
|
||||
{
|
||||
fprintf(aFile,
|
||||
"\tif ("STUBPARAMETER_POINTERHANDLING_ADDRESS_S " == " STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_S1"]."STUBPARAMETER_POINTERHANDLING_S")" NEWLINES "\t{" NEWLINES,
|
||||
aFunction->name, aFunction->name);
|
||||
fprintf(aFile, "\t\tCU_ASSERT_MEMORY_CHECK(\"%s(%s)\", ", aFunction->name, aParameter->name);
|
||||
// char array with string comparison
|
||||
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_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,
|
||||
aFunction->name, aParameterIndex);
|
||||
fprintf(aFile, ", strlen("STUBINIT_PARAM_PARAMETER_S1"));"NEWLINES, aParameterIndex);
|
||||
fprintf(aFile, "\t}" NEWLINES);
|
||||
// injection only for non constant parameter
|
||||
if (NULL == strstr(aParameter->dataType, "const"))
|
||||
{
|
||||
fprintf(aFile, "\telse" NEWLINES "\t{" NEWLINES);
|
||||
@@ -192,14 +197,18 @@ STATIC void createParameterSpecificCheck(FILE *aFile, cfunction_t *aFunction, cf
|
||||
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);
|
||||
fprintf(aFile, "\t\tCU_ASSERT_PTR_EQUAL(");
|
||||
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);
|
||||
// injection only for non constant parameter
|
||||
if (NULL == strstr(aParameter->dataType, "const"))
|
||||
{
|
||||
fprintf(aFile, "\telse" NEWLINES "\t{" NEWLINES);
|
||||
@@ -396,7 +405,7 @@ STATIC int8_t createStubFunctionBlock(FILE *aFile, FILE *aHeader, cfunction_t *a
|
||||
fprintf(aFile, "// Expected parameter and return value structures" NEWLINES);
|
||||
fprintf(aFile, "typedef struct _STUBPARAMETER_%s" NEWLINES, aFunction->name);
|
||||
fprintf(aFile, "{" NEWLINES);
|
||||
fprintf(aFile, "\tuint8_t "STUBPARAMETER_CALLTEST_S"; /*!< @brief If stub call is a STUB_CALL_PASS or STUB_CALL_FAIL */" NEWLINES);
|
||||
fprintf(aFile, "\tuint8_t "STUBPARAMETER_CALLTEST_S"; /*!< @brief Stub call is a STUB_CALL_PASS or STUB_CALL_FAIL */" NEWLINES);
|
||||
if (pointerAvailable)
|
||||
{
|
||||
fprintf(aFile, "\t%s "STUBPARAMETER_POINTERHANDLING_S"; /*!< @brief pointer handling */" NEWLINES, STUBPARAMETER_POINTERHANDLING_ENUM_S);
|
||||
@@ -449,6 +458,11 @@ STATIC int8_t createStubFunctionBlock(FILE *aFile, FILE *aHeader, cfunction_t *a
|
||||
|
||||
// stub function init header; function comment
|
||||
fprintf(aHeader, "/*! @brief Stub initialization of init_%s" NEWLINES, aFunction->name);
|
||||
if (pointerAvailable)
|
||||
{
|
||||
fprintf(aHeader,
|
||||
" * @attention In case of address comparison, ..._size parameter = 0 ignores result (@ref " STUBINIT_PARAM_POINTERHANDLING_S ")." NEWLINES);
|
||||
}
|
||||
fprintf(aHeader, " * @param " STUBINIT_PARAM_INSTANCE_S " Which stub call to initialize" NEWLINES);
|
||||
fprintf(aHeader, " * @param " STUBINIT_PARAM_CALLTEST_S " Is stub call allowed (STUB_CALL_FAIL, STUB_CALL_PASS)" NEWLINES);
|
||||
if (pointerAvailable)
|
||||
@@ -467,7 +481,7 @@ STATIC int8_t createStubFunctionBlock(FILE *aFile, FILE *aHeader, cfunction_t *a
|
||||
if (NULL != strstr(parameter->dataType, "*") || parameter->array)
|
||||
{
|
||||
fprintf(aHeader,
|
||||
" * @param " STUBINIT_PARAM_PARAMETER_S1 "_size Use injection size 0 to ignore pointer (e.g. test subject references to internal variables)" NEWLINES,
|
||||
" * @param " STUBINIT_PARAM_PARAMETER_S1 "_size 0 to ignore pointer for address comparison and injection (e.g. test subject references to internal variables)" NEWLINES,
|
||||
parameterIndex);
|
||||
}
|
||||
parameterIndex++;
|
||||
@@ -676,10 +690,9 @@ STATIC void createUserHeader(char *aOutput, char *aNoSuffix)
|
||||
}
|
||||
free(cHeaderName);
|
||||
|
||||
// TODO user c file
|
||||
if (!file_exist(cFileName))
|
||||
{
|
||||
// user header doesn't exist
|
||||
// user code doesn't exist
|
||||
fileDesc = fopen(cFileName, "w");
|
||||
if (NULL != fileDesc)
|
||||
{
|
||||
|
Reference in New Issue
Block a user