Skip to content

Commit

Permalink
Fix nasa#1650, Make Global struct for functional test.
Browse files Browse the repository at this point in the history
  • Loading branch information
zanzaben committed Jul 27, 2021
1 parent 81c598a commit 363722a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
5 changes: 5 additions & 0 deletions modules/cfe_testcase/src/cfe_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
#include "uttest.h"
#include "utassert.h"

typedef struct
{
CFE_FS_FileWriteMetaData_t FuncTestState;
} CFE_FT_Global_t;

/**
* Name of log file to write
*
Expand Down
27 changes: 14 additions & 13 deletions modules/cfe_testcase/src/fs_util_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@

#include "cfe_test.h"

CFE_FT_Global_t CFE_FT_Global;

void TestFileCategory(void)
{
UtPrintf("Testing: CFE_FS_GetDefaultMountPoint, CFE_FS_GetDefaultExtension");
Expand Down Expand Up @@ -121,33 +123,32 @@ 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;
memset(&State, 0, sizeof(State));
State.FileSubType = 2;
State.GetData = FS_DataGetter;
State.OnEvent = FS_OnEvent;
strncpy(State.FileName, "/ram/FT.bin", sizeof(State.FileName));
strncpy(State.Description, "FT", sizeof(State.Description));
memset(&CFE_FT_Global.FuncTestState, 0, sizeof(CFE_FT_Global.FuncTestState));
CFE_FT_Global.FuncTestState.FileSubType = 2;
CFE_FT_Global.FuncTestState.GetData = FS_DataGetter;
CFE_FT_Global.FuncTestState.OnEvent = FS_OnEvent;
strncpy(CFE_FT_Global.FuncTestState.FileName, "/ram/FT.bin", sizeof(CFE_FT_Global.FuncTestState.FileName));
strncpy(CFE_FT_Global.FuncTestState.Description, "FT", sizeof(CFE_FT_Global.FuncTestState.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);
UtAssert_INT32_EQ(CFE_FS_BackgroundFileDumpIsPending(&State), true);
UtAssert_INT32_EQ(CFE_FS_BackgroundFileDumpIsPending(&CFE_FT_Global.FuncTestState), false);
UtAssert_INT32_EQ(CFE_FS_BackgroundFileDumpRequest(&CFE_FT_Global.FuncTestState), CFE_SUCCESS);
UtAssert_INT32_EQ(CFE_FS_BackgroundFileDumpIsPending(&CFE_FT_Global.FuncTestState), true);

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

UtAssert_True(count < MaxWait, "count (%i) < MaxWait (%i)", count, MaxWait);

UtAssert_INT32_EQ(CFE_FS_BackgroundFileDumpRequest(NULL), CFE_FS_BAD_ARGUMENT);
UtAssert_INT32_EQ(CFE_FS_BackgroundFileDumpIsPending(NULL), false);
}
Expand Down

0 comments on commit 363722a

Please sign in to comment.