diff --git a/fsw/src/cf_cfdp.c b/fsw/src/cf_cfdp.c index fa2301d9..741bf784 100644 --- a/fsw/src/cf_cfdp.c +++ b/fsw/src/cf_cfdp.c @@ -1011,12 +1011,15 @@ void CF_CFDP_RecvIdle(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph) int32 CF_CFDP_InitEngine(void) { /* initialize all transaction nodes */ - int i; - int j; - int chunk_mem_offset = 0; + CF_History_t * h; CF_Transaction_t * t = CF_AppData.engine.transactions; CF_ChunkWrapper_t *c = CF_AppData.engine.chunks; int32 ret = CFE_SUCCESS; + int chunk_mem_offset = 0; + int i; + int j; + int k; + char nbuf[64]; static const int CF_DIR_MAX_CHUNKS[CF_Direction_NUM][CF_NUM_CHANNELS] = {CF_CHANNEL_NUM_RX_CHUNKS_PER_TRANSACTION, CF_CHANNEL_NUM_TX_CHUNKS_PER_TRANSACTION}; @@ -1025,7 +1028,6 @@ int32 CF_CFDP_InitEngine(void) for (i = 0; i < CF_NUM_CHANNELS; ++i) { - char nbuf[64]; snprintf(nbuf, sizeof(nbuf) - 1, "%s%d", CF_CHANNEL_PIPE_PREFIX, i); ret = CFE_SB_CreatePipe(&CF_AppData.engine.channels[i].pipe, CF_AppData.config_table->chan[i].pipe_depth_input, nbuf); @@ -1062,8 +1064,6 @@ int32 CF_CFDP_InitEngine(void) for (j = 0; j < CF_NUM_TRANSACTIONS_PER_CHANNEL; ++j, ++t) { - int k; - t->chan_num = i; CF_FreeTransaction(t); @@ -1079,7 +1079,7 @@ int32 CF_CFDP_InitEngine(void) for (j = 0; j < CF_NUM_HISTORIES_PER_CHANNEL; ++j) { - CF_History_t *h = &CF_AppData.engine.histories[(i * CF_NUM_HISTORIES_PER_CHANNEL) + j]; + h = &CF_AppData.engine.histories[(i * CF_NUM_HISTORIES_PER_CHANNEL) + j]; CF_CList_InitNode(&h->cl_node); CF_CList_InsertBack_Ex(&CF_AppData.engine.channels[i], CF_QueueIdx_HIST_FREE, &h->cl_node); } @@ -1454,15 +1454,14 @@ int32 CF_CFDP_PlaybackDir(const char *src_filename, const char *dst_filename, CF *-----------------------------------------------------------------*/ void CF_CFDP_ProcessPlaybackDirectory(CF_Channel_t *c, CF_Playback_t *p) { - os_dirent_t dirent; - /* either there's no transaction (first one) or the last one was finished, so check for a new one */ + os_dirent_t dirent; + CF_Transaction_t *pt; + int32 status; /* either there's no transaction (first one) or the last one was finished, so check for a new one */ memset(&dirent, 0, sizeof(dirent)); while (p->diropen && (p->num_ts < CF_NUM_TRANSACTIONS_PER_PLAYBACK)) { - int32 status; - CFE_ES_PerfLogEntry(CF_PERF_ID_DIRREAD); status = OS_DirectoryRead(p->dir_id, &dirent); CFE_ES_PerfLogExit(CF_PERF_ID_DIRREAD); @@ -1475,7 +1474,7 @@ void CF_CFDP_ProcessPlaybackDirectory(CF_Channel_t *c, CF_Playback_t *p) } { - CF_Transaction_t *pt = CF_FindUnusedTransaction(c); + pt = CF_FindUnusedTransaction(c); CF_Assert(pt); /* should be impossible not to have one because there are limits on the number of uses of them */ @@ -1568,15 +1567,21 @@ static void CF_CFDP_ProcessPlaybackDirectories(CF_Channel_t *c) *-----------------------------------------------------------------*/ void CF_CFDP_ProcessPollingDirectories(CF_Channel_t *c) { - int i; + CF_Poll_t * p; + CF_ChannelConfig_t *cc; + CF_PollDir_t * pd; + int i; + int chan_index; + int count_check; + int ret; for (i = 0; i < CF_MAX_POLLING_DIR_PER_CHAN; ++i) { - CF_Poll_t * p = &c->poll[i]; - int chan_index = (c - CF_AppData.engine.channels); - CF_ChannelConfig_t *cc = &CF_AppData.config_table->chan[chan_index]; - CF_PollDir_t * pd = &cc->polldir[i]; - int count_check = 0; + p = &c->poll[i]; + chan_index = (c - CF_AppData.engine.channels); + cc = &CF_AppData.config_table->chan[chan_index]; + pd = &cc->polldir[i]; + count_check = 0; if (pd->enabled && pd->interval_sec) { @@ -1592,8 +1597,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_Initiate(&p->pb, pd->src_dir, pd->dst_dir, pd->cfdp_class, 0, - chan_index, pd->priority, pd->dest_eid); + 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; @@ -1632,13 +1637,14 @@ void CF_CFDP_ProcessPollingDirectories(CF_Channel_t *c) *-----------------------------------------------------------------*/ void CF_CFDP_CycleEngine(void) { - int i; + CF_Channel_t *c; + int i; if (CF_AppData.engine.enabled) { for (i = 0; i < CF_NUM_CHANNELS; ++i) { - CF_Channel_t *c = &CF_AppData.engine.channels[i]; + c = &CF_AppData.engine.channels[i]; CF_AppData.engine.outgoing_counter = 0; /* consume all received messages, even if channel is frozen */ diff --git a/fsw/src/cf_cfdp_r.c b/fsw/src/cf_cfdp_r.c index 1170bf60..68e2426a 100644 --- a/fsw/src/cf_cfdp_r.c +++ b/fsw/src/cf_cfdp_r.c @@ -124,8 +124,9 @@ int CF_CFDP_R_CheckCrc(CF_Transaction_t *t, uint32 expected_crc) *-----------------------------------------------------------------*/ void CF_CFDP_R2_Complete(CF_Transaction_t *t, int ok_to_send_nak) { - int send_nak = 0; - int send_fin = 0; + uint32 ret; + int send_nak = 0; + int send_fin = 0; /* checking if r2 is complete. Check nak list, and send NAK if appropriate */ /* if all data is present, then there will be no gaps in the chunk */ @@ -139,7 +140,7 @@ void CF_CFDP_R2_Complete(CF_Transaction_t *t, int ok_to_send_nak) else { /* only look for 1 gap, since the goal here is just to know that there are gaps */ - uint32 ret = CF_ChunkList_ComputeGaps(&t->chunks->chunks, 1, t->fsize, 0, NULL, NULL); + ret = CF_ChunkList_ComputeGaps(&t->chunks->chunks, 1, t->fsize, 0, NULL, NULL); if (ret) { @@ -509,8 +510,8 @@ int CF_CFDP_R_SubstateSendNak(CF_Transaction_t *t) CF_AppData.config_table->local_eid, 1, t->history->seq_num, 1); CF_Logical_PduNak_t *nak; CF_SendRet_t sret; - - int ret = -1; + uint32 cret; + int ret = -1; if (ph) { @@ -520,7 +521,6 @@ int CF_CFDP_R_SubstateSendNak(CF_Transaction_t *t) { /* we have metadata, so send valid nak */ CF_GapComputeArgs_t args = {t, nak}; - uint32 cret; nak->scope_start = 0; cret = CF_ChunkList_ComputeGaps(&t->chunks->chunks, @@ -808,7 +808,10 @@ void CF_CFDP_R2_Recv_fin_ack(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph) *-----------------------------------------------------------------*/ void CF_CFDP_R2_RecvMd(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph) { - bool success = true; + char fname[CF_FILENAME_MAX_LEN]; + int status; + int32 ret; + bool success = true; /* it isn't an error to get another MD pdu, right? */ if (!t->flags.rx.md_recv) @@ -817,8 +820,6 @@ void CF_CFDP_R2_RecvMd(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph) /* parse the md pdu. this will overwrite the transaction's history, which contains our filename. so let's * save the filename in a local buffer so it can be used with OS_mv upon successful parsing of * the md pdu */ - char fname[CF_FILENAME_MAX_LEN]; - int status; strcpy( fname, @@ -866,7 +867,7 @@ void CF_CFDP_R2_RecvMd(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph) } else { - int32 ret = + ret = CF_WrappedOpenCreate(&t->fd, t->history->fnames.dst_filename, OS_FILE_FLAG_NONE, OS_READ_WRITE); if (ret < 0) { @@ -1000,7 +1001,8 @@ void CF_CFDP_R_Tick(CF_Transaction_t *t, int *cont /* unused */) * the logic by state so that it isn't a bunch of if statements for different flags */ - bool success = true; + CF_SendRet_t sret; + bool success = true; /* at each tick, various timers used by R are checked */ /* first, check inactivity timer */ @@ -1024,8 +1026,8 @@ void CF_CFDP_R_Tick(CF_Transaction_t *t, int *cont /* unused */) /* rx maintenance: possibly process send_eof_ack, send_nak or send_fin */ if (t->flags.rx.send_ack) { - CF_SendRet_t sret = CF_CFDP_SendAck(t, CF_CFDP_AckTxnStatus_ACTIVE, CF_CFDP_FileDirective_EOF, - t->state_data.r.r2.eof_cc, t->history->peer_eid, t->history->seq_num); + sret = CF_CFDP_SendAck(t, CF_CFDP_AckTxnStatus_ACTIVE, CF_CFDP_FileDirective_EOF, t->state_data.r.r2.eof_cc, + t->history->peer_eid, t->history->seq_num); CF_Assert(sret != CF_SendRet_ERROR); /* if CF_SendRet_SUCCESS, then move on in the state machine. CF_CFDP_SendAck does not return diff --git a/fsw/src/cf_cfdp_s.c b/fsw/src/cf_cfdp_s.c index 120e7099..7ff64202 100644 --- a/fsw/src/cf_cfdp_s.c +++ b/fsw/src/cf_cfdp_s.c @@ -277,11 +277,12 @@ void CF_CFDP_S_SubstateSendFileData(CF_Transaction_t *t) int CF_CFDP_S_CheckAndRespondNak(CF_Transaction_t *t) { const CF_Chunk_t *c; + CF_SendRet_t sret; int ret = 0; if (t->flags.tx.md_need_send) { - CF_SendRet_t sret = CF_CFDP_SendMd(t); + sret = CF_CFDP_SendMd(t); if (sret == CF_SendRet_ERROR) { ret = -1; /* error occurred */ @@ -358,14 +359,13 @@ void CF_CFDP_S2_SubstateSendFileData(CF_Transaction_t *t) *-----------------------------------------------------------------*/ void CF_CFDP_S_SubstateSendMetadata(CF_Transaction_t *t) { - bool success = true; - int status = 0; CF_SendRet_t sret; + int32 ret; + int status = 0; + bool success = true; if (!OS_ObjectIdDefined(t->fd)) { - int32 ret; - if (OS_FileOpenCheck(t->history->fnames.src_filename) == OS_SUCCESS) { CFE_EVS_SendEvent(CF_EID_ERR_CFDP_S_ALREADY_OPEN, CFE_EVS_EventType_ERROR, @@ -738,7 +738,8 @@ void CF_CFDP_S_Tick(CF_Transaction_t *t, int *cont /* unused */) /* Steven is not real happy with this function. There should be a better way to separate out * the logic by state so that it isn't a bunch of if statements for different flags */ - bool early_exit = false; + CF_SendRet_t sret; + bool early_exit = false; /* at each tick, various timers used by S are checked */ /* first, check inactivity timer */ @@ -779,7 +780,7 @@ void CF_CFDP_S_Tick(CF_Transaction_t *t, int *cont /* unused */) } else { - CF_SendRet_t sret = CF_CFDP_S_SendEof(t); + sret = CF_CFDP_S_SendEof(t); if (sret == CF_SendRet_NO_MSG) { early_exit = true; diff --git a/fsw/src/cf_cfdp_sbintf.c b/fsw/src/cf_cfdp_sbintf.c index f275665c..2c0ce9ba 100644 --- a/fsw/src/cf_cfdp_sbintf.c +++ b/fsw/src/cf_cfdp_sbintf.c @@ -186,6 +186,7 @@ void CF_CFDP_ReceiveMessage(CF_Channel_t *c) CFE_MSG_Type_t msg_type = CFE_MSG_Type_Invalid; CF_Logical_PduBuffer_t *ph; + CF_Transaction_t t_finack; for (; count < CF_AppData.config_table->chan[chan_num].rx_max_messages_per_wakeup; ++count) { @@ -237,8 +238,6 @@ void CF_CFDP_ReceiveMessage(CF_Channel_t *c) { if (!CF_CFDP_RecvFin(t, ph)) { - CF_Transaction_t t_finack; - memset(&t_finack, 0, sizeof(t_finack)); CF_CFDP_InitTxnTxFile(&t_finack, CF_CFDP_CLASS_2, 1, chan_num, 0); /* populate transaction with needed fields for CF_CFDP_SendAck() */ diff --git a/fsw/src/cf_chunk.c b/fsw/src/cf_chunk.c index 80deac03..4a532045 100644 --- a/fsw/src/cf_chunk.c +++ b/fsw/src/cf_chunk.c @@ -252,10 +252,14 @@ CF_ChunkIdx_t CF_Chunks_FindSmallestSize(const CF_ChunkList_t *chunks) *-----------------------------------------------------------------*/ void CF_Chunks_Insert(CF_ChunkList_t *chunks, CF_ChunkIdx_t i, const CF_Chunk_t *chunk) { - int n = CF_Chunks_CombineNext(chunks, i, chunk); + CF_ChunkIdx_t smallest_i; + CF_Chunk_t * smallest_c; + int n = CF_Chunks_CombineNext(chunks, i, chunk); + int combined; + if (n) { - int combined = CF_Chunks_CombinePrevious(chunks, i, &chunks->chunks[i]); + combined = CF_Chunks_CombinePrevious(chunks, i, &chunks->chunks[i]); if (combined) { CF_Chunks_EraseChunk(chunks, i); @@ -263,7 +267,7 @@ void CF_Chunks_Insert(CF_ChunkList_t *chunks, CF_ChunkIdx_t i, const CF_Chunk_t } else { - int combined = CF_Chunks_CombinePrevious(chunks, i, chunk); + combined = CF_Chunks_CombinePrevious(chunks, i, chunk); if (!combined) { if (chunks->count < chunks->max_chunks) @@ -272,8 +276,8 @@ void CF_Chunks_Insert(CF_ChunkList_t *chunks, CF_ChunkIdx_t i, const CF_Chunk_t } else { - CF_ChunkIdx_t smallest_i = CF_Chunks_FindSmallestSize(chunks); - CF_Chunk_t * smallest_c = &chunks->chunks[smallest_i]; + smallest_i = CF_Chunks_FindSmallestSize(chunks); + smallest_c = &chunks->chunks[smallest_i]; if (smallest_c->size < chunk->size) { CF_Chunks_EraseChunk(chunks, smallest_i); diff --git a/fsw/src/cf_clist.c b/fsw/src/cf_clist.c index 2e252c7a..3f7af2cd 100644 --- a/fsw/src/cf_clist.c +++ b/fsw/src/cf_clist.c @@ -56,6 +56,8 @@ void CF_CList_InitNode(CF_CListNode_t *node) *-----------------------------------------------------------------*/ void CF_CList_InsertFront(CF_CListNode_t **head, CF_CListNode_t *node) { + CF_CListNode_t *last; + CF_Assert(head); CF_Assert(node); CF_Assert(node->next == node); @@ -63,7 +65,7 @@ void CF_CList_InsertFront(CF_CListNode_t **head, CF_CListNode_t *node) if (*head) { - CF_CListNode_t *last = (*head)->prev; + last = (*head)->prev; node->next = *head; node->prev = last; @@ -85,6 +87,8 @@ void CF_CList_InsertFront(CF_CListNode_t **head, CF_CListNode_t *node) *-----------------------------------------------------------------*/ void CF_CList_InsertBack(CF_CListNode_t **head, CF_CListNode_t *node) { + CF_CListNode_t *last; + CF_Assert(head); CF_Assert(node); CF_Assert(node->next == node); @@ -96,7 +100,7 @@ void CF_CList_InsertBack(CF_CListNode_t **head, CF_CListNode_t *node) } else { - CF_CListNode_t *last = (*head)->prev; + last = (*head)->prev; node->next = *head; (*head)->prev = node; diff --git a/fsw/src/cf_cmd.c b/fsw/src/cf_cmd.c index 73a8e2ba..79dcbe0d 100644 --- a/fsw/src/cf_cmd.c +++ b/fsw/src/cf_cmd.c @@ -224,6 +224,7 @@ void CF_CmdPlaybackDir(CFE_SB_Buffer_t *msg) *-----------------------------------------------------------------*/ int CF_DoChanAction(CF_UnionArgsCmd_t *cmd, const char *errstr, CF_ChanActionFn_t fn, void *context) { + int i; int ret = 0; /* this function is generic for any ground command that takes a single channel @@ -232,7 +233,6 @@ int CF_DoChanAction(CF_UnionArgsCmd_t *cmd, const char *errstr, CF_ChanActionFn_ if (cmd->data.byte[0] == CF_ALL_CHANNELS) { /* apply to all channels */ - int i; for (i = 0; i < CF_NUM_CHANNELS; ++i) ret |= fn(i, context); } @@ -354,13 +354,14 @@ CF_Transaction_t *CF_FindTransactionBySequenceNumberAllChannels(CF_TransactionSe *-----------------------------------------------------------------*/ int CF_TsnChanAction(CF_TransactionCmd_t *cmd, const char *cmdstr, CF_TsnChanAction_fn_t fn, void *context) { - int ret = -1; + CF_Transaction_t *t; + int ret = -1; if (cmd->chan == CF_COMPOUND_KEY) { /* special value 254 means to use the compound key (cmd->eid, cmd->ts) to find the transaction * to act upon */ - CF_Transaction_t *t = CF_FindTransactionBySequenceNumberAllChannels(cmd->ts, cmd->eid); + t = CF_FindTransactionBySequenceNumberAllChannels(cmd->ts, cmd->eid); if (t) { fn(t, context); @@ -631,12 +632,12 @@ void CF_CmdDisableDequeue(CFE_SB_Buffer_t *msg) *-----------------------------------------------------------------*/ int CF_DoEnableDisablePolldir(uint8 chan_num, const CF_ChanAction_BoolMsgArg_t *context) { + int i; int ret = 0; /* no need to bounds check chan_num, done in caller */ if (context->msg->data.byte[1] == CF_ALL_POLLDIRS) { /* all polldirs in channel */ - int i; for (i = 0; i < CF_MAX_POLLING_DIR_PER_CHAN; ++i) CF_AppData.config_table->chan[chan_num].polldir[i].enabled = context->barg; } diff --git a/fsw/src/cf_utils.c b/fsw/src/cf_utils.c index eefa709c..ea0cc3e9 100644 --- a/fsw/src/cf_utils.c +++ b/fsw/src/cf_utils.c @@ -44,14 +44,16 @@ *-----------------------------------------------------------------*/ CF_Transaction_t *CF_FindUnusedTransaction(CF_Channel_t *c) { + CF_CListNode_t * n; + CF_Transaction_t *t; + int q_index; /* initialized below in if */ + CF_Assert(c); if (c->qs[CF_QueueIdx_FREE]) { - 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); + n = c->qs[CF_QueueIdx_FREE]; + t = container_of(n, CF_Transaction_t, cl_node); CF_CList_Remove_Ex(c, CF_QueueIdx_FREE, &t->cl_node); @@ -351,6 +353,7 @@ void CF_InsertSortPrio(CF_Transaction_t *t, CF_QueueIdx_t q) { int insert_back = 0; CF_Channel_t *c = &CF_AppData.engine.channels[t->chan_num]; + CF_Assert(t->chan_num < CF_NUM_CHANNELS); CF_Assert(t->state != CF_TxnState_IDLE); diff --git a/unit-test/cf_cmd_tests.c b/unit-test/cf_cmd_tests.c index dba29a03..05238652 100644 --- a/unit-test/cf_cmd_tests.c +++ b/unit-test/cf_cmd_tests.c @@ -206,15 +206,14 @@ void Test_CF_CmdReset_tests_WhenCommandByteIsEqTo_5_SendEventAndRejectCommand(vo { /* Arrange */ CF_UT_cmd_unionargs_buf_t utbuf; - CF_UnionArgsCmd_t * dummy_msg = &utbuf.ua; - CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_UnionArgsCmd_t * dummy_msg = &utbuf.ua; + CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + uint16 initial_hk_err_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); dummy_msg->data.byte[0] = 5; /* 5 is size of 'names' */ - uint16 initial_hk_err_counter = Any_uint16(); - CF_AppData.hk.counters.err = initial_hk_err_counter; /* Act */ @@ -231,15 +230,14 @@ void Test_CF_CmdReset_tests_WhenCommandByteIsGreaterThan_5_SendEventAndRejectCom { /* Arrange */ CF_UT_cmd_unionargs_buf_t utbuf; - CF_UnionArgsCmd_t * dummy_msg = &utbuf.ua; - CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_UnionArgsCmd_t * dummy_msg = &utbuf.ua; + CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + uint16 initial_hk_err_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); dummy_msg->data.byte[0] = Any_uint8_GreaterThan(5); /* 5 is size of 'names' */ - uint16 initial_hk_err_counter = Any_uint16(); - CF_AppData.hk.counters.err = initial_hk_err_counter; /* Act */ @@ -280,9 +278,10 @@ void Test_CF_CmdReset_tests_WhenCommandByteIs_fault_ResetAllHkFaultCountSendEven { /* Arrange */ CF_UT_cmd_unionargs_buf_t utbuf; - CF_UnionArgsCmd_t * dummy_msg = &utbuf.ua; - CFE_SB_Buffer_t * arg_msg = &utbuf.buf; - int i = 0; + CF_UnionArgsCmd_t * dummy_msg = &utbuf.ua; + CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + int i = 0; + uint16 initial_hk_cmd_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); @@ -304,8 +303,6 @@ void Test_CF_CmdReset_tests_WhenCommandByteIs_fault_ResetAllHkFaultCountSendEven CF_AppData.hk.channel_hk[i].counters.fault.spare = Any_uint16_Except(0); } - uint16 initial_hk_cmd_counter = Any_uint16(); - CF_AppData.hk.counters.cmd = initial_hk_cmd_counter; /* Act */ @@ -342,9 +339,10 @@ void Test_CF_CmdReset_tests_WhenCommandByteIs_up_AndResetAllHkRecvCountSendEvent { /* Arrange */ CF_UT_cmd_unionargs_buf_t utbuf; - CF_UnionArgsCmd_t * dummy_msg = &utbuf.ua; - CFE_SB_Buffer_t * arg_msg = &utbuf.buf; - int i = 0; + CF_UnionArgsCmd_t * dummy_msg = &utbuf.ua; + CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + int i = 0; + uint16 initial_hk_cmd_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); @@ -360,8 +358,6 @@ void Test_CF_CmdReset_tests_WhenCommandByteIs_up_AndResetAllHkRecvCountSendEvent CF_AppData.hk.channel_hk[i].counters.recv.nak_segment_requests = Any_uint32_Except(0); } - uint16 initial_hk_cmd_counter = Any_uint16(); - CF_AppData.hk.counters.cmd = initial_hk_cmd_counter; /* Act */ @@ -392,9 +388,10 @@ void Test_CF_CmdReset_tests_SWhenCommandByteIs_down_AndResetAllHkSentCountendEve { /* Arrange */ CF_UT_cmd_unionargs_buf_t utbuf; - CF_UnionArgsCmd_t * dummy_msg = &utbuf.ua; - CFE_SB_Buffer_t * arg_msg = &utbuf.buf; - uint8 i = 0; + CF_UnionArgsCmd_t * dummy_msg = &utbuf.ua; + CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + uint8 i = 0; + uint16 initial_hk_cmd_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); @@ -407,8 +404,6 @@ void Test_CF_CmdReset_tests_SWhenCommandByteIs_down_AndResetAllHkSentCountendEve CF_AppData.hk.channel_hk[i].counters.sent.pdu = Any_uint32_Except(0); } - uint16 initial_hk_cmd_counter = Any_uint16(); - CF_AppData.hk.counters.cmd = initial_hk_cmd_counter; /* Act */ @@ -851,12 +846,12 @@ void Test_CF_DoChanAction_WhenBadChannelNumber_Return_neg1_And_SendEvent(void) int dummy_context; void * arg_context = &dummy_context; int local_result; + int catastrophe_count = 0; memset(&utbuf, 0, sizeof(utbuf)); /* force CF_ALL_CHANNELS to not be a selection possibility */ arg_cmd->data.byte[0] = CF_ALL_CHANNELS; - int catastrophe_count = 0; while (arg_cmd->data.byte[0] == CF_ALL_CHANNELS) { if (catastrophe_count == 10) // 10 is arbitrary @@ -932,8 +927,9 @@ void Test_CF_CmdFreeze_Set_frozen_To_1_AndAcceptCommand(void) { /* Arrange */ CF_UT_cmd_unionargs_buf_t utbuf; - CF_UnionArgsCmd_t * dummy_msg = &utbuf.ua; - CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_UnionArgsCmd_t * dummy_msg = &utbuf.ua; + CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + uint16 initial_hk_cmd_counter = Any_uint16(); /* Arrange unstubbable: CF_DoFreezeThaw via CF_DoChanAction */ uint8 dummy_chan_num = Any_cf_channel(); @@ -943,8 +939,6 @@ void Test_CF_CmdFreeze_Set_frozen_To_1_AndAcceptCommand(void) /* Arrange unstubbable: CF_DoChanAction */ dummy_msg->data.byte[0] = dummy_chan_num; - uint16 initial_hk_cmd_counter = Any_uint16(); - CF_AppData.hk.counters.cmd = initial_hk_cmd_counter; /* Act */ @@ -996,8 +990,9 @@ void Test_CF_CmdThaw_Set_frozen_To_0_AndAcceptCommand(void) { /* Arrange */ CF_UT_cmd_unionargs_buf_t utbuf; - CF_UnionArgsCmd_t * dummy_msg = &utbuf.ua; - CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_UnionArgsCmd_t * dummy_msg = &utbuf.ua; + CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + uint16 initial_hk_cmd_counter = Any_uint16(); /* Arrange unstubbable: CF_DoFreezeThaw via CF_DoChanAction */ uint8 dummy_chan_num = Any_cf_channel(); @@ -1007,8 +1002,6 @@ void Test_CF_CmdThaw_Set_frozen_To_0_AndAcceptCommand(void) /* Arrange unstubbable: CF_DoChanAction */ dummy_msg->data.byte[0] = dummy_chan_num; - uint16 initial_hk_cmd_counter = Any_uint16(); - CF_AppData.hk.counters.cmd = initial_hk_cmd_counter; /* Act */ @@ -1094,11 +1087,11 @@ void Test_CF_FindTransactionBySequenceNumberAllChannels_Return_TransactionFound( CF_Transaction_t dummy_return_value; CF_Transaction_t * local_result; CF_Transaction_t * expected_result = &dummy_return_value; + int i = 0; CF_FindTransactionBySequenceNumber_context_t contexts_CF_CFDP_FTBSN[CF_NUM_CHANNELS]; /* set non-matching transactions */ - int i = 0; for (i = 0; i < number_transaction_match; ++i) { contexts_CF_CFDP_FTBSN[i].forced_return = NULL; @@ -1145,6 +1138,9 @@ void Test_CF_TsnChanAction_SendEvent_cmd_chan_Eq_CF_COMPOUND_KEY_TransactionNotF CF_TsnChanAction_fn_t arg_fn = &Dummy_CF_TsnChanAction_fn_t; int dummy_context; void * arg_context = &dummy_context; + int i = 0; + + CF_FindTransactionBySequenceNumber_context_t contexts_CF_CFDP_FTBSN[CF_NUM_CHANNELS]; memset(&utbuf, 0, sizeof(utbuf)); AnyRandomStringOfLettersOfLengthCopy(dummy_cmdstr, 10); @@ -1153,10 +1149,7 @@ void Test_CF_TsnChanAction_SendEvent_cmd_chan_Eq_CF_COMPOUND_KEY_TransactionNotF arg_cmd->chan = CF_COMPOUND_KEY; /* Arrange unstubbable: CF_FindTransactionBySequenceNumberAllChannels */ - CF_FindTransactionBySequenceNumber_context_t contexts_CF_CFDP_FTBSN[CF_NUM_CHANNELS]; - /* set non-matching transactions */ - int i = 0; for (i = 0; i < CF_NUM_CHANNELS; ++i) { contexts_CF_CFDP_FTBSN[i].forced_return = NULL; @@ -1659,8 +1652,9 @@ void Test_CF_CmdEnableDequeue_Success(void) { /* Arrange */ CF_UT_cmd_unionargs_buf_t utbuf; - CF_UnionArgsCmd_t * dummy_msg = &utbuf.ua; - CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_UnionArgsCmd_t * dummy_msg = &utbuf.ua; + CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + uint16 initial_hk_cmd_counter = Any_uint16(); /* Arrange unstubbable: CF_DoEnableDisableDequeue via CF_DoChanAction */ CF_ConfigTable_t dummy_config_table; @@ -1674,8 +1668,6 @@ void Test_CF_CmdEnableDequeue_Success(void) /* Arrange unstubbable: CF_DoChanAction */ dummy_msg->data.byte[0] = dummy_chan_num; - uint16 initial_hk_cmd_counter = Any_uint16(); - CF_AppData.hk.counters.cmd = initial_hk_cmd_counter; /* Act */ @@ -1734,8 +1726,9 @@ void Test_CF_CmdDisableDequeue_Success(void) { /* Arrange */ CF_UT_cmd_unionargs_buf_t utbuf; - CF_UnionArgsCmd_t * dummy_msg = &utbuf.ua; - CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_UnionArgsCmd_t * dummy_msg = &utbuf.ua; + CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + uint16 initial_hk_cmd_counter = Any_uint16(); /* Arrange unstubbable: CF_DoEnableDisableDequeue via CF_DoChanAction */ CF_ConfigTable_t dummy_config_table; @@ -1749,8 +1742,6 @@ void Test_CF_CmdDisableDequeue_Success(void) /* Arrange unstubbable: CF_DoChanAction */ dummy_msg->data.byte[0] = dummy_chan_num; - uint16 initial_hk_cmd_counter = Any_uint16(); - CF_AppData.hk.counters.cmd = initial_hk_cmd_counter; /* Act */ @@ -1807,13 +1798,14 @@ void Test_CF_CmdDisableDequeue_Failure(void) void Test_CF_DoEnableDisablePolldir_When_CF_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; CF_ChanAction_BoolMsgArg_t dummy_context; CF_ChanAction_BoolMsgArg_t *arg_context = &dummy_context; CF_ConfigTable_t dummy_config_table; + uint8 arg_chan_num = Any_cf_channel(); uint8 expected_enabled; + uint8 current_polldir = 0; int local_result; memset(&utbuf, 0, sizeof(utbuf)); @@ -1831,8 +1823,6 @@ void Test_CF_DoEnableDisablePolldir_When_CF_ALL_CHANNELS_SetAllPolldirsInChannel local_result = CF_DoEnableDisablePolldir(arg_chan_num, arg_context); /* Assert */ - uint8 current_polldir = 0; - for (current_polldir = 0; current_polldir < CF_MAX_POLLING_DIR_PER_CHAN; ++current_polldir) { UtAssert_True(CF_AppData.config_table->chan[arg_chan_num].polldir[current_polldir].enabled == expected_enabled, @@ -1949,8 +1939,9 @@ void Test_CF_CmdEnablePolldir_SuccessWhenActionSuccess(void) uint8 dummy_channel = Any_cf_channel(); uint8 dummy_polldir = Any_cf_polldir(); CF_UT_cmd_unionargs_buf_t utbuf; - CF_UnionArgsCmd_t * dummy_msg = &utbuf.ua; - CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_UnionArgsCmd_t * dummy_msg = &utbuf.ua; + CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + uint16 initial_hk_cmd_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); memset(&dummy_config_table, 0, sizeof(dummy_config_table)); @@ -1963,8 +1954,6 @@ void Test_CF_CmdEnablePolldir_SuccessWhenActionSuccess(void) /* Arrange unstubbable: CF_DoEnableDisablePolldir */ dummy_msg->data.byte[1] = dummy_polldir; - uint16 initial_hk_cmd_counter = Any_uint16(); - CF_AppData.hk.counters.cmd = initial_hk_cmd_counter; /* Act */ @@ -1988,8 +1977,9 @@ void Test_CF_CmdEnablePolldir_FailWhenActionFail(void) uint8 dummy_channel = Any_cf_channel(); uint8 error_polldir = Any_uint8_BetweenInclusive(CF_MAX_POLLING_DIR_PER_CHAN, CF_ALL_CHANNELS - 1); CF_UT_cmd_unionargs_buf_t utbuf; - CF_UnionArgsCmd_t * dummy_msg = &utbuf.ua; - CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_UnionArgsCmd_t * dummy_msg = &utbuf.ua; + CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + uint16 initial_hk_err_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); @@ -1999,8 +1989,6 @@ void Test_CF_CmdEnablePolldir_FailWhenActionFail(void) /* Arrange unstubbable: CF_DoEnableDisablePolldir */ dummy_msg->data.byte[1] = error_polldir; - uint16 initial_hk_err_counter = Any_uint16(); - CF_AppData.hk.counters.err = initial_hk_err_counter; /* Act */ @@ -2030,8 +2018,9 @@ void Test_CF_CmdDisablePolldir_SuccessWhenActionSuccess(void) uint8 dummy_channel = Any_cf_channel(); uint8 dummy_polldir = Any_cf_polldir(); CF_UT_cmd_unionargs_buf_t utbuf; - CF_UnionArgsCmd_t * dummy_msg = &utbuf.ua; - CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_UnionArgsCmd_t * dummy_msg = &utbuf.ua; + CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + uint16 initial_hk_cmd_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); memset(&dummy_config_table, 0, sizeof(dummy_config_table)); @@ -2044,8 +2033,6 @@ void Test_CF_CmdDisablePolldir_SuccessWhenActionSuccess(void) /* Arrange unstubbable: CF_DoEnableDisablePolldir */ dummy_msg->data.byte[1] = dummy_polldir; - uint16 initial_hk_cmd_counter = Any_uint16(); - CF_AppData.hk.counters.cmd = initial_hk_cmd_counter; /* Act */ @@ -2069,8 +2056,9 @@ void Test_CF_CmdDisablePolldir_FailWhenActionFail(void) uint8 dummy_channel = Any_cf_channel(); uint8 error_polldir = Any_uint8_BetweenInclusive(CF_MAX_POLLING_DIR_PER_CHAN, CF_ALL_CHANNELS - 1); CF_UT_cmd_unionargs_buf_t utbuf; - CF_UnionArgsCmd_t * dummy_msg = &utbuf.ua; - CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_UnionArgsCmd_t * dummy_msg = &utbuf.ua; + CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + uint16 initial_hk_err_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); @@ -2080,8 +2068,6 @@ void Test_CF_CmdDisablePolldir_FailWhenActionFail(void) /* Arrange unstubbable: CF_DoEnableDisablePolldir */ dummy_msg->data.byte[1] = error_polldir; - uint16 initial_hk_err_counter = Any_uint16(); - CF_AppData.hk.counters.err = initial_hk_err_counter; /* Act */ @@ -2341,8 +2327,9 @@ void Test_CF_CmdPurgeQueue_FailWhenActionFail(void) uint8 dummy_channel = Any_cf_channel(); uint8 error_purge = 3; /* Shortest return from CF_DoPurgeQueue */ CF_UT_cmd_unionargs_buf_t utbuf; - CF_UnionArgsCmd_t * dummy_msg = &utbuf.ua; - CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_UnionArgsCmd_t * dummy_msg = &utbuf.ua; + CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + uint16 initial_hk_err_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); @@ -2352,8 +2339,6 @@ void Test_CF_CmdPurgeQueue_FailWhenActionFail(void) /* Arrange unstubbable: CF_DoPurgeQueue */ dummy_msg->data.byte[1] = error_purge; - uint16 initial_hk_err_counter = Any_uint16(); - CF_AppData.hk.counters.err = initial_hk_err_counter; /* Act */ @@ -2404,16 +2389,15 @@ void Test_CF_CmdWriteQueue_When_chan_Eq_CF_NUM_CAHNNELS_SendEventAndRejectComman { /* Arrange */ CF_UT_cmd_write_q_buf_t utbuf; - CF_WriteQueueCmd_t * dummy_wq = &utbuf.wq; - CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_WriteQueueCmd_t * dummy_wq = &utbuf.wq; + CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + uint16 initial_hk_err_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); /* invalid channel */ dummy_wq->chan = CF_NUM_CHANNELS; - uint16 initial_hk_err_counter = Any_uint16(); - CF_AppData.hk.counters.err = initial_hk_err_counter; /* Act */ @@ -2430,16 +2414,15 @@ void Test_CF_CmdWriteQueue_When_chan_GreaterThan_CF_NUM_CAHNNELS_SendEventAndRej { /* Arrange */ CF_UT_cmd_write_q_buf_t utbuf; - CF_WriteQueueCmd_t * dummy_wq = &utbuf.wq; - CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_WriteQueueCmd_t * dummy_wq = &utbuf.wq; + CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + uint16 initial_hk_err_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); /* invalid channel */ dummy_wq->chan = Any_uint8_GreaterThan(CF_NUM_CHANNELS); - uint16 initial_hk_err_counter = Any_uint16(); - CF_AppData.hk.counters.err = initial_hk_err_counter; /* Act */ @@ -2457,8 +2440,9 @@ void Test_CF_CmdWriteQueue_WhenUpAndPendingQueueSendEventAndRejectCommand(void) { /* Arrange */ CF_UT_cmd_write_q_buf_t utbuf; - CF_WriteQueueCmd_t * dummy_wq = &utbuf.wq; - CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_WriteQueueCmd_t * dummy_wq = &utbuf.wq; + CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + uint16 initial_hk_err_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); @@ -2469,8 +2453,6 @@ void Test_CF_CmdWriteQueue_WhenUpAndPendingQueueSendEventAndRejectCommand(void) dummy_wq->type = CF_Type_up; dummy_wq->queue = CF_Queue_pend; - uint16 initial_hk_err_counter = Any_uint16(); - CF_AppData.hk.counters.err = initial_hk_err_counter; /* Act */ @@ -2488,9 +2470,11 @@ void Test_CF_CmdWriteQueue_When_CF_WrappedCreat_Fails_type_Is_type_up_And_queue_ void) { /* Arrange */ - CF_UT_cmd_write_q_buf_t utbuf; - CF_WriteQueueCmd_t * dummy_wq = &utbuf.wq; - CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_UT_cmd_write_q_buf_t utbuf; + CF_WriteQueueCmd_t * dummy_wq = &utbuf.wq; + CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; + CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + uint16 initial_hk_err_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); @@ -2504,13 +2488,10 @@ void Test_CF_CmdWriteQueue_When_CF_WrappedCreat_Fails_type_Is_type_up_And_queue_ /* invalid result from CF_WrappedCreat */ strncpy(dummy_wq->filename, AnyRandomStringOfLettersOfLength(10), 10); - CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; - context_CF_WrappedOpenCreate.forced_return = Any_int_Negative(); UT_SetDataBuffer(UT_KEY(CF_WrappedOpenCreate), &context_CF_WrappedOpenCreate, sizeof(context_CF_WrappedOpenCreate), false); - uint16 initial_hk_err_counter = Any_uint16(); CF_AppData.hk.counters.err = initial_hk_err_counter; @@ -2533,9 +2514,11 @@ void Test_CF_CmdWriteQueue_When_CF_WrappedCreat_Fails_type_IsNot_type_up_And_que void) { /* Arrange */ - CF_UT_cmd_write_q_buf_t utbuf; - CF_WriteQueueCmd_t * dummy_wq = &utbuf.wq; - CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_UT_cmd_write_q_buf_t utbuf; + CF_WriteQueueCmd_t * dummy_wq = &utbuf.wq; + CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; + CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + uint16 initial_hk_err_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); @@ -2549,15 +2532,11 @@ void Test_CF_CmdWriteQueue_When_CF_WrappedCreat_Fails_type_IsNot_type_up_And_que /* invalid result from CF_WrappedCreat */ strncpy(dummy_wq->filename, AnyRandomStringOfLettersOfLength(10), 10); - CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; - context_CF_WrappedOpenCreate.forced_return = Any_int_Negative(); UT_SetDataBuffer(UT_KEY(CF_WrappedOpenCreate), &context_CF_WrappedOpenCreate, sizeof(context_CF_WrappedOpenCreate), false); - uint16 initial_hk_err_counter = Any_uint16(); - CF_AppData.hk.counters.err = initial_hk_err_counter; /* Act */ @@ -2579,9 +2558,13 @@ void Test_CF_CmdWriteQueue_When_wq_IsAllAnd_queue_IsAll_fd_Is_0_Call_CF_WrappedC void) { /* Arrange */ - CF_UT_cmd_write_q_buf_t utbuf; - CF_WriteQueueCmd_t * dummy_wq = &utbuf.wq; - CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_UT_cmd_write_q_buf_t utbuf; + CF_WriteQueueCmd_t * dummy_wq = &utbuf.wq; + CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; + CF_WriteTxnQueueDataToFile_context_t context_CF_WriteTxnQueueDataToFile; + int32 forced_return_CF_WriteTxnQueueDataToFile = Any_int32_Except(0); + uint16 initial_hk_err_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); @@ -2595,23 +2578,16 @@ void Test_CF_CmdWriteQueue_When_wq_IsAllAnd_queue_IsAll_fd_Is_0_Call_CF_WrappedC /* valid result from CF_WrappedCreat */ strncpy(dummy_wq->filename, AnyRandomStringOfLettersOfLength(10), 10); - CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; - context_CF_WrappedOpenCreate.forced_return = 0; UT_SetDataBuffer(UT_KEY(CF_WrappedOpenCreate), &context_CF_WrappedOpenCreate, sizeof(context_CF_WrappedOpenCreate), false); /* invalid result from CF_WriteTxnQueueDataToFile */ - int32 forced_return_CF_WriteTxnQueueDataToFile = Any_int32_Except(0); - CF_WriteTxnQueueDataToFile_context_t context_CF_WriteTxnQueueDataToFile; - UT_SetDataBuffer(UT_KEY(CF_WriteTxnQueueDataToFile), &context_CF_WriteTxnQueueDataToFile, sizeof(context_CF_WriteTxnQueueDataToFile), false); UT_SetDefaultReturnValue(UT_KEY(CF_WriteTxnQueueDataToFile), forced_return_CF_WriteTxnQueueDataToFile); - uint16 initial_hk_err_counter = Any_uint16(); - CF_AppData.hk.counters.err = initial_hk_err_counter; /* Act */ @@ -2632,9 +2608,14 @@ void Test_CF_CmdWriteQueue_When_CF_WriteTxnQueueDataToFile_FailsAnd_wq_IsUpAnd_q void) { /* Arrange */ - CF_UT_cmd_write_q_buf_t utbuf; - CF_WriteQueueCmd_t * dummy_wq = &utbuf.wq; - CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_UT_cmd_write_q_buf_t utbuf; + CF_WriteQueueCmd_t * dummy_wq = &utbuf.wq; + CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; + CF_WriteTxnQueueDataToFile_context_t context_CF_WriteTxnQueueDataToFile; + int32 forced_return_CF_WriteTxnQueueDataToFile = Any_int32_Except(0); + int32 context_CF_WrappedClose_fd; + uint16 initial_hk_err_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); @@ -2648,27 +2629,18 @@ void Test_CF_CmdWriteQueue_When_CF_WriteTxnQueueDataToFile_FailsAnd_wq_IsUpAnd_q /* valid result from CF_WrappedCreat */ strncpy(dummy_wq->filename, AnyRandomStringOfLettersOfLength(10), 10); - CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; - context_CF_WrappedOpenCreate.forced_return = Any_int_Positive(); UT_SetDataBuffer(UT_KEY(CF_WrappedOpenCreate), &context_CF_WrappedOpenCreate, sizeof(context_CF_WrappedOpenCreate), false); /* invalid result from CF_WriteTxnQueueDataToFile */ - int32 forced_return_CF_WriteTxnQueueDataToFile = Any_int32_Except(0); - CF_WriteTxnQueueDataToFile_context_t context_CF_WriteTxnQueueDataToFile; - UT_SetDataBuffer(UT_KEY(CF_WriteTxnQueueDataToFile), &context_CF_WriteTxnQueueDataToFile, sizeof(context_CF_WriteTxnQueueDataToFile), false); UT_SetDefaultReturnValue(UT_KEY(CF_WriteTxnQueueDataToFile), forced_return_CF_WriteTxnQueueDataToFile); - int32 context_CF_WrappedClose_fd; - UT_SetDataBuffer(UT_KEY(CF_WrappedClose), &context_CF_WrappedClose_fd, sizeof(context_CF_WrappedClose_fd), false); - uint16 initial_hk_err_counter = Any_uint16(); - CF_AppData.hk.counters.err = initial_hk_err_counter; /* Act */ @@ -2689,9 +2661,14 @@ void Test_CF_CmdWriteQueue_When_CF_WriteHistoryQueueDataToFile_FailsAnd_wq_IsUpA void) { /* Arrange */ - CF_UT_cmd_write_q_buf_t utbuf; - CF_WriteQueueCmd_t * dummy_wq = &utbuf.wq; - CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_UT_cmd_write_q_buf_t utbuf; + CF_WriteQueueCmd_t * dummy_wq = &utbuf.wq; + CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; + CF_WriteHistoryQueueDataToFile_context_t context_CF_WriteHistoryQueueDataToFile; + int32 forced_return_CF_WriteHistoryQueueDataToFile = Any_int32_Except(0); + int32 context_CF_WrappedClose_fd; + uint16 initial_hk_err_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); @@ -2705,27 +2682,18 @@ void Test_CF_CmdWriteQueue_When_CF_WriteHistoryQueueDataToFile_FailsAnd_wq_IsUpA /* valid result from CF_WrappedCreat */ strncpy(dummy_wq->filename, AnyRandomStringOfLettersOfLength(10), 10); - CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; - context_CF_WrappedOpenCreate.forced_return = Any_int_Positive(); UT_SetDataBuffer(UT_KEY(CF_WrappedOpenCreate), &context_CF_WrappedOpenCreate, sizeof(context_CF_WrappedOpenCreate), false); /* invalid result from CF_WriteHistoryQueueDataToFile */ - int32 forced_return_CF_WriteHistoryQueueDataToFile = Any_int32_Except(0); - CF_WriteHistoryQueueDataToFile_context_t context_CF_WriteHistoryQueueDataToFile; - UT_SetDataBuffer(UT_KEY(CF_WriteHistoryQueueDataToFile), &context_CF_WriteHistoryQueueDataToFile, sizeof(context_CF_WriteHistoryQueueDataToFile), false); UT_SetDefaultReturnValue(UT_KEY(CF_WriteHistoryQueueDataToFile), forced_return_CF_WriteHistoryQueueDataToFile); - int32 context_CF_WrappedClose_fd; - UT_SetDataBuffer(UT_KEY(CF_WrappedClose), &context_CF_WrappedClose_fd, sizeof(context_CF_WrappedClose_fd), false); - uint16 initial_hk_err_counter = Any_uint16(); - CF_AppData.hk.counters.err = initial_hk_err_counter; /* Act */ @@ -2746,9 +2714,14 @@ void Test_CF_CmdWriteQueue_When_CF_WriteHistoryDataToFile_FailsOnFirstCallAnd_wq void) { /* Arrange */ - CF_UT_cmd_write_q_buf_t utbuf; - CF_WriteQueueCmd_t * dummy_wq = &utbuf.wq; - CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_UT_cmd_write_q_buf_t utbuf; + CF_WriteQueueCmd_t * dummy_wq = &utbuf.wq; + CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; + CF_WriteTxnQueueDataToFile_context_t context_CF_WriteTxnQueueDataToFile; + int32 forced_return_CF_WriteTxnQueueDataToFile = Any_int32_Except(0); + int32 context_CF_WrappedClose_fd; + uint16 initial_hk_err_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); @@ -2762,27 +2735,18 @@ void Test_CF_CmdWriteQueue_When_CF_WriteHistoryDataToFile_FailsOnFirstCallAnd_wq /* valid result from CF_WrappedCreat */ strncpy(dummy_wq->filename, AnyRandomStringOfLettersOfLength(10), 10); - CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; - context_CF_WrappedOpenCreate.forced_return = Any_int_Positive(); UT_SetDataBuffer(UT_KEY(CF_WrappedOpenCreate), &context_CF_WrappedOpenCreate, sizeof(context_CF_WrappedOpenCreate), false); /* invalid result from CF_WriteTxnQueueDataToFile */ - int32 forced_return_CF_WriteTxnQueueDataToFile = Any_int32_Except(0); - CF_WriteTxnQueueDataToFile_context_t context_CF_WriteTxnQueueDataToFile; - UT_SetDataBuffer(UT_KEY(CF_WriteTxnQueueDataToFile), &context_CF_WriteTxnQueueDataToFile, sizeof(context_CF_WriteTxnQueueDataToFile), false); UT_SetDefaultReturnValue(UT_KEY(CF_WriteTxnQueueDataToFile), forced_return_CF_WriteTxnQueueDataToFile); - int32 context_CF_WrappedClose_fd; - UT_SetDataBuffer(UT_KEY(CF_WrappedClose), &context_CF_WrappedClose_fd, sizeof(context_CF_WrappedClose_fd), false); - uint16 initial_hk_err_counter = Any_uint16(); - CF_AppData.hk.counters.err = initial_hk_err_counter; /* Act */ @@ -2803,9 +2767,15 @@ void Test_CF_CmdWriteQueue_When_CF_WriteHistoryDataToFile_FailsOnSecondCallAnd_w void) { /* Arrange */ - CF_UT_cmd_write_q_buf_t utbuf; - CF_WriteQueueCmd_t * dummy_wq = &utbuf.wq; - CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_UT_cmd_write_q_buf_t utbuf; + CF_WriteQueueCmd_t * dummy_wq = &utbuf.wq; + CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; + CF_WriteTxnQueueDataToFile_context_t context_CF_WriteTxnQueueDataToFile[2]; + int32 forced_return_CF_WriteTxnQueueDataToFile_1st_call = 0; + int32 forced_return_CF_WriteTxnQueueDataToFile_2nd_call = Any_int32_Except(0); + int32 context_CF_WrappedClose_fd; + uint16 initial_hk_err_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); @@ -2819,29 +2789,19 @@ void Test_CF_CmdWriteQueue_When_CF_WriteHistoryDataToFile_FailsOnSecondCallAnd_w /* valid result from CF_WrappedCreat */ strncpy(dummy_wq->filename, AnyRandomStringOfLettersOfLength(10), 10); - CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; - context_CF_WrappedOpenCreate.forced_return = Any_int_Positive(); UT_SetDataBuffer(UT_KEY(CF_WrappedOpenCreate), &context_CF_WrappedOpenCreate, sizeof(context_CF_WrappedOpenCreate), false); /* invalid result from CF_WriteTxnQueueDataToFile */ - int32 forced_return_CF_WriteTxnQueueDataToFile_1st_call = 0; - int32 forced_return_CF_WriteTxnQueueDataToFile_2nd_call = Any_int32_Except(0); - CF_WriteTxnQueueDataToFile_context_t context_CF_WriteTxnQueueDataToFile[2]; - UT_SetDataBuffer(UT_KEY(CF_WriteTxnQueueDataToFile), &context_CF_WriteTxnQueueDataToFile, sizeof(context_CF_WriteTxnQueueDataToFile), false); UT_SetDefaultReturnValue(UT_KEY(CF_WriteTxnQueueDataToFile), forced_return_CF_WriteTxnQueueDataToFile_1st_call); UT_SetDeferredRetcode(UT_KEY(CF_WriteTxnQueueDataToFile), 2, forced_return_CF_WriteTxnQueueDataToFile_2nd_call); - int32 context_CF_WrappedClose_fd; - UT_SetDataBuffer(UT_KEY(CF_WrappedClose), &context_CF_WrappedClose_fd, sizeof(context_CF_WrappedClose_fd), false); - uint16 initial_hk_err_counter = Any_uint16(); - CF_AppData.hk.counters.err = initial_hk_err_counter; /* Act */ @@ -2862,9 +2822,14 @@ void Test_CF_CmdWriteQueue_When_CF_WriteHistoryQueueDataToFile_FailsAnd_wq_IsDow void) { /* Arrange */ - CF_UT_cmd_write_q_buf_t utbuf; - CF_WriteQueueCmd_t * dummy_wq = &utbuf.wq; - CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_UT_cmd_write_q_buf_t utbuf; + CF_WriteQueueCmd_t * dummy_wq = &utbuf.wq; + CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; + CF_WriteTxnQueueDataToFile_context_t context_CF_WriteTxnQueueDataToFile; + int32 forced_return_CF_WriteTxnQueueDataToFile = Any_int32_Except(0); + int32 context_CF_WrappedClose_fd; + uint16 initial_hk_err_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); @@ -2878,27 +2843,18 @@ void Test_CF_CmdWriteQueue_When_CF_WriteHistoryQueueDataToFile_FailsAnd_wq_IsDow /* valid result from CF_WrappedCreat */ strncpy(dummy_wq->filename, AnyRandomStringOfLettersOfLength(10), 10); - CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; - context_CF_WrappedOpenCreate.forced_return = Any_int_Positive(); UT_SetDataBuffer(UT_KEY(CF_WrappedOpenCreate), &context_CF_WrappedOpenCreate, sizeof(context_CF_WrappedOpenCreate), false); /* invalid result from CF_WriteTxnQueueDataToFile */ - int32 forced_return_CF_WriteTxnQueueDataToFile = Any_int32_Except(0); - CF_WriteTxnQueueDataToFile_context_t context_CF_WriteTxnQueueDataToFile; - UT_SetDataBuffer(UT_KEY(CF_WriteTxnQueueDataToFile), &context_CF_WriteTxnQueueDataToFile, sizeof(context_CF_WriteTxnQueueDataToFile), false); UT_SetDefaultReturnValue(UT_KEY(CF_WriteTxnQueueDataToFile), forced_return_CF_WriteTxnQueueDataToFile); - int32 context_CF_WrappedClose_fd; - UT_SetDataBuffer(UT_KEY(CF_WrappedClose), &context_CF_WrappedClose_fd, sizeof(context_CF_WrappedClose_fd), false); - uint16 initial_hk_err_counter = Any_uint16(); - CF_AppData.hk.counters.err = initial_hk_err_counter; /* Act */ @@ -2919,9 +2875,14 @@ void Test_CF_CmdWriteQueue_When_CF_WriteHistoryQueueDataToFile_FailsAnd_wq_IsDow void) { /* Arrange */ - CF_UT_cmd_write_q_buf_t utbuf; - CF_WriteQueueCmd_t * dummy_wq = &utbuf.wq; - CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_UT_cmd_write_q_buf_t utbuf; + CF_WriteQueueCmd_t * dummy_wq = &utbuf.wq; + CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; + CF_WriteHistoryQueueDataToFile_context_t context_CF_WriteHistoryQueueDataToFile; + int32 forced_return_CF_WriteHistoryQueueDataToFile = Any_int32_Except(0); + int32 context_CF_WrappedClose_fd; + uint16 initial_hk_err_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); @@ -2935,27 +2896,18 @@ void Test_CF_CmdWriteQueue_When_CF_WriteHistoryQueueDataToFile_FailsAnd_wq_IsDow /* valid result from CF_WrappedCreat */ strncpy(dummy_wq->filename, AnyRandomStringOfLettersOfLength(10), 10); - CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; - context_CF_WrappedOpenCreate.forced_return = Any_int_Positive(); UT_SetDataBuffer(UT_KEY(CF_WrappedOpenCreate), &context_CF_WrappedOpenCreate, sizeof(context_CF_WrappedOpenCreate), false); /* invalid result from CF_WriteHistoryQueueDataToFile */ - int32 forced_return_CF_WriteHistoryQueueDataToFile = Any_int32_Except(0); - CF_WriteHistoryQueueDataToFile_context_t context_CF_WriteHistoryQueueDataToFile; - UT_SetDataBuffer(UT_KEY(CF_WriteHistoryQueueDataToFile), &context_CF_WriteHistoryQueueDataToFile, sizeof(context_CF_WriteHistoryQueueDataToFile), false); UT_SetDefaultReturnValue(UT_KEY(CF_WriteHistoryQueueDataToFile), forced_return_CF_WriteHistoryQueueDataToFile); - int32 context_CF_WrappedClose_fd; - UT_SetDataBuffer(UT_KEY(CF_WrappedClose), &context_CF_WrappedClose_fd, sizeof(context_CF_WrappedClose_fd), false); - uint16 initial_hk_err_counter = Any_uint16(); - CF_AppData.hk.counters.err = initial_hk_err_counter; /* Act */ @@ -2975,9 +2927,13 @@ void Test_CF_CmdWriteQueue_When_CF_WriteHistoryQueueDataToFile_FailsAnd_wq_IsDow void Test_CF_CmdWriteQueue_Success_type_AllAnd_q_All(void) { /* Arrange */ - CF_UT_cmd_write_q_buf_t utbuf; - CF_WriteQueueCmd_t * dummy_wq = &utbuf.wq; - CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_UT_cmd_write_q_buf_t utbuf; + CF_WriteQueueCmd_t * dummy_wq = &utbuf.wq; + CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; + int32 forced_return_CF_WriteTxnQueueDataToFile = 0; + int32 forced_return_CF_WriteHistoryQueueDataToFile = 0; + uint16 initial_hk_cmd_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); @@ -2991,25 +2947,17 @@ void Test_CF_CmdWriteQueue_Success_type_AllAnd_q_All(void) /* valid result from CF_WrappedCreat */ strncpy(dummy_wq->filename, AnyRandomStringOfLettersOfLength(10), 10); - CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; - context_CF_WrappedOpenCreate.forced_return = Any_int_Positive(); UT_SetDataBuffer(UT_KEY(CF_WrappedOpenCreate), &context_CF_WrappedOpenCreate, sizeof(context_CF_WrappedOpenCreate), false); /* valid result from CF_WriteTxnQueueDataToFile */ - int32 forced_return_CF_WriteTxnQueueDataToFile = 0; - UT_SetDefaultReturnValue(UT_KEY(CF_WriteTxnQueueDataToFile), forced_return_CF_WriteTxnQueueDataToFile); /* valid result from CF_WriteHistoryQueueDataToFile */ - int32 forced_return_CF_WriteHistoryQueueDataToFile = 0; - UT_SetDefaultReturnValue(UT_KEY(CF_WriteHistoryQueueDataToFile), forced_return_CF_WriteHistoryQueueDataToFile); - uint16 initial_hk_cmd_counter = Any_uint16(); - CF_AppData.hk.counters.cmd = initial_hk_cmd_counter; /* Act */ @@ -3029,9 +2977,12 @@ void Test_CF_CmdWriteQueue_Success_type_AllAnd_q_All(void) void Test_CF_CmdWriteQueue_Success_type_AllAnd_q_History(void) { /* Arrange */ - CF_UT_cmd_write_q_buf_t utbuf; - CF_WriteQueueCmd_t * dummy_wq = &utbuf.wq; - CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_UT_cmd_write_q_buf_t utbuf; + CF_WriteQueueCmd_t * dummy_wq = &utbuf.wq; + CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; + int32 forced_return_CF_WriteHistoryQueueDataToFile = 0; + uint16 initial_hk_cmd_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); @@ -3045,20 +2996,14 @@ void Test_CF_CmdWriteQueue_Success_type_AllAnd_q_History(void) /* valid result from CF_WrappedCreat */ strncpy(dummy_wq->filename, AnyRandomStringOfLettersOfLength(10), 10); - CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; - context_CF_WrappedOpenCreate.forced_return = Any_int_Positive(); UT_SetDataBuffer(UT_KEY(CF_WrappedOpenCreate), &context_CF_WrappedOpenCreate, sizeof(context_CF_WrappedOpenCreate), false); /* valid result from CF_WriteHistoryQueueDataToFile */ - int32 forced_return_CF_WriteHistoryQueueDataToFile = 0; - UT_SetDefaultReturnValue(UT_KEY(CF_WriteHistoryQueueDataToFile), forced_return_CF_WriteHistoryQueueDataToFile); - uint16 initial_hk_cmd_counter = Any_uint16(); - CF_AppData.hk.counters.cmd = initial_hk_cmd_counter; /* Act */ @@ -3078,9 +3023,12 @@ void Test_CF_CmdWriteQueue_Success_type_AllAnd_q_History(void) void Test_CF_CmdWriteQueue_Success_type_AllAnd_q_Active(void) { /* Arrange */ - CF_UT_cmd_write_q_buf_t utbuf; - CF_WriteQueueCmd_t * dummy_wq = &utbuf.wq; - CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_UT_cmd_write_q_buf_t utbuf; + CF_WriteQueueCmd_t * dummy_wq = &utbuf.wq; + CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; + int32 forced_return_CF_WriteTxnQueueDataToFile = 0; + uint16 initial_hk_cmd_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); @@ -3094,20 +3042,14 @@ void Test_CF_CmdWriteQueue_Success_type_AllAnd_q_Active(void) /* valid result from CF_WrappedCreat */ strncpy(dummy_wq->filename, AnyRandomStringOfLettersOfLength(10), 10); - CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; - context_CF_WrappedOpenCreate.forced_return = Any_int_Positive(); UT_SetDataBuffer(UT_KEY(CF_WrappedOpenCreate), &context_CF_WrappedOpenCreate, sizeof(context_CF_WrappedOpenCreate), false); /* valid result from CF_WriteTxnQueueDataToFile */ - int32 forced_return_CF_WriteTxnQueueDataToFile = 0; - UT_SetDefaultReturnValue(UT_KEY(CF_WriteTxnQueueDataToFile), forced_return_CF_WriteTxnQueueDataToFile); - uint16 initial_hk_cmd_counter = Any_uint16(); - CF_AppData.hk.counters.cmd = initial_hk_cmd_counter; /* Act */ @@ -3127,9 +3069,12 @@ void Test_CF_CmdWriteQueue_Success_type_AllAnd_q_Active(void) void Test_CF_CmdWriteQueue_Success_type_AllAnd_q_Pend(void) { /* Arrange */ - CF_UT_cmd_write_q_buf_t utbuf; - CF_WriteQueueCmd_t * dummy_wq = &utbuf.wq; - CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_UT_cmd_write_q_buf_t utbuf; + CF_WriteQueueCmd_t * dummy_wq = &utbuf.wq; + CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; + int32 forced_return_CF_WriteTxnQueueDataToFile = 0; + uint16 initial_hk_cmd_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); @@ -3143,20 +3088,14 @@ void Test_CF_CmdWriteQueue_Success_type_AllAnd_q_Pend(void) /* valid result from CF_WrappedCreat */ strncpy(dummy_wq->filename, AnyRandomStringOfLettersOfLength(10), 10); - CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; - context_CF_WrappedOpenCreate.forced_return = Any_int_Positive(); UT_SetDataBuffer(UT_KEY(CF_WrappedOpenCreate), &context_CF_WrappedOpenCreate, sizeof(context_CF_WrappedOpenCreate), false); /* valid result from CF_WriteTxnQueueDataToFile */ - int32 forced_return_CF_WriteTxnQueueDataToFile = 0; - UT_SetDefaultReturnValue(UT_KEY(CF_WriteTxnQueueDataToFile), forced_return_CF_WriteTxnQueueDataToFile); - uint16 initial_hk_cmd_counter = Any_uint16(); - CF_AppData.hk.counters.cmd = initial_hk_cmd_counter; /* Act */ @@ -3176,9 +3115,13 @@ void Test_CF_CmdWriteQueue_Success_type_AllAnd_q_Pend(void) void Test_CF_CmdWriteQueue_Success_type_UpAnd_q_All(void) { /* Arrange */ - CF_UT_cmd_write_q_buf_t utbuf; - CF_WriteQueueCmd_t * dummy_wq = &utbuf.wq; - CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_UT_cmd_write_q_buf_t utbuf; + CF_WriteQueueCmd_t * dummy_wq = &utbuf.wq; + CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; + int32 forced_return_CF_WriteTxnQueueDataToFile = 0; + int32 forced_return_CF_WriteHistoryQueueDataToFile = 0; + uint16 initial_hk_cmd_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); @@ -3192,25 +3135,17 @@ void Test_CF_CmdWriteQueue_Success_type_UpAnd_q_All(void) /* valid result from CF_WrappedCreat */ strncpy(dummy_wq->filename, AnyRandomStringOfLettersOfLength(10), 10); - CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; - context_CF_WrappedOpenCreate.forced_return = Any_int_Positive(); UT_SetDataBuffer(UT_KEY(CF_WrappedOpenCreate), &context_CF_WrappedOpenCreate, sizeof(context_CF_WrappedOpenCreate), false); /* valid result from CF_WriteTxnQueueDataToFile */ - int32 forced_return_CF_WriteTxnQueueDataToFile = 0; - UT_SetDefaultReturnValue(UT_KEY(CF_WriteTxnQueueDataToFile), forced_return_CF_WriteTxnQueueDataToFile); /* valid result from CF_WriteHistoryQueueDataToFile */ - int32 forced_return_CF_WriteHistoryQueueDataToFile = 0; - UT_SetDefaultReturnValue(UT_KEY(CF_WriteHistoryQueueDataToFile), forced_return_CF_WriteHistoryQueueDataToFile); - uint16 initial_hk_cmd_counter = Any_uint16(); - CF_AppData.hk.counters.cmd = initial_hk_cmd_counter; /* Act */ @@ -3230,9 +3165,12 @@ void Test_CF_CmdWriteQueue_Success_type_UpAnd_q_All(void) void Test_CF_CmdWriteQueue_Success_type_UpAnd_q_History(void) { /* Arrange */ - CF_UT_cmd_write_q_buf_t utbuf; - CF_WriteQueueCmd_t * dummy_wq = &utbuf.wq; - CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_UT_cmd_write_q_buf_t utbuf; + CF_WriteQueueCmd_t * dummy_wq = &utbuf.wq; + CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; + int32 forced_return_CF_WriteHistoryQueueDataToFile = 0; + uint16 initial_hk_cmd_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); @@ -3246,20 +3184,14 @@ void Test_CF_CmdWriteQueue_Success_type_UpAnd_q_History(void) /* valid result from CF_WrappedCreat */ strncpy(dummy_wq->filename, AnyRandomStringOfLettersOfLength(10), 10); - CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; - context_CF_WrappedOpenCreate.forced_return = Any_int_Positive(); UT_SetDataBuffer(UT_KEY(CF_WrappedOpenCreate), &context_CF_WrappedOpenCreate, sizeof(context_CF_WrappedOpenCreate), false); /* valid result from CF_WriteHistoryQueueDataToFile */ - int32 forced_return_CF_WriteHistoryQueueDataToFile = 0; - UT_SetDefaultReturnValue(UT_KEY(CF_WriteHistoryQueueDataToFile), forced_return_CF_WriteHistoryQueueDataToFile); - uint16 initial_hk_cmd_counter = Any_uint16(); - CF_AppData.hk.counters.cmd = initial_hk_cmd_counter; /* Act */ @@ -3279,9 +3211,12 @@ void Test_CF_CmdWriteQueue_Success_type_UpAnd_q_History(void) void Test_CF_CmdWriteQueue_Success_type_UpAnd_q_Active(void) { /* Arrange */ - CF_UT_cmd_write_q_buf_t utbuf; - CF_WriteQueueCmd_t * dummy_wq = &utbuf.wq; - CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_UT_cmd_write_q_buf_t utbuf; + CF_WriteQueueCmd_t * dummy_wq = &utbuf.wq; + CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; + int32 forced_return_CF_WriteTxnQueueDataToFile = 0; + uint16 initial_hk_cmd_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); @@ -3295,20 +3230,14 @@ void Test_CF_CmdWriteQueue_Success_type_UpAnd_q_Active(void) /* valid result from CF_WrappedCreat */ strncpy(dummy_wq->filename, AnyRandomStringOfLettersOfLength(10), 10); - CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; - context_CF_WrappedOpenCreate.forced_return = Any_int_Positive(); UT_SetDataBuffer(UT_KEY(CF_WrappedOpenCreate), &context_CF_WrappedOpenCreate, sizeof(context_CF_WrappedOpenCreate), false); /* valid result from CF_WriteTxnQueueDataToFile */ - int32 forced_return_CF_WriteTxnQueueDataToFile = 0; - UT_SetDefaultReturnValue(UT_KEY(CF_WriteTxnQueueDataToFile), forced_return_CF_WriteTxnQueueDataToFile); - uint16 initial_hk_cmd_counter = Any_uint16(); - CF_AppData.hk.counters.cmd = initial_hk_cmd_counter; /* Act */ @@ -3330,9 +3259,12 @@ void Test_CF_CmdWriteQueue_Success_type_UpAnd_q_Active(void) void Test_CF_CmdWriteQueue_Success_type_DownAnd_q_All(void) { /* Arrange */ - CF_UT_cmd_write_q_buf_t utbuf; - CF_WriteQueueCmd_t * dummy_wq = &utbuf.wq; - CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_UT_cmd_write_q_buf_t utbuf; + CF_WriteQueueCmd_t * dummy_wq = &utbuf.wq; + CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; + int32 forced_return_CF_WriteTxnQueueDataToFile = 0; + uint16 initial_hk_cmd_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); @@ -3346,20 +3278,14 @@ void Test_CF_CmdWriteQueue_Success_type_DownAnd_q_All(void) /* valid result from CF_WrappedCreat */ strncpy(dummy_wq->filename, AnyRandomStringOfLettersOfLength(10), 10); - CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; - context_CF_WrappedOpenCreate.forced_return = Any_int_Positive(); UT_SetDataBuffer(UT_KEY(CF_WrappedOpenCreate), &context_CF_WrappedOpenCreate, sizeof(context_CF_WrappedOpenCreate), false); /* valid result from CF_WriteTxnQueueDataToFile */ - int32 forced_return_CF_WriteTxnQueueDataToFile = 0; - UT_SetDefaultReturnValue(UT_KEY(CF_WriteTxnQueueDataToFile), forced_return_CF_WriteTxnQueueDataToFile); - uint16 initial_hk_cmd_counter = Any_uint16(); - CF_AppData.hk.counters.cmd = initial_hk_cmd_counter; /* Act */ @@ -3379,9 +3305,12 @@ void Test_CF_CmdWriteQueue_Success_type_DownAnd_q_All(void) void Test_CF_CmdWriteQueue_Success_type_DownAnd_q_History(void) { /* Arrange */ - CF_UT_cmd_write_q_buf_t utbuf; - CF_WriteQueueCmd_t * dummy_wq = &utbuf.wq; - CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_UT_cmd_write_q_buf_t utbuf; + CF_WriteQueueCmd_t * dummy_wq = &utbuf.wq; + CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; + int32 forced_return_CF_WriteTxnQueueDataToFile = 0; + uint16 initial_hk_cmd_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); @@ -3395,20 +3324,14 @@ void Test_CF_CmdWriteQueue_Success_type_DownAnd_q_History(void) /* valid result from CF_WrappedCreat */ strncpy(dummy_wq->filename, AnyRandomStringOfLettersOfLength(10), 10); - CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; - context_CF_WrappedOpenCreate.forced_return = Any_int_Positive(); UT_SetDataBuffer(UT_KEY(CF_WrappedOpenCreate), &context_CF_WrappedOpenCreate, sizeof(context_CF_WrappedOpenCreate), false); /* valid result from CF_WriteTxnQueueDataToFile */ - int32 forced_return_CF_WriteTxnQueueDataToFile = 0; - UT_SetDefaultReturnValue(UT_KEY(CF_WriteTxnQueueDataToFile), forced_return_CF_WriteTxnQueueDataToFile); - uint16 initial_hk_cmd_counter = Any_uint16(); - CF_AppData.hk.counters.cmd = initial_hk_cmd_counter; /* Act */ @@ -3428,9 +3351,12 @@ void Test_CF_CmdWriteQueue_Success_type_DownAnd_q_History(void) void Test_CF_CmdWriteQueue_Success_type_DownAnd_q_Active(void) { /* Arrange */ - CF_UT_cmd_write_q_buf_t utbuf; - CF_WriteQueueCmd_t * dummy_wq = &utbuf.wq; - CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_UT_cmd_write_q_buf_t utbuf; + CF_WriteQueueCmd_t * dummy_wq = &utbuf.wq; + CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; + int32 forced_return_CF_WriteTxnQueueDataToFile = 0; + uint16 initial_hk_cmd_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); @@ -3444,20 +3370,14 @@ void Test_CF_CmdWriteQueue_Success_type_DownAnd_q_Active(void) /* valid result from CF_WrappedCreat */ strncpy(dummy_wq->filename, AnyRandomStringOfLettersOfLength(10), 10); - CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; - context_CF_WrappedOpenCreate.forced_return = Any_int_Positive(); UT_SetDataBuffer(UT_KEY(CF_WrappedOpenCreate), &context_CF_WrappedOpenCreate, sizeof(context_CF_WrappedOpenCreate), false); /* valid result from CF_WriteTxnQueueDataToFile */ - int32 forced_return_CF_WriteTxnQueueDataToFile = 0; - UT_SetDefaultReturnValue(UT_KEY(CF_WriteTxnQueueDataToFile), forced_return_CF_WriteTxnQueueDataToFile); - uint16 initial_hk_cmd_counter = Any_uint16(); - CF_AppData.hk.counters.cmd = initial_hk_cmd_counter; /* Act */ @@ -3477,9 +3397,12 @@ void Test_CF_CmdWriteQueue_Success_type_DownAnd_q_Active(void) void Test_CF_CmdWriteQueue_Success_type_DownAnd_q_Pend(void) { /* Arrange */ - CF_UT_cmd_write_q_buf_t utbuf; - CF_WriteQueueCmd_t * dummy_wq = &utbuf.wq; - CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_UT_cmd_write_q_buf_t utbuf; + CF_WriteQueueCmd_t * dummy_wq = &utbuf.wq; + CFE_SB_Buffer_t * arg_msg = &utbuf.buf; + CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; + int32 forced_return_CF_WriteTxnQueueDataToFile = 0; + uint16 initial_hk_cmd_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); @@ -3493,20 +3416,14 @@ void Test_CF_CmdWriteQueue_Success_type_DownAnd_q_Pend(void) /* valid result from CF_WrappedCreat */ strncpy(dummy_wq->filename, AnyRandomStringOfLettersOfLength(10), 10); - CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; - context_CF_WrappedOpenCreate.forced_return = Any_int_Positive(); UT_SetDataBuffer(UT_KEY(CF_WrappedOpenCreate), &context_CF_WrappedOpenCreate, sizeof(context_CF_WrappedOpenCreate), false); /* valid result from CF_WriteTxnQueueDataToFile */ - int32 forced_return_CF_WriteTxnQueueDataToFile = 0; - UT_SetDefaultReturnValue(UT_KEY(CF_WriteTxnQueueDataToFile), forced_return_CF_WriteTxnQueueDataToFile); - uint16 initial_hk_cmd_counter = Any_uint16(); - CF_AppData.hk.counters.cmd = initial_hk_cmd_counter; /* Act */ @@ -3807,13 +3724,12 @@ void Test_CF_CmdEnableEngine_WithEngineNotEnableInitSuccessAndIncrementCmdCounte /* Arrange */ CFE_SB_Buffer_t *arg_msg = NULL; uint32 forced_return_CF_CFDP_InitEngine = CFE_SUCCESS; + uint16 initial_hk_cmd_counter = Any_uint16(); CF_AppData.engine.enabled = 0; /* 0 is not enabled */ UT_SetDefaultReturnValue(UT_KEY(CF_CFDP_InitEngine), forced_return_CF_CFDP_InitEngine); - uint16 initial_hk_cmd_counter = Any_uint16(); - CF_AppData.hk.counters.cmd = initial_hk_cmd_counter; /* Act */ @@ -3835,13 +3751,12 @@ void Test_CF_CmdEnableEngine_WithEngineNotEnableFailsInitSendEventAndIncrementEr /* Arrange */ CFE_SB_Buffer_t *arg_msg = NULL; uint32 forced_return_CF_CFDP_InitEngine = Any_uint32_Except(CFE_SUCCESS); + uint16 initial_hk_err_counter = Any_uint16(); CF_AppData.engine.enabled = 0; /* 0 is not enabled */ UT_SetDefaultReturnValue(UT_KEY(CF_CFDP_InitEngine), forced_return_CF_CFDP_InitEngine); - uint16 initial_hk_err_counter = Any_uint16(); - CF_AppData.hk.counters.err = initial_hk_err_counter; /* Act */ @@ -3861,12 +3776,11 @@ void Test_CF_CmdEnableEngine_WithEngineNotEnableFailsInitSendEventAndIncrementEr void Test_CF_CmdEnableEngine_WithEngineEnableFailsSendEventAndIncrementErrCounter(void) { /* Arrange */ - CFE_SB_Buffer_t *arg_msg = NULL; + CFE_SB_Buffer_t *arg_msg = NULL; + uint16 initial_hk_err_counter = Any_uint16(); CF_AppData.engine.enabled = 1; /* 1 is enabled */ - uint16 initial_hk_err_counter = Any_uint16(); - CF_AppData.hk.counters.err = initial_hk_err_counter; /* Act */ @@ -3892,12 +3806,11 @@ void Test_CF_CmdEnableEngine_WithEngineEnableFailsSendEventAndIncrementErrCounte void Test_CF_CmdDisableEngine_SuccessWhenEngineEnabledAndIncrementCmdCounter(void) { /* Arrange */ - CFE_SB_Buffer_t *arg_msg = NULL; + CFE_SB_Buffer_t *arg_msg = NULL; + uint16 initial_hk_cmd_counter = Any_uint16(); CF_AppData.engine.enabled = 1; /* 1 is enabled */ - uint16 initial_hk_cmd_counter = Any_uint16(); - CF_AppData.hk.counters.cmd = initial_hk_cmd_counter; /* Act */ @@ -3916,12 +3829,11 @@ void Test_CF_CmdDisableEngine_SuccessWhenEngineEnabledAndIncrementCmdCounter(voi void Test_CF_CmdDisableEngine_WhenEngineDisabledAndIncrementErrCounterThenFail(void) { /* Arrange */ - CFE_SB_Buffer_t *arg_msg = NULL; + CFE_SB_Buffer_t *arg_msg = NULL; + uint16 initial_hk_err_counter = Any_uint16(); CF_AppData.engine.enabled = 0; /* 0 is not enabled */ - uint16 initial_hk_err_counter = Any_uint16(); - CF_AppData.hk.counters.err = initial_hk_err_counter; /* Act */ diff --git a/unit-test/cf_utils_tests.c b/unit-test/cf_utils_tests.c index 7ae727dc..97176d49 100644 --- a/unit-test/cf_utils_tests.c +++ b/unit-test/cf_utils_tests.c @@ -266,6 +266,7 @@ void Test_cf_dequeue_transaction_Call_CF_CList_Remove_AndDecrement_q_size(void) CF_CListNode_t **expected_head; CF_CListNode_t * expected_cl_node; uint16 initial_q_size = Any_uint16_Except(0); /* 0 will CF_Assert */ + uint16 updated_q_size; CF_CList_Remove_context_t context_clist_remove; @@ -282,7 +283,7 @@ void Test_cf_dequeue_transaction_Call_CF_CList_Remove_AndDecrement_q_size(void) /* Act */ CF_DequeueTransaction(&arg_t); - uint16 updated_q_size = CF_AppData.hk.channel_hk[arg_t.chan_num].q_size[arg_t.flags.com.q_index]; + updated_q_size = CF_AppData.hk.channel_hk[arg_t.chan_num].q_size[arg_t.flags.com.q_index]; /* Assert */ UtAssert_ADDRESS_EQ(context_clist_remove.head, expected_head); @@ -299,26 +300,26 @@ void Test_cf_dequeue_transaction_Call_CF_CList_Remove_AndDecrement_q_size(void) void Test_cf_move_transaction_Call_CF_CList_InsertBack_AndSet_q_index_ToGiven_q(void) { /* Arrange */ - CF_Transaction_t dummy_t; - CF_Transaction_t *arg_t = &dummy_t; - uint8 dummy_chan_num = Any_uint8_LessThan(CF_NUM_CHANNELS); - CF_CListNode_t ** expected_remove_head; - CF_CListNode_t * expected_remove_node; - CF_CListNode_t ** expected_insert_back_head; - CF_CListNode_t * expected_insert_back_node; - CF_QueueIdx_t arg_q = Any_cf_queue_index_t(); + CF_Transaction_t dummy_t; + CF_Transaction_t * arg_t = &dummy_t; + uint8 dummy_chan_num = Any_uint8_LessThan(CF_NUM_CHANNELS); + CF_CListNode_t ** expected_remove_head; + CF_CListNode_t * expected_remove_node; + CF_CListNode_t ** expected_insert_back_head; + CF_CListNode_t * expected_insert_back_node; + CF_QueueIdx_t arg_q = Any_cf_queue_index_t(); + CF_CList_Remove_context_t context_clist_remove; + CF_CList_InsertBack_context_t context_clist_insert_back; memset(&dummy_t, 0, sizeof(dummy_t)); arg_t->chan_num = dummy_chan_num; - CF_CList_Remove_context_t context_clist_remove; UT_SetDataBuffer(UT_KEY(CF_CList_Remove), &context_clist_remove, sizeof(context_clist_remove), false); expected_remove_head = &CF_AppData.engine.channels[arg_t->chan_num].qs[arg_t->flags.com.q_index]; expected_remove_node = &arg_t->cl_node; - CF_CList_InsertBack_context_t context_clist_insert_back; UT_SetDataBuffer(UT_KEY(CF_CList_InsertBack), &context_clist_insert_back, sizeof(context_clist_insert_back), false); expected_insert_back_head = &CF_AppData.engine.channels[arg_t->chan_num].qs[arg_q]; @@ -356,8 +357,10 @@ void Test_CF_CList_Remove_Ex_Call_CF_CList_Remove_AndDecrement_q_size(void) CF_CListNode_t **expected_remove_head; CF_CListNode_t * expected_remove_node; uint16 initial_q_size = Any_uint16_Except(0); + uint16 updated_q_size; CF_CList_Remove_context_t context_clist_remove; + UT_SetDataBuffer(UT_KEY(CF_CList_Remove), &context_clist_remove, sizeof(context_clist_remove), false); expected_remove_head = &arg_c->qs[arg_index]; @@ -368,7 +371,7 @@ void Test_CF_CList_Remove_Ex_Call_CF_CList_Remove_AndDecrement_q_size(void) /* Act */ CF_CList_Remove_Ex(arg_c, arg_index, arg_node); - uint16 updated_q_size = CF_AppData.hk.channel_hk[arg_c - CF_AppData.engine.channels].q_size[arg_index]; + updated_q_size = CF_AppData.hk.channel_hk[arg_c - CF_AppData.engine.channels].q_size[arg_index]; /* Assert */ UtAssert_STUB_COUNT(CF_CList_Remove, 1); @@ -391,10 +394,12 @@ void Test_CF_CList_InsertAfter_Ex_Call_CF_CList_InsertAfter_AndIncrement_q_size( CF_CListNode_t * arg_start = &dummy_start; CF_CListNode_t dummy_after; CF_CListNode_t * arg_after = &dummy_after; - uint16 initial_q_size = Any_uint16(); CF_CListNode_t **expected_insert_after_head = &arg_c->qs[arg_index]; + uint16 initial_q_size = Any_uint16(); + uint16 updated_q_size; CF_CList_InsertAfter_context_t context_CF_CList_InsertAfter; + UT_SetDataBuffer(UT_KEY(CF_CList_InsertAfter), &context_CF_CList_InsertAfter, sizeof(context_CF_CList_InsertAfter), false); @@ -403,7 +408,7 @@ void Test_CF_CList_InsertAfter_Ex_Call_CF_CList_InsertAfter_AndIncrement_q_size( /* Act */ CF_CList_InsertAfter_Ex(arg_c, arg_index, arg_start, arg_after); - uint16 updated_q_size = CF_AppData.hk.channel_hk[arg_c - CF_AppData.engine.channels].q_size[arg_index]; + updated_q_size = CF_AppData.hk.channel_hk[arg_c - CF_AppData.engine.channels].q_size[arg_index]; /* Assert */ UtAssert_STUB_COUNT(CF_CList_InsertAfter, 1); @@ -429,6 +434,7 @@ void Test_CF_CList_InsertBack_Ex_Call_CF_CList_InsertBack_AndIncrement_q_size(vo uint16 initial_q_size = Any_uint16(); CF_CListNode_t **expected_insert_back_head; CF_CListNode_t * expected_insert_back_node; + uint16 updated_q_size; CF_CList_InsertBack_context_t context_clist_insert_back; UT_SetDataBuffer(UT_KEY(CF_CList_InsertBack), &context_clist_insert_back, sizeof(context_clist_insert_back), false); @@ -441,7 +447,7 @@ void Test_CF_CList_InsertBack_Ex_Call_CF_CList_InsertBack_AndIncrement_q_size(vo /* Act */ CF_CList_InsertBack_Ex(arg_c, arg_index, arg_node); - uint16 updated_q_size = CF_AppData.hk.channel_hk[arg_c - CF_AppData.engine.channels].q_size[arg_index]; + updated_q_size = CF_AppData.hk.channel_hk[arg_c - CF_AppData.engine.channels].q_size[arg_index]; /* Assert */ UtAssert_STUB_COUNT(CF_CList_InsertBack, 1); @@ -716,11 +722,12 @@ void Test_CF_InsertSortPrio_Call_CF_CList_InsertBack_Ex_ListIsEmpty_AndSet_q_ind CF_CListNode_t ** expected_insert_back_head; CF_CListNode_t * expected_insert_back_node; + CF_CList_InsertBack_context_t context_clist_insert_back; + /* dummy_t settings to bypass CF_Assert */ dummy_t.chan_num = Any_uint8_LessThan(CF_NUM_CHANNELS); dummy_t.state = Any_uint8_Except(CF_TxnState_IDLE); - CF_CList_InsertBack_context_t context_clist_insert_back; UT_SetDataBuffer(UT_KEY(CF_CList_InsertBack), &context_clist_insert_back, sizeof(context_clist_insert_back), false); /* setting (&CF_AppData.engine.channels[arg_t->chan_num])->qs[arg_q] to NULL @@ -758,7 +765,9 @@ void Test_CF_InsertSortPrio_Call_CF_CList_InsertAfter_Ex_AndSet_q_index_To_q(voi CF_CListNode_t ** expected_insert_after_start; CF_CListNode_t ** expected_insert_after_after; - CF_CList_Traverse_R_context_t context_cf_clist_traverse_r; + CF_CList_Traverse_R_context_t context_cf_clist_traverse_r; + CF_CList_InsertAfter_context_t context_CF_CList_InsertAfter; + UT_SetHandlerFunction(UT_KEY(CF_CList_Traverse_R), UT_AltHandler_CF_CList_Traverse_R_PRIO, &context_cf_clist_traverse_r); @@ -775,7 +784,6 @@ void Test_CF_InsertSortPrio_Call_CF_CList_InsertAfter_Ex_AndSet_q_index_To_q(voi context_cf_clist_traverse_r.context_t = &dummy_p_t; /* Arrange for CF_CList_InsertAfter_Ex */ - CF_CList_InsertAfter_context_t context_CF_CList_InsertAfter; UT_SetDataBuffer(UT_KEY(CF_CList_InsertAfter), &context_CF_CList_InsertAfter, sizeof(context_CF_CList_InsertAfter), false); @@ -816,6 +824,8 @@ void Test_CF_InsertSortPrio_When_p_t_Is_NULL_Call_CF_CList_InsertBack_Ex(void) CF_CListNode_t * expected_insert_back_node; CF_CList_Traverse_R_context_t context_cf_clist_traverse_r; + CF_CList_InsertBack_context_t context_clist_insert_back; + UT_SetDataBuffer(UT_KEY(CF_CList_Traverse_R), &context_cf_clist_traverse_r, sizeof(context_cf_clist_traverse_r), false); @@ -838,7 +848,6 @@ void Test_CF_InsertSortPrio_When_p_t_Is_NULL_Call_CF_CList_InsertBack_Ex(void) expected_insert_back_node = &arg_t->cl_node; /* Arrange for CF_CList_InsertBack_Ex */ - CF_CList_InsertBack_context_t context_clist_insert_back; UT_SetDataBuffer(UT_KEY(CF_CList_InsertBack), &context_clist_insert_back, sizeof(context_clist_insert_back), false); /* Act */ @@ -879,6 +888,8 @@ void Test_CF_TraverseAllTransactions_Impl_GetContainer_t_Call_args_fn_AndAdd_1_T void * expected_context; int32 result; + UT_Callback_CF_TraverseAllTransactions_context_t func_ptr_context; + dummy_args.fn = UT_Callback_CF_TraverseAllTransactions; dummy_args.context = dummy_context; dummy_args.counter = initial_args_counter; @@ -889,7 +900,6 @@ void Test_CF_TraverseAllTransactions_Impl_GetContainer_t_Call_args_fn_AndAdd_1_T expected_t = &dummy_t; expected_context = dummy_context; - UT_Callback_CF_TraverseAllTransactions_context_t func_ptr_context; UT_SetDataBuffer(UT_KEY(UT_Callback_CF_TraverseAllTransactions), &func_ptr_context, sizeof(func_ptr_context), false); @@ -921,18 +931,17 @@ void Test_CF_TraverseAllTransactions_CallOtherFunction_CF_Q_RX_TimesAndReturn_ar void * arg_context = &dummy_context; uint8 expected_count = CF_QueueIdx_RX - CF_QueueIdx_PEND + 1; CF_CListNode_t *expected_qs_nodes[expected_count]; + int i = 0; - CF_TraverseAllTransactions_fn_t arg_fn = UT_Callback_CF_TraverseAllTransactions; + CF_TraverseAllTransactions_fn_t arg_fn = UT_Callback_CF_TraverseAllTransactions; + CF_CList_Traverse_TRAVERSE_ALL_ARGS_T_context_t contexts_cf_clist_traverse[expected_count]; - int i = 0; for (i = 0; i < expected_count; ++i) { dummy_c.qs[i] = (CF_CListNode_t *)&expected_qs_nodes[i]; } /* set context */ - CF_CList_Traverse_TRAVERSE_ALL_ARGS_T_context_t contexts_cf_clist_traverse[expected_count]; - /* this must use data buffer hack to pass multiple contexts */ UT_SetHandlerFunction(UT_KEY(CF_CList_Traverse), UT_AltHandler_CF_CList_Traverse_TRAVERSE_ALL_ARGS_T, NULL); UT_SetDataBuffer(UT_KEY(CF_CList_Traverse), contexts_cf_clist_traverse, sizeof(contexts_cf_clist_traverse), false); diff --git a/unit-test/utilities/cf_test_utils.c b/unit-test/utilities/cf_test_utils.c index 3fdbc68e..86bc25e5 100644 --- a/unit-test/utilities/cf_test_utils.c +++ b/unit-test/utilities/cf_test_utils.c @@ -384,6 +384,7 @@ uint32 Any_uint32_Except(uint32 exception) int32 Any_int32_LessThan(int32 ceiling) { int32 random_val; + int32 new_ceiling; if (ceiling > 0) { @@ -391,8 +392,8 @@ int32 Any_int32_LessThan(int32 ceiling) } else { - int32 new_ceiling = abs(INT32_MIN - ceiling); - random_val = ceiling - (rand() % new_ceiling); + new_ceiling = abs(INT32_MIN - ceiling); + random_val = ceiling - (rand() % new_ceiling); } return random_val; @@ -448,7 +449,8 @@ int Any_int_Except(int exception) int Any_int_GreaterThan(int floor) /* NOTE: INTMAX_MAX will fail, and is invalid value */ { - int random_val; + int random_val; + bool coin_toss; if (floor > 0) { @@ -458,7 +460,7 @@ int Any_int_GreaterThan(int floor) /* NOTE: INTMAX_MAX will fail, and is invalid } else { - bool coin_toss = rand() % 2; + coin_toss = rand() % 2; if (coin_toss == HEADS) { @@ -561,10 +563,11 @@ char *AnyFilenameOfLength(size_t length) char *AnyRandomStringOfTextOfLength(size_t length) { size_t i; + int value; for (i = 0; i < length; ++i) { - int value = 32 + (rand() % 95); /* ASCII 32 to 126 */ + value = 32 + (rand() % 95); /* ASCII 32 to 126 */ random_length_string[i] = (char)value; } random_length_string[i] = '\0'; @@ -575,10 +578,11 @@ char *AnyRandomStringOfTextOfLength(size_t length) char *AnyRandomStringOfLettersOfLength(size_t length) { size_t i; + int value; for (i = 0; i < length; ++i) { - int value = 65 + (rand() % 26); /* ASCII 65 to 91 */ + value = 65 + (rand() % 26); /* ASCII 65 to 91 */ if (AnyCoinFlip() == HEADS) { @@ -595,10 +599,11 @@ char *AnyRandomStringOfLettersOfLength(size_t length) void AnyRandomStringOfLettersOfLengthCopy(char *random_string, size_t length) { size_t i; + int value; for (i = 0; i < (length - 1); ++i) { - int value = 65 + (rand() % 26); /* ASCII 65 to 91 */ + value = 65 + (rand() % 26); /* ASCII 65 to 91 */ if (AnyCoinFlip() == HEADS) {