Skip to content

Commit

Permalink
Fix nasa#1650, Make state global and limit delay loop.
Browse files Browse the repository at this point in the history
  • Loading branch information
zanzaben committed Jul 26, 2021
1 parent 6b75f6b commit 81c598a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions modules/cfe_testcase/src/fs_util_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ void TestFileName(void)
/* FT helper stub compatible with background file write DataGetter */
bool FS_DataGetter(void *Meta, uint32 RecordNum, void **Buffer, size_t *BufSize)
{
*Buffer = NULL;
*BufSize = 0;
return true;
}

Expand All @@ -119,6 +121,8 @@ void FS_OnEvent(void *Meta, CFE_FS_FileWriteEvent_t Event, int32 Status, uint32
{
}

CFE_FS_FileWriteMetaData_t State;

void TestFileDump(void)
{
CFE_FS_FileWriteMetaData_t State;
Expand All @@ -128,24 +132,24 @@ void TestFileDump(void)
State.OnEvent = FS_OnEvent;
strncpy(State.FileName, "/ram/FT.bin", sizeof(State.FileName));
strncpy(State.Description, "FT", sizeof(State.Description));
int count = 0;
int MaxWait = 20;

UtPrintf("Testing: CFE_FS_BackgroundFileDumpRequest, CFE_FS_BackgroundFileDumpIsPending");

UtAssert_INT32_EQ(CFE_FS_BackgroundFileDumpIsPending(&State), false);
UtAssert_INT32_EQ(CFE_FS_BackgroundFileDumpRequest(&State), CFE_SUCCESS);

State.IsPending = true;
UtAssert_INT32_EQ(CFE_FS_BackgroundFileDumpIsPending(&State), true);

/* Wait for background task to complete */
while(CFE_FS_BackgroundFileDumpIsPending(&State))
while (CFE_FS_BackgroundFileDumpIsPending(&State) && count < MaxWait)
{
OS_TaskDelay(100);
count++;
}

UtAssert_INT32_EQ(CFE_FS_BackgroundFileDumpRequest(NULL), CFE_FS_BAD_ARGUMENT);
UtAssert_INT32_EQ(CFE_FS_BackgroundFileDumpIsPending(NULL), false);

}

void FSUtilTestSetup(void)
Expand Down

0 comments on commit 81c598a

Please sign in to comment.