From 157e04aa42b2b9a011d266f6bd88d53cc136b2dc Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Fri, 29 Sep 2023 09:39:28 -0400 Subject: [PATCH] Fix #265, Updates from review of variable name changes --- fsw/src/cf_cfdp.c | 41 ++++----- fsw/src/cf_cfdp.h | 4 +- fsw/src/cf_cfdp_dispatch.c | 6 +- fsw/src/cf_cfdp_r.c | 43 +++++----- fsw/src/cf_cfdp_r.h | 2 +- fsw/src/cf_cfdp_s.c | 29 ++++--- fsw/src/cf_cfdp_sbintf.c | 9 +- fsw/src/cf_cfdp_types.h | 4 +- fsw/src/cf_cmd.c | 2 +- fsw/src/cf_utils.c | 17 ++-- fsw/src/cf_utils.h | 5 +- unit-test/cf_cfdp_dispatch_tests.c | 2 +- unit-test/cf_cfdp_r_tests.c | 110 ++++++++++++------------- unit-test/cf_cfdp_s_tests.c | 52 ++++++------ unit-test/cf_cfdp_sbintf_tests.c | 14 ++-- unit-test/cf_cfdp_tests.c | 44 +++++----- unit-test/cf_cmd_tests.c | 6 +- unit-test/cf_timer_tests.c | 6 +- unit-test/cf_utils_tests.c | 8 +- unit-test/stubs/cf_app_stubs.c | 4 + unit-test/stubs/cf_cfdp_sbintf_stubs.c | 2 +- unit-test/stubs/cf_cfdp_stubs.c | 8 +- unit-test/stubs/cf_timer_stubs.c | 4 +- unit-test/stubs/cf_utils_handlers.c | 10 +-- unit-test/stubs/cf_utils_stubs.c | 5 +- unit-test/utilities/cf_test_utils.h | 2 +- 26 files changed, 230 insertions(+), 209 deletions(-) diff --git a/fsw/src/cf_cfdp.c b/fsw/src/cf_cfdp.c index 5bf927f6..33d86cc9 100644 --- a/fsw/src/cf_cfdp.c +++ b/fsw/src/cf_cfdp.c @@ -346,7 +346,8 @@ CFE_Status_t CF_CFDP_SendMd(CF_Transaction_t *txn) md->source_filename.length = CF_strnlen(txn->history->fnames.src_filename, sizeof(txn->history->fnames.src_filename)); md->source_filename.data_ptr = txn->history->fnames.src_filename; - md->dest_filename.length = CF_strnlen(txn->history->fnames.dst_filename, sizeof(txn->history->fnames.dst_filename)); + md->dest_filename.length = + CF_strnlen(txn->history->fnames.dst_filename, sizeof(txn->history->fnames.dst_filename)); md->dest_filename.data_ptr = txn->history->fnames.dst_filename; CF_CFDP_EncodeMd(ph->penc, md); @@ -683,8 +684,8 @@ CFE_Status_t CF_CFDP_RecvMd(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph) } else { - lv_ret = CF_CFDP_CopyStringFromLV(txn->history->fnames.dst_filename, sizeof(txn->history->fnames.dst_filename), - &md->dest_filename); + lv_ret = CF_CFDP_CopyStringFromLV(txn->history->fnames.dst_filename, + sizeof(txn->history->fnames.dst_filename), &md->dest_filename); if (lv_ret < 0) { CFE_EVS_SendEvent(CF_EID_ERR_PDU_INVALID_DST_LEN, CFE_EVS_EventType_ERROR, @@ -947,8 +948,8 @@ CFE_Status_t CF_CFDP_InitEngine(void) { /* initialize all transaction nodes */ CF_History_t * history; - CF_Transaction_t * txn = CF_AppData.engine.transactions; - CF_ChunkWrapper_t *cw = CF_AppData.engine.chunks; + CF_Transaction_t * txn = CF_AppData.engine.transactions; + CF_ChunkWrapper_t *cw = CF_AppData.engine.chunks; CFE_Status_t ret = CFE_SUCCESS; int chunk_mem_offset = 0; int i; @@ -1056,7 +1057,7 @@ CFE_Status_t CF_CFDP_InitEngine(void) CFE_Status_t CF_CFDP_CycleTxFirstActive(CF_CListNode_t *node, void *context) { CF_CFDP_CycleTx_args_t *args = (CF_CFDP_CycleTx_args_t *)context; - CF_Transaction_t * txn = container_of(node, CF_Transaction_t, cl_node); + CF_Transaction_t * txn = container_of(node, CF_Transaction_t, cl_node); CFE_Status_t ret = 1; /* default option is exit traversal */ if (txn->flags.com.suspended) @@ -1136,7 +1137,7 @@ CFE_Status_t CF_CFDP_DoTick(CF_CListNode_t *node, void *context) { CFE_Status_t 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 * txn = container_of(node, CF_Transaction_t, cl_node); + CF_Transaction_t * txn = container_of(node, CF_Transaction_t, cl_node); if (!args->chan->cur || (args->chan->cur == txn)) { /* found where we left off, so clear that and move on */ @@ -1387,7 +1388,7 @@ CFE_Status_t CF_CFDP_PlaybackDir(const char *src_filename, const char *dst_filen *-----------------------------------------------------------------*/ void CF_CFDP_ProcessPlaybackDirectory(CF_Channel_t *chan, CF_Playback_t *pb) { - CF_Transaction_t *pt; + CF_Transaction_t *txn; os_dirent_t dirent; int32 status; @@ -1408,24 +1409,24 @@ void CF_CFDP_ProcessPlaybackDirectory(CF_Channel_t *chan, CF_Playback_t *pb) continue; } - pt = CF_FindUnusedTransaction(chan); + txn = CF_FindUnusedTransaction(chan); CF_Assert(pt); /* should be impossible not to have one because there are limits on the number of uses of them */ /* the -1 below is to make room for the slash */ - snprintf(pt->history->fnames.src_filename, sizeof(pt->history->fnames.src_filename), "%.*s/%.*s", + snprintf(txn->history->fnames.src_filename, sizeof(txn->history->fnames.src_filename), "%.*s/%.*s", CF_FILENAME_MAX_PATH - 1, pb->fnames.src_filename, CF_FILENAME_MAX_NAME - 1, dirent.FileName); - snprintf(pt->history->fnames.dst_filename, sizeof(pt->history->fnames.dst_filename), "%.*s/%.*s", + snprintf(txn->history->fnames.dst_filename, sizeof(txn->history->fnames.dst_filename), "%.*s/%.*s", CF_FILENAME_MAX_PATH - 1, pb->fnames.dst_filename, CF_FILENAME_MAX_NAME - 1, dirent.FileName); /* in case snprintf didn't have room for NULL terminator */ - pt->history->fnames.src_filename[CF_FILENAME_MAX_LEN - 1] = 0; - pt->history->fnames.dst_filename[CF_FILENAME_MAX_LEN - 1] = 0; + txn->history->fnames.src_filename[CF_FILENAME_MAX_LEN - 1] = 0; + txn->history->fnames.dst_filename[CF_FILENAME_MAX_LEN - 1] = 0; - CF_CFDP_TxFile_Initiate(pt, pb->cfdp_class, pb->keep, (chan - CF_AppData.engine.channels), pb->priority, + CF_CFDP_TxFile_Initiate(txn, pb->cfdp_class, pb->keep, (chan - CF_AppData.engine.channels), pb->priority, pb->dest_id); - pt->pb = pb; + txn->pb = pb; ++pb->num_ts; } else @@ -1504,7 +1505,7 @@ void CF_CFDP_ProcessPollingDirectories(CF_Channel_t *chan) for (i = 0; i < CF_MAX_POLLING_DIR_PER_CHAN; ++i) { - poll = &chan->poll[i]; + poll = &chan->poll[i]; chan_index = (chan - CF_AppData.engine.channels); cc = &CF_AppData.config_table->chan[chan_index]; pd = &cc->polldir[i]; @@ -1523,8 +1524,8 @@ void CF_CFDP_ProcessPollingDirectories(CF_Channel_t *chan) else if (CF_Timer_Expired(&poll->interval_timer)) { /* the timer has expired */ - ret = CF_CFDP_PlaybackDir_Initiate(&poll->pb, pd->src_dir, pd->dst_dir, pd->cfdp_class, 0, chan_index, - pd->priority, pd->dest_eid); + ret = CF_CFDP_PlaybackDir_Initiate(&poll->pb, pd->src_dir, pd->dst_dir, pd->cfdp_class, 0, + chan_index, pd->priority, pd->dest_eid); if (!ret) { poll->timer_set = 0; @@ -1570,7 +1571,7 @@ void CF_CFDP_CycleEngine(void) { for (i = 0; i < CF_NUM_CHANNELS; ++i) { - chan = &CF_AppData.engine.channels[i]; + chan = &CF_AppData.engine.channels[i]; CF_AppData.engine.outgoing_counter = 0; /* consume all received messages, even if channel is frozen */ @@ -1606,7 +1607,7 @@ void CF_CFDP_ResetTransaction(CF_Transaction_t *txn, int keep_history) char * filename; char destination[OS_MAX_PATH_LEN]; osal_status_t status = OS_ERROR; - CF_Channel_t *chan = &CF_AppData.engine.channels[txn->chan_num]; + CF_Channel_t *chan = &CF_AppData.engine.channels[txn->chan_num]; CF_Assert(txn->chan_num < CF_NUM_CHANNELS); CF_CFDP_SendEotPkt(txn); diff --git a/fsw/src/cf_cfdp.h b/fsw/src/cf_cfdp.h index e7e14564..de6a65c4 100644 --- a/fsw/src/cf_cfdp.h +++ b/fsw/src/cf_cfdp.h @@ -33,7 +33,7 @@ */ typedef struct CF_CFDP_CycleTx_args { - CF_Channel_t *chan; /**< \brief channel structure */ + CF_Channel_t *chan; /**< \brief channel structure */ int ran_one; /**< \brief should be set to 1 if a transaction was cycled */ } CF_CFDP_CycleTx_args_t; @@ -42,7 +42,7 @@ typedef struct CF_CFDP_CycleTx_args */ typedef struct CF_CFDP_Tick_args { - CF_Channel_t *chan; /**< \brief channel structure */ + CF_Channel_t *chan; /**< \brief channel structure */ void (*fn)(CF_Transaction_t *, int *); /**< \brief function pointer */ int early_exit; /**< \brief early exit result */ int cont; /**< \brief if 1, then re-traverse the list */ diff --git a/fsw/src/cf_cfdp_dispatch.c b/fsw/src/cf_cfdp_dispatch.c index 4e40b82d..31441acf 100644 --- a/fsw/src/cf_cfdp_dispatch.c +++ b/fsw/src/cf_cfdp_dispatch.c @@ -63,7 +63,8 @@ void CF_CFDP_R_DispatchRecv(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph, CFE_EVS_SendEvent(CF_EID_ERR_CFDP_R_DC_INV, CFE_EVS_EventType_ERROR, "CF R%d(%lu:%lu): received PDU with invalid directive code %d for sub-state %d", (txn->state == CF_TxnState_R2), (unsigned long)txn->history->src_eid, - (unsigned long)txn->history->seq_num, fdh->directive_code, txn->state_data.receive.sub_state); + (unsigned long)txn->history->seq_num, fdh->directive_code, + txn->state_data.receive.sub_state); } } else @@ -122,7 +123,8 @@ void CF_CFDP_S_DispatchRecv(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph, CFE_EVS_SendEvent(CF_EID_ERR_CFDP_S_DC_INV, CFE_EVS_EventType_ERROR, "CF S%d(%lu:%lu): received PDU with invalid directive code %d for sub-state %d", (txn->state == CF_TxnState_S2), (unsigned long)txn->history->src_eid, - (unsigned long)txn->history->seq_num, fdh->directive_code, txn->state_data.send.sub_state); + (unsigned long)txn->history->seq_num, fdh->directive_code, + txn->state_data.send.sub_state); } } else diff --git a/fsw/src/cf_cfdp_r.c b/fsw/src/cf_cfdp_r.c index 2436e5fb..edc66f5a 100644 --- a/fsw/src/cf_cfdp_r.c +++ b/fsw/src/cf_cfdp_r.c @@ -70,8 +70,8 @@ void CF_CFDP_R1_Reset(CF_Transaction_t *txn) void CF_CFDP_R2_Reset(CF_Transaction_t *txn) { if ((txn->state_data.receive.sub_state == CF_RxSubState_WAIT_FOR_FIN_ACK) || - (txn->state_data.receive.r2.eof_cc != CF_CFDP_ConditionCode_NO_ERROR) || CF_TxnStatus_IsError(txn->history->txn_stat) || - txn->flags.com.canceled) + (txn->state_data.receive.r2.eof_cc != CF_CFDP_ConditionCode_NO_ERROR) || + CF_TxnStatus_IsError(txn->history->txn_stat) || txn->flags.com.canceled) { CF_CFDP_R1_Reset(txn); /* it's done */ } @@ -210,8 +210,8 @@ CFE_Status_t CF_CFDP_R_ProcessFd(CF_Transaction_t *txn, CF_Logical_PduBuffer_t * { CFE_EVS_SendEvent(CF_EID_ERR_CFDP_R_SEEK_FD, CFE_EVS_EventType_ERROR, "CF R%d(%lu:%lu): failed to seek offset %ld, got %ld", (txn->state == CF_TxnState_R2), - (unsigned long)txn->history->src_eid, (unsigned long)txn->history->seq_num, (long)fd->offset, - (long)fret); + (unsigned long)txn->history->src_eid, (unsigned long)txn->history->seq_num, + (long)fd->offset, (long)fret); CF_CFDP_SetTxnStatus(txn, CF_TxnStatus_FILE_SIZE_ERROR); ++CF_AppData.hk.channel_hk[txn->chan_num].counters.fault.file_seek; ret = CF_ERROR; /* connection will reset in caller */ @@ -263,7 +263,8 @@ CFE_Status_t CF_CFDP_R_SubstateRecvEof(CF_Transaction_t *txn, CF_Logical_PduBuff CFE_EVS_SendEvent(CF_EID_ERR_CFDP_R_SIZE_MISMATCH, CFE_EVS_EventType_ERROR, "CF R%d(%lu:%lu): EOF file size mismatch: got %lu expected %lu", (txn->state == CF_TxnState_R2), (unsigned long)txn->history->src_eid, - (unsigned long)txn->history->seq_num, (unsigned long)eof->size, (unsigned long)txn->fsize); + (unsigned long)txn->history->seq_num, (unsigned long)eof->size, + (unsigned long)txn->fsize); ++CF_AppData.hk.channel_hk[txn->chan_num].counters.fault.file_size_mismatch; ret = CF_REC_PDU_FSIZE_MISMATCH_ERROR; } @@ -340,7 +341,7 @@ void CF_CFDP_R2_SubstateRecvEof(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *p /* always ACK the EOF, even if we're not done */ txn->state_data.receive.r2.eof_cc = eof->cc; - txn->flags.rx.send_ack = 1; /* defer sending ACK to tick handling */ + txn->flags.rx.send_ack = 1; /* defer sending ACK to tick handling */ /* only check for complete if EOF with no errors */ if (txn->state_data.receive.r2.eof_cc == CF_CFDP_ConditionCode_NO_ERROR) @@ -503,21 +504,21 @@ CFE_Status_t CF_CFDP_R_SubstateSendNak(CF_Transaction_t *txn) nak->scope_start = 0; cret = CF_ChunkList_ComputeGaps(&txn->chunks->chunks, (txn->chunks->chunks.count < txn->chunks->chunks.max_chunks) - ? txn->chunks->chunks.max_chunks - : (txn->chunks->chunks.max_chunks - 1), + ? txn->chunks->chunks.max_chunks + : (txn->chunks->chunks.max_chunks - 1), txn->fsize, 0, CF_CFDP_R2_GapCompute, &args); if (!cret) { /* no gaps left, so go ahead and check for completion */ txn->flags.rx.complete = 1; /* we know md was received, and there's no gaps -- it's complete */ - ret = CFE_SUCCESS; + ret = CFE_SUCCESS; } else { /* gaps are present, so let's send the NAK PDU */ - nak->scope_end = 0; - sret = CF_CFDP_SendNak(txn, ph); + nak->scope_end = 0; + sret = CF_CFDP_SendNak(txn, ph); txn->flags.rx.fd_nak_sent = 1; /* latch that at least one NAK has been sent requesting filedata */ CF_Assert(sret != CF_SEND_PDU_ERROR); /* NOTE: this CF_Assert is here because CF_CFDP_SendNak() does not return CF_SEND_PDU_ERROR, so if it's ever added to @@ -836,8 +837,8 @@ void CF_CFDP_R2_RecvMd(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph) } else { - ret = - CF_WrappedOpenCreate(&txn->fd, txn->history->fnames.dst_filename, OS_FILE_FLAG_NONE, OS_READ_WRITE); + ret = CF_WrappedOpenCreate(&txn->fd, txn->history->fnames.dst_filename, OS_FILE_FLAG_NONE, + OS_READ_WRITE); if (ret < 0) { CFE_EVS_SendEvent(CF_EID_ERR_CFDP_R_OPEN, CFE_EVS_EventType_ERROR, @@ -846,7 +847,7 @@ void CF_CFDP_R2_RecvMd(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph) (unsigned long)txn->history->seq_num, (long)ret); CF_CFDP_R2_SetFinTxnStatus(txn, CF_TxnStatus_FILESTORE_REJECTION); ++CF_AppData.hk.channel_hk[txn->chan_num].counters.fault.file_open; - txn->fd = OS_OBJECT_ID_UNDEFINED; /* just in case */ + txn->fd = OS_OBJECT_ID_UNDEFINED; /* just in case */ success = false; } } @@ -854,9 +855,9 @@ void CF_CFDP_R2_RecvMd(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph) if (success) { txn->state_data.receive.cached_pos = 0; /* reset psn due to open */ - txn->flags.rx.md_recv = 1; + txn->flags.rx.md_recv = 1; txn->state_data.receive.r2.acknak_count = 0; /* in case part of NAK */ - CF_CFDP_R2_Complete(txn, 1); /* check for completion now that md is received */ + CF_CFDP_R2_Complete(txn, 1); /* check for completion now that md is received */ } } } @@ -985,8 +986,8 @@ void CF_CFDP_R_Tick(CF_Transaction_t *txn, int *cont /* unused */) /* rx maintenance: possibly process send_eof_ack, send_nak or send_fin */ if (txn->flags.rx.send_ack) { - sret = CF_CFDP_SendAck(txn, CF_CFDP_AckTxnStatus_ACTIVE, CF_CFDP_FileDirective_EOF, txn->state_data.receive.r2.eof_cc, - txn->history->peer_eid, txn->history->seq_num); + sret = CF_CFDP_SendAck(txn, CF_CFDP_AckTxnStatus_ACTIVE, CF_CFDP_FileDirective_EOF, + txn->state_data.receive.r2.eof_cc, txn->history->peer_eid, txn->history->seq_num); CF_Assert(sret != CF_SEND_PDU_ERROR); /* if CFE_SUCCESS, then move on in the state machine. CF_CFDP_SendAck does not return @@ -1030,7 +1031,8 @@ void CF_CFDP_R_Tick(CF_Transaction_t *txn, int *cont /* unused */) ++txn->state_data.receive.r2.acknak_count; /* Check limit and handle if needed */ - if (txn->state_data.receive.r2.acknak_count >= CF_AppData.config_table->chan[txn->chan_num].ack_limit) + if (txn->state_data.receive.r2.acknak_count >= + CF_AppData.config_table->chan[txn->chan_num].ack_limit) { CFE_EVS_SendEvent(CF_EID_ERR_CFDP_R_ACK_LIMIT, CFE_EVS_EventType_ERROR, "CF R2(%lu:%lu): ACK limit reached, no fin-ack", @@ -1048,7 +1050,8 @@ void CF_CFDP_R_Tick(CF_Transaction_t *txn, int *cont /* unused */) if (success) { - CF_CFDP_ArmAckTimer(txn); /* whether sending FIN or waiting for more filedata, need ACK timer armed */ + /* whether sending FIN or waiting for more filedata, need ACK timer armed */ + CF_CFDP_ArmAckTimer(txn); } } else diff --git a/fsw/src/cf_cfdp_r.h b/fsw/src/cf_cfdp_r.h index a8c0a361..14b18569 100644 --- a/fsw/src/cf_cfdp_r.h +++ b/fsw/src/cf_cfdp_r.h @@ -38,7 +38,7 @@ */ typedef struct { - CF_Transaction_t * txn; /**< \brief Current transaction being processed */ + CF_Transaction_t * txn; /**< \brief Current transaction being processed */ CF_Logical_PduNak_t *nak; /**< \brief Current NAK PDU contents */ } CF_GapComputeArgs_t; diff --git a/fsw/src/cf_cfdp_s.c b/fsw/src/cf_cfdp_s.c index a23d260a..225199a0 100644 --- a/fsw/src/cf_cfdp_s.c +++ b/fsw/src/cf_cfdp_s.c @@ -92,7 +92,7 @@ void CF_CFDP_S1_SubstateSendEof(CF_Transaction_t *txn) *-----------------------------------------------------------------*/ void CF_CFDP_S2_SubstateSendEof(CF_Transaction_t *txn) { - txn->state_data.send.sub_state = CF_TxSubState_WAIT_FOR_EOF_ACK; + txn->state_data.send.sub_state = CF_TxSubState_WAIT_FOR_EOF_ACK; txn->flags.com.ack_timer_armed = 1; /* will cause tick to see ack_timer as expired, and act */ /* no longer need to send file data PDU except in the case of NAK response */ @@ -168,9 +168,9 @@ CFE_Status_t CF_CFDP_S_SendFileData(CF_Transaction_t *txn, uint32 foffs, uint32 if (status != foffs) { CFE_EVS_SendEvent(CF_EID_ERR_CFDP_S_SEEK_FD, CFE_EVS_EventType_ERROR, - "CF S%d(%lu:%lu): error seeking to offset %ld, got %ld", (txn->state == CF_TxnState_S2), - (unsigned long)txn->history->src_eid, (unsigned long)txn->history->seq_num, (long)foffs, - (long)status); + "CF S%d(%lu:%lu): error seeking to offset %ld, got %ld", + (txn->state == CF_TxnState_S2), (unsigned long)txn->history->src_eid, + (unsigned long)txn->history->seq_num, (long)foffs, (long)status); ++CF_AppData.hk.channel_hk[txn->chan_num].counters.fault.file_seek; success = false; } @@ -369,7 +369,7 @@ void CF_CFDP_S_SubstateSendMetadata(CF_Transaction_t *txn) (unsigned long)txn->history->src_eid, (unsigned long)txn->history->seq_num, txn->history->fnames.src_filename, (long)ret); ++CF_AppData.hk.channel_hk[txn->chan_num].counters.fault.file_open; - txn->fd = OS_OBJECT_ID_UNDEFINED; /* just in case */ + txn->fd = OS_OBJECT_ID_UNDEFINED; /* just in case */ success = false; } } @@ -382,7 +382,8 @@ void CF_CFDP_S_SubstateSendMetadata(CF_Transaction_t *txn) CFE_EVS_SendEvent(CF_EID_ERR_CFDP_S_SEEK_END, CFE_EVS_EventType_ERROR, "CF S%d(%lu:%lu): failed to seek end file %s, error=%ld", (txn->state == CF_TxnState_S2), (unsigned long)txn->history->src_eid, - (unsigned long)txn->history->seq_num, txn->history->fnames.src_filename, (long)status); + (unsigned long)txn->history->seq_num, txn->history->fnames.src_filename, + (long)status); ++CF_AppData.hk.channel_hk[txn->chan_num].counters.fault.file_seek; success = false; } @@ -398,7 +399,8 @@ void CF_CFDP_S_SubstateSendMetadata(CF_Transaction_t *txn) CFE_EVS_SendEvent(CF_EID_ERR_CFDP_S_SEEK_BEG, CFE_EVS_EventType_ERROR, "CF S%d(%lu:%lu): failed to seek begin file %s, got %ld", (txn->state == CF_TxnState_S2), (unsigned long)txn->history->src_eid, - (unsigned long)txn->history->seq_num, txn->history->fnames.src_filename, (long)status); + (unsigned long)txn->history->seq_num, txn->history->fnames.src_filename, + (long)status); ++CF_AppData.hk.channel_hk[txn->chan_num].counters.fault.file_seek; success = false; } @@ -532,8 +534,9 @@ void CF_CFDP_S2_Nak(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph) if (bad_sr) { CFE_EVS_SendEvent(CF_EID_ERR_CFDP_S_INVALID_SR, CFE_EVS_EventType_ERROR, - "CF S%d(%lu:%lu): received %d invalid NAK segment requests", (txn->state == CF_TxnState_S2), - (unsigned long)txn->history->src_eid, (unsigned long)txn->history->seq_num, bad_sr); + "CF S%d(%lu:%lu): received %d invalid NAK segment requests", + (txn->state == CF_TxnState_S2), (unsigned long)txn->history->src_eid, + (unsigned long)txn->history->seq_num, bad_sr); } } else @@ -575,7 +578,7 @@ void CF_CFDP_S2_WaitForEofAck(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph) } else { - txn->state_data.send.sub_state = CF_TxSubState_WAIT_FOR_FIN; + txn->state_data.send.sub_state = CF_TxSubState_WAIT_FOR_FIN; txn->flags.com.ack_timer_armed = 0; /* just wait for FIN now, nothing to re-send */ } } @@ -730,11 +733,13 @@ void CF_CFDP_S_Tick(CF_Transaction_t *txn, int *cont /* unused */) ++txn->state_data.send.s2.acknak_count; /* Check limit and handle if needed */ - if (txn->state_data.send.s2.acknak_count >= CF_AppData.config_table->chan[txn->chan_num].ack_limit) + if (txn->state_data.send.s2.acknak_count >= + CF_AppData.config_table->chan[txn->chan_num].ack_limit) { CFE_EVS_SendEvent(CF_EID_ERR_CFDP_S_ACK_LIMIT, CFE_EVS_EventType_ERROR, "CF S2(%lu:%lu), ack limit reached, no eof-ack", - (unsigned long)txn->history->src_eid, (unsigned long)txn->history->seq_num); + (unsigned long)txn->history->src_eid, + (unsigned long)txn->history->seq_num); CF_CFDP_SetTxnStatus(txn, CF_TxnStatus_ACK_LIMIT_NO_EOF); ++CF_AppData.hk.channel_hk[txn->chan_num].counters.fault.ack_limit; diff --git a/fsw/src/cf_cfdp_sbintf.c b/fsw/src/cf_cfdp_sbintf.c index a40db7ab..cbaa8813 100644 --- a/fsw/src/cf_cfdp_sbintf.c +++ b/fsw/src/cf_cfdp_sbintf.c @@ -61,7 +61,7 @@ CF_Logical_PduBuffer_t *CF_CFDP_MsgOutGet(const CF_Transaction_t *txn, bool silent) { /* if channel is frozen, do not take message */ - CF_Channel_t * chan = CF_AppData.engine.channels + txn->chan_num; + CF_Channel_t * chan = CF_AppData.engine.channels + txn->chan_num; bool success = true; CF_Logical_PduBuffer_t *ret; int32 os_status; @@ -81,8 +81,8 @@ CF_Logical_PduBuffer_t *CF_CFDP_MsgOutGet(const CF_Transaction_t *txn, bool sile CF_AppData.config_table->chan[txn->chan_num].max_outgoing_messages_per_wakeup)) { /* no more messages this wakeup allowed */ - chan->cur = txn; /* remember where we were for next time */ - success = false; + chan->cur = txn; /* remember where we were for next time */ + success = false; } if (success && !CF_AppData.hk.channel_hk[txn->chan_num].frozen && !txn->flags.com.suspended) @@ -118,7 +118,8 @@ CF_Logical_PduBuffer_t *CF_CFDP_MsgOutGet(const CF_Transaction_t *txn, bool sile if (success) { CFE_MSG_Init(&CF_AppData.engine.out.msg->Msg, - CFE_SB_ValueToMsgId(CF_AppData.config_table->chan[txn->chan_num].mid_output), offsetof(CF_PduTlmMsg_t, ph)); + CFE_SB_ValueToMsgId(CF_AppData.config_table->chan[txn->chan_num].mid_output), + offsetof(CF_PduTlmMsg_t, ph)); ++CF_AppData.engine.outgoing_counter; /* even if max_outgoing_messages_per_wakeup is 0 (unlimited), it's ok to inc this */ diff --git a/fsw/src/cf_cfdp_types.h b/fsw/src/cf_cfdp_types.h index cac7271b..188fd76f 100644 --- a/fsw/src/cf_cfdp_types.h +++ b/fsw/src/cf_cfdp_types.h @@ -195,7 +195,7 @@ typedef struct CF_ChunkWrapper /** * @brief CF Playback entry * - * Keeps the state of CF pb requests + * Keeps the state of CF playback requests */ typedef struct CF_Playback { @@ -385,7 +385,7 @@ typedef enum * * This keeps the state of CF channels * - * Each CF channel has a separate transaction list, PDU throttle, pb, + * Each CF channel has a separate transaction list, PDU throttle, playback, * and poll state, as well as separate addresses on the underlying message * transport (e.g. SB). */ diff --git a/fsw/src/cf_cmd.c b/fsw/src/cf_cmd.c index 0241e674..024a2d90 100644 --- a/fsw/src/cf_cmd.c +++ b/fsw/src/cf_cmd.c @@ -768,7 +768,7 @@ void CF_CmdPurgeQueue(CFE_SB_Buffer_t *msg) void CF_CmdWriteQueue(CFE_SB_Buffer_t *msg) { CF_WriteQueueCmd_t *wq = (CF_WriteQueueCmd_t *)msg; - CF_Channel_t * chan = &CF_AppData.engine.channels[wq->chan]; + CF_Channel_t * chan = &CF_AppData.engine.channels[wq->chan]; osal_id_t fd = OS_OBJECT_ID_UNDEFINED; bool success = true; int32 ret; diff --git a/fsw/src/cf_utils.c b/fsw/src/cf_utils.c index adf97bcf..b2a91d01 100644 --- a/fsw/src/cf_utils.c +++ b/fsw/src/cf_utils.c @@ -51,7 +51,7 @@ CF_Transaction_t *CF_FindUnusedTransaction(CF_Channel_t *chan) if (chan->qs[CF_QueueIdx_FREE]) { node = chan->qs[CF_QueueIdx_FREE]; - txn = container_of(node, CF_Transaction_t, cl_node); + txn = container_of(node, CF_Transaction_t, cl_node); CF_CList_Remove_Ex(chan, CF_QueueIdx_FREE, &txn->cl_node); @@ -118,13 +118,13 @@ void CF_FreeTransaction(CF_Transaction_t *txn) *-----------------------------------------------------------------*/ CFE_Status_t CF_FindTransactionBySequenceNumber_Impl(CF_CListNode_t *node, CF_Traverse_TransSeqArg_t *context) { - CF_Transaction_t *txn = container_of(node, CF_Transaction_t, cl_node); + CF_Transaction_t *txn = container_of(node, CF_Transaction_t, cl_node); CFE_Status_t ret = 0; if ((txn->history->src_eid == context->src_eid) && (txn->history->seq_num == context->transaction_sequence_number)) { context->txn = txn; - ret = 1; /* exit early */ + ret = 1; /* exit early */ } return ret; @@ -136,8 +136,9 @@ CFE_Status_t CF_FindTransactionBySequenceNumber_Impl(CF_CListNode_t *node, CF_Tr * See description in cf_utils.h for argument/return detail * *-----------------------------------------------------------------*/ -CF_Transaction_t *CF_FindTransactionBySequenceNumber(CF_Channel_t *chan, CF_TransactionSeq_t transaction_sequence_number, - CF_EntityId_t src_eid) +CF_Transaction_t *CF_FindTransactionBySequenceNumber(CF_Channel_t * chan, + CF_TransactionSeq_t transaction_sequence_number, + CF_EntityId_t src_eid) { /* need to find transaction by sequence number. It will either be the active transaction (front of Q_PEND), * or on Q_TX or Q_RX. Once a transaction moves to history, then it's done. @@ -218,7 +219,7 @@ CFE_Status_t CF_WriteHistoryEntryToFile(osal_id_t fd, const CF_History_t *histor CFE_Status_t CF_Traverse_WriteHistoryQueueEntryToFile(CF_CListNode_t *node, void *arg) { CF_Traverse_WriteHistoryFileArg_t *context = arg; - CF_History_t * history = container_of(node, CF_History_t, cl_node); + CF_History_t * history = container_of(node, CF_History_t, cl_node); /* if filter_dir is CF_Direction_NUM, this means both directions (all match) */ if (context->filter_dir == CF_Direction_NUM || history->dir == context->filter_dir) @@ -245,7 +246,7 @@ CFE_Status_t CF_Traverse_WriteHistoryQueueEntryToFile(CF_CListNode_t *node, void CFE_Status_t CF_Traverse_WriteTxnQueueEntryToFile(CF_CListNode_t *node, void *arg) { CF_Traverse_WriteTxnFileArg_t *context = arg; - CF_Transaction_t * txn = container_of(node, CF_Transaction_t, cl_node); + CF_Transaction_t * txn = container_of(node, CF_Transaction_t, cl_node); if (CF_WriteHistoryEntryToFile(context->fd, txn->history) < 0) { @@ -328,7 +329,7 @@ CFE_Status_t CF_PrioSearch(CF_CListNode_t *node, void *context) void CF_InsertSortPrio(CF_Transaction_t *txn, CF_QueueIdx_t queue) { int insert_back = 0; - CF_Channel_t *chan = &CF_AppData.engine.channels[txn->chan_num]; + CF_Channel_t *chan = &CF_AppData.engine.channels[txn->chan_num]; CF_Assert(txn->chan_num < CF_NUM_CHANNELS); CF_Assert(txn->state != CF_TxnState_IDLE); diff --git a/fsw/src/cf_utils.h b/fsw/src/cf_utils.h index bf8ce9d0..06b8de02 100644 --- a/fsw/src/cf_utils.h +++ b/fsw/src/cf_utils.h @@ -213,8 +213,9 @@ void CF_FreeTransaction(CF_Transaction_t *txn); * @returns Pointer to the given transaction if found * @retval NULL if the transaction is not found */ -CF_Transaction_t *CF_FindTransactionBySequenceNumber(CF_Channel_t *chan, CF_TransactionSeq_t transaction_sequence_number, - CF_EntityId_t src_eid); +CF_Transaction_t *CF_FindTransactionBySequenceNumber(CF_Channel_t * chan, + CF_TransactionSeq_t transaction_sequence_number, + CF_EntityId_t src_eid); /************************************************************************/ /** @brief List traversal function to check if the desired sequence number matches. diff --git a/unit-test/cf_cfdp_dispatch_tests.c b/unit-test/cf_cfdp_dispatch_tests.c index 84e87865..8ad4ce90 100644 --- a/unit-test/cf_cfdp_dispatch_tests.c +++ b/unit-test/cf_cfdp_dispatch_tests.c @@ -313,4 +313,4 @@ void UtTest_Setup(void) "CF_CFDP_TxStateDispatch"); UtTest_Add(Test_CF_CFDP_RxStateDispatch, cf_cfdp_dispatch_tests_Setup, cf_cfdp_dispatch_tests_Teardown, "CF_CFDP_RxStateDispatch"); -} \ No newline at end of file +} diff --git a/unit-test/cf_cfdp_r_tests.c b/unit-test/cf_cfdp_r_tests.c index b31be9eb..3184d2a5 100644 --- a/unit-test/cf_cfdp_r_tests.c +++ b/unit-test/cf_cfdp_r_tests.c @@ -282,7 +282,7 @@ void Test_CF_CFDP_R_Tick(void) txn->flags.com.ack_timer_armed = true; txn->flags.rx.inactivity_fired = true; txn->flags.rx.complete = true; - txn->state_data.receive.sub_state = CF_RxSubState_WAIT_FOR_FIN_ACK; + txn->state_data.receive.sub_state = CF_RxSubState_WAIT_FOR_FIN_ACK; UT_SetDeferredRetcode(UT_KEY(CF_Timer_Expired), 1, 1); UtAssert_VOIDCALL(CF_CFDP_R_Tick(txn, &cont)); UtAssert_STUB_COUNT(CF_CFDP_ArmAckTimer, 2); @@ -290,13 +290,13 @@ void Test_CF_CFDP_R_Tick(void) /* same as above, but acknak limit reached */ UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_TX, NULL, NULL, NULL, &txn, &config); - config->chan[txn->chan_num].ack_limit = 10; - txn->state = CF_TxnState_R2; - txn->flags.com.ack_timer_armed = true; - txn->flags.rx.inactivity_fired = true; - txn->flags.rx.complete = true; - txn->state_data.receive.sub_state = CF_RxSubState_WAIT_FOR_FIN_ACK; - txn->state_data.receive.r2.acknak_count = 9; + config->chan[txn->chan_num].ack_limit = 10; + txn->state = CF_TxnState_R2; + txn->flags.com.ack_timer_armed = true; + txn->flags.rx.inactivity_fired = true; + txn->flags.rx.complete = true; + txn->state_data.receive.sub_state = CF_RxSubState_WAIT_FOR_FIN_ACK; + txn->state_data.receive.r2.acknak_count = 9; UT_SetDeferredRetcode(UT_KEY(CF_Timer_Expired), 1, 1); UtAssert_VOIDCALL(CF_CFDP_R_Tick(txn, &cont)); UtAssert_STUB_COUNT(CF_CFDP_ResetTransaction, 2); @@ -309,7 +309,7 @@ void Test_CF_CFDP_R_Tick(void) txn->flags.com.ack_timer_armed = true; txn->flags.rx.inactivity_fired = true; txn->flags.rx.complete = true; - txn->state_data.receive.sub_state = CF_RxSubState_EOF; + txn->state_data.receive.sub_state = CF_RxSubState_EOF; UT_SetDeferredRetcode(UT_KEY(CF_Timer_Expired), 1, 1); UtAssert_VOIDCALL(CF_CFDP_R_Tick(txn, &cont)); UtAssert_STUB_COUNT(CF_CFDP_ArmAckTimer, 3); @@ -336,7 +336,7 @@ void Test_CF_CFDP_R_Cancel(void) /* for coverage, this should also go to reset */ UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, NULL, NULL, NULL, &txn, NULL); - txn->state = CF_TxnState_R2; + txn->state = CF_TxnState_R2; txn->state_data.receive.sub_state = CF_RxSubState_WAIT_FOR_FIN_ACK; UtAssert_VOIDCALL(CF_CFDP_R_Cancel(txn)); UtAssert_STUB_COUNT(CF_CFDP_ResetTransaction, 2); @@ -571,9 +571,9 @@ void Test_CF_CFDP_R_ProcessFd(void) /* call again, but with a failed write */ UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &txn, NULL); - fd = &ph->int_header.fd; - fd->data_len = 100; - fd->offset = 300; + fd = &ph->int_header.fd; + fd->data_len = 100; + fd->offset = 300; txn->state_data.receive.cached_pos = 300; UT_SetDefaultReturnValue(UT_KEY(CF_WrappedWrite), -1); UtAssert_INT32_EQ(CF_CFDP_R_ProcessFd(txn, ph), -1); @@ -583,9 +583,9 @@ void Test_CF_CFDP_R_ProcessFd(void) /* call again, but with a failed lseek */ UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &txn, NULL); - fd = &ph->int_header.fd; - fd->data_len = 100; - fd->offset = 200; + fd = &ph->int_header.fd; + fd->data_len = 100; + fd->offset = 200; txn->state_data.receive.cached_pos = 300; UT_SetDefaultReturnValue(UT_KEY(CF_WrappedLseek), -1); UtAssert_INT32_EQ(CF_CFDP_R_ProcessFd(txn, ph), -1); @@ -613,17 +613,17 @@ void Test_CF_CFDP_R_SubstateRecvEof(void) /* with md_recv and a matching size */ UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &txn, NULL); - eof = &ph->int_header.eof; + eof = &ph->int_header.eof; txn->flags.rx.md_recv = true; - eof->size = 200; + eof->size = 200; txn->fsize = 200; UtAssert_INT32_EQ(CF_CFDP_R_SubstateRecvEof(txn, ph), 0); /* with md_recv and a different size */ UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &txn, NULL); - eof = &ph->int_header.eof; + eof = &ph->int_header.eof; txn->flags.rx.md_recv = true; - eof->size = 100; + eof->size = 100; txn->fsize = 300; UtAssert_INT32_EQ(CF_CFDP_R_SubstateRecvEof(txn, ph), CF_REC_PDU_FSIZE_MISMATCH_ERROR); UT_CF_AssertEventID(CF_EID_ERR_CFDP_R_SIZE_MISMATCH); @@ -650,10 +650,10 @@ void Test_CF_CFDP_R1_SubstateRecvEof(void) /* nominal */ UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &txn, NULL); - eof = &ph->int_header.eof; - eof->crc = 0xf007ba11; + eof = &ph->int_header.eof; + eof->crc = 0xf007ba11; txn->crc.result = eof->crc; - eof->size = 0xccc; + eof->size = 0xccc; txn->fsize = eof->size; UtAssert_VOIDCALL(CF_CFDP_R1_SubstateRecvEof(txn, ph)); UtAssert_BOOL_TRUE(txn->keep); @@ -667,8 +667,8 @@ void Test_CF_CFDP_R1_SubstateRecvEof(void) /* failure in CF_CFDP_R_CheckCrc */ UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &txn, NULL); - eof = &ph->int_header.eof; - eof->crc = 0xf007ba11; + eof = &ph->int_header.eof; + eof->crc = 0xf007ba11; txn->crc.result = ~eof->crc; UtAssert_VOIDCALL(CF_CFDP_R1_SubstateRecvEof(txn, ph)); UtAssert_BOOL_FALSE(txn->keep); @@ -685,10 +685,10 @@ void Test_CF_CFDP_R2_SubstateRecvEof(void) /* nominal */ UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &txn, NULL); - eof = &ph->int_header.eof; - eof->crc = 0xf007ba11; + eof = &ph->int_header.eof; + eof->crc = 0xf007ba11; txn->crc.result = eof->crc; - eof->size = 0xbbb; + eof->size = 0xbbb; txn->fsize = 0xbbb; UtAssert_VOIDCALL(CF_CFDP_R2_SubstateRecvEof(txn, ph)); UtAssert_BOOL_TRUE(txn->flags.rx.eof_recv); @@ -708,8 +708,8 @@ void Test_CF_CFDP_R2_SubstateRecvEof(void) UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &txn, NULL); txn->flags.rx.eof_recv = true; UtAssert_VOIDCALL(CF_CFDP_R2_SubstateRecvEof(txn, ph)); - UtAssert_BOOL_TRUE(txn->flags.rx.eof_recv); /* unchanged */ - UtAssert_BOOL_FALSE(txn->flags.rx.send_ack); /* unchanged */ + UtAssert_BOOL_TRUE(txn->flags.rx.eof_recv); /* unchanged */ + UtAssert_BOOL_FALSE(txn->flags.rx.send_ack); /* unchanged */ UtAssert_STUB_COUNT(CF_CFDP_ResetTransaction, 1); /* unchanged */ /* failure in CF_CFDP_R_SubstateRecvEof - not a stub, but calls CF_CFDP_RecvEof, which is. */ @@ -721,8 +721,8 @@ void Test_CF_CFDP_R2_SubstateRecvEof(void) /* failure in CF_CFDP_R_SubstateRecvEof - set up for file size mismatch error */ UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &txn, NULL); - eof = &ph->int_header.eof; - eof->size = 0xddd; + eof = &ph->int_header.eof; + eof->size = 0xddd; txn->fsize = 0xbbb; txn->flags.rx.md_recv = true; UtAssert_VOIDCALL(CF_CFDP_R2_SubstateRecvEof(txn, ph)); @@ -774,7 +774,7 @@ void Test_CF_CFDP_R2_SubstateRecvFileData(void) /* with fd_nak_sent flag */ UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &txn, NULL); txn->state_data.receive.r2.acknak_count = 1; /* make nonzero so it can be checked */ - txn->flags.rx.fd_nak_sent = true; + txn->flags.rx.fd_nak_sent = true; UtAssert_VOIDCALL(CF_CFDP_R2_SubstateRecvFileData(txn, ph)); UtAssert_STUB_COUNT(CF_CFDP_ArmAckTimer, 2); UtAssert_ZERO(txn->state_data.receive.r2.acknak_count); /* this resets the counter */ @@ -782,9 +782,9 @@ void Test_CF_CFDP_R2_SubstateRecvFileData(void) /* with rx.complete flag */ UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &txn, NULL); txn->state_data.receive.r2.acknak_count = 1; /* make nonzero so it can be checked */ - txn->flags.rx.complete = true; + txn->flags.rx.complete = true; UtAssert_VOIDCALL(CF_CFDP_R2_SubstateRecvFileData(txn, ph)); - UtAssert_STUB_COUNT(CF_CFDP_ArmAckTimer, 2); /* does NOT increment here */ + UtAssert_STUB_COUNT(CF_CFDP_ArmAckTimer, 2); /* does NOT increment here */ UtAssert_ZERO(txn->state_data.receive.r2.acknak_count); /* this resets the counter */ /* failure in CF_CFDP_RecvFd (bad packet) */ @@ -818,8 +818,8 @@ void Test_CF_CFDP_R2_GapCompute(void) args.nak = &nak; /* nominal */ - chunk.offset = 11000; - chunk.size = 100; + chunk.offset = 11000; + chunk.size = 100; nak.scope_start = 10000; nak.scope_end = 20000; UtAssert_VOIDCALL(CF_CFDP_R2_GapCompute(&chunks, &chunk, &args)); @@ -867,8 +867,8 @@ void Test_CF_CFDP_R_SubstateSendNak(void) /* this requires the chunks list to be set up, and by default compute_gaps will return 0 (no gaps) so the transaction goes to complete */ UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_TX, &ph, NULL, NULL, &txn, NULL); - txn->flags.rx.md_recv = true; - txn->chunks = &chunks; + txn->flags.rx.md_recv = true; + txn->chunks = &chunks; chunks.chunks.count = 1; chunks.chunks.max_chunks = 2; UtAssert_INT32_EQ(CF_CFDP_R_SubstateSendNak(txn), 0); @@ -880,8 +880,8 @@ void Test_CF_CFDP_R_SubstateSendNak(void) /* this also should use the max chunks instead of count */ UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_TX, &ph, NULL, NULL, &txn, NULL); UT_SetDeferredRetcode(UT_KEY(CF_ChunkList_ComputeGaps), 1, 1); - txn->flags.rx.md_recv = true; - txn->chunks = &chunks; + txn->flags.rx.md_recv = true; + txn->chunks = &chunks; chunks.chunks.count = 3; chunks.chunks.max_chunks = 2; UtAssert_INT32_EQ(CF_CFDP_R_SubstateSendNak(txn), 0); @@ -915,14 +915,14 @@ void Test_CF_CFDP_R2_CalcCrcChunk(void) /* nominal with non zero size file, runs the loop */ UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_NONE, NULL, NULL, NULL, &txn, &config); config->rx_crc_calc_bytes_per_wakeup = 100; - txn->fsize = 70; + txn->fsize = 70; UT_SetDeferredRetcode(UT_KEY(CF_WrappedRead), 1, txn->fsize); UtAssert_INT32_EQ(CF_CFDP_R2_CalcCrcChunk(txn), 0); UtAssert_BOOL_TRUE(txn->flags.com.crc_calc); /* force a CRC mismatch */ UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_NONE, NULL, NULL, NULL, &txn, NULL); - txn->crc.result = 0xabadf00d; + txn->crc.result = 0xabadf00d; txn->state_data.receive.r2.eof_crc = 0xdeadbeef; UtAssert_INT32_EQ(CF_CFDP_R2_CalcCrcChunk(txn), 0); UtAssert_BOOL_TRUE(txn->flags.com.crc_calc); @@ -931,7 +931,7 @@ void Test_CF_CFDP_R2_CalcCrcChunk(void) /* nominal with file larger than rx_crc_calc_bytes_per_wakeup */ UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_NONE, NULL, NULL, NULL, &txn, &config); config->rx_crc_calc_bytes_per_wakeup = CF_R2_CRC_CHUNK_SIZE; - txn->fsize = CF_R2_CRC_CHUNK_SIZE + 100; + txn->fsize = CF_R2_CRC_CHUNK_SIZE + 100; UT_SetDeferredRetcode(UT_KEY(CF_WrappedRead), 1, CF_R2_CRC_CHUNK_SIZE); UtAssert_INT32_EQ(CF_CFDP_R2_CalcCrcChunk(txn), -1); /* -1 because its incomplete */ UtAssert_BOOL_FALSE(txn->flags.com.crc_calc); @@ -939,7 +939,7 @@ void Test_CF_CFDP_R2_CalcCrcChunk(void) /* nominal with file size larger than CF_R2_CRC_CHUNK_SIZE (this will do 2 reads) */ UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_NONE, NULL, NULL, NULL, &txn, &config); config->rx_crc_calc_bytes_per_wakeup = CF_R2_CRC_CHUNK_SIZE * 2; - txn->fsize = CF_R2_CRC_CHUNK_SIZE + 100; + txn->fsize = CF_R2_CRC_CHUNK_SIZE + 100; UT_SetDeferredRetcode(UT_KEY(CF_WrappedRead), 1, CF_R2_CRC_CHUNK_SIZE); UT_SetDeferredRetcode(UT_KEY(CF_WrappedRead), 1, 100); UtAssert_INT32_EQ(CF_CFDP_R2_CalcCrcChunk(txn), 0); @@ -949,8 +949,8 @@ void Test_CF_CFDP_R2_CalcCrcChunk(void) UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_NONE, NULL, NULL, NULL, &txn, &config); txn->state_data.receive.r2.rx_crc_calc_bytes = 10; txn->state_data.receive.cached_pos = 20; - config->rx_crc_calc_bytes_per_wakeup = 100; - txn->fsize = 50; + config->rx_crc_calc_bytes_per_wakeup = 100; + txn->fsize = 50; UT_SetDeferredRetcode(UT_KEY(CF_WrappedLseek), 1, txn->state_data.receive.r2.rx_crc_calc_bytes); UT_SetDeferredRetcode(UT_KEY(CF_WrappedRead), 1, txn->fsize - txn->state_data.receive.r2.rx_crc_calc_bytes); UtAssert_INT32_EQ(CF_CFDP_R2_CalcCrcChunk(txn), 0); @@ -959,7 +959,7 @@ void Test_CF_CFDP_R2_CalcCrcChunk(void) /* failure of read */ UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_NONE, NULL, NULL, NULL, &txn, &config); config->rx_crc_calc_bytes_per_wakeup = 100; - txn->fsize = 50; + txn->fsize = 50; UT_SetDeferredRetcode(UT_KEY(CF_WrappedRead), 1, -1); UtAssert_INT32_EQ(CF_CFDP_R2_CalcCrcChunk(txn), -1); UT_CF_AssertEventID(CF_EID_ERR_CFDP_R_READ); @@ -971,8 +971,8 @@ void Test_CF_CFDP_R2_CalcCrcChunk(void) UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_NONE, NULL, NULL, NULL, &txn, &config); txn->state_data.receive.r2.rx_crc_calc_bytes = 20; txn->state_data.receive.cached_pos = 10; - config->rx_crc_calc_bytes_per_wakeup = 100; - txn->fsize = 50; + config->rx_crc_calc_bytes_per_wakeup = 100; + txn->fsize = 50; UT_SetDeferredRetcode(UT_KEY(CF_WrappedLseek), 1, -1); UtAssert_INT32_EQ(CF_CFDP_R2_CalcCrcChunk(txn), -1); UT_CF_AssertEventID(CF_EID_ERR_CFDP_R_SEEK_CRC); @@ -1058,16 +1058,16 @@ void Test_CF_CFDP_R2_RecvMd(void) /* EOF already received, file size match */ UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &txn, NULL); - txn->fsize = 100; + txn->fsize = 100; txn->state_data.receive.r2.eof_size = 100; - txn->flags.rx.eof_recv = true; + txn->flags.rx.eof_recv = true; UtAssert_VOIDCALL(CF_CFDP_R2_RecvMd(txn, ph)); /* EOF already received, file size different */ UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &txn, NULL); - txn->fsize = 100; + txn->fsize = 100; txn->state_data.receive.r2.eof_size = 120; - txn->flags.rx.eof_recv = true; + txn->flags.rx.eof_recv = true; UtAssert_VOIDCALL(CF_CFDP_R2_RecvMd(txn, ph)); UT_CF_AssertEventID(CF_EID_ERR_CFDP_R_EOF_MD_SIZE); UtAssert_INT32_EQ(txn->history->txn_stat, CF_TxnStatus_FILE_SIZE_ERROR); @@ -1150,4 +1150,4 @@ void UtTest_Setup(void) UtTest_Add(Test_CF_CFDP_R2_RecvMd, cf_cfdp_r_tests_Setup, cf_cfdp_r_tests_Teardown, "CF_CFDP_R2_RecvMd"); UtTest_Add(Test_CF_CFDP_R_SendInactivityEvent, cf_cfdp_r_tests_Setup, cf_cfdp_r_tests_Teardown, "CF_CFDP_R_SendInactivityEvent"); -} \ No newline at end of file +} diff --git a/unit-test/cf_cfdp_s_tests.c b/unit-test/cf_cfdp_s_tests.c index 5cd75851..38858cb9 100644 --- a/unit-test/cf_cfdp_s_tests.c +++ b/unit-test/cf_cfdp_s_tests.c @@ -270,7 +270,7 @@ void Test_CF_CFDP_S_Tick(void) config->chan[txn->chan_num].ack_limit = 10; txn->state = CF_TxnState_S2; txn->flags.com.ack_timer_armed = true; - txn->state_data.send.sub_state = CF_TxSubState_WAIT_FOR_EOF_ACK; + txn->state_data.send.sub_state = CF_TxSubState_WAIT_FOR_EOF_ACK; UtAssert_VOIDCALL(CF_CFDP_S_Tick(txn, &cont)); UtAssert_STUB_COUNT(CF_CFDP_SendEof, 1); @@ -280,8 +280,8 @@ void Test_CF_CFDP_S_Tick(void) config->chan[txn->chan_num].ack_limit = 10; txn->state = CF_TxnState_S2; txn->flags.com.ack_timer_armed = true; - txn->state_data.send.sub_state = CF_TxSubState_WAIT_FOR_EOF_ACK; - txn->state_data.send.s2.acknak_count = 9; + txn->state_data.send.sub_state = CF_TxSubState_WAIT_FOR_EOF_ACK; + txn->state_data.send.s2.acknak_count = 9; UtAssert_VOIDCALL(CF_CFDP_S_Tick(txn, &cont)); UT_CF_AssertEventID(CF_EID_ERR_CFDP_S_ACK_LIMIT); UtAssert_UINT32_EQ(CF_AppData.hk.channel_hk[txn->chan_num].counters.fault.ack_limit, 1); @@ -293,7 +293,7 @@ void Test_CF_CFDP_S_Tick(void) config->chan[txn->chan_num].ack_limit = 10; txn->state = CF_TxnState_S2; txn->flags.com.ack_timer_armed = true; - txn->state_data.send.sub_state = CF_TxSubState_WAIT_FOR_EOF_ACK; + txn->state_data.send.sub_state = CF_TxSubState_WAIT_FOR_EOF_ACK; UT_SetDeferredRetcode(UT_KEY(CF_CFDP_SendEof), 1, CF_SEND_PDU_NO_BUF_AVAIL_ERROR); UtAssert_VOIDCALL(CF_CFDP_S_Tick(txn, &cont)); @@ -303,13 +303,13 @@ void Test_CF_CFDP_S_Tick(void) config->chan[txn->chan_num].ack_limit = 10; txn->state = CF_TxnState_S2; txn->flags.com.ack_timer_armed = true; - txn->state_data.send.sub_state = CF_TxSubState_WAIT_FOR_EOF_ACK; + txn->state_data.send.sub_state = CF_TxSubState_WAIT_FOR_EOF_ACK; UT_SetDeferredRetcode(UT_KEY(CF_CFDP_SendEof), 1, CF_SEND_PDU_ERROR); UtAssert_VOIDCALL(CF_CFDP_S_Tick(txn, &cont)); UtAssert_STUB_COUNT(CF_CFDP_ResetTransaction, 3); UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_TX, NULL, NULL, NULL, &txn, NULL); - txn->state = CF_TxnState_S2; + txn->state = CF_TxnState_S2; txn->state_data.send.sub_state = CF_TxSubState_SEND_FIN_ACK; UtAssert_VOIDCALL(CF_CFDP_S_Tick(txn, &cont)); UtAssert_STUB_COUNT(CF_CFDP_ResetTransaction, 4); @@ -435,7 +435,7 @@ void Test_CF_CFDP_S_SendFileData(void) /* nominal, smaller than chunk, no CRC */ UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_TX, NULL, NULL, NULL, &txn, &config); config->outgoing_file_chunk_size = 150; - txn->fsize = 300; + txn->fsize = 300; UT_SetDeferredRetcode(UT_KEY(CF_WrappedRead), 1, read_size); UtAssert_INT32_EQ(CF_CFDP_S_SendFileData(txn, offset, read_size, false), read_size); cumulative_read += read_size; @@ -444,7 +444,7 @@ void Test_CF_CFDP_S_SendFileData(void) /* nominal, larger than PDU, no CRC */ UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_TX, NULL, NULL, NULL, &txn, &config); config->outgoing_file_chunk_size = CF_MAX_PDU_SIZE * 2; - txn->fsize = CF_MAX_PDU_SIZE * 2; + txn->fsize = CF_MAX_PDU_SIZE * 2; read_size = CF_MAX_PDU_SIZE; UT_SetDeferredRetcode(UT_KEY(CF_WrappedRead), 1, read_size); UtAssert_INT32_EQ(CF_CFDP_S_SendFileData(txn, offset, read_size * 2, false), read_size); @@ -456,7 +456,7 @@ void Test_CF_CFDP_S_SendFileData(void) UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_TX, NULL, NULL, NULL, &txn, &config); config->outgoing_file_chunk_size = 50; read_size = 100; - txn->fsize = 300; + txn->fsize = 300; UT_SetDeferredRetcode(UT_KEY(CF_WrappedRead), 1, config->outgoing_file_chunk_size); UtAssert_INT32_EQ(CF_CFDP_S_SendFileData(txn, offset, read_size, true), config->outgoing_file_chunk_size); cumulative_read += config->outgoing_file_chunk_size; @@ -468,7 +468,7 @@ void Test_CF_CFDP_S_SendFileData(void) UT_SetDeferredRetcode(UT_KEY(CF_CFDP_SendFd), 1, CF_SEND_PDU_NO_BUF_AVAIL_ERROR); UT_SetDeferredRetcode(UT_KEY(CF_WrappedRead), 1, read_size); config->outgoing_file_chunk_size = read_size; - txn->fsize = 300; + txn->fsize = 300; UtAssert_INT32_EQ(CF_CFDP_S_SendFileData(txn, offset, read_size, true), 0); UtAssert_UINT32_EQ(CF_AppData.hk.channel_hk[txn->chan_num].counters.sent.file_data_bytes, cumulative_read); @@ -477,7 +477,7 @@ void Test_CF_CFDP_S_SendFileData(void) UT_SetDeferredRetcode(UT_KEY(CF_CFDP_SendFd), 1, CF_SEND_PDU_ERROR); UT_SetDeferredRetcode(UT_KEY(CF_WrappedRead), 1, read_size); config->outgoing_file_chunk_size = read_size; - txn->fsize = 300; + txn->fsize = 300; UtAssert_INT32_EQ(CF_CFDP_S_SendFileData(txn, offset, read_size, true), -1); UT_CF_AssertEventID(CF_EID_ERR_CFDP_S_SEND_FD); UtAssert_UINT32_EQ(CF_AppData.hk.channel_hk[txn->chan_num].counters.sent.file_data_bytes, cumulative_read); @@ -486,7 +486,7 @@ void Test_CF_CFDP_S_SendFileData(void) UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_TX, NULL, NULL, NULL, &txn, &config); UT_SetDeferredRetcode(UT_KEY(CF_WrappedRead), 1, -1); config->outgoing_file_chunk_size = read_size; - txn->fsize = 300; + txn->fsize = 300; UtAssert_INT32_EQ(CF_CFDP_S_SendFileData(txn, offset, read_size, true), -1); UtAssert_UINT32_EQ(CF_AppData.hk.channel_hk[txn->chan_num].counters.sent.file_data_bytes, cumulative_read); UtAssert_UINT32_EQ(CF_AppData.hk.channel_hk[txn->chan_num].counters.fault.file_read, 1); @@ -498,7 +498,7 @@ void Test_CF_CFDP_S_SendFileData(void) UT_SetDeferredRetcode(UT_KEY(CF_WrappedLseek), 1, offset); UT_SetDeferredRetcode(UT_KEY(CF_WrappedRead), 1, read_size); config->outgoing_file_chunk_size = read_size; - txn->fsize = 300; + txn->fsize = 300; UtAssert_INT32_EQ(CF_CFDP_S_SendFileData(txn, offset, read_size, true), read_size); cumulative_read += read_size; UtAssert_UINT32_EQ(CF_AppData.hk.channel_hk[txn->chan_num].counters.sent.file_data_bytes, cumulative_read); @@ -507,7 +507,7 @@ void Test_CF_CFDP_S_SendFileData(void) UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_TX, NULL, NULL, NULL, &txn, &config); UT_SetDeferredRetcode(UT_KEY(CF_WrappedLseek), 1, -1); config->outgoing_file_chunk_size = read_size; - txn->fsize = 300; + txn->fsize = 300; UtAssert_INT32_EQ(CF_CFDP_S_SendFileData(txn, offset, read_size, true), -1); UtAssert_UINT32_EQ(CF_AppData.hk.channel_hk[txn->chan_num].counters.sent.file_data_bytes, cumulative_read); UtAssert_UINT32_EQ(CF_AppData.hk.channel_hk[txn->chan_num].counters.fault.file_seek, 1); @@ -529,8 +529,8 @@ void Test_CF_CFDP_S_SubstateSendFileData(void) /* nominal, whole file at once */ UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_TX, NULL, NULL, NULL, &txn, &config); config->outgoing_file_chunk_size = CF_MAX_PDU_SIZE; - txn->state_data.send.sub_state = CF_TxSubState_FILEDATA; - txn->fsize = CF_MAX_PDU_SIZE / 2; + txn->state_data.send.sub_state = CF_TxSubState_FILEDATA; + txn->fsize = CF_MAX_PDU_SIZE / 2; UT_SetDeferredRetcode(UT_KEY(CF_WrappedRead), 1, txn->fsize); UtAssert_VOIDCALL(CF_CFDP_S_SubstateSendFileData(txn)); UtAssert_UINT32_EQ(txn->state_data.send.sub_state, CF_TxSubState_EOF); @@ -539,8 +539,8 @@ void Test_CF_CFDP_S_SubstateSendFileData(void) /* nominal, less than whole file at once */ UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_TX, NULL, NULL, NULL, &txn, &config); config->outgoing_file_chunk_size = CF_MAX_PDU_SIZE / 2; - txn->state_data.send.sub_state = CF_TxSubState_FILEDATA; - txn->fsize = CF_MAX_PDU_SIZE; + txn->state_data.send.sub_state = CF_TxSubState_FILEDATA; + txn->fsize = CF_MAX_PDU_SIZE; UT_SetDeferredRetcode(UT_KEY(CF_WrappedRead), 1, config->outgoing_file_chunk_size); UtAssert_VOIDCALL(CF_CFDP_S_SubstateSendFileData(txn)); UtAssert_UINT32_EQ(txn->state_data.send.sub_state, CF_TxSubState_FILEDATA); @@ -598,8 +598,8 @@ void Test_CF_CFDP_S_CheckAndRespondNak(void) /* with chunklist - this will send file data, which needs to be set up for */ UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_TX, NULL, NULL, NULL, &txn, &config); config->outgoing_file_chunk_size = CF_MAX_PDU_SIZE; - txn->fsize = ut_chunk.size; - txn->chunks = &chunks; + txn->fsize = ut_chunk.size; + txn->chunks = &chunks; UT_SetHandlerFunction(UT_KEY(CF_ChunkList_GetFirstChunk), UT_AltHandler_GenericPointerReturn, &ut_chunk); UT_SetDeferredRetcode(UT_KEY(CF_WrappedRead), 1, ut_chunk.size); UtAssert_INT32_EQ(CF_CFDP_S_CheckAndRespondNak(txn), 1); @@ -607,8 +607,8 @@ void Test_CF_CFDP_S_CheckAndRespondNak(void) /* with chunklist - failure to send file data */ UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_TX, NULL, NULL, NULL, &txn, &config); config->outgoing_file_chunk_size = CF_MAX_PDU_SIZE; - txn->fsize = ut_chunk.size; - txn->chunks = &chunks; + txn->fsize = ut_chunk.size; + txn->chunks = &chunks; UT_SetHandlerFunction(UT_KEY(CF_ChunkList_GetFirstChunk), UT_AltHandler_GenericPointerReturn, &ut_chunk); UT_SetDeferredRetcode(UT_KEY(CF_WrappedRead), 1, -1); UtAssert_INT32_EQ(CF_CFDP_S_CheckAndRespondNak(txn), -1); @@ -616,8 +616,8 @@ void Test_CF_CFDP_S_CheckAndRespondNak(void) /* with chunklist but CF_CFDP_S_SendFileData returning 0 (nothing to send) */ UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_TX, NULL, NULL, NULL, &txn, &config); config->outgoing_file_chunk_size = CF_MAX_PDU_SIZE; - txn->fsize = ut_chunk.size; - txn->chunks = &chunks; + txn->fsize = ut_chunk.size; + txn->chunks = &chunks; UT_SetHandlerFunction(UT_KEY(CF_ChunkList_GetFirstChunk), UT_AltHandler_GenericPointerReturn, &ut_chunk); UT_ResetState(UT_KEY(CF_CFDP_ConstructPduHeader)); /* Returns NULL by default */ UtAssert_INT32_EQ(CF_CFDP_S_CheckAndRespondNak(txn), 0); @@ -790,7 +790,7 @@ void Test_CF_CFDP_S2_Nak(void) nak->segment_list.num_segments = 2; nak->segment_list.segments[0] = (CF_Logical_SegmentRequest_t) {0, 200}; nak->segment_list.segments[1] = (CF_Logical_SegmentRequest_t) {200, 300}; - txn->fsize = 300; + txn->fsize = 300; UtAssert_VOIDCALL(CF_CFDP_S2_Nak(txn, ph)); UtAssert_UINT32_EQ(CF_AppData.hk.channel_hk[txn->chan_num].counters.recv.nak_segment_requests, 3); @@ -801,7 +801,7 @@ void Test_CF_CFDP_S2_Nak(void) nak->segment_list.segments[0] = (CF_Logical_SegmentRequest_t) {200, 100}; nak->segment_list.segments[1] = (CF_Logical_SegmentRequest_t) {100, 400}; nak->segment_list.segments[2] = (CF_Logical_SegmentRequest_t) {400, 0}; - txn->fsize = 300; + txn->fsize = 300; UtAssert_VOIDCALL(CF_CFDP_S2_Nak(txn, ph)); UtAssert_UINT32_EQ(CF_AppData.hk.channel_hk[txn->chan_num].counters.recv.nak_segment_requests, 6); UT_CF_AssertEventID(CF_EID_ERR_CFDP_S_INVALID_SR); diff --git a/unit-test/cf_cfdp_sbintf_tests.c b/unit-test/cf_cfdp_sbintf_tests.c index 1e1d7df2..bf646809 100644 --- a/unit-test/cf_cfdp_sbintf_tests.c +++ b/unit-test/cf_cfdp_sbintf_tests.c @@ -282,7 +282,7 @@ void Test_CF_CFDP_ReceiveMessage(void) config->local_eid = 123; ph->pdu_header.source_eid = config->local_eid; ph->fdirective.directive_code = CF_CFDP_FileDirective_FIN; - chan->cur = txn; + chan->cur = txn; UtAssert_VOIDCALL(CF_CFDP_ReceiveMessage(chan)); UtAssert_UINT32_EQ(CF_AppData.hk.channel_hk[txn->chan_num].counters.recv.spurious, 1); UtAssert_STUB_COUNT(CF_CFDP_SendAck, 1); @@ -296,8 +296,8 @@ void Test_CF_CFDP_ReceiveMessage(void) ph->fdirective.directive_code = CF_CFDP_FileDirective_FIN; UtAssert_VOIDCALL(CF_CFDP_ReceiveMessage(chan)); UtAssert_UINT32_EQ(CF_AppData.hk.channel_hk[txn->chan_num].counters.recv.spurious, 1); /* no increment */ - UtAssert_STUB_COUNT(CF_CFDP_SendAck, 1); /* no increment */ - UtAssert_NULL(chan->cur); /* cleared */ + UtAssert_STUB_COUNT(CF_CFDP_SendAck, 1); /* no increment */ + UtAssert_NULL(chan->cur); /* cleared */ /* FIN handling special case, but failure of CF_CFDP_SendAck */ UT_CFDP_SetupBasicTestState(UT_CF_Setup_RX, &ph, &chan, NULL, &txn, &config); @@ -305,10 +305,10 @@ void Test_CF_CFDP_ReceiveMessage(void) config->local_eid = 123; ph->pdu_header.source_eid = config->local_eid; ph->fdirective.directive_code = CF_CFDP_FileDirective_FIN; - chan->cur = txn; + chan->cur = txn; UtAssert_VOIDCALL(CF_CFDP_ReceiveMessage(chan)); UtAssert_UINT32_EQ(CF_AppData.hk.channel_hk[txn->chan_num].counters.recv.spurious, 2); /* this does get increment */ - UtAssert_ADDRESS_EQ(chan->cur, txn); /* not changed */ + UtAssert_ADDRESS_EQ(chan->cur, txn); /* not changed */ /* recv but not the correct destination_eid */ UT_CFDP_SetupBasicTestState(UT_CF_Setup_RX, &ph, &chan, NULL, &txn, &config); @@ -320,8 +320,8 @@ void Test_CF_CFDP_ReceiveMessage(void) /* recv correct destination_eid but CF_MAX_SIMULTANEOUS_RX hit */ UT_CFDP_SetupBasicTestState(UT_CF_Setup_RX, &ph, &chan, NULL, &txn, &config); CF_AppData.hk.channel_hk[txn->chan_num].q_size[CF_QueueIdx_RX] = CF_MAX_SIMULTANEOUS_RX; - config->local_eid = 123; - ph->pdu_header.destination_eid = config->local_eid; + config->local_eid = 123; + ph->pdu_header.destination_eid = config->local_eid; UtAssert_VOIDCALL(CF_CFDP_ReceiveMessage(chan)); UT_CF_AssertEventID(CF_EID_ERR_CFDP_RX_DROPPED); } diff --git a/unit-test/cf_cfdp_tests.c b/unit-test/cf_cfdp_tests.c index e1ffde5f..f1d0615c 100644 --- a/unit-test/cf_cfdp_tests.c +++ b/unit-test/cf_cfdp_tests.c @@ -702,7 +702,7 @@ void Test_CF_CFDP_SendAck(void) /* nominal as receiver */ UT_CFDP_SetupBasicTestState(UT_CF_Setup_TX, &ph, NULL, NULL, &txn, NULL); - ack = &ph->int_header.ack; + ack = &ph->int_header.ack; txn->state = CF_TxnState_R2; UtAssert_INT32_EQ(CF_CFDP_SendAck(txn, CF_CFDP_AckTxnStatus_ACTIVE, CF_CFDP_FileDirective_EOF, CF_CFDP_ConditionCode_NO_ERROR, 1, 42), @@ -714,7 +714,7 @@ void Test_CF_CFDP_SendAck(void) /* nominal as sender */ UT_CFDP_SetupBasicTestState(UT_CF_Setup_TX, &ph, NULL, NULL, &txn, NULL); - ack = &ph->int_header.ack; + ack = &ph->int_header.ack; txn->state = CF_TxnState_S2; UtAssert_INT32_EQ(CF_CFDP_SendAck(txn, CF_CFDP_AckTxnStatus_ACTIVE, CF_CFDP_FileDirective_EOF, CF_CFDP_ConditionCode_NO_ERROR, 1, 42), @@ -726,7 +726,7 @@ void Test_CF_CFDP_SendAck(void) /* still success path but with non-nominal values */ UT_CFDP_SetupBasicTestState(UT_CF_Setup_TX, &ph, NULL, NULL, &txn, NULL); - ack = &ph->int_header.ack; + ack = &ph->int_header.ack; txn->state = CF_TxnState_R2; UtAssert_INT32_EQ(CF_CFDP_SendAck(txn, CF_CFDP_AckTxnStatus_TERMINATED, CF_CFDP_FileDirective_FIN, CF_CFDP_ConditionCode_FILESTORE_REJECTION, 1, 42), @@ -1062,7 +1062,7 @@ void Test_CF_CFDP_CycleTxFirstActive(void) /* nominal, with chan->cur set non-null, should skip loop and return 1 */ UT_CFDP_SetupBasicTestState(UT_CF_Setup_TX, NULL, &args.chan, NULL, &txn, NULL); txn->flags.com.q_index = CF_QueueIdx_TXA; /* must be this */ - args.chan->cur = txn; + args.chan->cur = txn; UtAssert_INT32_EQ(CF_CFDP_CycleTxFirstActive(&txn->cl_node, &args), 1); UtAssert_BOOL_TRUE(args.ran_one); @@ -1072,7 +1072,7 @@ void Test_CF_CFDP_CycleTxFirstActive(void) UT_CFDP_SetupBasicTestState(UT_CF_Setup_TX, NULL, NULL, NULL, &txn, NULL); txn->state = CF_TxnState_S1; txn->flags.com.q_index = CF_QueueIdx_TXA; /* must be this */ - args.chan->cur = NULL; + args.chan->cur = NULL; UT_SetHookFunction(UT_KEY(CF_CFDP_TxStateDispatch), Ut_Hook_StateHandler_SetQIndex, NULL); UtAssert_INT32_EQ(CF_CFDP_CycleTxFirstActive(&txn->cl_node, &args), 1); } @@ -1102,7 +1102,7 @@ void Test_CF_CFDP_DoTick(void) UT_CFDP_SetupBasicTestState(UT_CF_Setup_TX, NULL, &args.chan, NULL, &txn, NULL); args.chan->cur = &txn2; - args.cont = true; + args.cont = true; UtAssert_INT32_EQ(CF_CFDP_DoTick(&txn->cl_node, &args), CF_CLIST_CONT); UtAssert_BOOL_TRUE(args.cont); @@ -1113,7 +1113,7 @@ void Test_CF_CFDP_DoTick(void) UT_CFDP_SetupBasicTestState(UT_CF_Setup_TX, NULL, &args.chan, NULL, &txn, NULL); txn->flags.com.suspended = 1; - args.cont = true; + args.cont = true; UtAssert_INT32_EQ(CF_CFDP_DoTick(&txn->cl_node, &args), CF_CLIST_CONT); UtAssert_BOOL_TRUE(args.cont); @@ -1368,9 +1368,9 @@ void Test_CF_CFDP_ResetTransaction(void) UT_ResetState(UT_KEY(CF_FreeTransaction)); UT_CFDP_SetupBasicTestState(UT_CF_Setup_TX, NULL, NULL, &history, &txn, NULL); - txn->fd = OS_ObjectIdFromInteger(1); - history->dir = CF_Direction_TX; - txn->state = CF_TxnState_S1; + txn->fd = OS_ObjectIdFromInteger(1); + history->dir = CF_Direction_TX; + txn->state = CF_TxnState_S1; UtAssert_VOIDCALL(CF_CFDP_ResetTransaction(txn, 1)); UtAssert_VOIDCALL(CF_CFDP_ResetTransaction(txn, 0)); UtAssert_STUB_COUNT(CF_FreeTransaction, 2); @@ -1401,19 +1401,19 @@ void Test_CF_CFDP_ResetTransaction(void) UT_ResetState(UT_KEY(CF_FreeTransaction)); UT_CFDP_SetupBasicTestState(UT_CF_Setup_RX, NULL, NULL, &history, &txn, NULL); - txn->fd = OS_ObjectIdFromInteger(1); - history->dir = CF_Direction_RX; - txn->state = CF_TxnState_R1; + txn->fd = OS_ObjectIdFromInteger(1); + history->dir = CF_Direction_RX; + txn->state = CF_TxnState_R1; UtAssert_VOIDCALL(CF_CFDP_ResetTransaction(txn, 1)); UtAssert_VOIDCALL(CF_CFDP_ResetTransaction(txn, 0)); UtAssert_STUB_COUNT(CF_FreeTransaction, 2); UT_ResetState(UT_KEY(CF_FreeTransaction)); UT_CFDP_SetupBasicTestState(UT_CF_Setup_TX, NULL, NULL, NULL, &txn, NULL); - txn->fd = OS_ObjectIdFromInteger(1); - history->dir = CF_Direction_TX; - txn->keep = 1; - txn->state = CF_TxnState_S1; + txn->fd = OS_ObjectIdFromInteger(1); + history->dir = CF_Direction_TX; + txn->keep = 1; + txn->state = CF_TxnState_S1; UtAssert_VOIDCALL(CF_CFDP_ResetTransaction(txn, 1)); UtAssert_VOIDCALL(CF_CFDP_ResetTransaction(txn, 0)); UtAssert_STUB_COUNT(CF_FreeTransaction, 2); @@ -1425,12 +1425,12 @@ void Test_CF_CFDP_ResetTransaction(void) */ UT_ResetState(UT_KEY(CF_FreeTransaction)); UT_CFDP_SetupBasicTestState(UT_CF_Setup_TX, NULL, &chan, &history, &txn, NULL); - pb.num_ts = 10; - txn->pb = &pb; - chan->cur = txn; + pb.num_ts = 10; + txn->pb = &pb; + chan->cur = txn; txn->flags.tx.cmd_tx = 5; - chan->num_cmd_tx = 8; - history->dir = CF_Direction_TX; + chan->num_cmd_tx = 8; + history->dir = CF_Direction_TX; txn->state = CF_TxnState_S1; UtAssert_VOIDCALL(CF_CFDP_ResetTransaction(txn, 1)); UtAssert_NULL(chan->cur); diff --git a/unit-test/cf_cmd_tests.c b/unit-test/cf_cmd_tests.c index 3709b1f5..852c90b6 100644 --- a/unit-test/cf_cmd_tests.c +++ b/unit-test/cf_cmd_tests.c @@ -157,7 +157,7 @@ void Dummy_CF_TsnChanAction_fn_t(CF_Transaction_t *txn, void *context) if (ctxt) { - ctxt->txn = txn; + ctxt->txn = txn; ctxt->context = context; } @@ -252,7 +252,7 @@ void Test_CF_CmdReset_tests_WhenCommandByteIs_command_AndResetHkCmdAndErrCountSe memset(&utbuf, 0, sizeof(utbuf)); - msg->data.byte[0] = CF_Reset_command; + msg->data.byte[0] = CF_Reset_command; CF_AppData.hk.counters.cmd = Any_uint16_Except(0); CF_AppData.hk.counters.err = Any_uint16_Except(0); @@ -1951,7 +1951,7 @@ void Test_CF_CmdEnablePolldir_FailWhenActionFail(void) msg->data.byte[0] = channel; /* Arrange unstubbable: CF_DoEnableDisablePolldir */ - msg->data.byte[1] = error_polldir; + msg->data.byte[1] = error_polldir; CF_AppData.hk.counters.err = initial_hk_err_counter; /* Act */ diff --git a/unit-test/cf_timer_tests.c b/unit-test/cf_timer_tests.c index 38739520..c276aa72 100644 --- a/unit-test/cf_timer_tests.c +++ b/unit-test/cf_timer_tests.c @@ -138,8 +138,8 @@ void Test_CF_Timer_Tick_When_t_tick_Is_non0_Decrement_t_tick(void) { /* Arrange */ uint32 initial_tick = Any_uint32_Except(0); - CF_Timer_t txn; - CF_Timer_t *arg_t = &txn; + CF_Timer_t timer; + CF_Timer_t *arg_t = &timer; arg_t->tick = initial_tick; @@ -203,4 +203,4 @@ void UtTest_Setup(void) add_CF_Timer_Expired_tests(); add_CF_Timer_Tick_tests(); -} \ No newline at end of file +} diff --git a/unit-test/cf_utils_tests.c b/unit-test/cf_utils_tests.c index b7c8f71a..13a513c2 100644 --- a/unit-test/cf_utils_tests.c +++ b/unit-test/cf_utils_tests.c @@ -95,7 +95,7 @@ static void UT_Callback_CF_TraverseAllTransactions(CF_Transaction_t *txn, void * if (ctxt) { - ctxt->txn = txn; + ctxt->txn = txn; ctxt->context = context; } } @@ -109,7 +109,7 @@ static void UT_AltHandler_CF_CList_Traverse_SeqArg_SetTxn(void *UserObj, UT_Entr const UT_StubContext_t *Context) { CF_Traverse_TransSeqArg_t *arg = UT_Hook_GetArgValueByName(Context, "context", CF_Traverse_TransSeqArg_t *); - arg->txn = UserObj; + arg->txn = UserObj; } /******************************************************************************* @@ -145,7 +145,7 @@ void Test_CF_FindUnusedTransaction(void) memset(&hist, 0, sizeof(hist)); memset(&txn, 0, sizeof(txn)); memset(&CF_AppData, 0, sizeof(CF_AppData)); - chan = &CF_AppData.engine.channels[UT_CFDP_CHANNEL]; + chan = &CF_AppData.engine.channels[UT_CFDP_CHANNEL]; CF_AppData.hk.channel_hk[UT_CFDP_CHANNEL].q_size[CF_QueueIdx_FREE] = 2; CF_AppData.hk.channel_hk[UT_CFDP_CHANNEL].q_size[CF_QueueIdx_HIST_FREE] = 1; CF_AppData.hk.channel_hk[UT_CFDP_CHANNEL].q_size[CF_QueueIdx_HIST] = 1; @@ -1332,4 +1332,4 @@ void UtTest_Setup(void) add_CF_WrappedWrite_tests(); add_CF_WrappedLseek_tests(); -} \ No newline at end of file +} diff --git a/unit-test/stubs/cf_app_stubs.c b/unit-test/stubs/cf_app_stubs.c index 10660328..bceb5843 100644 --- a/unit-test/stubs/cf_app_stubs.c +++ b/unit-test/stubs/cf_app_stubs.c @@ -33,6 +33,7 @@ */ void CF_AppMain(void) { + UT_GenStub_Execute(CF_AppMain, Basic, NULL); } @@ -43,6 +44,7 @@ void CF_AppMain(void) */ void CF_CheckTables(void) { + UT_GenStub_Execute(CF_CheckTables, Basic, NULL); } @@ -53,6 +55,7 @@ void CF_CheckTables(void) */ void CF_HkCmd(void) { + UT_GenStub_Execute(CF_HkCmd, Basic, NULL); } @@ -119,5 +122,6 @@ CFE_Status_t CF_ValidateConfigTable(void *tbl_ptr) */ void CF_WakeUp(void) { + UT_GenStub_Execute(CF_WakeUp, Basic, NULL); } diff --git a/unit-test/stubs/cf_cfdp_sbintf_stubs.c b/unit-test/stubs/cf_cfdp_sbintf_stubs.c index 52d5dc58..afd26193 100644 --- a/unit-test/stubs/cf_cfdp_sbintf_stubs.c +++ b/unit-test/stubs/cf_cfdp_sbintf_stubs.c @@ -2,7 +2,7 @@ * NASA Docket No. GSC-18,447-1, and identified as “CFS CFDP (CF) * Application version 3.0.0” * - * Copyright (chan) 2019 United States Government as represented by the + * Copyright (c) 2019 United States Government as represented by the * Administrator of the National Aeronautics and Space Administration. * All Rights Reserved. * diff --git a/unit-test/stubs/cf_cfdp_stubs.c b/unit-test/stubs/cf_cfdp_stubs.c index 3fddfa68..a9d67b14 100644 --- a/unit-test/stubs/cf_cfdp_stubs.c +++ b/unit-test/stubs/cf_cfdp_stubs.c @@ -135,6 +135,7 @@ int CF_CFDP_CopyStringFromLV(char *buf, size_t buf_maxsz, const CF_Logical_Lv_t */ void CF_CFDP_CycleEngine(void) { + UT_GenStub_Execute(CF_CFDP_CycleEngine, Basic, NULL); } @@ -191,6 +192,7 @@ void CF_CFDP_DecodeStart(CF_DecoderState_t *pdec, const void *msgbuf, CF_Logical */ void CF_CFDP_DisableEngine(void) { + UT_GenStub_Execute(CF_CFDP_DisableEngine, Basic, NULL); } @@ -452,16 +454,16 @@ CFE_Status_t CF_CFDP_RecvNak(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph) * Generated stub function for CF_CFDP_RecvPh() * ---------------------------------------------------- */ -int CF_CFDP_RecvPh(uint8 chan_num, CF_Logical_PduBuffer_t *ph) +CFE_Status_t CF_CFDP_RecvPh(uint8 chan_num, CF_Logical_PduBuffer_t *ph) { - UT_GenStub_SetupReturnBuffer(CF_CFDP_RecvPh, int); + UT_GenStub_SetupReturnBuffer(CF_CFDP_RecvPh, CFE_Status_t); UT_GenStub_AddParam(CF_CFDP_RecvPh, uint8, chan_num); UT_GenStub_AddParam(CF_CFDP_RecvPh, CF_Logical_PduBuffer_t *, ph); UT_GenStub_Execute(CF_CFDP_RecvPh, Basic, NULL); - return UT_GenStub_GetReturnValue(CF_CFDP_RecvPh, int); + return UT_GenStub_GetReturnValue(CF_CFDP_RecvPh, CFE_Status_t); } /* diff --git a/unit-test/stubs/cf_timer_stubs.c b/unit-test/stubs/cf_timer_stubs.c index bc0fa419..6cfa71d3 100644 --- a/unit-test/stubs/cf_timer_stubs.c +++ b/unit-test/stubs/cf_timer_stubs.c @@ -33,13 +33,13 @@ */ bool CF_Timer_Expired(const CF_Timer_t *txn) { - UT_GenStub_SetupReturnBuffer(CF_Timer_Expired, int); + UT_GenStub_SetupReturnBuffer(CF_Timer_Expired, bool); UT_GenStub_AddParam(CF_Timer_Expired, const CF_Timer_t *, txn); UT_GenStub_Execute(CF_Timer_Expired, Basic, NULL); - return UT_GenStub_GetReturnValue(CF_Timer_Expired, int); + return UT_GenStub_GetReturnValue(CF_Timer_Expired, bool); } /* diff --git a/unit-test/stubs/cf_utils_handlers.c b/unit-test/stubs/cf_utils_handlers.c index 49bf3664..a062f260 100644 --- a/unit-test/stubs/cf_utils_handlers.c +++ b/unit-test/stubs/cf_utils_handlers.c @@ -2,7 +2,7 @@ * NASA Docket No. GSC-18,447-1, and identified as “CFS CFDP (CF) * Application version 3.0.0” * - * Copyright (chan) 2019 United States Government as represented by the + * Copyright (c) 2019 United States Government as represented by the * Administrator of the National Aeronautics and Space Administration. * All Rights Reserved. * @@ -113,9 +113,9 @@ void UT_DefaultHandler_CF_WriteTxnQueueDataToFile(void *UserObj, UT_EntryKey_t F if (ctxt) { - ctxt->fd = UT_Hook_GetArgValueByName(Context, "fd", int32); - ctxt->chan = UT_Hook_GetArgValueByName(Context, "chan", CF_Channel_t *); - ctxt->queue = UT_Hook_GetArgValueByName(Context, "queue", CF_QueueIdx_t); + ctxt->fd = UT_Hook_GetArgValueByName(Context, "fd", int32); + ctxt->chan = UT_Hook_GetArgValueByName(Context, "chan", CF_Channel_t *); + ctxt->queue = UT_Hook_GetArgValueByName(Context, "queue", CF_QueueIdx_t); } } @@ -213,4 +213,4 @@ void UT_DefaultHandler_CF_TxnStatus_IsError(void *UserObj, UT_EntryKey_t FuncKey result = (bool)Context->Int32StatusCode; UT_Stub_SetReturnValue(FuncKey, result); -} \ No newline at end of file +} diff --git a/unit-test/stubs/cf_utils_stubs.c b/unit-test/stubs/cf_utils_stubs.c index 7ad5d0b1..d1224791 100644 --- a/unit-test/stubs/cf_utils_stubs.c +++ b/unit-test/stubs/cf_utils_stubs.c @@ -41,8 +41,9 @@ void UT_DefaultHandler_CF_WriteTxnQueueDataToFile(void *, UT_EntryKey_t, const U * Generated stub function for CF_FindTransactionBySequenceNumber() * ---------------------------------------------------- */ -CF_Transaction_t *CF_FindTransactionBySequenceNumber(CF_Channel_t *chan, CF_TransactionSeq_t transaction_sequence_number, - CF_EntityId_t src_eid) +CF_Transaction_t *CF_FindTransactionBySequenceNumber(CF_Channel_t * chan, + CF_TransactionSeq_t transaction_sequence_number, + CF_EntityId_t src_eid) { UT_GenStub_SetupReturnBuffer(CF_FindTransactionBySequenceNumber, CF_Transaction_t *); diff --git a/unit-test/utilities/cf_test_utils.h b/unit-test/utilities/cf_test_utils.h index 996fe48f..b1883a7d 100644 --- a/unit-test/utilities/cf_test_utils.h +++ b/unit-test/utilities/cf_test_utils.h @@ -2,7 +2,7 @@ * NASA Docket No. GSC-18,447-1, and identified as “CFS CFDP (CF) * Application version 3.0.0” * - * Copyright (chan) 2019 United States Government as represented by the + * Copyright (c) 2019 United States Government as represented by the * Administrator of the National Aeronautics and Space Administration. * All Rights Reserved. *