diff --git a/src/stubser/stubser.c b/src/stubser/stubser.c index 6935636..504fb52 100644 --- a/src/stubser/stubser.c +++ b/src/stubser/stubser.c @@ -88,7 +88,7 @@ STATIC void createVariableSpecificInit(const char* aVariableTemplate, FILE *aFil { fprintf(aFile, "\t(void) memset("); fprintf(aFile, aVariableTemplate, aVariable->name); - fprintf(aFile, ", 0x55, sizeof(%s)); /* %s */" NEWLINES, aVariable->name, aVariable->dataType); + fprintf(aFile, ", "STUBDEFAULT_VALUE_VARIABLE_S", sizeof(%s)); /* %s */" NEWLINES, aVariable->name, aVariable->dataType); } else { @@ -102,13 +102,13 @@ STATIC void createVariableSpecificInit(const char* aVariableTemplate, FILE *aFil { fprintf(aFile, "\t"); fprintf(aFile, aVariableTemplate, aVariable->name); - fprintf(aFile, " = 0x55;" NEWLINES); + fprintf(aFile, " = "STUBDEFAULT_VALUE_VARIABLE_S";" NEWLINES); } else { fprintf(aFile, "\t(void) memset(&"); fprintf(aFile, aVariableTemplate, aVariable->name); - fprintf(aFile, ", 0x55, sizeof(%s)); /* %s */" NEWLINES, aVariable->name, aVariable->dataType); + fprintf(aFile, ", "STUBDEFAULT_VALUE_VARIABLE_S", sizeof(%s)); /* %s */" NEWLINES, aVariable->name, aVariable->dataType); } } @@ -168,6 +168,8 @@ 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, aFunction->name, aParameterIndex); fprintf(aFile, ");"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); } else if (NULL != strstr(aParameter->dataType, "*") && NULL != strstr(aParameter->dataType, "char")) { @@ -193,6 +195,10 @@ STATIC void createParameterSpecificCheck(FILE *aFile, cfunction_t *aFunction, cf 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); } else if (NULL != strstr(aParameter->dataType, "*") || NULL != aParameter->array) { @@ -218,6 +224,10 @@ STATIC void createParameterSpecificCheck(FILE *aFile, cfunction_t *aFunction, cf 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); } else if (isDatatypeStandard(aParameter->dataType)) { @@ -225,6 +235,8 @@ 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, aFunction->name, aParameterIndex); fprintf(aFile, ");"NEWLINES); + fprintf(aFile, "\t"STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_S1"]."STUBPARAMETER_PARAM_S1" = (%s) "STUBDEFAULT_VALUE_VARIABLE_S";" NEWLINES, aFunction->name, + aFunction->name, aParameterIndex, aParameter->dataType); } else { @@ -232,6 +244,8 @@ 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, aFunction->name, aParameterIndex); fprintf(aFile, ", sizeof("STUBINIT_PARAM_PARAMETER_S1"));"NEWLINES, aParameterIndex); + fprintf(aFile, "\t"STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_S1"]."STUBPARAMETER_PARAM_S1" = (%s) "STUBDEFAULT_VALUE_VARIABLE_S";" NEWLINES, aFunction->name, + aFunction->name, aParameterIndex, aParameter->dataType); } } @@ -466,9 +480,16 @@ STATIC int8_t createStubFunctionBlock(FILE *aFile, FILE *aHeader, cfunction_t *a // initialize _size parameter to 1 (default to check addresses) if (CPARAMETER_TYPE_FUNCPTR != parameter->type && (parameter->array || NULL != strstr(parameter->dataType, "*"))) { - fprintf(aFile, "\t[0 ... %u]."STUBPARAMETER_PARAM_S1" = (%s) 0x55," NEWLINES, STUB_INSTANCES_AMOUNT - 1, parameterIndex, parameter->dataType); + fprintf(aFile, "\t[0 ... %u]."STUBPARAMETER_PARAM_S1" = (%s) "STUBDEFAULT_VALUE_POINTER_S"," NEWLINES, STUB_INSTANCES_AMOUNT - 1, parameterIndex, + parameter->dataType); fprintf(aFile, "\t[0 ... %u]."STUBPARAMETER_PARAM_S1"_size = 1," NEWLINES, STUB_INSTANCES_AMOUNT - 1, parameterIndex); } + else + { + fprintf(aFile, "\t[0 ... %u]."STUBPARAMETER_PARAM_S1" = (%s) "STUBDEFAULT_VALUE_VARIABLE_S"," NEWLINES, STUB_INSTANCES_AMOUNT - 1, parameterIndex, + parameter->dataType); + } + ++parameterIndex; parameter = parameter->next; } @@ -636,8 +657,12 @@ STATIC int8_t createStubFunctionBlock(FILE *aFile, FILE *aHeader, cfunction_t *a fprintf(aFile, "\t\tCU_FAIL(\"Inadvertent %s() call.\");"NEWLINES"\t\tbreak;"NEWLINES, aFunction->name); fprintf(aFile, "\tcase STUB_CALL_PASS:" NEWLINES); fprintf(aFile, "\t\tCU_PASS(\"%s() called.\");"NEWLINES"\t\tbreak;"NEWLINES, aFunction->name); - fprintf(aFile, "\tdefault:"NEWLINES"\t\tbreak;"NEWLINES); + fprintf(aFile, "\tdefault:"NEWLINES); + fprintf(aFile, "\t\tCU_FAIL_OUTPUT_LESS(\"Invalid STUB_CALL test value: \","STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_S1"]."STUBPARAMETER_CALLTEST_S", \"%%u\");"NEWLINES, + aFunction->name, aFunction->name); + fprintf(aFile, "\t\tbreak;"NEWLINES); fprintf(aFile, "\t}" NEWLINES); + fprintf(aFile, "\t"STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_S1"]."STUBPARAMETER_CALLTEST_S" = STUB_CALL_FAIL;" NEWLINES, aFunction->name, aFunction->name); parameter = aFunction->parameter.head; parameterIndex = 'a'; @@ -647,6 +672,11 @@ STATIC int8_t createStubFunctionBlock(FILE *aFile, FILE *aHeader, cfunction_t *a ++parameterIndex; parameter = parameter->next; } + if (pointerAvailable) + { + fprintf(aFile, "\t"STUBPARAMETER_STRUCT_S1"["STUBINSTANCE_S1"]."STUBPARAMETER_POINTERHANDLING_S" = " STUBPARAMETER_POINTERHANDLING_ADDRESS_S ";" NEWLINES, + aFunction->name, aFunction->name); + } if (!isDatatypeVoid(aFunction->dataType)) { diff --git a/src/stubser/stubser_loc.h b/src/stubser/stubser_loc.h index 306e780..0809cbe 100644 --- a/src/stubser/stubser_loc.h +++ b/src/stubser/stubser_loc.h @@ -44,6 +44,11 @@ #define STUBINIT_PARAM_RETURN_S "aReturnValue" #define STUBINIT_PARAM_POINTERHANDLING_S "aPointerHandling" +#define STUBDEFAULT_VALUE_FUNCTIONPOINTER_S "0x55" +#define STUBDEFAULT_VALUE_POINTER_S "0x55" +#define STUBDEFAULT_VALUE_POINTERSIZE_S "1" +#define STUBDEFAULT_VALUE_VARIABLE_S "0x55" + #define STUBFUNCTION_USER_INITEXPECTED_S1 "stub_%s_user_initExpected" // stub_testfunction_initExpected #define STUBFUNCTION_USER_INITGLOBALS_S1 "stub_%s_user_initGlobals" // stub_testfunction_initGlobals #define STUBFUNCTION_USER_CHECK_S1 "stub_%s_user_checkGlobals" // stub_testfunction_checkGlobals