Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[nasa/nos3#176] Unit Tests #2

Merged
merged 18 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
5cb25f5
Fix #116, Removed command header from payload struct
havencarlson Sep 20, 2023
7b20419
Merge pull request #118 from havencarlson/fix#116
dzbaker Sep 21, 2023
f600acd
Fix #111: Use correct length filename for too large test
irowebbn Nov 30, 2023
f04f6a0
Merge pull request #112 from irowebbn/111-max_file-len-move-test
dzbaker Dec 5, 2023
dc14784
Fix #119, remove dependency on MID_BASE defines
jphickey Dec 13, 2023
77b016d
Merge pull request #120 from jphickey/fix-119-midbase
dmknutsen Dec 15, 2023
9f6138a
Fix #121, correct casting on printf format strings
jphickey Jan 10, 2024
b540e3b
Merge pull request #122 from jphickey/fix-121-formats
dzbaker Jan 11, 2024
f2b9d11
Fix #115, Adds distinct identifiers from command name
Jan 23, 2024
fe2ea87
Merge pull request #123 from chillfig/nondistinct_id
dzbaker Feb 1, 2024
20236a4
Fix #125, Adds utassert macro for logging function calls
Feb 15, 2024
ce8902c
Merge pull request #126 from chillfig/function_macros
dzbaker Feb 15, 2024
3f41af7
Fix #95, Replaces conditionally compiled code with runtime conditiona…
Jan 31, 2024
ec96b02
Merge pull request #124 from chillfig/cond_comp_code
dzbaker Mar 28, 2024
a5f1a8e
Fix #127, Adds static analysis comments and replaces strncpy with snp…
Jun 10, 2024
c83933f
Merge pull request #130 from chillfig/SA_jsc2_1
dzbaker Jun 27, 2024
659e972
Merge remote-tracking branch 'origin/main' into nos3#176-unit-tests
jlucas9 Jul 3, 2024
1427a22
[nasa/nos3#176] Change from bools to int32 across the entire applicat…
jlucas9 Jul 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
[nasa/nos3#176] Change from bools to int32 across the entire applicat…
…ion;
  • Loading branch information
jlucas9 committed Jul 23, 2024
commit 1427a22cf1e419cf212193e65f6269a97d43040b
2 changes: 1 addition & 1 deletion fsw/src/ds_dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@

#include <stdio.h>

bool DS_VerifyLength(const CFE_SB_Buffer_t *BufPtr, size_t ExpectedLength, uint16 FailEventID, const char *CommandName)
int32 DS_VerifyLength(const CFE_SB_Buffer_t *BufPtr, size_t ExpectedLength, uint16 FailEventID, const char *CommandName)

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
{
size_t ActualLength = 0;

Expand Down
10 changes: 5 additions & 5 deletions fsw/src/ds_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@
/* Apply common filter algorithm to Software Bus packet */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
bool DS_IsPacketFiltered(CFE_MSG_Message_t *MessagePtr, uint16 FilterType, uint16 Algorithm_N, uint16 Algorithm_X,
int32 DS_IsPacketFiltered(CFE_MSG_Message_t *MessagePtr, uint16 FilterType, uint16 Algorithm_N, uint16 Algorithm_X,

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.

Check notice

Code scanning / CodeQL

Function too long Note

DS_IsPacketFiltered has too many lines (124, while 60 are allowed).
uint16 Algorithm_O)
{
/*
** Algorithm_N = the filter will pass this many packets
** Algorithm_X = out of every group of this many packets
** Algorithm_O = starting at this offset within the group
*/
bool PacketIsFiltered = false;
int32 PacketIsFiltered = false;
CFE_TIME_SysTime_t PacketTime;
uint16 PacketValue;
uint16 Seconds;
Expand Down Expand Up @@ -188,8 +188,8 @@
{
DS_PacketEntry_t *PacketEntry = NULL;
DS_FilterParms_t *FilterParms = NULL;
bool PassedFilter = false;
bool FilterResult = false;
int32 PassedFilter = false;
int32 FilterResult = false;
int32 FilterIndex = 0;
int32 FileIndex = 0;
int32 i = 0;
Expand Down Expand Up @@ -271,7 +271,7 @@
{
DS_DestFileEntry_t *DestFile = &DS_AppData.DestFileTblPtr->File[FileIndex];
DS_AppFileStatus_t *FileStatus = &DS_AppData.FileStatus[FileIndex];
bool OpenNewFile = false;
int32 OpenNewFile = false;
size_t PacketLength = 0;

/*
Expand Down
2 changes: 1 addition & 1 deletion fsw/src/ds_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ void DS_FileTransmit(DS_AppFileStatus_t *FileStatus);
* \retval true The packet should be filtered (not used)
* \retval false The packet should not be filtered (used)
*/
bool DS_IsPacketFiltered(CFE_MSG_Message_t *MessagePtr, uint16 FilterType, uint16 Algorithm_N, uint16 Algorithm_X,
int32 DS_IsPacketFiltered(CFE_MSG_Message_t *MessagePtr, uint16 FilterType, uint16 Algorithm_N, uint16 Algorithm_X,
uint16 Algorithm_O);

#endif
44 changes: 22 additions & 22 deletions fsw/src/ds_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
{
CFE_Status_t Result1;
CFE_Status_t Result2;
bool NeedToLoadDestTable = false;
bool NeedToLoadFilterTable = false;
int32 NeedToLoadDestTable = false;
int32 NeedToLoadFilterTable = false;
uint16 TableRegisterFlags = CFE_TBL_OPT_SNGL_BUFFER | CFE_TBL_OPT_LOAD_DUMP;

if (DS_MAKE_TABLES_CRITICAL == 1)
Expand Down Expand Up @@ -441,10 +441,10 @@
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

bool DS_TableVerifyDestFileEntry(DS_DestFileEntry_t *DestFileEntry, uint8 TableIndex, int32 ErrorCount)
int32 DS_TableVerifyDestFileEntry(DS_DestFileEntry_t *DestFileEntry, uint8 TableIndex, int32 ErrorCount)

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.

Check notice

Code scanning / CodeQL

Function too long Note

DS_TableVerifyDestFileEntry has too many lines (63, while 60 are allowed).
{
const char *CommonErrorText = "Destination file table verify err:";
bool Result = true;
int32 Result = true;

/*
** Perform the following "per table entry" validation:
Expand Down Expand Up @@ -563,11 +563,11 @@
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

bool DS_TableVerifyFilterEntry(DS_PacketEntry_t *PacketEntry, int32 TableIndex, int32 ErrorCount)
int32 DS_TableVerifyFilterEntry(DS_PacketEntry_t *PacketEntry, int32 TableIndex, int32 ErrorCount)

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.

Check notice

Code scanning / CodeQL

Function too long Note

DS_TableVerifyFilterEntry has too many lines (70, while 60 are allowed).
{
const char * CommonErrorText = "Filter table verify err:";
DS_FilterParms_t *FilterParms;
bool Result = true;
int32 Result = true;
int32 i = 0;

/*
Expand Down Expand Up @@ -640,10 +640,10 @@
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

bool DS_TableEntryUnused(const void *TableEntry, int32 BufferSize)
int32 DS_TableEntryUnused(const void *TableEntry, int32 BufferSize)

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
{
const char *Buffer = (char *)TableEntry;
bool Result = true;
int32 Result = true;
int32 i = 0;

for (i = 0; i < BufferSize; i++)
Expand All @@ -664,9 +664,9 @@
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

bool DS_TableVerifyFileIndex(uint16 FileTableIndex)
int32 DS_TableVerifyFileIndex(uint16 FileTableIndex)
{
bool Result = true;
int32 Result = true;

if (FileTableIndex >= DS_DEST_FILE_CNT)
{
Expand All @@ -682,9 +682,9 @@
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

bool DS_TableVerifyParms(uint16 Algorithm_N, uint16 Algorithm_X, uint16 Algorithm_O)
int32 DS_TableVerifyParms(uint16 Algorithm_N, uint16 Algorithm_X, uint16 Algorithm_O)

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
{
bool Result = true;
int32 Result = true;

/*
** Unused entries (all zero's) are valid
Expand Down Expand Up @@ -716,9 +716,9 @@
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

bool DS_TableVerifyType(uint16 TimeVsCount)
int32 DS_TableVerifyType(uint16 TimeVsCount)
{
bool Result = true;
int32 Result = true;

if ((TimeVsCount != DS_BY_COUNT) && (TimeVsCount != DS_BY_TIME))
{
Expand All @@ -734,9 +734,9 @@
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

bool DS_TableVerifyState(uint16 EnableState)
int32 DS_TableVerifyState(uint16 EnableState)
{
bool Result = true;
int32 Result = true;

if ((EnableState != DS_ENABLED) && (EnableState != DS_DISABLED))
{
Expand All @@ -752,9 +752,9 @@
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

bool DS_TableVerifySize(uint32 MaxFileSize)
int32 DS_TableVerifySize(uint32 MaxFileSize)
{
bool Result = true;
int32 Result = true;

if (MaxFileSize < DS_FILE_MIN_SIZE_LIMIT)
{
Expand All @@ -770,9 +770,9 @@
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

bool DS_TableVerifyAge(uint32 MaxFileAge)
int32 DS_TableVerifyAge(uint32 MaxFileAge)
{
bool Result = true;
int32 Result = true;

if (MaxFileAge < DS_FILE_MIN_AGE_LIMIT)
{
Expand All @@ -788,9 +788,9 @@
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

bool DS_TableVerifyCount(uint32 SequenceCount)
int32 DS_TableVerifyCount(uint32 SequenceCount)
{
bool Result = true;
int32 Result = true;

if (SequenceCount > DS_MAX_SEQUENCE_COUNT)
{
Expand Down
20 changes: 10 additions & 10 deletions fsw/src/ds_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ CFE_Status_t DS_TableVerifyDestFile(const void *TableData);
*
* \sa #DS_DestFileEntry_t, #DS_TableVerifyDestFile
*/
bool DS_TableVerifyDestFileEntry(DS_DestFileEntry_t *DestFileEntry, uint8 TableIndex, int32 ErrorCount);
int32 DS_TableVerifyDestFileEntry(DS_DestFileEntry_t *DestFileEntry, uint8 TableIndex, int32 ErrorCount);

/**
* \brief Verify packet filter table data
Expand Down Expand Up @@ -208,7 +208,7 @@ CFE_Status_t DS_TableVerifyFilter(const void *TableData);
*
* \sa #DS_PacketEntry_t, #DS_FilterParms_t, #DS_TableVerifyFilter
*/
bool DS_TableVerifyFilterEntry(DS_PacketEntry_t *PacketEntry, int32 TableIndex, int32 ErrorCount);
int32 DS_TableVerifyFilterEntry(DS_PacketEntry_t *PacketEntry, int32 TableIndex, int32 ErrorCount);

/**
* \brief Test for unused table entry
Expand All @@ -229,7 +229,7 @@ bool DS_TableVerifyFilterEntry(DS_PacketEntry_t *PacketEntry, int32 TableIndex,
*
* \sa #DS_PacketEntry_t, #DS_FilterParms_t, #DS_DestFileEntry_t
*/
bool DS_TableEntryUnused(const void *TableEntry, int32 BufferSize);
int32 DS_TableEntryUnused(const void *TableEntry, int32 BufferSize);

/**
* \brief Verify destination file index
Expand Down Expand Up @@ -262,7 +262,7 @@ bool DS_TableEntryUnused(const void *TableEntry, int32 BufferSize);
*
* \sa #DS_PacketEntry_t, #DS_FilterParms_t, #DS_DestFileEntry_t
*/
bool DS_TableVerifyFileIndex(uint16 FileTableIndex);
int32 DS_TableVerifyFileIndex(uint16 FileTableIndex);

/**
* \brief Verify packet filter parameters
Expand All @@ -286,7 +286,7 @@ bool DS_TableVerifyFileIndex(uint16 FileTableIndex);
*
* \sa #DS_TableVerifyType, #DS_TableVerifyState, #DS_DestFileEntry_t
*/
bool DS_TableVerifyParms(uint16 Algorithm_N, uint16 Algorithm_X, uint16 Algorithm_O);
int32 DS_TableVerifyParms(uint16 Algorithm_N, uint16 Algorithm_X, uint16 Algorithm_O);

/**
* \brief Verify packet filter type or filename type
Expand All @@ -311,7 +311,7 @@ bool DS_TableVerifyParms(uint16 Algorithm_N, uint16 Algorithm_X, uint16 Algorith
*
* \sa #DS_TableVerifyState, #DS_TableVerifySize, #DS_DestFileEntry_t
*/
bool DS_TableVerifyType(uint16 TimeVsCount);
int32 DS_TableVerifyType(uint16 TimeVsCount);

/**
* \brief Verify application or destination file enable/disable state
Expand All @@ -333,7 +333,7 @@ bool DS_TableVerifyType(uint16 TimeVsCount);
*
* \sa #DS_TableVerifySize, #DS_TableVerifyAge, #DS_DestFileEntry_t
*/
bool DS_TableVerifyState(uint16 EnableState);
int32 DS_TableVerifyState(uint16 EnableState);

/**
* \brief Verify destination file max size limit
Expand All @@ -354,7 +354,7 @@ bool DS_TableVerifyState(uint16 EnableState);
*
* \sa #DS_TableVerifyAge, #DS_TableVerifyCount, #DS_DestFileEntry_t
*/
bool DS_TableVerifySize(uint32 MaxFileSize);
int32 DS_TableVerifySize(uint32 MaxFileSize);

/**
* \brief Verify destination file max age limit
Expand All @@ -375,7 +375,7 @@ bool DS_TableVerifySize(uint32 MaxFileSize);
*
* \sa #DS_TableVerifySize, #DS_TableVerifyCount, #DS_DestFileEntry_t
*/
bool DS_TableVerifyAge(uint32 MaxFileAge);
int32 DS_TableVerifyAge(uint32 MaxFileAge);

/**
* \brief Verify destination file sequence count
Expand All @@ -396,7 +396,7 @@ bool DS_TableVerifyAge(uint32 MaxFileAge);
*
* \sa #DS_TableVerifySize, #DS_TableVerifyAge, #DS_DestFileEntry_t
*/
bool DS_TableVerifyCount(uint32 SequenceCount);
int32 DS_TableVerifyCount(uint32 SequenceCount);

/**
* \brief Subscribe to packet filter table packets
Expand Down
6 changes: 3 additions & 3 deletions unit-test/stubs/ds_file_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,10 @@ void DS_FileWriteHeader(int32 FileIndex)
* Generated stub function for DS_IsPacketFiltered()
* ----------------------------------------------------
*/
bool DS_IsPacketFiltered(CFE_MSG_Message_t *MessagePtr, uint16 FilterType, uint16 Algorithm_N, uint16 Algorithm_X,
int32 DS_IsPacketFiltered(CFE_MSG_Message_t *MessagePtr, uint16 FilterType, uint16 Algorithm_N, uint16 Algorithm_X,
uint16 Algorithm_O)
{
UT_GenStub_SetupReturnBuffer(DS_IsPacketFiltered, bool);
UT_GenStub_SetupReturnBuffer(DS_IsPacketFiltered, int32);

UT_GenStub_AddParam(DS_IsPacketFiltered, CFE_MSG_Message_t *, MessagePtr);
UT_GenStub_AddParam(DS_IsPacketFiltered, uint16, FilterType);
Expand All @@ -196,5 +196,5 @@ bool DS_IsPacketFiltered(CFE_MSG_Message_t *MessagePtr, uint16 FilterType, uint1

UT_GenStub_Execute(DS_IsPacketFiltered, Basic, NULL);

return UT_GenStub_GetReturnValue(DS_IsPacketFiltered, bool);
return UT_GenStub_GetReturnValue(DS_IsPacketFiltered, int32);
}
Loading
Loading