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

Fix #1362, Simplify CFE_ES_QueryAllCmd file open logic #1582

Merged
merged 1 commit into from
May 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
24 changes: 2 additions & 22 deletions modules/es/fsw/src/cfe_es_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -1317,17 +1317,7 @@ int32 CFE_ES_QueryAllCmd(const CFE_ES_QueryAllCmd_t *data)
if (Result == CFE_SUCCESS)
{
/*
** Check to see if the file already exists
*/
Result = OS_OpenCreate(&FileDescriptor, QueryAllFilename, OS_FILE_FLAG_NONE, OS_READ_ONLY);
if (Result >= 0)
{
OS_close(FileDescriptor);
OS_remove(QueryAllFilename);
}

/*
** Create ES task log data file
** Create (or truncate) ES task log data file
*/
Result = OS_OpenCreate(&FileDescriptor, QueryAllFilename, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE,
OS_WRITE_ONLY);
Expand Down Expand Up @@ -1469,17 +1459,7 @@ int32 CFE_ES_QueryAllTasksCmd(const CFE_ES_QueryAllTasksCmd_t *data)
if (Result == CFE_SUCCESS)
{
/*
** Check to see if the file already exists
*/
Result = OS_OpenCreate(&FileDescriptor, QueryAllFilename, OS_FILE_FLAG_NONE, OS_READ_ONLY);
if (Result >= 0)
{
OS_close(FileDescriptor);
OS_remove(QueryAllFilename);
}

/*
** Create ES task log data file
** Create (or truncate) ES task log data file
*/
Result = OS_OpenCreate(&FileDescriptor, QueryAllFilename, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE,
OS_WRITE_ONLY);
Expand Down
17 changes: 0 additions & 17 deletions modules/es/ut-coverage/es_UT.c
Original file line number Diff line number Diff line change
Expand Up @@ -3151,14 +3151,6 @@ void TestTask(void)
UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_ES_LEN_ERR_EID), "CFE_ES_QueryAllAppCmd",
"Query all applications command; invalid command length");

/* Test write of all app data to file with a file open failure */
ES_ResetUnitTest();
memset(&CmdBuf, 0, sizeof(CmdBuf));
UT_SetDeferredRetcode(UT_KEY(OS_OpenCreate), 1, OS_ERROR);
UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CmdBuf.QueryAllCmd), UT_TPID_CFE_ES_CMD_QUERY_ALL_CC);
UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_ES_ALL_APPS_EID), "CFE_ES_QueryAllCmd",
"Write application information file fail; file open");

/* Test sending a write request for all tasks with an
* invalid command length
*/
Expand All @@ -3167,15 +3159,6 @@ void TestTask(void)
UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_ES_LEN_ERR_EID), "CFE_ES_QueryAllAppCmd",
"Query all tasks command; invalid command length");

/* Test write of all task data to file with a file open failure */
ES_ResetUnitTest();
memset(&CmdBuf, 0, sizeof(CmdBuf));
UT_SetDeferredRetcode(UT_KEY(OS_OpenCreate), 1, OS_ERROR);
UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CmdBuf.QueryAllTasksCmd),
UT_TPID_CFE_ES_CMD_QUERY_ALL_TASKS_CC);
UT_Report(__FILE__, __LINE__, UT_EventIsInHistory(CFE_ES_TASKINFO_EID), "CFE_ES_QueryAllCmd",
"Write task information file fail; file open");

/* Test sending a request to clear the system log with an
* invalid command length
*/
Expand Down