stub init with fail condition initializes expected parameter with default, keeping structure array clean for further tests
This commit is contained in:
@@ -600,34 +600,72 @@ STATIC int8_t createStubFunctionBlock(FILE *aFile, FILE *aHeader, cfunction_t *a
|
||||
fprintf(aFile, "\t{" NEWLINES);
|
||||
fprintf(aFile, "\t\tCU_FAIL_FATAL(\"init_%s() - "STUBINIT_PARAM_INSTANCE_S" out of bounce\");" NEWLINES, aFunction->name);
|
||||
fprintf(aFile, "\t}" NEWLINES);
|
||||
// setting parameter
|
||||
fprintf(aFile, "\t"STUBINSTANCE_S1" = 0;" NEWLINES, aFunction->name);
|
||||
fprintf(aFile, "\t"STUBPARAMETER_STRUCT_S1"["STUBINIT_PARAM_INSTANCE_S"]."STUBPARAMETER_CALLTEST_S" = "STUBINIT_PARAM_CALLTEST_S";" NEWLINES,
|
||||
aFunction->name);
|
||||
|
||||
// if STUB_CALL_PASS is requested init with parameter
|
||||
fprintf(aFile, "\tif ( STUB_CALL_PASS == " STUBINIT_PARAM_CALLTEST_S ")" NEWLINES "\t{" NEWLINES);
|
||||
if (pointerAvailable)
|
||||
{
|
||||
fprintf(aFile,
|
||||
"\t"STUBPARAMETER_STRUCT_S1"["STUBINIT_PARAM_INSTANCE_S"]."STUBPARAMETER_POINTERHANDLING_S" = "STUBINIT_PARAM_POINTERHANDLING_S";" 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"STUBPARAMETER_STRUCT_S1"["STUBINIT_PARAM_INSTANCE_S"]."STUBPARAMETER_RETURN_S" = "STUBINIT_PARAM_RETURN_S";" NEWLINES,
|
||||
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 = 'a';
|
||||
while (parameter)
|
||||
{
|
||||
fprintf(aFile, "\t"STUBPARAMETER_STRUCT_S1"["STUBINIT_PARAM_INSTANCE_S"]."STUBPARAMETER_PARAM_S1" = "STUBINIT_PARAM_PARAMETER_S1";" NEWLINES,
|
||||
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, "\t"STUBPARAMETER_STRUCT_S1"["STUBINIT_PARAM_INSTANCE_S"]."STUBPARAMETER_PARAM_S1"_size = "STUBINIT_PARAM_PARAMETER_S1"_size;" NEWLINES,
|
||||
fprintf(aFile,
|
||||
"\t\t"STUBPARAMETER_STRUCT_S1"["STUBINIT_PARAM_INSTANCE_S"]."STUBPARAMETER_PARAM_S1"_size = "STUBINIT_PARAM_PARAMETER_S1"_size;" NEWLINES,
|
||||
aFunction->name, parameterIndex, parameterIndex);
|
||||
}
|
||||
++parameterIndex;
|
||||
parameter = parameter->next;
|
||||
}
|
||||
fprintf(aFile, "\t}" NEWLINES);
|
||||
// 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_POINTERHANDLING_S" = "STUBPARAMETER_POINTERHANDLING_ADDRESS_S";" NEWLINES,
|
||||
aFunction->name);
|
||||
}
|
||||
parameter = aFunction->parameter.head;
|
||||
parameterIndex = 'a';
|
||||
while (parameter)
|
||||
{
|
||||
// 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) "STUBDEFAULT_VALUE_POINTER_S";" NEWLINES,
|
||||
aFunction->name, parameterIndex, parameter->dataType);
|
||||
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);
|
||||
|
||||
fprintf(aFile, "}" NEWLINES);
|
||||
NEWLINE(aFile);
|
||||
|
||||
@@ -658,7 +696,8 @@ STATIC int8_t createStubFunctionBlock(FILE *aFile, FILE *aHeader, cfunction_t *a
|
||||
fprintf(aFile, "\tcase STUB_CALL_PASS:" NEWLINES);
|
||||
fprintf(aFile, "\t\tCU_PASS(\"%s() called.\");"NEWLINES"\t\tbreak;"NEWLINES, aFunction->name);
|
||||
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,
|
||||
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);
|
||||
|
@@ -44,10 +44,10 @@
|
||||
#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_FUNCTIONPOINTER_S "0xAA"
|
||||
#define STUBDEFAULT_VALUE_POINTER_S "0xAA"
|
||||
#define STUBDEFAULT_VALUE_POINTERSIZE_S "1"
|
||||
#define STUBDEFAULT_VALUE_VARIABLE_S "0x55"
|
||||
#define STUBDEFAULT_VALUE_VARIABLE_S "0xAA"
|
||||
|
||||
#define STUBFUNCTION_USER_INITEXPECTED_S1 "stub_%s_user_initExpected" // stub_testfunction_initExpected
|
||||
#define STUBFUNCTION_USER_INITGLOBALS_S1 "stub_%s_user_initGlobals" // stub_testfunction_initGlobals
|
||||
|
Reference in New Issue
Block a user