- added creating function to work with stub global variables (init expected, init globals, check globals)
This commit is contained in:
@@ -38,6 +38,107 @@ STATIC bool isDatatypeVoid(char *aType)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STATIC int8_t createStubExpected(char *aNoSuffix, FILE *aFile, FILE *aHeader, cfile_variableList_t *aList)
|
||||||
|
{
|
||||||
|
cfile_variable_t *work = NULL;
|
||||||
|
if (NULL == aFile || NULL == aHeader || NULL == aList)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
work = aList->head;
|
||||||
|
while (work)
|
||||||
|
{
|
||||||
|
if (CVARIABLE_TYPE_REGULAR != work->type)
|
||||||
|
{
|
||||||
|
work = work->next;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
fprintf(aFile, "%s "STUBVARIABLE_EXTENDED_S1";"NEWLINES, work->dataType, work->name);
|
||||||
|
fprintf(aHeader, "extern %s "STUBVARIABLE_EXTENDED_S1";"NEWLINES, work->dataType, work->name);
|
||||||
|
work = work->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(aHeader, "void "STUBFUNCTION_INITEXPECTED_S1"();"NEWLINES NEWLINES, aNoSuffix);
|
||||||
|
fprintf(aFile, NEWLINES"void "STUBFUNCTION_INITEXPECTED_S1"()"NEWLINES"{"NEWLINES, aNoSuffix);
|
||||||
|
|
||||||
|
work = aList->head;
|
||||||
|
while (work)
|
||||||
|
{
|
||||||
|
if (CVARIABLE_TYPE_REGULAR != work->type)
|
||||||
|
{
|
||||||
|
work = work->next;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// TODO type specific initialization
|
||||||
|
fprintf(aFile, "\t"STUBVARIABLE_EXTENDED_S1" = 0x55;"NEWLINES, work->name);
|
||||||
|
work = work->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(aFile, "}"NEWLINES);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC int8_t createStubGlobals(char *aNoSuffix, FILE *aFile, FILE *aHeader, cfile_variableList_t *aList)
|
||||||
|
{
|
||||||
|
cfile_variable_t *work = NULL;
|
||||||
|
if (NULL == aFile || NULL == aHeader || NULL == aList)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(aFile, NEWLINES"void "STUBFUNCTION_INITGLOBALS_S1"()"NEWLINES"{"NEWLINES, aNoSuffix);
|
||||||
|
|
||||||
|
work = aList->head;
|
||||||
|
while (work)
|
||||||
|
{
|
||||||
|
if (CVARIABLE_TYPE_REGULAR != work->type)
|
||||||
|
{
|
||||||
|
work = work->next;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// TODO type specific initialization
|
||||||
|
fprintf(aFile, "\t%s = 0x55;"NEWLINES, work->name);
|
||||||
|
fprintf(aHeader, "extern %s %s;"NEWLINES, work->dataType, work->name);
|
||||||
|
work = work->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(aFile, "}"NEWLINES);
|
||||||
|
fprintf(aHeader, "void "STUBFUNCTION_INITGLOBALS_S1"();"NEWLINES NEWLINES, aNoSuffix);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC int8_t createStubCheck(char *aNoSuffix, FILE *aFile, FILE *aHeader, cfile_variableList_t *aList)
|
||||||
|
{
|
||||||
|
cfile_variable_t *work = NULL;
|
||||||
|
if (NULL == aFile || NULL == aHeader || NULL == aList)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(aHeader, "void "STUBFUNCTION_CHECK_S1"();"NEWLINES NEWLINES, aNoSuffix);
|
||||||
|
fprintf(aFile, NEWLINES"void "STUBFUNCTION_CHECK_S1"()"NEWLINES"{"NEWLINES, aNoSuffix);
|
||||||
|
|
||||||
|
work = aList->head;
|
||||||
|
while (work)
|
||||||
|
{
|
||||||
|
if (CVARIABLE_TYPE_REGULAR != work->type)
|
||||||
|
{
|
||||||
|
work = work->next;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// TODO type specific initialization
|
||||||
|
fprintf(aFile, "\tCU_ASSERT_EQUAL(%s, "STUBVARIABLE_EXTENDED_S1");"NEWLINES, work->name, work->name);
|
||||||
|
work = work->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(aFile, "}"NEWLINES NEWLINES);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
STATIC int8_t createStubFunctionBlock(FILE *aFile, FILE *aHeader, cfunction_t *aFunction)
|
STATIC int8_t createStubFunctionBlock(FILE *aFile, FILE *aHeader, cfunction_t *aFunction)
|
||||||
{
|
{
|
||||||
cfunction_parameter_t *parameter = NULL;
|
cfunction_parameter_t *parameter = NULL;
|
||||||
@@ -297,6 +398,10 @@ STATIC int8_t createStub(char *aOutput, char *aNoSuffix, cfile_t *aCfile)
|
|||||||
fprintf(cheader, "#ifndef _STUB_%s_H"NEWLINES, aNoSuffix);
|
fprintf(cheader, "#ifndef _STUB_%s_H"NEWLINES, aNoSuffix);
|
||||||
fprintf(cheader, "#define _STUB_%s_H"NEWLINES NEWLINES, aNoSuffix);
|
fprintf(cheader, "#define _STUB_%s_H"NEWLINES NEWLINES, aNoSuffix);
|
||||||
|
|
||||||
|
createStubExpected(aNoSuffix, cfile, cheader, &aCfile->variables);
|
||||||
|
createStubGlobals(aNoSuffix, cfile, cheader, &aCfile->variables);
|
||||||
|
createStubCheck(aNoSuffix, cfile, cheader, &aCfile->variables);
|
||||||
|
|
||||||
function = aCfile->functions.head;
|
function = aCfile->functions.head;
|
||||||
while (function)
|
while (function)
|
||||||
{
|
{
|
||||||
|
@@ -38,6 +38,11 @@
|
|||||||
#define STUBINIT_PARAM_PARAMETER_S1 "aParameter_%c" // aParameter_a
|
#define STUBINIT_PARAM_PARAMETER_S1 "aParameter_%c" // aParameter_a
|
||||||
#define STUBINIT_PARAM_RETURN_S "aReturnValue"
|
#define STUBINIT_PARAM_RETURN_S "aReturnValue"
|
||||||
|
|
||||||
|
#define STUBFUNCTION_INITEXPECTED_S1 "stub_%s_initExpected" // stub_testfunction_checkGlobals
|
||||||
|
#define STUBFUNCTION_INITGLOBALS_S1 "stub_%s_initGlobals" // stub_testfunction_checkGlobals
|
||||||
|
#define STUBFUNCTION_CHECK_S1 "stub_%s_checkGlobals" // stub_testfunction_checkGlobals
|
||||||
|
#define STUBVARIABLE_EXTENDED_S1 "%s_expected" // variable_expected
|
||||||
|
|
||||||
#define STUB_CONSOLE_OK "[ OK ]"
|
#define STUB_CONSOLE_OK "[ OK ]"
|
||||||
#define STUB_CONSOLE_FAIL "[FAIL]"
|
#define STUB_CONSOLE_FAIL "[FAIL]"
|
||||||
#define STUB_CONSOLE_PARSE_ERROR_S2 STUB_CONSOLE_FAIL " %s parsing failed (%d)\n"
|
#define STUB_CONSOLE_PARSE_ERROR_S2 STUB_CONSOLE_FAIL " %s parsing failed (%d)\n"
|
||||||
|
Reference in New Issue
Block a user