From 0f2f11cb51f74c598e8dacaa19fb432aef1f0ad1 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Thu, 6 Jan 2022 16:15:43 -0500 Subject: [PATCH 1/4] Fix #129, reject FD packets with segment_metadata flag set The CF does not currently interpret/use the segment metadata option inside file data PDUs. Packets with this bit set should be rejected. --- fsw/src/cf_cfdp.c | 8 ++++++++ fsw/src/cf_events.h | 1 + unit-test/cf_cfdp_tests.c | 6 ++++++ 3 files changed, 15 insertions(+) diff --git a/fsw/src/cf_cfdp.c b/fsw/src/cf_cfdp.c index 4196a4db..e3e00f30 100644 --- a/fsw/src/cf_cfdp.c +++ b/fsw/src/cf_cfdp.c @@ -839,6 +839,14 @@ int CF_CFDP_RecvFd(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph) ++CF_AppData.hk.channel_hk[t->chan_num].counters.recv.error; ret = -1; } + else if (ph->pdu_header.segment_meta_flag) + { + /* If recv PDU has the "segment_meta_flag" set, this is not currently handled in CF. */ + CFE_EVS_SendEvent(CF_EID_ERR_PDU_FD_UNSUPPORTED, CFE_EVS_EventType_ERROR, + "CF: filedata pdu with segment metadata received"); + ++CF_AppData.hk.channel_hk[t->chan_num].counters.recv.error; + ret = -1; + } return ret; } diff --git a/fsw/src/cf_events.h b/fsw/src/cf_events.h index ea34c128..79ab0d3f 100644 --- a/fsw/src/cf_events.h +++ b/fsw/src/cf_events.h @@ -63,6 +63,7 @@ #define CF_EID_ERR_PDU_BAD_RX_MSG_SIZE 51 #define CF_EID_ERR_PDU_GET_EID_SIZE 52 #define CF_EID_ERR_PDU_GET_TSN_SIZE 53 +#define CF_EID_ERR_PDU_FD_UNSUPPORTED 54 /* CF_CFDP event ids (engine) */ #define CF_EID_ERR_CFDP_RX_DROPPED 60 diff --git a/unit-test/cf_cfdp_tests.c b/unit-test/cf_cfdp_tests.c index 7925ceb9..c7dd34e5 100644 --- a/unit-test/cf_cfdp_tests.c +++ b/unit-test/cf_cfdp_tests.c @@ -336,6 +336,12 @@ void Test_CF_CFDP_RecvFd(void) ph->int_header.fd.data_len = sizeof(CF_CFDP_uint32_t) - 1; UtAssert_INT32_EQ(CF_CFDP_RecvFd(t, ph), -1); UtAssert_BOOL_FALSE(CF_CODEC_IS_OK(ph->pdec)); + + /* with segment metadata (unimplemented) */ + UT_CFDP_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &t, NULL); + ph->pdu_header.segment_meta_flag = 1; + UtAssert_INT32_EQ(CF_CFDP_RecvFd(t, ph), -1); + UT_CF_AssertEventID(CF_EID_ERR_PDU_FD_UNSUPPORTED); } void Test_CF_CFDP_RecvEof(void) From c43981bde6e276defa70296c6c6c833a1bff2756 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Thu, 6 Jan 2022 14:49:25 -0500 Subject: [PATCH 2/4] Fix #148, use proper types for MsgId and mid values Ensures use of the proper SB-provided types for MsgIDs and MsgId values (aka CFE_SB_MsgId_Atom_t). This ensures that the values are used and converted properly. --- fsw/platform_inc/cf_tbldefs.h | 4 +-- fsw/src/cf_app.c | 26 +++++++++--------- fsw/src/cf_cfdp.c | 8 +++--- fsw/src/cf_cfdp_sbintf.c | 3 ++- unit-test/cf_app_tests.c | 29 ++++++++++++-------- unit-test/utilities/cf_test_utils.c | 42 ----------------------------- unit-test/utilities/cf_test_utils.h | 3 --- 7 files changed, 38 insertions(+), 77 deletions(-) diff --git a/fsw/platform_inc/cf_tbldefs.h b/fsw/platform_inc/cf_tbldefs.h index 11353896..ed12dbf9 100644 --- a/fsw/platform_inc/cf_tbldefs.h +++ b/fsw/platform_inc/cf_tbldefs.h @@ -47,8 +47,8 @@ typedef struct CF_ChannelConfig uint32 max_outgoing_messages_per_wakeup; /* max number of messages to send per wakeup (0 - unlimited) */ uint32 rx_max_messages_per_wakeup; /* max number of rx messages to process per wakeup */ - uint16 apid_input; /* apid for incoming messages */ - uint16 apid_output; /* apid for outgoing messages */ + CFE_SB_MsgId_Atom_t mid_input; /* msgid integer value for incoming messages */ + CFE_SB_MsgId_Atom_t mid_output; /* msgid integer value for outgoing messages */ uint16 pipe_depth_input; /* depth of pipe to receive incoming pdu */ diff --git a/fsw/src/cf_app.c b/fsw/src/cf_app.c index 9f83b35a..20890d56 100644 --- a/fsw/src/cf_app.c +++ b/fsw/src/cf_app.c @@ -342,12 +342,14 @@ int32 CF_Init(void) {CF_EID_ERR_CMD_WHIST_WRITE, 0x0000}, }; - int32 status = CFE_SUCCESS; + int32 status = CFE_SUCCESS; + static const CFE_SB_MsgId_Atom_t MID_VALUES[] = {CF_CMD_MID, CF_SEND_HK_MID, CF_WAKE_UP_MID}; + uint32 i; CF_AppData.run_status = CFE_ES_RunStatus_APP_RUN; - CFE_MSG_Init(&CF_AppData.hk.tlm_header.Msg, CF_HK_TLM_MID, sizeof(CF_AppData.hk)); - CFE_MSG_Init(&CF_AppData.cfg.tlm_header.Msg, CF_CONFIG_TLM_MID, sizeof(CF_AppData.cfg)); + CFE_MSG_Init(&CF_AppData.hk.tlm_header.Msg, CFE_SB_ValueToMsgId(CF_HK_TLM_MID), sizeof(CF_AppData.hk)); + CFE_MSG_Init(&CF_AppData.cfg.tlm_header.Msg, CFE_SB_ValueToMsgId(CF_CONFIG_TLM_MID), sizeof(CF_AppData.cfg)); if ((status = CFE_EVS_Register(cf_event_filters, sizeof(cf_event_filters) / sizeof(*cf_event_filters), CFE_EVS_EventFilter_BINARY)) != CFE_SUCCESS) @@ -362,17 +364,13 @@ int32 CF_Init(void) goto err_out; } + for (i = 0; i < (sizeof(MID_VALUES) / sizeof(MID_VALUES[0])); ++i) { - const CFE_SB_MsgId_t mids[] = {CF_CMD_MID, CF_SEND_HK_MID, CF_WAKE_UP_MID}; - int i; - - for (i = 0; i < (sizeof(mids) / sizeof(*mids)); ++i) + if ((status = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(MID_VALUES[i]), CF_AppData.cmd_pipe)) != CFE_SUCCESS) { - if ((status = CFE_SB_Subscribe(mids[i], CF_AppData.cmd_pipe)) != CFE_SUCCESS) - { - CFE_ES_WriteToSysLog("CF app: failed to subscribe to MID 0x%04x, returned 0x%08x", mids[i], status); - goto err_out; - } + CFE_ES_WriteToSysLog("CF app: failed to subscribe to MID 0x%04lx, returned 0x%08lx", + (unsigned long)MID_VALUES[i], (unsigned long)status); + goto err_out; } } @@ -435,7 +433,7 @@ void CF_ProcessMsg(CFE_SB_Buffer_t *msg) CFE_MSG_GetMsgId(&msg->Msg, &msg_id); - switch (msg_id) + switch (CFE_SB_MsgIdToValue(msg_id)) { case CF_CMD_MID: CF_ProcessGroundCommand(msg); @@ -453,7 +451,7 @@ void CF_ProcessMsg(CFE_SB_Buffer_t *msg) default: ++CF_AppData.hk.counters.err; CFE_EVS_SendEvent(CF_EID_ERR_INIT_CMD_LENGTH, CFE_EVS_EventType_ERROR, - "CF: invalid command packet id=0x%02x", msg_id); + "CF: invalid command packet id=0x%lx", (unsigned long)CFE_SB_MsgIdToValue(msg_id)); break; } } diff --git a/fsw/src/cf_cfdp.c b/fsw/src/cf_cfdp.c index 4196a4db..be6df85f 100644 --- a/fsw/src/cf_cfdp.c +++ b/fsw/src/cf_cfdp.c @@ -1107,13 +1107,13 @@ int32 CF_CFDP_InitEngine(void) goto err_out; } - if ((ret = - CFE_SB_SubscribeLocal(CF_AppData.config_table->chan[i].apid_input, CF_AppData.engine.channels[i].pipe, - CF_AppData.config_table->chan[i].pipe_depth_input)) != CFE_SUCCESS) + if ((ret = CFE_SB_SubscribeLocal(CFE_SB_ValueToMsgId(CF_AppData.config_table->chan[i].mid_input), + CF_AppData.engine.channels[i].pipe, + CF_AppData.config_table->chan[i].pipe_depth_input)) != CFE_SUCCESS) { CFE_EVS_SendEvent(CF_EID_ERR_INIT_SUB, CFE_EVS_EventType_ERROR, "CF: failed to subscribe to MID 0x%04x, returned 0x%08x", - CF_AppData.config_table->chan[i].apid_input, ret); + CF_AppData.config_table->chan[i].mid_input, ret); goto err_out; } diff --git a/fsw/src/cf_cfdp_sbintf.c b/fsw/src/cf_cfdp_sbintf.c index 6655d109..ca695b10 100644 --- a/fsw/src/cf_cfdp_sbintf.c +++ b/fsw/src/cf_cfdp_sbintf.c @@ -116,7 +116,8 @@ CF_Logical_PduBuffer_t *CF_CFDP_MsgOutGet(const CF_Transaction_t *t, bool silent goto error_out; } - CFE_MSG_Init(&CF_AppData.engine.out.msg->Msg, CF_AppData.config_table->chan[t->chan_num].apid_output, 0); + CFE_MSG_Init(&CF_AppData.engine.out.msg->Msg, + CFE_SB_ValueToMsgId(CF_AppData.config_table->chan[t->chan_num].mid_output), 0); ++CF_AppData.engine.outgoing_counter; /* even if max_outgoing_messages_per_wakeup is 0 (unlimited), it's ok to inc this */ diff --git a/unit-test/cf_app_tests.c b/unit-test/cf_app_tests.c index facacc68..6e3bb7ec 100644 --- a/unit-test/cf_app_tests.c +++ b/unit-test/cf_app_tests.c @@ -611,7 +611,7 @@ void Test_CF_ProcessMsg_ProcessGroundCommand(void) /* Arrange */ CFE_SB_Buffer_t dummy_msg; CFE_SB_Buffer_t *arg_msg = &dummy_msg; - CFE_SB_MsgId_t forced_MsgID = CF_CMD_MID; + CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(CF_CMD_MID); CFE_SB_Buffer_t *context_CF_ProcessGroundCommand_msg; CFE_MSG_GetMsgId_context_t context_CFE_MSG_GetMsgId; @@ -637,7 +637,7 @@ void Test_CF_ProcessMsg_WakeUp(void) /* Arrange */ CFE_SB_Buffer_t dummy_msg; CFE_SB_Buffer_t *arg_msg = &dummy_msg; - CFE_SB_MsgId_t forced_MsgID = CF_WAKE_UP_MID; + CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(CF_WAKE_UP_MID); CFE_MSG_GetMsgId_context_t context_CFE_MSG_GetMsgId; /* CFE_MSG_GetMsgId uses return by ref */ @@ -661,7 +661,7 @@ void Test_CF_ProcessMsg_SendHk(void) // CFE_MSG_Message_t dummy_Msg; // CFE_SB_Buffer_t dummy_msg; CFE_SB_Buffer_t *arg_msg = NULL; - CFE_SB_MsgId_t forced_MsgID = CF_SEND_HK_MID; + CFE_SB_MsgId_t forced_MsgID = CFE_SB_ValueToMsgId(CF_SEND_HK_MID); CFE_MSG_GetMsgId_context_t context_CFE_MSG_GetMsgId; /* CFE_MSG_GetMsgId uses return by ref */ @@ -687,14 +687,24 @@ void Test_CF_ProcessMsg_SendHk(void) void Test_CF_ProcessMsg_UnrecognizedCommandEnterDefaultPath(void) { /* Arrange */ - uint16 initial_err_count = CF_AppData.hk.counters.err; - CFE_SB_MsgId_t excepted_msg_ids[3] = {CF_CMD_MID, CF_WAKE_UP_MID, CF_SEND_HK_MID}; - CFE_SB_MsgId_t forced_MsgID = Any_MsgId_ExceptThese(excepted_msg_ids, 3); - CFE_SB_Buffer_t *arg_msg = NULL; - const char *expected_Spec = "CF: invalid command packet id=0x%02x"; + uint16 initial_err_count = CF_AppData.hk.counters.err; + CFE_SB_MsgId_Atom_t midval; + CFE_SB_MsgId_t forced_MsgID; + CFE_SB_Buffer_t *arg_msg = NULL; CFE_MSG_GetMsgId_context_t context_CFE_MSG_GetMsgId; CFE_EVS_SendEvent_context_t context_CFE_EVS_SendEvent; + /* do not use one of the three real MIDs. + * As this depends on configuration, should not hardcode values here + */ + midval = 1; + while (midval == CF_CMD_MID || midval == CF_WAKE_UP_MID || midval == CF_SEND_HK_MID) + { + ++midval; + } + + forced_MsgID = CFE_SB_ValueToMsgId(midval); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &forced_MsgID, sizeof(forced_MsgID), false); UT_SetHookFunction(UT_KEY(CFE_MSG_GetMsgId), UT_Hook_CFE_MSG_GetMsgId, &context_CFE_MSG_GetMsgId); UT_CF_ResetEventCapture(UT_KEY(CFE_EVS_SendEvent)); @@ -713,9 +723,6 @@ void Test_CF_ProcessMsg_UnrecognizedCommandEnterDefaultPath(void) UtAssert_True(context_CFE_EVS_SendEvent.EventType == CFE_EVS_EventType_ERROR, "CFE_EVS_SendEvent received EventType %u and should have received %u (CFE_EVS_EventType_ERROR)", context_CFE_EVS_SendEvent.EventType, CFE_EVS_EventType_ERROR); - UtAssert_StrCmp(context_CFE_EVS_SendEvent.Spec, expected_Spec, - "CFE_EVS_SendEvent received expected Spec\n'%s' - Received\n'%s' - Expected", - context_CFE_EVS_SendEvent.Spec, expected_Spec); } /* end Test_CF_ProcessMsg_UnrecognizedCommandEnterDefaultPath */ diff --git a/unit-test/utilities/cf_test_utils.c b/unit-test/utilities/cf_test_utils.c index 01bd2ff6..90584098 100644 --- a/unit-test/utilities/cf_test_utils.c +++ b/unit-test/utilities/cf_test_utils.c @@ -796,45 +796,3 @@ uint8 Any_cf_chan_num(void) { return Any_uint8_LessThan(CF_NUM_CHANNELS); } - -CFE_SB_MsgId_t Any_MsgId(void) -{ - size_t msg_id_size = sizeof(CFE_SB_MsgId_t); - - switch (msg_id_size) - { - case 4: - return Any_uint32(); - - case 2: - return Any_uint16(); - - default: - UtAssert_Failed("Any_MsgId_ExceptThese unimplemented sizeof(CFE_SB_MsgId_t) = %lu", msg_id_size); - UtAssert_Abort(__func__); - } - - return (CFE_SB_MsgId_t)UT_UINT_16_DEFAULT; /* default for switch(msg_id_size) will always assert, this should not be - able to happen, but removes warning on build */ -} - -CFE_SB_MsgId_t Any_MsgId_ExceptThese(CFE_SB_MsgId_t exceptions[], uint8 num_exceptions) -{ - size_t msg_id_size = sizeof(CFE_SB_MsgId_t); - - switch (msg_id_size) - { - case 4: - return Any_uint32_ExceptThese((uint32 *)exceptions, num_exceptions); - - case 2: - return Any_uint16_ExceptThese((uint16 *)exceptions, num_exceptions); - - default: - UtAssert_Failed("Any_MsgId_ExceptThese unimplemented sizeof(CFE_SB_MsgId_t) = %lu", msg_id_size); - UtAssert_Abort(__func__); - } - - return (CFE_SB_MsgId_t)UT_UINT_16_DEFAULT; /* default for switch(msg_id_size) will always assert, this should not be - able to happen, but removes warning on build */ -} diff --git a/unit-test/utilities/cf_test_utils.h b/unit-test/utilities/cf_test_utils.h index 0a33883c..dbfd3241 100644 --- a/unit-test/utilities/cf_test_utils.h +++ b/unit-test/utilities/cf_test_utils.h @@ -283,7 +283,4 @@ CFE_Status_t Any_CFE_Status_t_Except(CFE_Status_t exception); CFE_MSG_Size_t Any_CFE_MSG_Size_t(void); CFE_MSG_Size_t Any_CFE_MSG_Size_t_LessThan(size_t ceiling); -CFE_SB_MsgId_t Any_MsgId(void); -CFE_SB_MsgId_t Any_MsgId_ExceptThese(CFE_SB_MsgId_t exceptions[], uint8 num_exceptions); - #endif /* _cf_test_utils_h_ */ From 5855cf0d0351f8c6bce73dc23debd1e6d98a78fc Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Thu, 6 Jan 2022 17:27:41 -0500 Subject: [PATCH 3/4] Fix #110, #149, update identifier names Renames all remaining identifiers that did not have an appropriate name per the coding standards. Specifically, this is anything that did not start with CF prefix (#149) and anything that ended with an underscore only (#110). --- fsw/src/cf_cfdp.c | 35 ++-- fsw/src/cf_cfdp.h | 8 +- fsw/src/cf_cmd.c | 54 +++--- fsw/src/cf_cmd.h | 36 ++-- fsw/src/cf_utils.c | 34 ++-- fsw/src/cf_utils.h | 24 +-- unit-test/cf_cfdp_tests.c | 25 +-- unit-test/cf_cmd_tests.c | 198 +++++++++++----------- unit-test/cf_utils_tests.c | 187 ++++++++++---------- unit-test/stubs/cf_cfdp_stubs.c | 14 +- unit-test/stubs/cf_cmd_stubs.c | 46 ++--- unit-test/stubs/cf_utils_stubs.c | 52 +++--- unit-test/utilities/cf_test_alt_handler.c | 12 +- 13 files changed, 364 insertions(+), 361 deletions(-) diff --git a/fsw/src/cf_cfdp.c b/fsw/src/cf_cfdp.c index 4196a4db..50eccdab 100644 --- a/fsw/src/cf_cfdp.c +++ b/fsw/src/cf_cfdp.c @@ -1178,7 +1178,7 @@ int32 CF_CFDP_InitEngine(void) ** \endreturns ** *************************************************************************/ -int CF_CFDP_CycleTx_(CF_CListNode_t *node, void *context) +int CF_CFDP_CycleTxFirstActive(CF_CListNode_t *node, void *context) { CF_CFDP_CycleTx_args_t *args = (CF_CFDP_CycleTx_args_t *)context; CF_Transaction_t *t = container_of(node, CF_Transaction_t, cl_node); @@ -1246,7 +1246,7 @@ void CF_CFDP_CycleTx(CF_Channel_t *c) CF_MoveTransaction(t, CF_QueueIdx_TXA); /* args is ok, still { c, 0 } */ entry_jump: - CF_CList_Traverse(c->qs[CF_QueueIdx_TXA], CF_CFDP_CycleTx_, &args); + CF_CList_Traverse(c->qs[CF_QueueIdx_TXA], CF_CFDP_CycleTxFirstActive, &args); } } @@ -1269,9 +1269,9 @@ void CF_CFDP_CycleTx(CF_Channel_t *c) *************************************************************************/ int CF_CFDP_DoTick(CF_CListNode_t *node, void *context) { - int ret = CF_CLIST_CONT; /* CF_CLIST_CONT means don't tick one, keep looking for cur */ - tick_args_t *args = (tick_args_t *)context; - CF_Transaction_t *t = container_of(node, CF_Transaction_t, cl_node); + int ret = CF_CLIST_CONT; /* CF_CLIST_CONT means don't tick one, keep looking for cur */ + CF_CFDP_Tick_args_t *args = (CF_CFDP_Tick_args_t *)context; + CF_Transaction_t *t = container_of(node, CF_Transaction_t, cl_node); if (!args->c->cur || (args->c->cur == t)) { /* found where we left off, so clear that and move on */ @@ -1321,7 +1321,7 @@ void CF_CFDP_TickTransactions(CF_Channel_t *c) for (; c->tick_type < CF_TickType_NUM_TYPES; ++c->tick_type) { - tick_args_t args = {c, fns[c->tick_type], 0, 0}; + CF_CFDP_Tick_args_t args = {c, fns[c->tick_type], 0, 0}; do { @@ -1384,8 +1384,8 @@ void CF_CFDP_InitTxnTxFile(CF_Transaction_t *t, CF_CFDP_Class_t cfdp_class, uint ** t must not be NULL. ** *************************************************************************/ -static void CF_CFDP_TxFile_(CF_Transaction_t *t, CF_CFDP_Class_t cfdp_class, uint8 keep, uint8 chan, uint8 priority, - CF_EntityId_t dest_id) +static void CF_CFDP_TxFile_Initiate(CF_Transaction_t *t, CF_CFDP_Class_t cfdp_class, uint8 keep, uint8 chan, + uint8 priority, CF_EntityId_t dest_id) { CFE_EVS_SendEvent(CF_EID_INF_CFDP_S_START_SEND, CFE_EVS_EventType_INFORMATION, "CF: start class %d tx of file %d:%.*s -> %d:%.*s", cfdp_class + 1, @@ -1448,7 +1448,7 @@ int32 CF_CFDP_TxFile(const char *src_filename, const char *dst_filename, CF_CFDP t->history->fnames.src_filename[sizeof(t->history->fnames.src_filename) - 1] = 0; strncpy(t->history->fnames.dst_filename, dst_filename, sizeof(t->history->fnames.dst_filename) - 1); t->history->fnames.dst_filename[sizeof(t->history->fnames.dst_filename) - 1] = 0; - CF_CFDP_TxFile_(t, cfdp_class, keep, chan, priority, dest_id); + CF_CFDP_TxFile_Initiate(t, cfdp_class, keep, chan, priority, dest_id); ++c->num_cmd_tx; t->flags.tx.cmd_tx = 1; @@ -1472,9 +1472,9 @@ int32 CF_CFDP_TxFile(const char *src_filename, const char *dst_filename, CF_CFDP ** \endreturns ** *************************************************************************/ -static int32 CF_CFDP_PlaybackDir_(CF_Playback_t *p, const char *src_filename, const char *dst_filename, - CF_CFDP_Class_t cfdp_class, uint8 keep, uint8 chan, uint8 priority, - CF_EntityId_t dest_id) +static int32 CF_CFDP_PlaybackDir_Initiate(CF_Playback_t *p, const char *src_filename, const char *dst_filename, + CF_CFDP_Class_t cfdp_class, uint8 keep, uint8 chan, uint8 priority, + CF_EntityId_t dest_id) { int32 ret = CFE_SUCCESS; @@ -1544,7 +1544,7 @@ int32 CF_CFDP_PlaybackDir(const char *src_filename, const char *dst_filename, CF return -1; } - return CF_CFDP_PlaybackDir_(p, src_filename, dst_filename, cfdp_class, keep, chan, priority, dest_id); + return CF_CFDP_PlaybackDir_Initiate(p, src_filename, dst_filename, cfdp_class, keep, chan, priority, dest_id); } /************************************************************************/ @@ -1598,7 +1598,8 @@ void CF_CFDP_ProcessPlaybackDirectory(CF_Channel_t *c, CF_Playback_t *p) pt->history->fnames.src_filename[CF_FILENAME_MAX_LEN - 1] = 0; pt->history->fnames.dst_filename[CF_FILENAME_MAX_LEN - 1] = 0; - CF_CFDP_TxFile_(pt, p->cfdp_class, p->keep, (c - CF_AppData.engine.channels), p->priority, p->dest_id); + CF_CFDP_TxFile_Initiate(pt, p->cfdp_class, p->keep, (c - CF_AppData.engine.channels), p->priority, + p->dest_id); pt->p = p; ++p->num_ts; @@ -1707,8 +1708,8 @@ void CF_CFDP_ProcessPollingDirectories(CF_Channel_t *c) else if (CF_Timer_Expired(&p->interval_timer)) { /* the timer has expired */ - int ret = CF_CFDP_PlaybackDir_(&p->pb, pd->src_dir, pd->dst_dir, pd->cfdp_class, 0, chan_index, - pd->priority, pd->dest_eid); + int ret = CF_CFDP_PlaybackDir_Initiate(&p->pb, pd->src_dir, pd->dst_dir, pd->cfdp_class, 0, + chan_index, pd->priority, pd->dest_eid); if (!ret) { p->timer_set = 0; @@ -1716,7 +1717,7 @@ void CF_CFDP_ProcessPollingDirectories(CF_Channel_t *c) else { /* error occured in playback directory, so reset the timer */ - /* an event is sent in CF_CFDP_PlaybackDir_ so there is no reason to + /* an event is sent in CF_CFDP_PlaybackDir_Initiate so there is no reason to * to have another here */ CF_Timer_InitRelSec(&p->interval_timer, pd->interval_sec); } diff --git a/fsw/src/cf_cfdp.h b/fsw/src/cf_cfdp.h index 25535d1b..9a749260 100644 --- a/fsw/src/cf_cfdp.h +++ b/fsw/src/cf_cfdp.h @@ -29,19 +29,19 @@ #include "cf_cfdp_types.h" -typedef struct CF_CFDP_CycleTx_args_t +typedef struct CF_CFDP_CycleTx_args { CF_Channel_t *c; int ran_one; } CF_CFDP_CycleTx_args_t; -typedef struct +typedef struct CF_CFDP_Tick_args { CF_Channel_t *c; /* IN param */ void (*fn)(CF_Transaction_t *, int *); /* IN param */ int early_exit; /* OUT param */ int cont; /* if 1, then re-traverse the list */ -} tick_args_t; +} CF_CFDP_Tick_args_t; void CF_CFDP_EncodeStart(CF_EncoderState_t *penc, void *msgbuf, CF_Logical_PduBuffer_t *ph, size_t encap_hdr_size, size_t total_size); @@ -110,7 +110,7 @@ void CF_CFDP_RecvIdle(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph); int CF_CFDP_CloseFiles(CF_CListNode_t *n, void *context); void CF_CFDP_CycleTx(CF_Channel_t *c); -int CF_CFDP_CycleTx_(CF_CListNode_t *node, void *context); +int CF_CFDP_CycleTxFirstActive(CF_CListNode_t *node, void *context); void CF_CFDP_TickTransactions(CF_Channel_t *c); void CF_CFDP_ProcessPlaybackDirectory(CF_Channel_t *c, CF_Playback_t *p); void CF_CFDP_ProcessPollingDirectories(CF_Channel_t *c); diff --git a/fsw/src/cf_cmd.c b/fsw/src/cf_cmd.c index 54748e71..78f12d46 100644 --- a/fsw/src/cf_cmd.c +++ b/fsw/src/cf_cmd.c @@ -204,7 +204,7 @@ void CF_CmdPlaybackDir(CFE_SB_Buffer_t *msg) ** \endreturns ** *************************************************************************/ -int CF_DoChanAction(CF_UnionArgsCmd_t *cmd, const char *errstr, chan_action_fn_t fn, void *context) +int CF_DoChanAction(CF_UnionArgsCmd_t *cmd, const char *errstr, CF_ChanActionFn_t fn, void *context) { int ret = 0; @@ -244,7 +244,7 @@ int CF_DoChanAction(CF_UnionArgsCmd_t *cmd, const char *errstr, chan_action_fn_t ** \endreturns ** *************************************************************************/ -int CF_DoFreezeThaw(uint8 chan_num, const bool_arg_t *context) +int CF_DoFreezeThaw(uint8 chan_num, const CF_ChanAction_BoolArg_t *context) { /* no need to bounds check chan_num, done in caller */ CF_AppData.hk.channel_hk[chan_num].frozen = context->barg; @@ -260,8 +260,8 @@ int CF_DoFreezeThaw(uint8 chan_num, const bool_arg_t *context) *************************************************************************/ void CF_CmdFreeze(CFE_SB_Buffer_t *msg) { - bool_arg_t barg = {1}; /* param is frozen, so 1 means freeze */ - CF_CmdCond(CF_DoChanAction((CF_UnionArgsCmd_t *)msg, "freeze", (chan_action_fn_t)CF_DoFreezeThaw, &barg)); + CF_ChanAction_BoolArg_t barg = {1}; /* param is frozen, so 1 means freeze */ + CF_CmdCond(CF_DoChanAction((CF_UnionArgsCmd_t *)msg, "freeze", (CF_ChanActionFn_t)CF_DoFreezeThaw, &barg)); } /************************************************************************/ @@ -273,8 +273,8 @@ void CF_CmdFreeze(CFE_SB_Buffer_t *msg) *************************************************************************/ void CF_CmdThaw(CFE_SB_Buffer_t *msg) { - bool_arg_t barg = {0}; /* param is frozen, so 0 means thawed */ - CF_CmdCond(CF_DoChanAction((CF_UnionArgsCmd_t *)msg, "thaw", (chan_action_fn_t)CF_DoFreezeThaw, &barg)); + CF_ChanAction_BoolArg_t barg = {0}; /* param is frozen, so 0 means thawed */ + CF_CmdCond(CF_DoChanAction((CF_UnionArgsCmd_t *)msg, "thaw", (CF_ChanActionFn_t)CF_DoFreezeThaw, &barg)); } /************************************************************************/ @@ -374,7 +374,7 @@ int CF_TsnChanAction(CF_TransactionCmd_t *cmd, const char *cmdstr, CF_TsnChanAct ** t must not be NULL. context must not be NULL. ** *************************************************************************/ -void CF_DoSuspRes_(CF_Transaction_t *t, susp_res_arg_t *context) +void CF_DoSuspRes_Txn(CF_Transaction_t *t, CF_ChanAction_SuspResArg_t *context) { CF_Assert(t); if (t->flags.com.suspended == context->action) @@ -401,9 +401,9 @@ void CF_DoSuspRes_(CF_Transaction_t *t, susp_res_arg_t *context) void CF_DoSuspRes(CF_TransactionCmd_t *cmd, uint8 action) { /* ok to not bounds check action, because the caller is using it in two places with constant values 0 or 1 */ - static const char *msgstr[] = {"resume", "suspend"}; - susp_res_arg_t args = {0, action}; - int ret = CF_TsnChanAction(cmd, msgstr[action], (CF_TsnChanAction_fn_t)CF_DoSuspRes_, &args); + static const char *msgstr[] = {"resume", "suspend"}; + CF_ChanAction_SuspResArg_t args = {0, action}; + int ret = CF_TsnChanAction(cmd, msgstr[action], (CF_TsnChanAction_fn_t)CF_DoSuspRes_Txn, &args); if (!ret && args.same) { @@ -454,7 +454,7 @@ void CF_CmdResume(CFE_SB_Buffer_t *msg) ** t must not be NULL. ** *************************************************************************/ -void CF_CmdCancel_(CF_Transaction_t *t, void *ignored) +void CF_CmdCancel_Txn(CF_Transaction_t *t, void *ignored) { CF_CFDP_CancelTransaction(t); } @@ -468,7 +468,7 @@ void CF_CmdCancel_(CF_Transaction_t *t, void *ignored) *************************************************************************/ void CF_CmdCancel(CFE_SB_Buffer_t *msg) { - CF_CmdCond(CF_TsnChanAction((CF_TransactionCmd_t *)msg, "cancel", CF_CmdCancel_, NULL)); + CF_CmdCond(CF_TsnChanAction((CF_TransactionCmd_t *)msg, "cancel", CF_CmdCancel_Txn, NULL)); } /************************************************************************/ @@ -478,7 +478,7 @@ void CF_CmdCancel(CFE_SB_Buffer_t *msg) ** msg must not be NULL. ** *************************************************************************/ -void CF_CmdAbandon_(CF_Transaction_t *t, void *ignored) +void CF_CmdAbandon_Txn(CF_Transaction_t *t, void *ignored) { CF_CFDP_ResetTransaction(t, 0); } @@ -492,7 +492,7 @@ void CF_CmdAbandon_(CF_Transaction_t *t, void *ignored) *************************************************************************/ void CF_CmdAbandon(CFE_SB_Buffer_t *msg) { - CF_CmdCond(CF_TsnChanAction((CF_TransactionCmd_t *)msg, "abandon", CF_CmdAbandon_, NULL)); + CF_CmdCond(CF_TsnChanAction((CF_TransactionCmd_t *)msg, "abandon", CF_CmdAbandon_Txn, NULL)); } /************************************************************************/ @@ -506,7 +506,7 @@ void CF_CmdAbandon(CFE_SB_Buffer_t *msg) ** \endreturns ** *************************************************************************/ -int CF_DoEnableDisableDequeue(uint8 chan_num, const bool_arg_t *context) +int CF_DoEnableDisableDequeue(uint8 chan_num, const CF_ChanAction_BoolArg_t *context) { /* no need to bounds check chan_num, done in caller */ CF_AppData.config_table->chan[chan_num].dequeue_enabled = context->barg; @@ -522,8 +522,8 @@ int CF_DoEnableDisableDequeue(uint8 chan_num, const bool_arg_t *context) *************************************************************************/ void CF_CmdEnableDequeue(CFE_SB_Buffer_t *msg) { - bool_arg_t barg = {1}; - CF_CmdCond(CF_DoChanAction((CF_UnionArgsCmd_t *)msg, "enable_dequeue", (chan_action_fn_t)CF_DoEnableDisableDequeue, + CF_ChanAction_BoolArg_t barg = {1}; + CF_CmdCond(CF_DoChanAction((CF_UnionArgsCmd_t *)msg, "enable_dequeue", (CF_ChanActionFn_t)CF_DoEnableDisableDequeue, &barg)); } @@ -536,9 +536,9 @@ void CF_CmdEnableDequeue(CFE_SB_Buffer_t *msg) *************************************************************************/ void CF_CmdDisableDequeue(CFE_SB_Buffer_t *msg) { - bool_arg_t barg = {0}; - CF_CmdCond(CF_DoChanAction((CF_UnionArgsCmd_t *)msg, "disable_dequeue", (chan_action_fn_t)CF_DoEnableDisableDequeue, - &barg)); + CF_ChanAction_BoolArg_t barg = {0}; + CF_CmdCond(CF_DoChanAction((CF_UnionArgsCmd_t *)msg, "disable_dequeue", + (CF_ChanActionFn_t)CF_DoEnableDisableDequeue, &barg)); } /************************************************************************/ @@ -548,7 +548,7 @@ void CF_CmdDisableDequeue(CFE_SB_Buffer_t *msg) ** context must not be NULL. ** *************************************************************************/ -int CF_DoEnableDisablePolldir(uint8 chan_num, const bool_msg_arg_t *context) +int CF_DoEnableDisablePolldir(uint8 chan_num, const CF_ChanAction_BoolMsgArg_t *context) { int ret = 0; /* no need to bounds check chan_num, done in caller */ @@ -583,8 +583,8 @@ int CF_DoEnableDisablePolldir(uint8 chan_num, const bool_msg_arg_t *context) *************************************************************************/ void CF_CmdEnablePolldir(CFE_SB_Buffer_t *msg) { - bool_msg_arg_t barg = {(CF_UnionArgsCmd_t *)msg, 1}; - CF_CmdCond(CF_DoChanAction((CF_UnionArgsCmd_t *)msg, "enable_polldir", (chan_action_fn_t)CF_DoEnableDisablePolldir, + CF_ChanAction_BoolMsgArg_t barg = {(CF_UnionArgsCmd_t *)msg, 1}; + CF_CmdCond(CF_DoChanAction((CF_UnionArgsCmd_t *)msg, "enable_polldir", (CF_ChanActionFn_t)CF_DoEnableDisablePolldir, &barg)); } @@ -597,9 +597,9 @@ void CF_CmdEnablePolldir(CFE_SB_Buffer_t *msg) *************************************************************************/ void CF_CmdDisablePolldir(CFE_SB_Buffer_t *msg) { - bool_msg_arg_t barg = {(CF_UnionArgsCmd_t *)msg, 0}; - CF_CmdCond(CF_DoChanAction((CF_UnionArgsCmd_t *)msg, "disable_polldir", (chan_action_fn_t)CF_DoEnableDisablePolldir, - &barg)); + CF_ChanAction_BoolMsgArg_t barg = {(CF_UnionArgsCmd_t *)msg, 0}; + CF_CmdCond(CF_DoChanAction((CF_UnionArgsCmd_t *)msg, "disable_polldir", + (CF_ChanActionFn_t)CF_DoEnableDisablePolldir, &barg)); } /************************************************************************/ @@ -698,7 +698,7 @@ int CF_DoPurgeQueue(uint8 chan_num, CF_UnionArgsCmd_t *cmd) *************************************************************************/ void CF_CmdPurgeQueue(CFE_SB_Buffer_t *msg) { - CF_CmdCond(CF_DoChanAction((CF_UnionArgsCmd_t *)msg, "purge_queue", (chan_action_fn_t)CF_DoPurgeQueue, msg)); + CF_CmdCond(CF_DoChanAction((CF_UnionArgsCmd_t *)msg, "purge_queue", (CF_ChanActionFn_t)CF_DoPurgeQueue, msg)); } /************************************************************************/ diff --git a/fsw/src/cf_cmd.h b/fsw/src/cf_cmd.h index 8fec7a60..37ec12c7 100644 --- a/fsw/src/cf_cmd.h +++ b/fsw/src/cf_cmd.h @@ -26,26 +26,26 @@ #include "cf_app.h" #include "cf_utils.h" -typedef int (*chan_action_fn_t)(uint8 chan_num, void *context); +typedef int (*CF_ChanActionFn_t)(uint8 chan_num, void *context); -typedef struct +typedef struct CF_ChanAction_BoolArg { - uint8 barg; -} bool_arg_t; + bool barg; +} CF_ChanAction_BoolArg_t; typedef CF_TraverseAllTransactions_fn_t CF_TsnChanAction_fn_t; -typedef struct +typedef struct CF_ChanAction_SuspResArg { - int same; /* out param -- indicates at least one action was set to its current value */ - uint8 action; -} susp_res_arg_t; + int same; /* out param -- indicates at least one action was set to its current value */ + bool action; +} CF_ChanAction_SuspResArg_t; -typedef struct +typedef struct CF_ChanAction_BoolMsgArg { const CF_UnionArgsCmd_t *msg; - uint8 barg; -} bool_msg_arg_t; + bool barg; +} CF_ChanAction_BoolMsgArg_t; /************************************************************************/ /** \brief Increment the command accepted counter. @@ -88,24 +88,24 @@ void CF_CmdNoop(CFE_SB_Buffer_t *msg); void CF_CmdReset(CFE_SB_Buffer_t *msg); void CF_CmdTxFile(CFE_SB_Buffer_t *msg); void CF_CmdPlaybackDir(CFE_SB_Buffer_t *msg); -int CF_DoChanAction(CF_UnionArgsCmd_t *cmd, const char *errstr, chan_action_fn_t fn, void *context); -int CF_DoFreezeThaw(uint8 chan_num, const bool_arg_t *context); +int CF_DoChanAction(CF_UnionArgsCmd_t *cmd, const char *errstr, CF_ChanActionFn_t fn, void *context); +int CF_DoFreezeThaw(uint8 chan_num, const CF_ChanAction_BoolArg_t *context); void CF_CmdFreeze(CFE_SB_Buffer_t *msg); void CF_CmdThaw(CFE_SB_Buffer_t *msg); CF_Transaction_t *CF_FindTransactionBySequenceNumberAllChannels(CF_TransactionSeq_t ts, CF_EntityId_t eid); int CF_TsnChanAction(CF_TransactionCmd_t *cmd, const char *cmdstr, CF_TsnChanAction_fn_t fn, void *context); -void CF_DoSuspRes_(CF_Transaction_t *t, susp_res_arg_t *context); +void CF_DoSuspRes_Txn(CF_Transaction_t *t, CF_ChanAction_SuspResArg_t *context); void CF_DoSuspRes(CF_TransactionCmd_t *cmd, uint8 action); void CF_CmdSuspend(CFE_SB_Buffer_t *msg); void CF_CmdResume(CFE_SB_Buffer_t *msg); -void CF_CmdCancel_(CF_Transaction_t *t, void *ignored); +void CF_CmdCancel_Txn(CF_Transaction_t *t, void *ignored); void CF_CmdCancel(CFE_SB_Buffer_t *msg); -void CF_CmdAbandon_(CF_Transaction_t *t, void *ignored); +void CF_CmdAbandon_Txn(CF_Transaction_t *t, void *ignored); void CF_CmdAbandon(CFE_SB_Buffer_t *msg); -int CF_DoEnableDisableDequeue(uint8 chan_num, const bool_arg_t *context); +int CF_DoEnableDisableDequeue(uint8 chan_num, const CF_ChanAction_BoolArg_t *context); void CF_CmdEnableDequeue(CFE_SB_Buffer_t *msg); void CF_CmdDisableDequeue(CFE_SB_Buffer_t *msg); -int CF_DoEnableDisablePolldir(uint8 chan_num, const bool_msg_arg_t *context); +int CF_DoEnableDisablePolldir(uint8 chan_num, const CF_ChanAction_BoolMsgArg_t *context); void CF_CmdEnablePolldir(CFE_SB_Buffer_t *msg); void CF_CmdDisablePolldir(CFE_SB_Buffer_t *msg); int CF_PurgeHistory(CF_CListNode_t *n, CF_Channel_t *c); diff --git a/fsw/src/cf_utils.c b/fsw/src/cf_utils.c index dc5ef79c..f214b076 100644 --- a/fsw/src/cf_utils.c +++ b/fsw/src/cf_utils.c @@ -138,7 +138,7 @@ void CF_FreeTransaction(CF_Transaction_t *t) ** \endreturns ** *************************************************************************/ -int CF_FindTransactionBySequenceNumber_(CF_CListNode_t *n, trans_seq_arg_t *context) +int CF_FindTransactionBySequenceNumber_Impl(CF_CListNode_t *n, CF_Traverse_TransSeqArg_t *context) { CF_Transaction_t *t = container_of(n, CF_Transaction_t, cl_node); int ret = 0; @@ -174,15 +174,15 @@ CF_Transaction_t *CF_FindTransactionBySequenceNumber(CF_Channel_t *c, CF_Transac * or on Q_TX or Q_RX. Once a transaction moves to history, then it's done. * * Let's put CF_QueueIdx_RX up front, because most RX packets will be file data PDUs */ - trans_seq_arg_t ctx = {transaction_sequence_number, src_eid, NULL}; - CF_CListNode_t *ptrs[] = {c->qs[CF_QueueIdx_RX], c->qs[CF_QueueIdx_PEND], c->qs[CF_QueueIdx_TXA], + CF_Traverse_TransSeqArg_t ctx = {transaction_sequence_number, src_eid, NULL}; + CF_CListNode_t *ptrs[] = {c->qs[CF_QueueIdx_RX], c->qs[CF_QueueIdx_PEND], c->qs[CF_QueueIdx_TXA], c->qs[CF_QueueIdx_TXW]}; - int i; - CF_Transaction_t *ret = NULL; + int i; + CF_Transaction_t *ret = NULL; for (i = 0; i < (sizeof(ptrs) / sizeof(ptrs[0])); ++i) { - CF_CList_Traverse(ptrs[i], (CF_CListFn_t)CF_FindTransactionBySequenceNumber_, &ctx); + CF_CList_Traverse(ptrs[i], (CF_CListFn_t)CF_FindTransactionBySequenceNumber_Impl, &ctx); if (ctx.t) { ret = ctx.t; @@ -209,7 +209,7 @@ CF_Transaction_t *CF_FindTransactionBySequenceNumber(CF_Channel_t *c, CF_Transac ** \endreturns ** *************************************************************************/ -int CF_TraverseHistory(CF_CListNode_t *n, trav_arg_t *context) +int CF_TraverseHistory(CF_CListNode_t *n, CF_Traverse_WriteFileArg_t *context) { static const char *dstr[] = {"RX", "TX"}; int i; @@ -251,7 +251,7 @@ int CF_TraverseHistory(CF_CListNode_t *n, trav_arg_t *context) ** \endreturns ** *************************************************************************/ -int CF_TraverseTransactions(CF_CListNode_t *n, trav_arg_t *context) +int CF_TraverseTransactions(CF_CListNode_t *n, CF_Traverse_WriteFileArg_t *context) { CF_Transaction_t *t = container_of(n, CF_Transaction_t, cl_node); @@ -282,7 +282,7 @@ int CF_TraverseTransactions(CF_CListNode_t *n, trav_arg_t *context) *************************************************************************/ int32 CF_WriteQueueDataToFile(int32 fd, CF_Channel_t *c, CF_QueueIdx_t q) { - trav_arg_t arg = {fd, 0, 0}; + CF_Traverse_WriteFileArg_t arg = {fd, 0, 0}; CF_CList_Traverse(c->qs[q], (CF_CListFn_t)CF_TraverseTransactions, &arg); return arg.result; } @@ -300,7 +300,7 @@ int32 CF_WriteQueueDataToFile(int32 fd, CF_Channel_t *c, CF_QueueIdx_t q) *************************************************************************/ int32 CF_WriteHistoryQueueDataToFile(int32 fd, CF_Channel_t *c, CF_Direction_t dir) { - trav_arg_t arg = {fd, 0, 0}; + CF_Traverse_WriteFileArg_t arg = {fd, 0, 0}; CF_CList_Traverse(c->qs[CF_QueueIdx_HIST], (CF_CListFn_t)CF_TraverseHistory, &arg); return arg.result; } @@ -322,8 +322,8 @@ int32 CF_WriteHistoryQueueDataToFile(int32 fd, CF_Channel_t *c, CF_Direction_t d *************************************************************************/ int CF_PrioSearch(CF_CListNode_t *node, void *context) { - CF_Transaction_t *t = container_of(node, CF_Transaction_t, cl_node); - priority_arg_t *p = (priority_arg_t *)context; + CF_Transaction_t *t = container_of(node, CF_Transaction_t, cl_node); + CF_Traverse_PriorityArg_t *p = (CF_Traverse_PriorityArg_t *)context; if (t->priority <= p->priority) { @@ -368,7 +368,7 @@ void CF_InsertSortPrio(CF_Transaction_t *t, CF_QueueIdx_t q) } else { - priority_arg_t p = {NULL, t->priority}; + CF_Traverse_PriorityArg_t p = {NULL, t->priority}; CF_CList_Traverse_R(c->qs[q], CF_PrioSearch, &p); if (p.t) { @@ -402,7 +402,7 @@ void CF_InsertSortPrio(CF_Transaction_t *t, CF_QueueIdx_t q) ** \endreturns ** *************************************************************************/ -int CF_TraverseAllTransactions_(CF_CListNode_t *n, traverse_all_args_t *args) +int CF_TraverseAllTransactions_Impl(CF_CListNode_t *n, CF_TraverseAll_Arg_t *args) { CF_Transaction_t *t = container_of(n, CF_Transaction_t, cl_node); args->fn(t, args->context); @@ -423,10 +423,10 @@ int CF_TraverseAllTransactions_(CF_CListNode_t *n, traverse_all_args_t *args) *************************************************************************/ int CF_TraverseAllTransactions(CF_Channel_t *c, CF_TraverseAllTransactions_fn_t fn, void *context) { - traverse_all_args_t args = {fn, context, 0}; - CF_QueueIdx_t index; + CF_TraverseAll_Arg_t args = {fn, context, 0}; + CF_QueueIdx_t index; for (index = CF_QueueIdx_PEND; index <= CF_QueueIdx_RX; ++index) - CF_CList_Traverse(c->qs[index], (CF_CListFn_t)CF_TraverseAllTransactions_, &args); + CF_CList_Traverse(c->qs[index], (CF_CListFn_t)CF_TraverseAllTransactions_Impl, &args); return args.counter; } diff --git a/fsw/src/cf_utils.h b/fsw/src/cf_utils.h index 981dfb5d..9a98c13f 100644 --- a/fsw/src/cf_utils.h +++ b/fsw/src/cf_utils.h @@ -31,34 +31,34 @@ #include "cf_app.h" #include "cf_assert.h" -typedef struct trans_seq_arg_t +typedef struct CF_Traverse_TransSeqArg { CF_TransactionSeq_t transaction_sequence_number; CF_EntityId_t src_eid; CF_Transaction_t *t; /* out param */ -} trans_seq_arg_t; +} CF_Traverse_TransSeqArg_t; -typedef struct +typedef struct CF_Traverse_WriteFileArg { osal_id_t fd; int32 result; int32 counter; -} trav_arg_t; +} CF_Traverse_WriteFileArg_t; typedef void (*CF_TraverseAllTransactions_fn_t)(CF_Transaction_t *t, void *context); -typedef struct +typedef struct CF_TraverseAll_Arg { CF_TraverseAllTransactions_fn_t fn; void *context; int counter; -} traverse_all_args_t; +} CF_TraverseAll_Arg_t; -typedef struct priority_arg_t +typedef struct CF_Traverse_PriorityArg { CF_Transaction_t *t; /* OUT: holds value of transaction with which to call CF_CList_InsertAfter on */ uint8 priority; /* seeking this priority */ -} priority_arg_t; +} CF_Traverse_PriorityArg_t; /* free a transaction from the queue it's on. * NOTE: this leaves the transaction in a bad state, @@ -162,7 +162,7 @@ void CF_FreeTransaction(CF_Transaction_t *t); CF_Transaction_t *CF_FindTransactionBySequenceNumber(CF_Channel_t *c, CF_TransactionSeq_t transaction_sequence_number, CF_EntityId_t src_eid); -int CF_FindTransactionBySequenceNumber_(CF_CListNode_t *n, trans_seq_arg_t *context); +int CF_FindTransactionBySequenceNumber_Impl(CF_CListNode_t *n, CF_Traverse_TransSeqArg_t *context); int32 CF_WriteQueueDataToFile(int32 fd, CF_Channel_t *c, CF_QueueIdx_t q); int32 CF_WriteHistoryQueueDataToFile(int32 fd, CF_Channel_t *c, CF_Direction_t dir); @@ -173,9 +173,9 @@ void CF_InsertSortPrio(CF_Transaction_t *t, CF_QueueIdx_t q); int CF_TraverseAllTransactions(CF_Channel_t *c, CF_TraverseAllTransactions_fn_t fn, void *context); int CF_TraverseAllTransactions_All_Channels(CF_TraverseAllTransactions_fn_t fn, void *context); -int CF_TraverseAllTransactions_(CF_CListNode_t *n, traverse_all_args_t *args); -int CF_TraverseHistory(CF_CListNode_t *n, trav_arg_t *context); -int CF_TraverseTransactions(CF_CListNode_t *n, trav_arg_t *context); +int CF_TraverseAllTransactions_Impl(CF_CListNode_t *n, CF_TraverseAll_Arg_t *args); +int CF_TraverseHistory(CF_CListNode_t *n, CF_Traverse_WriteFileArg_t *context); +int CF_TraverseTransactions(CF_CListNode_t *n, CF_Traverse_WriteFileArg_t *context); int32 CF_WriteQueueDataToFile(int32 fd, CF_Channel_t *c, CF_QueueIdx_t q); int32 CF_WriteHistoryQueueDataToFile(int32 fd, CF_Channel_t *c, CF_Direction_t dir); diff --git a/unit-test/cf_cfdp_tests.c b/unit-test/cf_cfdp_tests.c index 7925ceb9..0a524b0f 100644 --- a/unit-test/cf_cfdp_tests.c +++ b/unit-test/cf_cfdp_tests.c @@ -979,10 +979,10 @@ static int32 Ut_Hook_StateHandler_SetQIndex(void *UserObj, int32 StubRetcode, ui return StubRetcode; } -void Test_CF_CFDP_CycleTx_(void) +void Test_CF_CFDP_CycleTxFirstActive(void) { /* Test case for: - int CF_CFDP_CycleTx_(CF_CListNode_t *node, void *context); + int CF_CFDP_CycleTxFirstActive(CF_CListNode_t *node, void *context); */ CF_CFDP_CycleTx_args_t args; CF_Transaction_t *t; @@ -992,13 +992,13 @@ void Test_CF_CFDP_CycleTx_(void) /* suspended, should return 0 */ UT_CFDP_SetupBasicTestState(UT_CF_Setup_TX, NULL, NULL, NULL, &t, NULL); t->flags.com.suspended = 1; - UtAssert_INT32_EQ(CF_CFDP_CycleTx_(&t->cl_node, &args), 0); + UtAssert_INT32_EQ(CF_CFDP_CycleTxFirstActive(&t->cl_node, &args), 0); /* nominal, with c->cur set non-null, should skip loop and return 1 */ UT_CFDP_SetupBasicTestState(UT_CF_Setup_TX, NULL, &args.c, NULL, &t, NULL); t->flags.com.q_index = CF_QueueIdx_TXA; /* must be this */ args.c->cur = t; - UtAssert_INT32_EQ(CF_CFDP_CycleTx_(&t->cl_node, &args), 1); + UtAssert_INT32_EQ(CF_CFDP_CycleTxFirstActive(&t->cl_node, &args), 1); UtAssert_BOOL_TRUE(args.ran_one); /* nominal, with c->cur set null, should do loop and return 1 */ @@ -1009,7 +1009,7 @@ void Test_CF_CFDP_CycleTx_(void) t->flags.com.q_index = CF_QueueIdx_TXA; /* must be this */ args.c->cur = NULL; UT_SetHookFunction(UT_KEY(CF_CFDP_TxStateDispatch), Ut_Hook_StateHandler_SetQIndex, NULL); - UtAssert_INT32_EQ(CF_CFDP_CycleTx_(&t->cl_node, &args), 1); + UtAssert_INT32_EQ(CF_CFDP_CycleTxFirstActive(&t->cl_node, &args), 1); } static void DoTickFnClearCont(CF_Transaction_t *t, int *cont) @@ -1027,9 +1027,9 @@ void Test_CF_CFDP_DoTick(void) /* Test case for: * int CF_CFDP_DoTick(CF_CListNode_t *node, void *context); */ - CF_Transaction_t *t; - CF_Transaction_t t2; - tick_args_t args; + CF_Transaction_t *t; + CF_Transaction_t t2; + CF_CFDP_Tick_args_t args; memset(&args, 0, sizeof(args)); memset(&t2, 0, sizeof(t2)); @@ -1101,7 +1101,7 @@ void Test_CF_CFDP_ProcessPollingDirectories(void) UtAssert_BOOL_TRUE(poll->pb.busy); UtAssert_UINT32_EQ(CF_AppData.hk.channel_hk[UT_CFDP_CHANNEL].poll_counter, 1); - /* make an error occur in CF_CFDP_PlaybackDir_() */ + /* make an error occur in CF_CFDP_PlaybackDir_Initiate() */ poll->pb.busy = false; /* above would have set it true */ poll->timer_set = true; UT_SetDeferredRetcode(UT_KEY(CF_Timer_Expired), 1, true); @@ -1203,7 +1203,7 @@ void Test_CF_CFDP_ProcessPlaybackDirectory(void) static int32 Ut_Hook_TickTransactions_SetEarlyExit(void *UserObj, int32 StubRetcode, uint32 CallCount, const UT_StubContext_t *Context) { - tick_args_t *args = UT_Hook_GetArgValueByName(Context, "context", tick_args_t *); + CF_CFDP_Tick_args_t *args = UT_Hook_GetArgValueByName(Context, "context", CF_CFDP_Tick_args_t *); /* set flag on the second call */ if ((CallCount & 1) == 1) @@ -1217,7 +1217,7 @@ static int32 Ut_Hook_TickTransactions_SetEarlyExit(void *UserObj, int32 StubRetc static int32 Ut_Hook_TickTransactions_SetCont(void *UserObj, int32 StubRetcode, uint32 CallCount, const UT_StubContext_t *Context) { - tick_args_t *args = UT_Hook_GetArgValueByName(Context, "context", tick_args_t *); + CF_CFDP_Tick_args_t *args = UT_Hook_GetArgValueByName(Context, "context", CF_CFDP_Tick_args_t *); /* every other call do not set "cont" flag */ if ((CallCount & 1) == 0) @@ -1412,7 +1412,8 @@ void UtTest_Setup(void) UtTest_Add(Test_CF_CFDP_ProcessPollingDirectories, cf_cfdp_tests_Setup, cf_cfdp_tests_Teardown, "Test_CF_CFDP_ProcessPollingDirectories"); UtTest_Add(Test_CF_CFDP_CycleTx, cf_cfdp_tests_Setup, cf_cfdp_tests_Teardown, "Test_CF_CFDP_CycleTx"); - UtTest_Add(Test_CF_CFDP_CycleTx_, cf_cfdp_tests_Setup, cf_cfdp_tests_Teardown, "Test_CF_CFDP_CycleTx_"); + UtTest_Add(Test_CF_CFDP_CycleTxFirstActive, cf_cfdp_tests_Setup, cf_cfdp_tests_Teardown, + "Test_CF_CFDP_CycleTxFirstActive"); UtTest_Add(Test_CF_CFDP_DoTick, cf_cfdp_tests_Setup, cf_cfdp_tests_Teardown, "CF_CFDP_DoTick"); UtTest_Add(Test_CF_CFDP_TickTransactions, cf_cfdp_tests_Setup, cf_cfdp_tests_Teardown, "CF_CFDP_TickTransactions"); UtTest_Add(Test_CF_CFDP_ResetTransaction, cf_cfdp_tests_Setup, cf_cfdp_tests_Teardown, "CF_CFDP_ResetTransaction"); diff --git a/unit-test/cf_cmd_tests.c b/unit-test/cf_cmd_tests.c index a9ef2fe4..ddf83712 100644 --- a/unit-test/cf_cmd_tests.c +++ b/unit-test/cf_cmd_tests.c @@ -934,7 +934,7 @@ void Test_CF_DoChanAction_ALL_CHANNELS_WhenAny_fn_returns_1_Return_1(void) CF_UT_cmd_unionargs_buf_t utbuf; CF_UnionArgsCmd_t *arg_cmd = &utbuf.ua; const char *arg_errstr = "CANNOT TEST SENT TO SEND EVENT"; - chan_action_fn_t arg_fn = &Dummy_chan_action_fn_t; + CF_ChanActionFn_t arg_fn = &Dummy_chan_action_fn_t; int dummy_context; void *arg_context = &dummy_context; uint8 random_fn_call = Any_uint8_LessThan(CF_NUM_CHANNELS) + 1; @@ -965,7 +965,7 @@ void Test_CF_DoChanAction_ALL_CHANNELS_WhenAll_fn_return_1_Return_1(void) CF_UT_cmd_unionargs_buf_t utbuf; CF_UnionArgsCmd_t *arg_cmd = &utbuf.ua; const char *arg_errstr = "CANNOT TEST SENT TO SEND EVENT"; - chan_action_fn_t arg_fn = &Dummy_chan_action_fn_t; + CF_ChanActionFn_t arg_fn = &Dummy_chan_action_fn_t; int dummy_context; void *arg_context = &dummy_context; int local_result; @@ -995,7 +995,7 @@ void Test_CF_DoChanAction_ALL_CHANNELS_WhenNo_fn_returns_0_Return_0(void) CF_UT_cmd_unionargs_buf_t utbuf; CF_UnionArgsCmd_t *arg_cmd = &utbuf.ua; const char *arg_errstr = "CANNOT TEST SENT TO SEND EVENT"; - chan_action_fn_t arg_fn = &Dummy_chan_action_fn_t; + CF_ChanActionFn_t arg_fn = &Dummy_chan_action_fn_t; int dummy_context; void *arg_context = &dummy_context; int local_result; @@ -1025,7 +1025,7 @@ void Test_CF_DoChanAction_WhenChannel_fn_ActionReturns_1_Return_1(void) CF_UT_cmd_unionargs_buf_t utbuf; CF_UnionArgsCmd_t *arg_cmd = &utbuf.ua; const char *arg_errstr = "CANNOT TEST SENT TO SEND EVENT"; - chan_action_fn_t arg_fn = &Dummy_chan_action_fn_t; + CF_ChanActionFn_t arg_fn = &Dummy_chan_action_fn_t; int dummy_context; void *arg_context = &dummy_context; int local_result; @@ -1055,7 +1055,7 @@ void Test_CF_DoChanAction_WhenChannel_fn_ActionReturns_0_Return_1(void) CF_UT_cmd_unionargs_buf_t utbuf; CF_UnionArgsCmd_t *arg_cmd = &utbuf.ua; const char *arg_errstr = "CANNOT TEST SENT TO SEND EVENT"; - chan_action_fn_t arg_fn = &Dummy_chan_action_fn_t; + CF_ChanActionFn_t arg_fn = &Dummy_chan_action_fn_t; int dummy_context; void *arg_context = &dummy_context; int local_result; @@ -1085,7 +1085,7 @@ void Test_CF_DoChanAction_WhenChanNumberEq_CF_NUM_CHANNELS_Return_neg1_And_SendE CF_UT_cmd_unionargs_buf_t utbuf; CF_UnionArgsCmd_t *arg_cmd = &utbuf.ua; const char *arg_errstr = "CANNOT TEST SENT TO SEND EVENT"; - chan_action_fn_t arg_fn = &Dummy_chan_action_fn_t; + CF_ChanActionFn_t arg_fn = &Dummy_chan_action_fn_t; int dummy_context; void *arg_context = &dummy_context; int local_result; @@ -1118,7 +1118,7 @@ void Test_CF_DoChanAction_WhenBadChannelNumber_Return_neg1_And_SendEvent(void) CF_UT_cmd_unionargs_buf_t utbuf; CF_UnionArgsCmd_t *arg_cmd = &utbuf.ua; const char *arg_errstr = "CANNOT TEST SENT TO SEND EVENT"; - chan_action_fn_t arg_fn = &Dummy_chan_action_fn_t; + CF_ChanActionFn_t arg_fn = &Dummy_chan_action_fn_t; int dummy_context; void *arg_context = &dummy_context; int local_result; @@ -1169,10 +1169,10 @@ void Test_CF_DoChanAction_WhenBadChannelNumber_Return_neg1_And_SendEvent(void) void Test_CF_DoFreezeThaw_Set_frozen_ToGiven_context_barg_AndReturn_0(void) { /* Arrange */ - uint8 arg_chan_num = Any_cf_channel(); - bool_arg_t dummy_context; - const bool_arg_t *arg_context; - int local_result; + uint8 arg_chan_num = Any_cf_channel(); + CF_ChanAction_BoolArg_t dummy_context; + const CF_ChanAction_BoolArg_t *arg_context; + int local_result; dummy_context.barg = Any_bool_arg_t_barg(); @@ -1564,11 +1564,11 @@ void Test_CF_TsnChanAction_cmd_FailBecause_cmd_chan_IsInvalid(void) /******************************************************************************* ** -** CF_DoSuspRes_ tests +** CF_DoSuspRes_Txn tests ** *******************************************************************************/ -void Test_CF_DoSuspRes__Asserts_t_Is_NULL(void) +void Test_CF_DoSuspRes_Txn_Asserts_t_Is_NULL(void) { // /* Arrange */ @@ -1576,15 +1576,15 @@ void Test_CF_DoSuspRes__Asserts_t_Is_NULL(void) // /* Assert */ UtAssert_MIR("JIRA: GSFCCFS-1733 CF_Assert"); -} /* end Test_CF_DoSuspRes__Asserts_t_Is_NULL */ +} /* end Test_CF_DoSuspRes_Txn_Asserts_t_Is_NULL */ -void Test_CF_DoSuspRes__Set_context_same_To_1_suspended_Eq_action(void) +void Test_CF_DoSuspRes_Txn_Set_context_same_To_1_suspended_Eq_action(void) { /* Arrange */ - CF_Transaction_t dummy_t; - CF_Transaction_t *arg_t = &dummy_t; - susp_res_arg_t dummy_context; - susp_res_arg_t *arg_context = &dummy_context; + CF_Transaction_t dummy_t; + CF_Transaction_t *arg_t = &dummy_t; + CF_ChanAction_SuspResArg_t dummy_context; + CF_ChanAction_SuspResArg_t *arg_context = &dummy_context; /* set same to 0 to ensure change was done - not required for test, * but it is helpful for verification that the function did the change */ @@ -1594,20 +1594,20 @@ void Test_CF_DoSuspRes__Set_context_same_To_1_suspended_Eq_action(void) arg_t->flags.com.suspended = arg_context->action; /* Act */ - CF_DoSuspRes_(arg_t, arg_context); + CF_DoSuspRes_Txn(arg_t, arg_context); /* Assert */ - UtAssert_True(arg_context->same == 1, "CF_DoSuspRes_ set context->same to %d and should be 1 (direct set)", + UtAssert_True(arg_context->same == 1, "CF_DoSuspRes_Txn set context->same to %d and should be 1 (direct set)", arg_context->same); -} /* end Test_CF_DoSuspRes__Set_context_same_To_1_suspended_Eq_action */ +} /* end Test_CF_DoSuspRes_Txn_Set_context_same_To_1_suspended_Eq_action */ -void Test_CF_DoSuspRes__When_suspended_NotEqTo_action_Set_suspended_To_action(void) +void Test_CF_DoSuspRes_Txn_When_suspended_NotEqTo_action_Set_suspended_To_action(void) { /* Arrange */ - CF_Transaction_t dummy_t; - CF_Transaction_t *arg_t = &dummy_t; - susp_res_arg_t dummy_context; - susp_res_arg_t *arg_context = &dummy_context; + CF_Transaction_t dummy_t; + CF_Transaction_t *arg_t = &dummy_t; + CF_ChanAction_SuspResArg_t dummy_context; + CF_ChanAction_SuspResArg_t *arg_context = &dummy_context; /* set same to 0 to ensure change was done - not required for test, * but it is helpful for verification that the function did the change */ @@ -1617,13 +1617,13 @@ void Test_CF_DoSuspRes__When_suspended_NotEqTo_action_Set_suspended_To_action(vo arg_t->flags.com.suspended = !arg_context->action; /* Act */ - CF_DoSuspRes_(arg_t, arg_context); + CF_DoSuspRes_Txn(arg_t, arg_context); /* Assert */ UtAssert_True(arg_t->flags.com.suspended == arg_context->action, - "CF_DoSuspRes_ set arg_t->flags.com.suspended to %d and should be %d (context->action)", + "CF_DoSuspRes_Txn set arg_t->flags.com.suspended to %d and should be %d (context->action)", arg_t->flags.com.suspended, arg_context->action); -} /* end Test_CF_DoSuspRes__When_suspended_NotEqTo_action_Set_suspended_To_action */ +} /* end Test_CF_DoSuspRes_Txn_When_suspended_NotEqTo_action_Set_suspended_To_action */ /******************************************************************************* ** @@ -1653,7 +1653,7 @@ void Test_CF_DoSuspRes_CallTo_CF_TsnChanAction_Returns_0_And_args_same_WasChange UT_SetDataBuffer(UT_KEY(CF_FindTransactionBySequenceNumber), &context_CF_FindTransactionBySequenceNumber, sizeof(context_CF_FindTransactionBySequenceNumber), false); - /* Arrange unstubbable: CF_DoSuspRes_ */ + /* Arrange unstubbable: CF_DoSuspRes_Txn */ dummy_t->flags.com.suspended = arg_action; /* Arrange unstubbable: CF_CmdRej */ @@ -1777,7 +1777,7 @@ void Test_CF_DoSuspRes_CallTo_CF_TsnChanAction_Returns_0_And_args_same_WasNotCha UT_SetDataBuffer(UT_KEY(CF_TraverseAllTransactions_All_Channels), &context_CF_TraverseAllTransactions_All_Channels, sizeof(context_CF_TraverseAllTransactions_All_Channels), false); - /* Arrange unstubbable: CF_DoSuspRes_ */ + /* Arrange unstubbable: CF_DoSuspRes_Txn */ dummy_t->flags.com.suspended = arg_action; /* Arrange unstubbable: CF_CmdAcc */ @@ -1884,11 +1884,11 @@ void Test_CF_CmdResume_Call_CF_DoSuspRes_WithGiven_msg_And_action_0(void) /******************************************************************************* ** -** CF_CmdCancel_ tests +** CF_CmdCancel_Txn tests ** *******************************************************************************/ -void Test_CF_CmdCancel__Call_CF_CFDP_CancelTransaction_WithGiven_t(void) +void Test_CF_CmdCancel_Txn_Call_CF_CFDP_CancelTransaction_WithGiven_t(void) { /* Arrange */ CF_Transaction_t dummy_t; @@ -1900,12 +1900,12 @@ void Test_CF_CmdCancel__Call_CF_CFDP_CancelTransaction_WithGiven_t(void) sizeof(context_CF_CFDP_CancelTransaction), false); /* Act */ - CF_CmdCancel_(arg_t, arg_ignored); + CF_CmdCancel_Txn(arg_t, arg_ignored); /* Assert */ UtAssert_ADDRESS_EQ(context_CF_CFDP_CancelTransaction, arg_t); -} /* end Test_CF_CmdCancel__Call_CF_CFDP_CancelTransaction_WithGiven_t */ +} /* end Test_CF_CmdCancel_Txn_Call_CF_CFDP_CancelTransaction_WithGiven_t */ /******************************************************************************* ** @@ -1945,8 +1945,8 @@ void Test_CF_CmdCancel_Call_CF_CmdCond_WithNotted_CF_TsnChanAction(void) /* Assert for CF_TsnChanAction */ UtAssert_STUB_COUNT(CF_TraverseAllTransactions, 1); UtAssert_ADDRESS_EQ(context_CF_TraverseAllTransactions.c, CF_AppData.engine.channels + dummy_msg->chan); - UtAssert_True(context_CF_TraverseAllTransactions.fn == CF_CmdCancel_, - "context_CF_TraverseAllTransactions.fn == CF_CmdCancel_"); + UtAssert_True(context_CF_TraverseAllTransactions.fn == CF_CmdCancel_Txn, + "context_CF_TraverseAllTransactions.fn == CF_CmdCancel_Txn"); UtAssert_ADDRESS_EQ(context_CF_TraverseAllTransactions.context, NULL); /* Assert for CF_CmdRej */ UtAssert_True(CF_AppData.hk.counters.err == (uint16)(initial_hk_err_counter + 1), @@ -1956,11 +1956,11 @@ void Test_CF_CmdCancel_Call_CF_CmdCond_WithNotted_CF_TsnChanAction(void) /******************************************************************************* ** -** CF_CmdAbandon_ tests +** CF_CmdAbandon_Txn tests ** *******************************************************************************/ -void Test_CF_CmdAbandon__Call_CF_CFDP_ResetTransaction_WithGiven_t_And_0(void) +void Test_CF_CmdAbandon_Txn_Call_CF_CFDP_ResetTransaction_WithGiven_t_And_0(void) { /* Arrange */ CF_Transaction_t dummy_t; @@ -1972,7 +1972,7 @@ void Test_CF_CmdAbandon__Call_CF_CFDP_ResetTransaction_WithGiven_t_And_0(void) sizeof(context_CF_CFDP_ResetTransaction), false); /* Act */ - CF_CmdAbandon_(arg_t, arg_ignored); + CF_CmdAbandon_Txn(arg_t, arg_ignored); /* Assert */ UtAssert_ADDRESS_EQ(context_CF_CFDP_ResetTransaction.t, arg_t); @@ -1980,7 +1980,7 @@ void Test_CF_CmdAbandon__Call_CF_CFDP_ResetTransaction_WithGiven_t_And_0(void) "CF_CFDP_CancelTransaction was called with int %d and should be 0 (constant in call)", context_CF_CFDP_ResetTransaction.keep_history); -} /* end Test_CF_CmdAbandon__Call_CF_CFDP_ResetTransaction_WithGiven_t_And_0 */ +} /* end Test_CF_CmdAbandon_Txn_Call_CF_CFDP_ResetTransaction_WithGiven_t_And_0 */ /******************************************************************************* ** @@ -2020,8 +2020,8 @@ void Test_CF_CmdAbandon_Call_CF_CmdCond_WithNotted_CF_TsnChanAction(void) /* Assert for CF_TsnChanAction */ UtAssert_STUB_COUNT(CF_TraverseAllTransactions, 1); UtAssert_ADDRESS_EQ(context_CF_TraverseAllTransactions.c, CF_AppData.engine.channels + dummy_msg->chan); - UtAssert_True(context_CF_TraverseAllTransactions.fn == CF_CmdAbandon_, - "context_CF_TraverseAllTransactions.fn == CF_CmdAbandon_"); + UtAssert_True(context_CF_TraverseAllTransactions.fn == CF_CmdAbandon_Txn, + "context_CF_TraverseAllTransactions.fn == CF_CmdAbandon_Txn"); UtAssert_ADDRESS_EQ(context_CF_TraverseAllTransactions.context, NULL); /* Assert for CF_CmdRej */ UtAssert_True(CF_AppData.hk.counters.err == (uint16)(initial_hk_err_counter + 1), @@ -2038,10 +2038,10 @@ void Test_CF_CmdAbandon_Call_CF_CmdCond_WithNotted_CF_TsnChanAction(void) void Test_CF_DoEnableDisableDequeue_Set_chan_num_EnabledFlagTo_context_barg(void) { /* Arrange */ - CF_ConfigTable_t dummy_config_table; - uint8 arg_chan_num = Any_cf_channel(); - bool_arg_t dummy_context; - bool_arg_t *arg_context = &dummy_context; + CF_ConfigTable_t dummy_config_table; + uint8 arg_chan_num = Any_cf_channel(); + CF_ChanAction_BoolArg_t dummy_context; + CF_ChanAction_BoolArg_t *arg_context = &dummy_context; CF_AppData.config_table = &dummy_config_table; dummy_context.barg = Any_bool_arg_t_barg(); @@ -2152,14 +2152,14 @@ void Test_CF_CmdDisableDequeue_Call_CmdCond_WithResultsOf_CF_DoChanAction(void) void Test_CF_DoEnableDisablePolldir_When_ALL_CHANNELS_SetAllPolldirsInChannelEnabledTo_context_barg(void) { /* Arrange */ - uint8 arg_chan_num = Any_cf_channel(); - CF_UT_cmd_unionargs_buf_t utbuf; - CF_UnionArgsCmd_t *dummy_msg = &utbuf.ua; - bool_msg_arg_t dummy_context; - bool_msg_arg_t *arg_context = &dummy_context; - CF_ConfigTable_t dummy_config_table; - uint8 expected_enabled; - int local_result; + uint8 arg_chan_num = Any_cf_channel(); + CF_UT_cmd_unionargs_buf_t utbuf; + CF_UnionArgsCmd_t *dummy_msg = &utbuf.ua; + CF_ChanAction_BoolMsgArg_t dummy_context; + CF_ChanAction_BoolMsgArg_t *arg_context = &dummy_context; + CF_ConfigTable_t dummy_config_table; + uint8 expected_enabled; + int local_result; memset(&utbuf, 0, sizeof(utbuf)); @@ -2190,15 +2190,15 @@ void Test_CF_DoEnableDisablePolldir_When_ALL_CHANNELS_SetAllPolldirsInChannelEna void Test_CF_DoEnableDisablePolldir_WhenSetToSpecificPolldirSetPolldirFrom_context_ChannelEnabledTo_context_barg(void) { /* Arrange */ - uint8 arg_chan_num = Any_cf_channel(); - uint8 dummy_polldir = Any_cf_polldir(); - CF_UT_cmd_unionargs_buf_t utbuf; - CF_UnionArgsCmd_t *dummy_msg = &utbuf.ua; - bool_msg_arg_t dummy_context; - bool_msg_arg_t *arg_context = &dummy_context; - CF_ConfigTable_t dummy_config_table; - uint8 expected_enabled; - int local_result; + uint8 arg_chan_num = Any_cf_channel(); + uint8 dummy_polldir = Any_cf_polldir(); + CF_UT_cmd_unionargs_buf_t utbuf; + CF_UnionArgsCmd_t *dummy_msg = &utbuf.ua; + CF_ChanAction_BoolMsgArg_t dummy_context; + CF_ChanAction_BoolMsgArg_t *arg_context = &dummy_context; + CF_ConfigTable_t dummy_config_table; + uint8 expected_enabled; + int local_result; memset(&utbuf, 0, sizeof(utbuf)); @@ -2224,13 +2224,13 @@ void Test_CF_DoEnableDisablePolldir_WhenSetToSpecificPolldirSetPolldirFrom_conte void Test_CF_DoEnableDisablePolldir_FailPolldirEq_CF_MAX_POLLING_DIR_PER_CHAN_AndSendEvent(void) { /* Arrange */ - uint8 arg_chan_num = Any_cf_channel(); - CF_UT_cmd_unionargs_buf_t utbuf; - CF_UnionArgsCmd_t *dummy_msg = &utbuf.ua; - bool_msg_arg_t dummy_context; - bool_msg_arg_t *arg_context = &dummy_context; - CF_ConfigTable_t dummy_config_table; - int local_result; + uint8 arg_chan_num = Any_cf_channel(); + CF_UT_cmd_unionargs_buf_t utbuf; + CF_UnionArgsCmd_t *dummy_msg = &utbuf.ua; + CF_ChanAction_BoolMsgArg_t dummy_context; + CF_ChanAction_BoolMsgArg_t *arg_context = &dummy_context; + CF_ConfigTable_t dummy_config_table; + int local_result; memset(&utbuf, 0, sizeof(utbuf)); @@ -2255,13 +2255,13 @@ void Test_CF_DoEnableDisablePolldir_FailPolldirEq_CF_MAX_POLLING_DIR_PER_CHAN_An void Test_CF_DoEnableDisablePolldir_FailAnyBadPolldirSendEvent(void) { /* Arrange */ - uint8 arg_chan_num = Any_cf_channel(); - CF_UT_cmd_unionargs_buf_t utbuf; - CF_UnionArgsCmd_t *dummy_msg = &utbuf.ua; - bool_msg_arg_t dummy_context; - bool_msg_arg_t *arg_context = &dummy_context; - CF_ConfigTable_t dummy_config_table; - int local_result; + uint8 arg_chan_num = Any_cf_channel(); + CF_UT_cmd_unionargs_buf_t utbuf; + CF_UnionArgsCmd_t *dummy_msg = &utbuf.ua; + CF_ChanAction_BoolMsgArg_t dummy_context; + CF_ChanAction_BoolMsgArg_t *arg_context = &dummy_context; + CF_ConfigTable_t dummy_config_table; + int local_result; memset(&utbuf, 0, sizeof(utbuf)); @@ -5085,15 +5085,15 @@ void add_CF_TsnChanAction_tests(void) "Test_CF_TsnChanAction_cmd_FailBecause_cmd_chan_IsInvalid"); } /* end add_CF_TsnChanAction_tests */ -void add_CF_DoSuspRes__tests(void) +void add_CF_DoSuspRes_Txn_tests(void) { - UtTest_Add(Test_CF_DoSuspRes__Asserts_t_Is_NULL, cf_cmd_tests_Setup, cf_cmd_tests_Teardown, - "Test_CF_DoSuspRes__Asserts_t_Is_NULL"); - UtTest_Add(Test_CF_DoSuspRes__Set_context_same_To_1_suspended_Eq_action, cf_cmd_tests_Setup, cf_cmd_tests_Teardown, - "Test_CF_DoSuspRes__Set_context_same_To_1_suspended_Eq_action"); - UtTest_Add(Test_CF_DoSuspRes__When_suspended_NotEqTo_action_Set_suspended_To_action, cf_cmd_tests_Setup, - cf_cmd_tests_Teardown, "Test_CF_DoSuspRes__When_suspended_NotEqTo_action_Set_suspended_To_action"); -} /* end add_CF_DoSuspRes__tests */ + UtTest_Add(Test_CF_DoSuspRes_Txn_Asserts_t_Is_NULL, cf_cmd_tests_Setup, cf_cmd_tests_Teardown, + "Test_CF_DoSuspRes_Txn_Asserts_t_Is_NULL"); + UtTest_Add(Test_CF_DoSuspRes_Txn_Set_context_same_To_1_suspended_Eq_action, cf_cmd_tests_Setup, + cf_cmd_tests_Teardown, "Test_CF_DoSuspRes_Txn_Set_context_same_To_1_suspended_Eq_action"); + UtTest_Add(Test_CF_DoSuspRes_Txn_When_suspended_NotEqTo_action_Set_suspended_To_action, cf_cmd_tests_Setup, + cf_cmd_tests_Teardown, "Test_CF_DoSuspRes_Txn_When_suspended_NotEqTo_action_Set_suspended_To_action"); +} /* end add_CF_DoSuspRes_Txn_tests */ void add_CF_DoSuspRes_tests(void) { @@ -5127,11 +5127,11 @@ void add_CF_CmdResume_tests(void) cf_cmd_tests_Teardown, "Test_CF_CmdResume_Call_CF_DoSuspRes_WithGiven_msg_And_action_0"); } /* end add_CF_CmdResume_tests */ -void add_CF_CmdCancel__tests(void) +void add_CF_CmdCancel_Txn_tests(void) { - UtTest_Add(Test_CF_CmdCancel__Call_CF_CFDP_CancelTransaction_WithGiven_t, cf_cmd_tests_Setup, cf_cmd_tests_Teardown, - "Test_CF_CmdCancel__Call_CF_CFDP_CancelTransaction_WithGiven_t"); -} /* end add_CF_CF_CmdCancel__tests */ + UtTest_Add(Test_CF_CmdCancel_Txn_Call_CF_CFDP_CancelTransaction_WithGiven_t, cf_cmd_tests_Setup, + cf_cmd_tests_Teardown, "Test_CF_CmdCancel_Txn_Call_CF_CFDP_CancelTransaction_WithGiven_t"); +} /* end add_CF_CF_CmdCancel_Txn_tests */ void add_CF_CmdCancel_tests(void) { @@ -5139,17 +5139,17 @@ void add_CF_CmdCancel_tests(void) "Test_CF_CmdCancel_Call_CF_CmdCond_WithNotted_CF_TsnChanAction"); } /* end add_CF_CmdCancel_tests */ -void add_CF_CmdAbandon__tests(void) +void add_CF_CmdAbandon_Txn_tests(void) { - UtTest_Add(Test_CF_CmdAbandon__Call_CF_CFDP_ResetTransaction_WithGiven_t_And_0, cf_cmd_tests_Setup, - cf_cmd_tests_Teardown, "Test_CF_CmdAbandon__Call_CF_CFDP_ResetTransaction_WithGiven_t_And_0"); -} /* end add_CF_CmdAbandon__tests */ + UtTest_Add(Test_CF_CmdAbandon_Txn_Call_CF_CFDP_ResetTransaction_WithGiven_t_And_0, cf_cmd_tests_Setup, + cf_cmd_tests_Teardown, "Test_CF_CmdAbandon_Txn_Call_CF_CFDP_ResetTransaction_WithGiven_t_And_0"); +} /* end add_CF_CmdAbandon_Txn_tests */ void add_CF_CmdAbandon_tests(void) { UtTest_Add(Test_CF_CmdAbandon_Call_CF_CmdCond_WithNotted_CF_TsnChanAction, cf_cmd_tests_Setup, cf_cmd_tests_Teardown, "Test_CF_CmdAbandon_Call_CF_CmdCond_WithNotted_CF_TsnChanAction"); -} /* end add_CF_CmdAbandon__tests */ +} /* end add_CF_CmdAbandon_Txn_tests */ void add_CF_DoEnableDisableDequeue_tests(void) { @@ -5467,7 +5467,7 @@ void UtTest_Setup(void) add_CF_TsnChanAction_tests(); - add_CF_DoSuspRes__tests(); + add_CF_DoSuspRes_Txn_tests(); add_CF_DoSuspRes_tests(); @@ -5475,11 +5475,11 @@ void UtTest_Setup(void) add_CF_CmdResume_tests(); - add_CF_CmdCancel__tests(); + add_CF_CmdCancel_Txn_tests(); add_CF_CmdCancel_tests(); - add_CF_CmdAbandon__tests(); + add_CF_CmdAbandon_Txn_tests(); add_CF_CmdAbandon_tests(); diff --git a/unit-test/cf_utils_tests.c b/unit-test/cf_utils_tests.c index a0952742..edfb53a4 100644 --- a/unit-test/cf_utils_tests.c +++ b/unit-test/cf_utils_tests.c @@ -92,8 +92,8 @@ static void UT_Callback_CF_TraverseAllTransactions(CF_Transaction_t *t, void *co static void UT_AltHandler_CF_CList_Traverse_SeqArg_SetTxn(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) { - trans_seq_arg_t *arg = UT_Hook_GetArgValueByName(Context, "context", trans_seq_arg_t *); - arg->t = UserObj; + CF_Traverse_TransSeqArg_t *arg = UT_Hook_GetArgValueByName(Context, "context", CF_Traverse_TransSeqArg_t *); + arg->t = UserObj; } /******************************************************************************* @@ -165,14 +165,14 @@ void Test_CF_FreeTransaction(void) UtAssert_UINT32_EQ(t->flags.com.q_index, CF_QueueIdx_FREE); } -void Test_CF_FindTransactionBySequenceNumber_(void) +void Test_CF_FindTransactionBySequenceNumber_Impl(void) { /* Test case for: - * int CF_FindTransactionBySequenceNumber_(CF_CListNode_t *n, trans_seq_arg_t *context) + * int CF_FindTransactionBySequenceNumber_Impl(CF_CListNode_t *n, CF_Traverse_TransSeqArg_t *context) */ - trans_seq_arg_t ctxt; - CF_Transaction_t txn; - CF_History_t hist; + CF_Traverse_TransSeqArg_t ctxt; + CF_Transaction_t txn; + CF_History_t hist; memset(&txn, 0, sizeof(txn)); memset(&hist, 0, sizeof(hist)); @@ -185,7 +185,7 @@ void Test_CF_FindTransactionBySequenceNumber_(void) ctxt.src_eid = 34; hist.seq_num = 56; ctxt.transaction_sequence_number = 78; - UtAssert_INT32_EQ(CF_FindTransactionBySequenceNumber_(&txn.cl_node, &ctxt), 0); + UtAssert_INT32_EQ(CF_FindTransactionBySequenceNumber_Impl(&txn.cl_node, &ctxt), 0); UtAssert_NULL(ctxt.t); /* matching eid and non-matching sequence */ @@ -193,7 +193,7 @@ void Test_CF_FindTransactionBySequenceNumber_(void) ctxt.src_eid = 13; hist.seq_num = 56; ctxt.transaction_sequence_number = 78; - UtAssert_INT32_EQ(CF_FindTransactionBySequenceNumber_(&txn.cl_node, &ctxt), 0); + UtAssert_INT32_EQ(CF_FindTransactionBySequenceNumber_Impl(&txn.cl_node, &ctxt), 0); UtAssert_NULL(ctxt.t); /* non-matching eid and matching sequence */ @@ -201,7 +201,7 @@ void Test_CF_FindTransactionBySequenceNumber_(void) ctxt.src_eid = 34; hist.seq_num = 57; ctxt.transaction_sequence_number = 57; - UtAssert_INT32_EQ(CF_FindTransactionBySequenceNumber_(&txn.cl_node, &ctxt), 0); + UtAssert_INT32_EQ(CF_FindTransactionBySequenceNumber_Impl(&txn.cl_node, &ctxt), 0); UtAssert_NULL(ctxt.t); /* matching eid and matching sequence */ @@ -209,7 +209,7 @@ void Test_CF_FindTransactionBySequenceNumber_(void) ctxt.src_eid = 23; hist.seq_num = 67; ctxt.transaction_sequence_number = 67; - UtAssert_INT32_EQ(CF_FindTransactionBySequenceNumber_(&txn.cl_node, &ctxt), 1); + UtAssert_INT32_EQ(CF_FindTransactionBySequenceNumber_Impl(&txn.cl_node, &ctxt), 1); UtAssert_ADDRESS_EQ(ctxt.t, &txn); } @@ -544,8 +544,8 @@ void Test_CF_TraverseHistory_AssertsBecause_h_dir_GreaterThan_CF_DIR_NUM(void) // /* Arrange */ // CF_History_t dummy_h; // CF_CListNode_t * arg_n = &dummy_h.cl_node; - // trav_arg_t dummy_context; - // trav_arg_t* arg_context = &dummy_context; + // CF_Traverse_WriteFileArg_t dummy_context; + // CF_Traverse_WriteFileArg_t* arg_context = &dummy_context; // // dummy_h.src_eid = Any_uint8(); // dummy_h.seq_num = Any_uint32(); @@ -564,13 +564,13 @@ void Test_CF_TraverseHistory_AssertsBecause_h_dir_GreaterThan_CF_DIR_NUM(void) void Test_CF_TraverseHistory_When_CF_WrappedWrite_FailsFirstCallReturn_CLIST_EXIT(void) { /* Arrange */ - CF_History_t dummy_h; - CF_CListNode_t *arg_n = &dummy_h.cl_node; - trav_arg_t dummy_context; - trav_arg_t *arg_context = &dummy_context; - char src_colon_str[6] = "SRC: "; /* duplicates function value */ - uint8 dummy_len; - int local_result; + CF_History_t dummy_h; + CF_CListNode_t *arg_n = &dummy_h.cl_node; + CF_Traverse_WriteFileArg_t dummy_context; + CF_Traverse_WriteFileArg_t *arg_context = &dummy_context; + char src_colon_str[6] = "SRC: "; /* duplicates function value */ + uint8 dummy_len; + int local_result; dummy_h.src_eid = Any_uint8(); dummy_h.seq_num = Any_uint32(); @@ -603,15 +603,15 @@ void Test_CF_TraverseHistory_When_CF_WrappedWrite_FailsFirstCallReturn_CLIST_EXI void Test_CF_TraverseHistory_When_CF_WrappedWrite_FailsSecondCallReturn_CLIST_EXIT(void) { /* Arrange */ - CF_History_t dummy_h; - CF_CListNode_t *arg_n = &dummy_h.cl_node; - trav_arg_t dummy_context; - trav_arg_t *arg_context = &dummy_context; - char src_colon_str[6] = "SRC: "; /* duplicates function value */ - char dst_colon_str[6] = "DST: "; /* duplicates function value */ - uint8 dummy_len_src; - uint8 dummy_len_dst; - int local_result; + CF_History_t dummy_h; + CF_CListNode_t *arg_n = &dummy_h.cl_node; + CF_Traverse_WriteFileArg_t dummy_context; + CF_Traverse_WriteFileArg_t *arg_context = &dummy_context; + char src_colon_str[6] = "SRC: "; /* duplicates function value */ + char dst_colon_str[6] = "DST: "; /* duplicates function value */ + uint8 dummy_len_src; + uint8 dummy_len_dst; + int local_result; dummy_h.src_eid = Any_uint8(); dummy_h.seq_num = Any_uint32(); @@ -646,15 +646,15 @@ void Test_CF_TraverseHistory_When_CF_WrappedWrite_FailsSecondCallReturn_CLIST_EX void Test_CF_TraverseHistory_WhenBothWrappedWritesSuccessfulReturn_CLIST_CONT(void) { /* Arrange */ - CF_History_t dummy_h; - CF_CListNode_t *arg_n = &dummy_h.cl_node; - trav_arg_t dummy_context; - trav_arg_t *arg_context = &dummy_context; - char src_colon_str[6] = "SRC: "; /* duplicates function value */ - char dst_colon_str[6] = "DST: "; /* duplicates function value */ - uint8 dummy_len_src; - uint8 dummy_len_dst; - int local_result; + CF_History_t dummy_h; + CF_CListNode_t *arg_n = &dummy_h.cl_node; + CF_Traverse_WriteFileArg_t dummy_context; + CF_Traverse_WriteFileArg_t *arg_context = &dummy_context; + char src_colon_str[6] = "SRC: "; /* duplicates function value */ + char dst_colon_str[6] = "DST: "; /* duplicates function value */ + uint8 dummy_len_src; + uint8 dummy_len_dst; + int local_result; dummy_h.src_eid = Any_uint8(); dummy_h.seq_num = Any_uint32(); @@ -697,12 +697,12 @@ void Test_CF_TraverseHistory_WhenBothWrappedWritesSuccessfulReturn_CLIST_CONT(vo void Test_CF_TraverseTransactions_When_context_result_Is_1_Return_CLIST_EXIT(void) { /* Arrange */ - CF_History_t dummy_history; - CF_Transaction_t dummy_t; - CF_CListNode_t *arg_n = &dummy_t.cl_node; - trav_arg_t dummy_context; - trav_arg_t *arg_context = &dummy_context; - int local_result; + CF_History_t dummy_history; + CF_Transaction_t dummy_t; + CF_CListNode_t *arg_n = &dummy_t.cl_node; + CF_Traverse_WriteFileArg_t dummy_context; + CF_Traverse_WriteFileArg_t *arg_context = &dummy_context; + int local_result; /* Arrange for CF_TraverseHistory in same file as CF_TraverseTransactions */ @@ -732,12 +732,12 @@ void Test_CF_TraverseTransactions_When_context_result_Is_1_Return_CLIST_EXIT(voi void Test_CF_TraverseTransactions_When_context_result_Is_0_Return_CLIST_CONT(void) { /* Arrange */ - CF_History_t dummy_history; - CF_Transaction_t dummy_t; - CF_CListNode_t *arg_n = &dummy_t.cl_node; - trav_arg_t dummy_context; - trav_arg_t *arg_context = &dummy_context; - int local_result; + CF_History_t dummy_history; + CF_Transaction_t dummy_t; + CF_CListNode_t *arg_n = &dummy_t.cl_node; + CF_Traverse_WriteFileArg_t dummy_context; + CF_Traverse_WriteFileArg_t *arg_context = &dummy_context; + int local_result; arg_context->result = 0; /* ensures arg_context->result starts at 0 */ @@ -870,11 +870,11 @@ void Test_CF_WriteHistoryQueueDataToFile_Call_CF_CList_Traverse_AndReturn_arg_re void Test_CF_PrioSearch_When_t_PrioIsGreaterThanContextPrioReturn_CLIST_CONT(void) { /* Arrange */ - CF_Transaction_t dummy_t; - CF_CListNode_t *arg_node = &dummy_t.cl_node; - priority_arg_t dummy_p; - void *arg_context = (void *)&dummy_p; - int32 result; + CF_Transaction_t dummy_t; + CF_CListNode_t *arg_node = &dummy_t.cl_node; + CF_Traverse_PriorityArg_t dummy_p; + void *arg_context = (void *)&dummy_p; + int32 result; dummy_t.priority = Any_uint8_Except(0); dummy_p.priority = Any_uint8_LessThan(dummy_t.priority); @@ -891,11 +891,11 @@ void Test_CF_PrioSearch_When_t_PrioIsGreaterThanContextPrioReturn_CLIST_CONT(voi void Test_CF_PrioSearch_When_t_PrioIsEqToContextPrio_Set_context_t_To_t_AndReturn_CLIST_EXIT(void) { /* Arrange */ - CF_Transaction_t dummy_t; - CF_CListNode_t *arg_node = &dummy_t.cl_node; - priority_arg_t dummy_p; - void *arg_context = (void *)&dummy_p; - int32 result; + CF_Transaction_t dummy_t; + CF_CListNode_t *arg_node = &dummy_t.cl_node; + CF_Traverse_PriorityArg_t dummy_p; + void *arg_context = (void *)&dummy_p; + int32 result; /* NOTE: these are inverted from previous test! */ dummy_t.priority = Any_uint8_Except(0); @@ -914,11 +914,11 @@ void Test_CF_PrioSearch_When_t_PrioIsEqToContextPrio_Set_context_t_To_t_AndRetur void Test_CF_PrioSearch_When_t_PrioIsLessThanContextPrio_Set_context_t_To_t_AndReturn_CLIST_EXIT(void) { /* Arrange */ - CF_Transaction_t dummy_t; - CF_CListNode_t *arg_node = &dummy_t.cl_node; - priority_arg_t dummy_p; - void *arg_context = (void *)&dummy_p; - int32 result; + CF_Transaction_t dummy_t; + CF_CListNode_t *arg_node = &dummy_t.cl_node; + CF_Traverse_PriorityArg_t dummy_p; + void *arg_context = (void *)&dummy_p; + int32 result; /* NOTE: these are inverted from previous test! */ dummy_p.priority = Any_uint8_Except(0); @@ -1027,7 +1027,7 @@ void Test_CF_InsertSortPrio_Call_CF_CList_InsertAfter_Ex_AndSet_q_index_To_q(voi dummy_c = &CF_AppData.engine.channels[arg_t->chan_num]; dummy_c->qs[arg_q] = (CF_CListNode_t *)&dummy_qs; - /* setup priority_arg_t altered value */ + /* setup CF_Traverse_PriorityArg_t altered value */ context_cf_clist_traverse_r.context_t = &dummy_p_t; /* Arrange for CF_CList_InsertAfter_Ex */ @@ -1084,7 +1084,7 @@ void Test_CF_InsertSortPrio_When_p_t_Is_NULL_Call_CF_CList_InsertBack_Ex(void) dummy_c = &CF_AppData.engine.channels[arg_t->chan_num]; dummy_c->qs[arg_q] = (CF_CListNode_t *)&dummy_qs; - /* setup priority_arg_t altered value */ + /* setup CF_Traverse_PriorityArg_t altered value */ context_cf_clist_traverse_r.context_t = NULL; /* set expected values */ @@ -1117,23 +1117,23 @@ void Test_CF_InsertSortPrio_When_p_t_Is_NULL_Call_CF_CList_InsertBack_Ex(void) /******************************************************************************* ** -** CF_TraverseAllTransactions_ tests +** CF_TraverseAllTransactions_Impl tests ** *******************************************************************************/ -void Test_CF_TraverseAllTransactions__GetContainer_t_Call_args_fn_AndAdd_1_ToCounter(void) +void Test_CF_TraverseAllTransactions_Impl_GetContainer_t_Call_args_fn_AndAdd_1_ToCounter(void) { /* Arrange */ - CF_Transaction_t dummy_t; - CF_CListNode_t *arg_n = &dummy_t.cl_node; - traverse_all_args_t dummy_args; - traverse_all_args_t *arg_args; - int dummy_context_val; - void *dummy_context = &dummy_context_val; - int initial_args_counter = Any_int(); - CF_Transaction_t *expected_t; - void *expected_context; - int32 result; + CF_Transaction_t dummy_t; + CF_CListNode_t *arg_n = &dummy_t.cl_node; + CF_TraverseAll_Arg_t dummy_args; + CF_TraverseAll_Arg_t *arg_args; + int dummy_context_val; + void *dummy_context = &dummy_context_val; + int initial_args_counter = Any_int(); + CF_Transaction_t *expected_t; + void *expected_context; + int32 result; dummy_args.fn = UT_Callback_CF_TraverseAllTransactions; dummy_args.context = dummy_context; @@ -1150,18 +1150,19 @@ void Test_CF_TraverseAllTransactions__GetContainer_t_Call_args_fn_AndAdd_1_ToCou false); /* Act */ - result = CF_TraverseAllTransactions_(arg_n, arg_args); + result = CF_TraverseAllTransactions_Impl(arg_n, arg_args); /* Assert */ UtAssert_ADDRESS_EQ(func_ptr_context.t, expected_t); UtAssert_ADDRESS_EQ(func_ptr_context.context, expected_context); UtAssert_True(arg_args->counter == initial_args_counter + 1, - "CF_TraverseAllTransactions_ set args->counter to %d which is 1 more than initial value %d", + "CF_TraverseAllTransactions_Impl set args->counter to %d which is 1 more than initial value %d", arg_args->counter, initial_args_counter); - UtAssert_True(result == CF_CLIST_CONT, "CF_TraverseAllTransactions_ returned %d and should be %d (CF_CLIST_CONT)", - result, CF_CLIST_CONT); + UtAssert_True(result == CF_CLIST_CONT, + "CF_TraverseAllTransactions_Impl returned %d and should be %d (CF_CLIST_CONT)", result, + CF_CLIST_CONT); -} /* end Test_CF_TraverseAllTransactions__GetContainer_t_Call_args_fn_AndAdd_1_ToCounter */ +} /* end Test_CF_TraverseAllTransactions_Impl_GetContainer_t_Call_args_fn_AndAdd_1_ToCounter */ /******************************************************************************* ** @@ -1205,8 +1206,8 @@ void Test_CF_TraverseAllTransactions_CallOtherFunction_CF_Q_RX_TimesAndReturn_ar for (i = 0; i < expected_count; ++i) { UtAssert_ADDRESS_EQ(contexts_cf_clist_traverse[i].start, (CF_CListNode_t *)&expected_qs_nodes[i]); - UtAssert_True(contexts_cf_clist_traverse[i].fn == (CF_CListFn_t)CF_TraverseAllTransactions_, - "contexts_cf_clist_traverse[i].fn == (CF_CListFn_t ) CF_TraverseAllTransactions_"); + UtAssert_True(contexts_cf_clist_traverse[i].fn == (CF_CListFn_t)CF_TraverseAllTransactions_Impl, + "contexts_cf_clist_traverse[i].fn == (CF_CListFn_t ) CF_TraverseAllTransactions_Impl"); UtAssert_True(contexts_cf_clist_traverse[i].context_fn == UT_Callback_CF_TraverseAllTransactions, "contexts_cf_clist_traverse[i].context_fn == UT_Callback_CF_TraverseAllTransactions"); UtAssert_ADDRESS_EQ(contexts_cf_clist_traverse[i].context_context, arg_context); @@ -1421,8 +1422,8 @@ void add_cf_utils_h_tests(void) UtTest_Add(Test_CF_FindUnusedTransaction, cf_utils_tests_Setup, cf_utils_tests_Teardown, "CF_FindUnusedTransaction"); UtTest_Add(Test_CF_FreeTransaction, cf_utils_tests_Setup, cf_utils_tests_Teardown, "CF_FreeTransaction"); - UtTest_Add(Test_CF_FindTransactionBySequenceNumber_, cf_utils_tests_Setup, cf_utils_tests_Teardown, - "Test_CF_FindTransactionBySequenceNumber_"); + UtTest_Add(Test_CF_FindTransactionBySequenceNumber_Impl, cf_utils_tests_Setup, cf_utils_tests_Teardown, + "CF_FindTransactionBySequenceNumber_Impl"); UtTest_Add(Test_CF_FindTransactionBySequenceNumber, cf_utils_tests_Setup, cf_utils_tests_Teardown, "CF_FindTransactionBySequenceNumber"); @@ -1528,11 +1529,11 @@ void add_CF_InsertSortPrio_tests(void) cf_utils_tests_Teardown, "Test_CF_InsertSortPrio_When_p_t_Is_NULL_Call_CF_CList_InsertBack_Ex"); } -void add_CF_TraverseAllTransactions__tests(void) +void add_CF_TraverseAllTransactions_Impl_tests(void) { - UtTest_Add(Test_CF_TraverseAllTransactions__GetContainer_t_Call_args_fn_AndAdd_1_ToCounter, cf_utils_tests_Setup, - cf_utils_tests_Teardown, - "Test_CF_TraverseAllTransactions__GetContainer_t_Call_args_fn_AndAdd_1_ToCounter"); + UtTest_Add(Test_CF_TraverseAllTransactions_Impl_GetContainer_t_Call_args_fn_AndAdd_1_ToCounter, + cf_utils_tests_Setup, cf_utils_tests_Teardown, + "Test_CF_TraverseAllTransactions_Impl_GetContainer_t_Call_args_fn_AndAdd_1_ToCounter"); } void add_CF_TraverseAllTransactions_tests(void) @@ -1605,7 +1606,7 @@ void UtTest_Setup(void) add_CF_InsertSortPrio_tests(); - add_CF_TraverseAllTransactions__tests(); + add_CF_TraverseAllTransactions_Impl_tests(); add_CF_TraverseAllTransactions_tests(); diff --git a/unit-test/stubs/cf_cfdp_stubs.c b/unit-test/stubs/cf_cfdp_stubs.c index 457346ce..691d36b6 100644 --- a/unit-test/stubs/cf_cfdp_stubs.c +++ b/unit-test/stubs/cf_cfdp_stubs.c @@ -160,19 +160,19 @@ void CF_CFDP_CycleTx(CF_Channel_t *c) /* * ---------------------------------------------------- - * Generated stub function for CF_CFDP_CycleTx_() + * Generated stub function for CF_CFDP_CycleTxFirstActive() * ---------------------------------------------------- */ -int CF_CFDP_CycleTx_(CF_CListNode_t *node, void *context) +int CF_CFDP_CycleTxFirstActive(CF_CListNode_t *node, void *context) { - UT_GenStub_SetupReturnBuffer(CF_CFDP_CycleTx_, int); + UT_GenStub_SetupReturnBuffer(CF_CFDP_CycleTxFirstActive, int); - UT_GenStub_AddParam(CF_CFDP_CycleTx_, CF_CListNode_t *, node); - UT_GenStub_AddParam(CF_CFDP_CycleTx_, void *, context); + UT_GenStub_AddParam(CF_CFDP_CycleTxFirstActive, CF_CListNode_t *, node); + UT_GenStub_AddParam(CF_CFDP_CycleTxFirstActive, void *, context); - UT_GenStub_Execute(CF_CFDP_CycleTx_, Basic, NULL); + UT_GenStub_Execute(CF_CFDP_CycleTxFirstActive, Basic, NULL); - return UT_GenStub_GetReturnValue(CF_CFDP_CycleTx_, int); + return UT_GenStub_GetReturnValue(CF_CFDP_CycleTxFirstActive, int); } /* diff --git a/unit-test/stubs/cf_cmd_stubs.c b/unit-test/stubs/cf_cmd_stubs.c index e3721df3..855197ca 100644 --- a/unit-test/stubs/cf_cmd_stubs.c +++ b/unit-test/stubs/cf_cmd_stubs.c @@ -44,15 +44,15 @@ void CF_CmdAbandon(CFE_SB_Buffer_t *msg) /* * ---------------------------------------------------- - * Generated stub function for CF_CmdAbandon_() + * Generated stub function for CF_CmdAbandon_Txn() * ---------------------------------------------------- */ -void CF_CmdAbandon_(CF_Transaction_t *t, void *ignored) +void CF_CmdAbandon_Txn(CF_Transaction_t *t, void *ignored) { - UT_GenStub_AddParam(CF_CmdAbandon_, CF_Transaction_t *, t); - UT_GenStub_AddParam(CF_CmdAbandon_, void *, ignored); + UT_GenStub_AddParam(CF_CmdAbandon_Txn, CF_Transaction_t *, t); + UT_GenStub_AddParam(CF_CmdAbandon_Txn, void *, ignored); - UT_GenStub_Execute(CF_CmdAbandon_, Basic, NULL); + UT_GenStub_Execute(CF_CmdAbandon_Txn, Basic, NULL); } /* @@ -69,15 +69,15 @@ void CF_CmdCancel(CFE_SB_Buffer_t *msg) /* * ---------------------------------------------------- - * Generated stub function for CF_CmdCancel_() + * Generated stub function for CF_CmdCancel_Txn() * ---------------------------------------------------- */ -void CF_CmdCancel_(CF_Transaction_t *t, void *ignored) +void CF_CmdCancel_Txn(CF_Transaction_t *t, void *ignored) { - UT_GenStub_AddParam(CF_CmdCancel_, CF_Transaction_t *, t); - UT_GenStub_AddParam(CF_CmdCancel_, void *, ignored); + UT_GenStub_AddParam(CF_CmdCancel_Txn, CF_Transaction_t *, t); + UT_GenStub_AddParam(CF_CmdCancel_Txn, void *, ignored); - UT_GenStub_Execute(CF_CmdCancel_, Basic, NULL); + UT_GenStub_Execute(CF_CmdCancel_Txn, Basic, NULL); } /* @@ -362,13 +362,13 @@ void CF_CmdWriteQueue(CFE_SB_Buffer_t *msg) * Generated stub function for CF_DoChanAction() * ---------------------------------------------------- */ -int CF_DoChanAction(CF_UnionArgsCmd_t *cmd, const char *errstr, chan_action_fn_t fn, void *context) +int CF_DoChanAction(CF_UnionArgsCmd_t *cmd, const char *errstr, CF_ChanActionFn_t fn, void *context) { UT_GenStub_SetupReturnBuffer(CF_DoChanAction, int); UT_GenStub_AddParam(CF_DoChanAction, CF_UnionArgsCmd_t *, cmd); UT_GenStub_AddParam(CF_DoChanAction, const char *, errstr); - UT_GenStub_AddParam(CF_DoChanAction, chan_action_fn_t, fn); + UT_GenStub_AddParam(CF_DoChanAction, CF_ChanActionFn_t, fn); UT_GenStub_AddParam(CF_DoChanAction, void *, context); UT_GenStub_Execute(CF_DoChanAction, Basic, NULL); @@ -381,12 +381,12 @@ int CF_DoChanAction(CF_UnionArgsCmd_t *cmd, const char *errstr, chan_action_fn_t * Generated stub function for CF_DoEnableDisableDequeue() * ---------------------------------------------------- */ -int CF_DoEnableDisableDequeue(uint8 chan_num, const bool_arg_t *context) +int CF_DoEnableDisableDequeue(uint8 chan_num, const CF_ChanAction_BoolArg_t *context) { UT_GenStub_SetupReturnBuffer(CF_DoEnableDisableDequeue, int); UT_GenStub_AddParam(CF_DoEnableDisableDequeue, uint8, chan_num); - UT_GenStub_AddParam(CF_DoEnableDisableDequeue, const bool_arg_t *, context); + UT_GenStub_AddParam(CF_DoEnableDisableDequeue, const CF_ChanAction_BoolArg_t *, context); UT_GenStub_Execute(CF_DoEnableDisableDequeue, Basic, NULL); @@ -398,12 +398,12 @@ int CF_DoEnableDisableDequeue(uint8 chan_num, const bool_arg_t *context) * Generated stub function for CF_DoEnableDisablePolldir() * ---------------------------------------------------- */ -int CF_DoEnableDisablePolldir(uint8 chan_num, const bool_msg_arg_t *context) +int CF_DoEnableDisablePolldir(uint8 chan_num, const CF_ChanAction_BoolMsgArg_t *context) { UT_GenStub_SetupReturnBuffer(CF_DoEnableDisablePolldir, int); UT_GenStub_AddParam(CF_DoEnableDisablePolldir, uint8, chan_num); - UT_GenStub_AddParam(CF_DoEnableDisablePolldir, const bool_msg_arg_t *, context); + UT_GenStub_AddParam(CF_DoEnableDisablePolldir, const CF_ChanAction_BoolMsgArg_t *, context); UT_GenStub_Execute(CF_DoEnableDisablePolldir, Basic, NULL); @@ -415,12 +415,12 @@ int CF_DoEnableDisablePolldir(uint8 chan_num, const bool_msg_arg_t *context) * Generated stub function for CF_DoFreezeThaw() * ---------------------------------------------------- */ -int CF_DoFreezeThaw(uint8 chan_num, const bool_arg_t *context) +int CF_DoFreezeThaw(uint8 chan_num, const CF_ChanAction_BoolArg_t *context) { UT_GenStub_SetupReturnBuffer(CF_DoFreezeThaw, int); UT_GenStub_AddParam(CF_DoFreezeThaw, uint8, chan_num); - UT_GenStub_AddParam(CF_DoFreezeThaw, const bool_arg_t *, context); + UT_GenStub_AddParam(CF_DoFreezeThaw, const CF_ChanAction_BoolArg_t *, context); UT_GenStub_Execute(CF_DoFreezeThaw, Basic, NULL); @@ -459,15 +459,15 @@ void CF_DoSuspRes(CF_TransactionCmd_t *cmd, uint8 action) /* * ---------------------------------------------------- - * Generated stub function for CF_DoSuspRes_() + * Generated stub function for CF_DoSuspRes_Txn() * ---------------------------------------------------- */ -void CF_DoSuspRes_(CF_Transaction_t *t, susp_res_arg_t *context) +void CF_DoSuspRes_Txn(CF_Transaction_t *t, CF_ChanAction_SuspResArg_t *context) { - UT_GenStub_AddParam(CF_DoSuspRes_, CF_Transaction_t *, t); - UT_GenStub_AddParam(CF_DoSuspRes_, susp_res_arg_t *, context); + UT_GenStub_AddParam(CF_DoSuspRes_Txn, CF_Transaction_t *, t); + UT_GenStub_AddParam(CF_DoSuspRes_Txn, CF_ChanAction_SuspResArg_t *, context); - UT_GenStub_Execute(CF_DoSuspRes_, Basic, NULL); + UT_GenStub_Execute(CF_DoSuspRes_Txn, Basic, NULL); } /* diff --git a/unit-test/stubs/cf_utils_stubs.c b/unit-test/stubs/cf_utils_stubs.c index 758820d2..ad055ff1 100644 --- a/unit-test/stubs/cf_utils_stubs.c +++ b/unit-test/stubs/cf_utils_stubs.c @@ -63,19 +63,19 @@ CF_Transaction_t *CF_FindTransactionBySequenceNumber(CF_Channel_t *c, CF_Transac /* * ---------------------------------------------------- - * Generated stub function for CF_FindTransactionBySequenceNumber_() + * Generated stub function for CF_FindTransactionBySequenceNumber_Impl() * ---------------------------------------------------- */ -int CF_FindTransactionBySequenceNumber_(CF_CListNode_t *n, trans_seq_arg_t *context) +int CF_FindTransactionBySequenceNumber_Impl(CF_CListNode_t *n, CF_Traverse_TransSeqArg_t *context) { - UT_GenStub_SetupReturnBuffer(CF_FindTransactionBySequenceNumber_, int); + UT_GenStub_SetupReturnBuffer(CF_FindTransactionBySequenceNumber_Impl, int); - UT_GenStub_AddParam(CF_FindTransactionBySequenceNumber_, CF_CListNode_t *, n); - UT_GenStub_AddParam(CF_FindTransactionBySequenceNumber_, trans_seq_arg_t *, context); + UT_GenStub_AddParam(CF_FindTransactionBySequenceNumber_Impl, CF_CListNode_t *, n); + UT_GenStub_AddParam(CF_FindTransactionBySequenceNumber_Impl, CF_Traverse_TransSeqArg_t *, context); - UT_GenStub_Execute(CF_FindTransactionBySequenceNumber_, Basic, NULL); + UT_GenStub_Execute(CF_FindTransactionBySequenceNumber_Impl, Basic, NULL); - return UT_GenStub_GetReturnValue(CF_FindTransactionBySequenceNumber_, int); + return UT_GenStub_GetReturnValue(CF_FindTransactionBySequenceNumber_Impl, int); } /* @@ -169,37 +169,37 @@ int CF_TraverseAllTransactions(CF_Channel_t *c, CF_TraverseAllTransactions_fn_t /* * ---------------------------------------------------- - * Generated stub function for CF_TraverseAllTransactions_() + * Generated stub function for CF_TraverseAllTransactions_All_Channels() * ---------------------------------------------------- */ -int CF_TraverseAllTransactions_(CF_CListNode_t *n, traverse_all_args_t *args) +int CF_TraverseAllTransactions_All_Channels(CF_TraverseAllTransactions_fn_t fn, void *context) { - UT_GenStub_SetupReturnBuffer(CF_TraverseAllTransactions_, int); + UT_GenStub_SetupReturnBuffer(CF_TraverseAllTransactions_All_Channels, int); - UT_GenStub_AddParam(CF_TraverseAllTransactions_, CF_CListNode_t *, n); - UT_GenStub_AddParam(CF_TraverseAllTransactions_, traverse_all_args_t *, args); + UT_GenStub_AddParam(CF_TraverseAllTransactions_All_Channels, CF_TraverseAllTransactions_fn_t, fn); + UT_GenStub_AddParam(CF_TraverseAllTransactions_All_Channels, void *, context); - UT_GenStub_Execute(CF_TraverseAllTransactions_, Basic, NULL); + UT_GenStub_Execute(CF_TraverseAllTransactions_All_Channels, Basic, + UT_DefaultHandler_CF_TraverseAllTransactions_All_Channels); - return UT_GenStub_GetReturnValue(CF_TraverseAllTransactions_, int); + return UT_GenStub_GetReturnValue(CF_TraverseAllTransactions_All_Channels, int); } /* * ---------------------------------------------------- - * Generated stub function for CF_TraverseAllTransactions_All_Channels() + * Generated stub function for CF_TraverseAllTransactions_Impl() * ---------------------------------------------------- */ -int CF_TraverseAllTransactions_All_Channels(CF_TraverseAllTransactions_fn_t fn, void *context) +int CF_TraverseAllTransactions_Impl(CF_CListNode_t *n, CF_TraverseAll_Arg_t *args) { - UT_GenStub_SetupReturnBuffer(CF_TraverseAllTransactions_All_Channels, int); + UT_GenStub_SetupReturnBuffer(CF_TraverseAllTransactions_Impl, int); - UT_GenStub_AddParam(CF_TraverseAllTransactions_All_Channels, CF_TraverseAllTransactions_fn_t, fn); - UT_GenStub_AddParam(CF_TraverseAllTransactions_All_Channels, void *, context); + UT_GenStub_AddParam(CF_TraverseAllTransactions_Impl, CF_CListNode_t *, n); + UT_GenStub_AddParam(CF_TraverseAllTransactions_Impl, CF_TraverseAll_Arg_t *, args); - UT_GenStub_Execute(CF_TraverseAllTransactions_All_Channels, Basic, - UT_DefaultHandler_CF_TraverseAllTransactions_All_Channels); + UT_GenStub_Execute(CF_TraverseAllTransactions_Impl, Basic, NULL); - return UT_GenStub_GetReturnValue(CF_TraverseAllTransactions_All_Channels, int); + return UT_GenStub_GetReturnValue(CF_TraverseAllTransactions_Impl, int); } /* @@ -207,12 +207,12 @@ int CF_TraverseAllTransactions_All_Channels(CF_TraverseAllTransactions_fn_t fn, * Generated stub function for CF_TraverseHistory() * ---------------------------------------------------- */ -int CF_TraverseHistory(CF_CListNode_t *n, trav_arg_t *context) +int CF_TraverseHistory(CF_CListNode_t *n, CF_Traverse_WriteFileArg_t *context) { UT_GenStub_SetupReturnBuffer(CF_TraverseHistory, int); UT_GenStub_AddParam(CF_TraverseHistory, CF_CListNode_t *, n); - UT_GenStub_AddParam(CF_TraverseHistory, trav_arg_t *, context); + UT_GenStub_AddParam(CF_TraverseHistory, CF_Traverse_WriteFileArg_t *, context); UT_GenStub_Execute(CF_TraverseHistory, Basic, NULL); @@ -224,12 +224,12 @@ int CF_TraverseHistory(CF_CListNode_t *n, trav_arg_t *context) * Generated stub function for CF_TraverseTransactions() * ---------------------------------------------------- */ -int CF_TraverseTransactions(CF_CListNode_t *n, trav_arg_t *context) +int CF_TraverseTransactions(CF_CListNode_t *n, CF_Traverse_WriteFileArg_t *context) { UT_GenStub_SetupReturnBuffer(CF_TraverseTransactions, int); UT_GenStub_AddParam(CF_TraverseTransactions, CF_CListNode_t *, n); - UT_GenStub_AddParam(CF_TraverseTransactions, trav_arg_t *, context); + UT_GenStub_AddParam(CF_TraverseTransactions, CF_Traverse_WriteFileArg_t *, context); UT_GenStub_Execute(CF_TraverseTransactions, Basic, NULL); diff --git a/unit-test/utilities/cf_test_alt_handler.c b/unit-test/utilities/cf_test_alt_handler.c index cfa6d419..cac832e5 100644 --- a/unit-test/utilities/cf_test_alt_handler.c +++ b/unit-test/utilities/cf_test_alt_handler.c @@ -16,13 +16,13 @@ * Function: UT_AltHandler_CF_CList_Traverse_TRAV_ARG_T * * A handler for CF_CList_Traverse which saves its arguments - * including the opaque context pointer as a trav_arg_t object. + * including the opaque context pointer as a CF_Traverse_WriteFileArg_t object. * *-----------------------------------------------------------------*/ void UT_AltHandler_CF_CList_Traverse_TRAV_ARG_T(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) { CF_CList_Traverse_TRAV_ARG_T_context_t *ctxt; - trav_arg_t *arg = UT_Hook_GetArgValueByName(Context, "context", trav_arg_t *); + CF_Traverse_WriteFileArg_t *arg = UT_Hook_GetArgValueByName(Context, "context", CF_Traverse_WriteFileArg_t *); if (UserObj) { @@ -51,14 +51,14 @@ void UT_AltHandler_CF_CList_Traverse_TRAV_ARG_T(void *UserObj, UT_EntryKey_t Fun * Function: UT_AltHandler_CF_CList_Traverse_TRAVERSE_ALL_ARGS_T * * A handler for CF_CList_Traverse which saves its arguments - * including the opaque context pointer as a traverse_all_args_t object. + * including the opaque context pointer as a CF_TraverseAll_Arg_t object. * *-----------------------------------------------------------------*/ void UT_AltHandler_CF_CList_Traverse_TRAVERSE_ALL_ARGS_T(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) { CF_CList_Traverse_TRAVERSE_ALL_ARGS_T_context_t *ctxt; - traverse_all_args_t *arg = UT_Hook_GetArgValueByName(Context, "context", traverse_all_args_t *); + CF_TraverseAll_Arg_t *arg = UT_Hook_GetArgValueByName(Context, "context", CF_TraverseAll_Arg_t *); if (UserObj) { @@ -122,13 +122,13 @@ void UT_AltHandler_CF_CList_Traverse_POINTER(void *UserObj, UT_EntryKey_t FuncKe * Function: UT_AltHandler_CF_CList_Traverse_R_PRIO * * A handler for CF_CList_Traverse which saves its arguments - * including the opaque context pointer as a priority_arg_t object. + * including the opaque context pointer as a CF_Traverse_PriorityArg_t object. * *-----------------------------------------------------------------*/ void UT_AltHandler_CF_CList_Traverse_R_PRIO(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) { CF_CList_Traverse_R_context_t *ctxt; - priority_arg_t *arg = UT_Hook_GetArgValueByName(Context, "context", priority_arg_t *); + CF_Traverse_PriorityArg_t *arg = UT_Hook_GetArgValueByName(Context, "context", CF_Traverse_PriorityArg_t *); if (UserObj) { From 743aaf3d41fd3f0c517c4990826a82839f75a21d Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Thu, 6 Jan 2022 18:20:48 -0500 Subject: [PATCH 4/4] Fix #32, compile out CF_Asserts by default Changes CF_Assert to be opt-in rather than opt-out, so that under normal verification and validation the asserts will _not_ be included, but they can still be added back during development, if desired. They mainly exist as notes to developers as to what is supposed to be true, once debugged it is impossible to get these conditions, by definition. Also removes one channel calculation that was only for assert. Note that the same condition is asserted later, so it was redundant anyway. --- CMakeLists.txt | 1 - fsw/src/cf_assert.c | 35 ------------ fsw/src/cf_assert.h | 42 ++++++++------- fsw/src/cf_utils.c | 5 +- unit-test/CMakeLists.txt | 2 - unit-test/cf_assert_tests.c | 80 ---------------------------- unit-test/cf_utils_tests.c | 3 -- unit-test/stubs/cf_assert_handlers.c | 33 ------------ unit-test/stubs/cf_assert_stubs.c | 49 ----------------- 9 files changed, 25 insertions(+), 225 deletions(-) delete mode 100644 fsw/src/cf_assert.c delete mode 100644 unit-test/cf_assert_tests.c delete mode 100644 unit-test/stubs/cf_assert_handlers.c delete mode 100644 unit-test/stubs/cf_assert_stubs.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d30349b..177f87d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,6 @@ include_directories(${CFS_IO_LIB_MISSION_DIR}/fsw/public_inc) set(APP_SRC_FILES fsw/src/cf_app.c - fsw/src/cf_assert.c fsw/src/cf_cfdp.c fsw/src/cf_cfdp_r.c fsw/src/cf_cfdp_s.c diff --git a/fsw/src/cf_assert.c b/fsw/src/cf_assert.c deleted file mode 100644 index d64654c2..00000000 --- a/fsw/src/cf_assert.c +++ /dev/null @@ -1,35 +0,0 @@ -/************************************************************************ -** File: CF_Assert.c -** -** NASA Docket No. GSC-18,447-1, and identified as “CFS CFDP (CF) -** Application version 3.0.0” -** Copyright © 2019 United States Government as represented by the -** Administrator of the National Aeronautics and Space Administration. -** All Rights Reserved. -** Licensed under the Apache License, Version 2.0 (the "License"); you may -** not use this file except in compliance with the License. You may obtain -** a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and -** limitations under the License. -** -** -** Purpose: -** The CF Application CF_Assertion macro -** -** Revision 1.0 2020/07/15 sseeger -** -*************************************************************************/ - -#include "cf_assert.h" -#include "cf_verify.h" -#include "cf_events.h" - -void CF_HandleAssert(const char *file, int line) -{ - CFE_EVS_SendEvent(CF_EID_ERR_ASSERT, CFE_EVS_EventType_ERROR, "CF: failed CF_Assertion (%s:%d)", file, line); - CFE_ES_ExitApp(-1); -} diff --git a/fsw/src/cf_assert.h b/fsw/src/cf_assert.h index 1c39362c..fb42c9d0 100644 --- a/fsw/src/cf_assert.h +++ b/fsw/src/cf_assert.h @@ -29,27 +29,33 @@ #include "cfe.h" -extern void CF_HandleAssert(const char *file, int line); - /* - * Note that in some cases, code in CF may compute or store a value for the - * sole purpose of checking it with a CF_Assert(). If CF_Assert is then entirely - * compiled out with NDEBUG, the compiler may see that as an unused value and - * trigger a warning. - * - * To avoid this, a no-op inline function is used, such that the value in the - * CF_Assert call is still evaluated, but the result is ignored. + * CF_Assert statements within the code are primarily informational for developers, + * as the conditions within them should always be true. Barring any unforeseen + * bugs in the code, they should never get triggered. However, if the code is + * modified, these conditions could happen, so it is still worthwhile to keep + * these statements in the source code, so they can be enabled if necessary. */ -#ifdef NDEBUG -/* this is release mode */ -static inline void CF_NoAssert(bool cond) -{ - /* no-op to avoid unused value warning */ -} -#define CF_Assert(x) CF_NoAssert(x) -#else /* NDEBUG */ +#ifdef CF_DEBUG_BUILD + +/* + * Debug build: + * Translate CF_Assert to the system assert. Note that asserts may still get disabled + * if building with NDEBUG flag set, even if CF_DEBUG_BUILD flag is enabled. + */ #include #define CF_Assert(x) assert(x) -#endif /* !NDEBUG */ + +#else /* CF_DEBUG_BUILD */ + +/* + * Normal build: + * It should be impossible to get any conditions which are asserted, so it should + * be safe to turn these off. This is the configuration that the code should be + * normally tested and verified in. + */ +#define CF_Assert(x) /* no-op */ + +#endif /* CF_DEBUG_BUILD */ #endif /* !CF_ASSERT__H */ diff --git a/fsw/src/cf_utils.c b/fsw/src/cf_utils.c index dc5ef79c..26ef0623 100644 --- a/fsw/src/cf_utils.c +++ b/fsw/src/cf_utils.c @@ -55,8 +55,7 @@ CF_Transaction_t *CF_FindUnusedTransaction(CF_Channel_t *c) if (c->qs[CF_QueueIdx_FREE]) { - int q_index; /* initialized below in if */ - const int chan_index = (c - CF_AppData.engine.channels); + int q_index; /* initialized below in if */ CF_CListNode_t *n = c->qs[CF_QueueIdx_FREE]; CF_Transaction_t *t = container_of(n, CF_Transaction_t, cl_node); @@ -66,8 +65,6 @@ CF_Transaction_t *CF_FindUnusedTransaction(CF_Channel_t *c) /* now that a transaction is acquired, must also acquire a history slot to go along with it */ if (c->qs[CF_QueueIdx_HIST_FREE]) { - CF_Assert(CF_AppData.hk.channel_hk[chan_index].q_size[CF_QueueIdx_HIST] < - CF_NUM_HISTORIES_PER_CHANNEL); /* sanity check */ q_index = CF_QueueIdx_HIST_FREE; } else diff --git a/unit-test/CMakeLists.txt b/unit-test/CMakeLists.txt index 3f574b87..da1d43bd 100644 --- a/unit-test/CMakeLists.txt +++ b/unit-test/CMakeLists.txt @@ -41,8 +41,6 @@ add_cfe_coverage_stubs(cf_internal stubs/cf_app_global.c stubs/cf_app_stubs.c - stubs/cf_assert_handlers.c - stubs/cf_assert_stubs.c stubs/cf_cfdp_handlers.c stubs/cf_cfdp_dispatch_stubs.c stubs/cf_cfdp_r_stubs.c diff --git a/unit-test/cf_assert_tests.c b/unit-test/cf_assert_tests.c deleted file mode 100644 index 9afe6e04..00000000 --- a/unit-test/cf_assert_tests.c +++ /dev/null @@ -1,80 +0,0 @@ -/* cf testing includes */ -#include "cf_test_utils.h" -#include "cf_events.h" -#include "cf_app.h" - -/******************************************************************************* -** -** cf_assert_tests Setup and Teardown -** -*******************************************************************************/ - -void cf_assert_tests_Setup(void) -{ - cf_tests_Setup(); -} /* end cf_assert_tests_Setup */ - -void cf_assert_tests_Teardown(void) -{ - cf_tests_Teardown(); -} /* end cf_assert_tests_Teardown */ - -/* end cf_assert_tests Setup and Teardown */ - -/******************************************************************************* -** -** CF_HandleAssert tests -** -*******************************************************************************/ - -void Test_CF_HandleAssert_SendEventAndExitWithNegativeOne(void) -{ - /* Arrange */ - const char *arg_file = AnyRandomStringOfLettersOfLength(10); - int arg_line = Any_int(); - uint32 context_CFE_ES_ExitApp_ExitStatus; - - UT_CF_ResetEventCapture(UT_KEY(CFE_EVS_SendEvent)); - UT_SetDataBuffer(UT_KEY(CFE_ES_ExitApp), &context_CFE_ES_ExitApp_ExitStatus, - sizeof(context_CFE_ES_ExitApp_ExitStatus), false); - - /* Act */ - CF_HandleAssert(arg_file, arg_line); - - /* Assert */ - UT_CF_AssertEventID(CF_EID_ERR_ASSERT); - UtAssert_True(context_CFE_ES_ExitApp_ExitStatus == -1, "CFE_ES_ExitApp received %d and should have recieved -1", - context_CFE_ES_ExitApp_ExitStatus); -} /* end Test_CF_HandleAssert_SendEventAndExitWithNegativeOne */ - -/* end CF_HandleAssert tests */ - -/******************************************************************************* -** -** cf_assert_tests UtTest_Add groups -** -*******************************************************************************/ - -void add_CF_HandleAssert_tests(void) -{ - UtTest_Add(Test_CF_HandleAssert_SendEventAndExitWithNegativeOne, cf_assert_tests_Setup, cf_assert_tests_Teardown, - "Test_CF_HandleAssert_SendEventAndExitWithNegativeOne"); -} /* end add_CF_HandleAssert_tests */ - -/* end cf_assert_tests UtTest_Add groups */ - -/******************************************************************************* -** -** cf_assert_tests UtTest_Setup -** -*******************************************************************************/ - -void UtTest_Setup(void) -{ - TestUtil_InitializeRandomSeed(); - - add_CF_HandleAssert_tests(); - -} /* end UtTest_Setup for cf_assert_tests.c */ - -/* end cf_assert_tests.c */ \ No newline at end of file diff --git a/unit-test/cf_utils_tests.c b/unit-test/cf_utils_tests.c index a0952742..6da70861 100644 --- a/unit-test/cf_utils_tests.c +++ b/unit-test/cf_utils_tests.c @@ -305,7 +305,6 @@ void Test_cf_dequeue_transaction_Call_CF_CList_Remove_AndDecrement_q_size(void) uint16 updated_q_size = CF_AppData.hk.channel_hk[arg_t.chan_num].q_size[arg_t.flags.com.q_index]; /* Assert */ - UtAssert_STUB_COUNT(CF_HandleAssert, 0); UtAssert_ADDRESS_EQ(context_clist_remove.head, expected_head); UtAssert_ADDRESS_EQ(context_clist_remove.node, expected_cl_node); UtAssert_True(updated_q_size == initial_q_size - 1, "q_size is %d and that is 1 less than initial value %d", @@ -381,7 +380,6 @@ void Test_cf_move_transaction_Call_CF_CList_InsertBack_AndSet_q_index_ToGiven_q( CF_MoveTransaction(arg_t, arg_q); /* Assert */ - UtAssert_STUB_COUNT(CF_HandleAssert, 0); UtAssert_STUB_COUNT(CF_CList_Remove, 1); UtAssert_ADDRESS_EQ(context_clist_remove.head, expected_remove_head); UtAssert_ADDRESS_EQ(context_clist_remove.node, expected_remove_node); @@ -447,7 +445,6 @@ void Test_CF_CList_Remove_Ex_Call_CF_CList_Remove_AndDecrement_q_size(void) uint16 updated_q_size = CF_AppData.hk.channel_hk[arg_c - CF_AppData.engine.channels].q_size[arg_index]; /* Assert */ - UtAssert_STUB_COUNT(CF_HandleAssert, 0); UtAssert_STUB_COUNT(CF_CList_Remove, 1); UtAssert_ADDRESS_EQ(context_clist_remove.head, expected_remove_head); UtAssert_ADDRESS_EQ(context_clist_remove.node, expected_remove_node); diff --git a/unit-test/stubs/cf_assert_handlers.c b/unit-test/stubs/cf_assert_handlers.c deleted file mode 100644 index 514e716b..00000000 --- a/unit-test/stubs/cf_assert_handlers.c +++ /dev/null @@ -1,33 +0,0 @@ -/************************************************************************ -** File: cf_assert_stubs.c -** -** %LICENSE_START -** %LICENSE_STOP -** -** Purpose: -** File contains stubs for the CF Application CF_Assertion macro file -** -** Revision 1.0 2020/08/04 agibso1 -** Initial revision -*************************************************************************/ - -#include "cf_assert.h" -#include "cf_verify.h" -#include "cf_events.h" - -/* UT includes */ -#include "utassert.h" -#include "uttest.h" -#include "utstubs.h" - -/*---------------------------------------------------------------- - * - * Function: UT_DefaultHandler_CF_HandleAssert - * - * This registers a failure in logs. Should not normally be invoked. - * - *-----------------------------------------------------------------*/ -void UT_DefaultHandler_CF_HandleAssert(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) -{ - UtAssert_Failed("CF_HandleAssert was called issue"); -} diff --git a/unit-test/stubs/cf_assert_stubs.c b/unit-test/stubs/cf_assert_stubs.c deleted file mode 100644 index 378c27c6..00000000 --- a/unit-test/stubs/cf_assert_stubs.c +++ /dev/null @@ -1,49 +0,0 @@ -/************************************************************************ -** File: CF_Assert.h -** -** NASA Docket No. GSC-18,447-1, and identified as “CFS CFDP (CF) -** Application version 3.0.0” -** Copyright © 2019 United States Government as represented by the -** Administrator of the National Aeronautics and Space Administration. -** All Rights Reserved. -** Licensed under the Apache License, Version 2.0 (the "License"); you may -** not use this file except in compliance with the License. You may obtain -** a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and -** limitations under the License. -** -** -** Purpose: -** The CF Application CF_Assert macro -** -** Revision 1.0 2020/07/15 sseeger -** -*************************************************************************/ - -/** - * @file - * - * Auto-Generated stub implementations for functions defined in cf_assert header - */ - -#include "cf_assert.h" -#include "utgenstub.h" - -extern void UT_DefaultHandler_CF_HandleAssert(void *, UT_EntryKey_t, const UT_StubContext_t *); - -/* - * ---------------------------------------------------- - * Generated stub function for CF_HandleAssert() - * ---------------------------------------------------- - */ -void CF_HandleAssert(const char *file, int line) -{ - UT_GenStub_AddParam(CF_HandleAssert, const char *, file); - UT_GenStub_AddParam(CF_HandleAssert, int, line); - - UT_GenStub_Execute(CF_HandleAssert, Basic, UT_DefaultHandler_CF_HandleAssert); -}