Skip to content

Commit

Permalink
Fix nasa#17, update code coverage
Browse files Browse the repository at this point in the history
Increases code coverage for fm_child_tests.c and fm_cmds_tests.c
  • Loading branch information
chillfig committed Jun 9, 2022
1 parent 1c1c1ad commit 1c5c1d2
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 3 deletions.
66 changes: 65 additions & 1 deletion unit-test/fm_child_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -3512,6 +3512,63 @@ void Test_FM_ChildLoop_CountSemTakeSuccessDefault(void)
* ChildSleepStat Tests
* ***************/

void Test_FM_ChildSleepStat_getSizeTimeModeFalse(void)
{
// Arrange
const char *dummy_filename = "dummy_filename";
FM_DirListEntry_t dummy_DirListData = {.EntrySize=1, .ModifyTime=1, .Mode=1};
int32 dummy_FilesTillSleep = UT_Utils_Any_int32();
uint8 dummy_getSizeTimeMode = 0;

// Act
FM_ChildSleepStat(dummy_filename, &dummy_DirListData, &dummy_FilesTillSleep, dummy_getSizeTimeMode);

// Assert
UtAssert_INT32_EQ(dummy_DirListData.EntrySize, 0);
UtAssert_INT32_EQ(dummy_DirListData.ModifyTime, 0);
UtAssert_INT32_EQ(dummy_DirListData.Mode, 0);
}

/*
void Test_FM_ChildSleepStat_FilesTillSleepPositive(void)
{
// Arrange
const char *dummy_filename = "dummy_filename";
FM_DirListEntry_t dummy_DirListData = {.EntrySize=1, .ModifyTime=1, .Mode=1};
int32 dummy_FilesTillSleep = UT_Utils_Any_uint32_GreaterThan(0);
uint8 dummy_getSizeTimeMode = 1;
int32 dummy_FilesTillSleep_before = dummy_FilesTillSleep;
// Act
FM_ChildSleepStat(dummy_filename, &dummy_DirListData, &dummy_FilesTillSleep, dummy_getSizeTimeMode);
uint8 count_ostaskdelay = UT_GetStubCount(UT_KEY(OS_TaskDelay));
// Assert
UtAssert_INT32_EQ(count_ostaskdelay, 1);
UtAssert_INT32_EQ(dummy_FilesTillSleep, dummy_FilesTillSleep_before - 1);
}
void Test_FM_ChildSleepStat_FilesTillSleepLTEQZero(void)
{
// Arrange
const char *dummy_filename = "dummy_filename";
FM_DirListEntry_t dummy_DirListData = {.EntrySize=1, .ModifyTime=1, .Mode=1};
int32 dummy_FilesTillSleep = UT_Utils_Any_uint8_LessThan(1);
uint8 dummy_getSizeTimeMode = 1;
int32 dummy_FilesTillSleep_before = dummy_FilesTillSleep;
// Act
FM_ChildSleepStat(dummy_filename, &dummy_DirListData, &dummy_FilesTillSleep, dummy_getSizeTimeMode);
uint8 count_ostaskdelay = UT_GetStubCount(UT_KEY(OS_TaskDelay));
// Assert
UtAssert_INT32_EQ(count_ostaskdelay, 1);
UtAssert_INT32_EQ(dummy_FilesTillSleep, dummy_FilesTillSleep_before - 1);
}
*/

/* * * * * * * * * * * * * *
* Add Method Tests
* * * * * * * * * * * * * */
Expand Down Expand Up @@ -3854,7 +3911,14 @@ void add_FM_ChildSizeTimeMode_tests(void)
"Test_FM_ChildSizeTimeMode_OSFilestateTimeDefined");
}

void add_FM_ChildSleepStat_tests(void) {}
void add_FM_ChildSleepStat_tests(void)
{
UtTest_Add(Test_FM_ChildSleepStat_getSizeTimeModeFalse, FM_Test_Setup, FM_Test_Teardown,
"Test_FM_ChildSleepStat_getSizeTimeModeFalse");

/*UtTest_Add(Test_FM_ChildSleepStat_FilesTillSleepPositive, FM_Test_Setup, FM_Test_Teardown,
"Test_FM_ChildSleepStat_FilesTillSleepPositive");*/
}

void add_FM_ChildLoop_tests(void)
{
Expand Down
4 changes: 2 additions & 2 deletions unit-test/fm_cmds_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -2273,9 +2273,9 @@ void UtTest_Setup(void)
add_FM_NoopCmd_tests();
add_FM_ResetCountersCmd_tests();
add_FM_CopyFileCmd_tests();
// add_FM_MoveFileCmd_tests();
add_FM_MoveFileCmd_tests();
add_FM_RenameFileCmd_tests();
// add_FM_DeleteFileCmd_tests();
add_FM_DeleteFileCmd_tests();
add_FM_DeleteAllFilesCmd_tests();

#ifdef FM_INCLUDE_DECOMPRESS
Expand Down

0 comments on commit 1c5c1d2

Please sign in to comment.