Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #109, use generated stubs in unit tests #110

Merged
merged 1 commit into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions unit-test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

add_cfe_coverage_stubs("sc_internal"
utilities/sc_test_utils.c
stubs/sc_global_stubs.c
stubs/sc_loads_stubs.c
stubs/sc_cmds_stubs.c
stubs/sc_atsrq_stubs.c
Expand Down
128 changes: 107 additions & 21 deletions unit-test/stubs/sc_app_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,56 +17,142 @@
* limitations under the License.
************************************************************************/

/*
* Includes
/**
* @file
*
* Auto-Generated stub implementations for functions defined in sc_app header
*/

#include "sc_app.h"
#include "utgenstub.h"

/*
* ----------------------------------------------------
* Generated stub function for SC_AppInit()
* ----------------------------------------------------
*/
CFE_Status_t SC_AppInit(void)
{
UT_GenStub_SetupReturnBuffer(SC_AppInit, CFE_Status_t);

/* UT includes */
#include "uttest.h"
#include "utassert.h"
#include "utstubs.h"
UT_GenStub_Execute(SC_AppInit, Basic, NULL);

SC_AppData_t SC_AppData;
SC_OperData_t SC_OperData;
return UT_GenStub_GetReturnValue(SC_AppInit, CFE_Status_t);
}

/*
* ----------------------------------------------------
* Generated stub function for SC_AppMain()
* ----------------------------------------------------
*/
void SC_AppMain(void)
{
UT_DEFAULT_IMPL(SC_AppMain);

UT_GenStub_Execute(SC_AppMain, Basic, NULL);
}

CFE_Status_t SC_AppInit(void)
/*
* ----------------------------------------------------
* Generated stub function for SC_GetDumpTablePointers()
* ----------------------------------------------------
*/
CFE_Status_t SC_GetDumpTablePointers(void)
{
return UT_DEFAULT_IMPL(SC_AppMain);
UT_GenStub_SetupReturnBuffer(SC_GetDumpTablePointers, CFE_Status_t);

UT_GenStub_Execute(SC_GetDumpTablePointers, Basic, NULL);

return UT_GenStub_GetReturnValue(SC_GetDumpTablePointers, CFE_Status_t);
}

/*
* ----------------------------------------------------
* Generated stub function for SC_GetLoadTablePointers()
* ----------------------------------------------------
*/
CFE_Status_t SC_GetLoadTablePointers(void)
{
UT_GenStub_SetupReturnBuffer(SC_GetLoadTablePointers, CFE_Status_t);

UT_GenStub_Execute(SC_GetLoadTablePointers, Basic, NULL);

return UT_GenStub_GetReturnValue(SC_GetLoadTablePointers, CFE_Status_t);
}

/*
* ----------------------------------------------------
* Generated stub function for SC_InitTables()
* ----------------------------------------------------
*/
CFE_Status_t SC_InitTables(void)
{
return UT_DEFAULT_IMPL(SC_InitTables);
UT_GenStub_SetupReturnBuffer(SC_InitTables, CFE_Status_t);

UT_GenStub_Execute(SC_InitTables, Basic, NULL);

return UT_GenStub_GetReturnValue(SC_InitTables, CFE_Status_t);
}

CFE_Status_t SC_RegisterAllTables(void)
/*
* ----------------------------------------------------
* Generated stub function for SC_LoadDefaultTables()
* ----------------------------------------------------
*/
void SC_LoadDefaultTables(void)
{
return UT_DEFAULT_IMPL(SC_RegisterAllTables);

UT_GenStub_Execute(SC_LoadDefaultTables, Basic, NULL);
}

CFE_Status_t SC_GetDumpTablePointers(void)
/*
* ----------------------------------------------------
* Generated stub function for SC_RegisterAllTables()
* ----------------------------------------------------
*/
CFE_Status_t SC_RegisterAllTables(void)
{
return UT_DEFAULT_IMPL(SC_GetDumpTablePointers);
UT_GenStub_SetupReturnBuffer(SC_RegisterAllTables, CFE_Status_t);

UT_GenStub_Execute(SC_RegisterAllTables, Basic, NULL);

return UT_GenStub_GetReturnValue(SC_RegisterAllTables, CFE_Status_t);
}

CFE_Status_t SC_GetLoadTablePointers(void)
/*
* ----------------------------------------------------
* Generated stub function for SC_RegisterDumpOnlyTables()
* ----------------------------------------------------
*/
CFE_Status_t SC_RegisterDumpOnlyTables(void)
{
return UT_DEFAULT_IMPL(SC_GetLoadTablePointers);
UT_GenStub_SetupReturnBuffer(SC_RegisterDumpOnlyTables, CFE_Status_t);

UT_GenStub_Execute(SC_RegisterDumpOnlyTables, Basic, NULL);

return UT_GenStub_GetReturnValue(SC_RegisterDumpOnlyTables, CFE_Status_t);
}

void SC_LoadDefaultTables(void)
/*
* ----------------------------------------------------
* Generated stub function for SC_RegisterLoadableTables()
* ----------------------------------------------------
*/
CFE_Status_t SC_RegisterLoadableTables(void)
{
UT_DEFAULT_IMPL(SC_LoadDefaultTables);
UT_GenStub_SetupReturnBuffer(SC_RegisterLoadableTables, CFE_Status_t);

UT_GenStub_Execute(SC_RegisterLoadableTables, Basic, NULL);

return UT_GenStub_GetReturnValue(SC_RegisterLoadableTables, CFE_Status_t);
}

/*
* ----------------------------------------------------
* Generated stub function for SC_RegisterManageCmds()
* ----------------------------------------------------
*/
void SC_RegisterManageCmds(void)
{
UT_DEFAULT_IMPL(SC_RegisterManageCmds);

UT_GenStub_Execute(SC_RegisterManageCmds, Basic, NULL);
}
135 changes: 100 additions & 35 deletions unit-test/stubs/sc_atsrq_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,71 +17,136 @@
* limitations under the License.
************************************************************************/

/*
* Includes
/**
* @file
*
* Auto-Generated stub implementations for functions defined in sc_atsrq header
*/

#include "sc_atsrq.h"
#include "utgenstub.h"

/* UT includes */
#include "uttest.h"
#include "utassert.h"
#include "utstubs.h"

bool SC_BeginAts(uint16 AtsId, uint16 TimeOffset)
/*
* ----------------------------------------------------
* Generated stub function for SC_AppendAtsCmd()
* ----------------------------------------------------
*/
void SC_AppendAtsCmd(const CFE_SB_Buffer_t *BufPtr)
{
UT_Stub_RegisterContextGenericArg(UT_KEY(SC_BeginAts), AtsId);
UT_Stub_RegisterContextGenericArg(UT_KEY(SC_BeginAts), TimeOffset);
return UT_DEFAULT_IMPL(SC_BeginAts);
UT_GenStub_AddParam(SC_AppendAtsCmd, const CFE_SB_Buffer_t *, BufPtr);

UT_GenStub_Execute(SC_AppendAtsCmd, Basic, NULL);
}

void SC_StartAtsCmd(const CFE_SB_Buffer_t *CmdPacket)
/*
* ----------------------------------------------------
* Generated stub function for SC_BeginAts()
* ----------------------------------------------------
*/
bool SC_BeginAts(uint16 AtsIndex, uint16 TimeOffset)
{
UT_Stub_RegisterContext(UT_KEY(SC_StartAtsCmd), CmdPacket);
UT_DEFAULT_IMPL(SC_StartAtsCmd);
UT_GenStub_SetupReturnBuffer(SC_BeginAts, bool);

UT_GenStub_AddParam(SC_BeginAts, uint16, AtsIndex);
UT_GenStub_AddParam(SC_BeginAts, uint16, TimeOffset);

UT_GenStub_Execute(SC_BeginAts, Basic, NULL);

return UT_GenStub_GetReturnValue(SC_BeginAts, bool);
}

void SC_StopAtsCmd(const CFE_SB_Buffer_t *CmdPacket)
/*
* ----------------------------------------------------
* Generated stub function for SC_ContinueAtsOnFailureCmd()
* ----------------------------------------------------
*/
void SC_ContinueAtsOnFailureCmd(const CFE_SB_Buffer_t *BufPtr)
{
UT_Stub_RegisterContext(UT_KEY(SC_StopAtsCmd), CmdPacket);
UT_DEFAULT_IMPL(SC_StopAtsCmd);
UT_GenStub_AddParam(SC_ContinueAtsOnFailureCmd, const CFE_SB_Buffer_t *, BufPtr);

UT_GenStub_Execute(SC_ContinueAtsOnFailureCmd, Basic, NULL);
}

void SC_KillAts(void)
/*
* ----------------------------------------------------
* Generated stub function for SC_GroundSwitchCmd()
* ----------------------------------------------------
*/
void SC_GroundSwitchCmd(const CFE_SB_Buffer_t *BufPtr)
{
UT_DEFAULT_IMPL(SC_KillAts);
UT_GenStub_AddParam(SC_GroundSwitchCmd, const CFE_SB_Buffer_t *, BufPtr);

UT_GenStub_Execute(SC_GroundSwitchCmd, Basic, NULL);
}

void SC_GroundSwitchCmd(const CFE_SB_Buffer_t *CmdPacket)
/*
* ----------------------------------------------------
* Generated stub function for SC_InlineSwitch()
* ----------------------------------------------------
*/
bool SC_InlineSwitch(void)
{
UT_Stub_RegisterContext(UT_KEY(SC_GroundSwitchCmd), CmdPacket);
UT_DEFAULT_IMPL(SC_GroundSwitchCmd);
UT_GenStub_SetupReturnBuffer(SC_InlineSwitch, bool);

UT_GenStub_Execute(SC_InlineSwitch, Basic, NULL);

return UT_GenStub_GetReturnValue(SC_InlineSwitch, bool);
}

bool SC_InlineSwitch(void)
/*
* ----------------------------------------------------
* Generated stub function for SC_JumpAtsCmd()
* ----------------------------------------------------
*/
void SC_JumpAtsCmd(const CFE_SB_Buffer_t *BufPtr)
{
return UT_DEFAULT_IMPL(SC_InlineSwitch);
UT_GenStub_AddParam(SC_JumpAtsCmd, const CFE_SB_Buffer_t *, BufPtr);

UT_GenStub_Execute(SC_JumpAtsCmd, Basic, NULL);
}

void SC_ServiceSwitchPend(void)
/*
* ----------------------------------------------------
* Generated stub function for SC_KillAts()
* ----------------------------------------------------
*/
void SC_KillAts(void)
{
UT_DEFAULT_IMPL(SC_ServiceSwitchPend);

UT_GenStub_Execute(SC_KillAts, Basic, NULL);
}

void SC_JumpAtsCmd(const CFE_SB_Buffer_t *CmdPacket)
/*
* ----------------------------------------------------
* Generated stub function for SC_ServiceSwitchPend()
* ----------------------------------------------------
*/
void SC_ServiceSwitchPend(void)
{
UT_Stub_RegisterContext(UT_KEY(SC_JumpAtsCmd), CmdPacket);
UT_DEFAULT_IMPL(SC_JumpAtsCmd);

UT_GenStub_Execute(SC_ServiceSwitchPend, Basic, NULL);
}

void SC_ContinueAtsOnFailureCmd(const CFE_SB_Buffer_t *CmdPacket)
/*
* ----------------------------------------------------
* Generated stub function for SC_StartAtsCmd()
* ----------------------------------------------------
*/
void SC_StartAtsCmd(const CFE_SB_Buffer_t *BufPtr)
{
UT_Stub_RegisterContext(UT_KEY(SC_ContinueAtsOnFailureCmd), CmdPacket);
UT_DEFAULT_IMPL(SC_ContinueAtsOnFailureCmd);
UT_GenStub_AddParam(SC_StartAtsCmd, const CFE_SB_Buffer_t *, BufPtr);

UT_GenStub_Execute(SC_StartAtsCmd, Basic, NULL);
}

void SC_AppendAtsCmd(const CFE_SB_Buffer_t *CmdPacket)
/*
* ----------------------------------------------------
* Generated stub function for SC_StopAtsCmd()
* ----------------------------------------------------
*/
void SC_StopAtsCmd(const CFE_SB_Buffer_t *BufPtr)
{
UT_Stub_RegisterContext(UT_KEY(SC_AppendAtsCmd), CmdPacket);
UT_DEFAULT_IMPL(SC_AppendAtsCmd);
UT_GenStub_AddParam(SC_StopAtsCmd, const CFE_SB_Buffer_t *, BufPtr);

UT_GenStub_Execute(SC_StopAtsCmd, Basic, NULL);
}
Loading