diff --git a/docs/dox_src/cfs_ds.dox b/docs/dox_src/cfs_ds.dox index 84de6cf..c3f341e 100644 --- a/docs/dox_src/cfs_ds.dox +++ b/docs/dox_src/cfs_ds.dox @@ -147,7 +147,7 @@ the platform.

Move File Capability

- If the DS_MOVE_FILES configuration parameter is set to a non-empty string, the telemetry + If the DS_MOVE_FILES configuration parameter is set to TRUE, the telemetry database, Destination File table load images and the File Table display page require changes. The Destination File Table rdl file uses the DS_MOVE_FILES definition in the ds_platform_cfg.h file. However, in order to get the diff --git a/fsw/inc/ds_platform_cfg.h b/fsw/inc/ds_platform_cfg.h index f5c1a3b..5985b00 100644 --- a/fsw/inc/ds_platform_cfg.h +++ b/fsw/inc/ds_platform_cfg.h @@ -441,10 +441,10 @@ * * \par Limits * This parameter must be set to one of the following: - * non-empty string = add move pathname field to Destination File Table - * empty string = do not add move pathname to Destination File Table + * true = add move pathname field to Destination File Table + * false = do not add move pathname to Destination File Table */ -#define DS_MOVE_FILES "Move to downlink directory" +#define DS_MOVE_FILES true /** * \brief Application Per Packet Pipe Limit diff --git a/fsw/src/ds_app.c b/fsw/src/ds_app.c index 9f7b74b..9bd982b 100644 --- a/fsw/src/ds_app.c +++ b/fsw/src/ds_app.c @@ -184,6 +184,7 @@ CFE_Status_t DS_AppInitialize(void) memset(&DS_AppData, 0, sizeof(DS_AppData)); DS_AppData.AppEnableState = DS_DEF_ENABLE_STATE; + DS_AppData.EnableMoveFiles = DS_MOVE_FILES; /* ** Mark files as closed diff --git a/fsw/src/ds_app.h b/fsw/src/ds_app.h index 94c731a..488e189 100644 --- a/fsw/src/ds_app.h +++ b/fsw/src/ds_app.h @@ -104,6 +104,8 @@ typedef struct DS_HashLink_t HashLinks[DS_PACKETS_IN_FILTER_TABLE]; /**< \brief Hash table linked list elements */ DS_HashLink_t *HashTable[DS_HASH_TABLE_ENTRIES]; /**< \brief Each hash table entry is a linked list */ + + uint8 EnableMoveFiles; /**< \brief Whether to move files to downlink directory after close */ } DS_AppData_t; /** \brief DS global data structure reference */ diff --git a/fsw/src/ds_file.c b/fsw/src/ds_file.c index 2aea73c..fb9f31c 100644 --- a/fsw/src/ds_file.c +++ b/fsw/src/ds_file.c @@ -811,7 +811,7 @@ void DS_FileCloseDest(int32 FileIndex) */ OS_close(FileStatus->FileHandle); - if (strlen(DS_MOVE_FILES) > 0) + if (DS_AppData.EnableMoveFiles == DS_ENABLED) { /* ** Move file only if table has a downlink directory name... diff --git a/unit-test/ds_cmds_tests.c b/unit-test/ds_cmds_tests.c index 7b7e893..654e5ab 100644 --- a/unit-test/ds_cmds_tests.c +++ b/unit-test/ds_cmds_tests.c @@ -991,7 +991,7 @@ void DS_SetDestSizeCmd_Test_FileTableNotLoaded(void) UT_SetDefaultReturnValue(UT_KEY(DS_TableVerifySize), true); /* Execute the function being tested */ - UtAssert_VOIDCALL(DS_SetDestSizeCmd(&UT_CmdBuf.Buf)); + UtAssert_VOIDCALL(DS_SetDestSizeCmd(&UT_CmdBuf.Buf)); /* Verify results */ UtAssert_UINT32_EQ(DS_AppData.CmdRejectedCounter, 1); @@ -1276,11 +1276,6 @@ void DS_CloseAllCmd_Test_Nominal(void) DS_AppData.FileStatus[i].FileHandle = OS_OBJECT_ID_UNDEFINED; } - if (strlen(DS_MOVE_FILES) > 0) - { - strncpy(DS_AppData.DestFileTblPtr->File[0].Movename, "", DS_PATHNAME_BUFSIZE); - } - /* Execute the function being tested */ UtAssert_VOIDCALL(DS_CloseAllCmd(&UT_CmdBuf.Buf)); diff --git a/unit-test/ds_file_tests.c b/unit-test/ds_file_tests.c index 93240cd..340c413 100644 --- a/unit-test/ds_file_tests.c +++ b/unit-test/ds_file_tests.c @@ -297,7 +297,7 @@ void DS_FileSetupWrite_Test_MaxFileSizeExceeded(void) strncpy(DS_AppData.FileStatus[FileIndex].FileName, "directory1/", sizeof(DS_AppData.FileStatus[FileIndex].FileName)); - if (strlen(DS_MOVE_FILES) > 0) + if (DS_AppData.EnableMoveFiles == DS_ENABLED) { strncpy(DS_AppData.DestFileTblPtr->File[FileIndex].Movename, "directory2/movename/", sizeof(DS_AppData.DestFileTblPtr->File[FileIndex].Movename)); @@ -572,10 +572,7 @@ void DS_FileCreateDest_Test_ClosedFileHandle(void) DS_AppData.DestFileTblPtr->File[FileIndex].FileNameType = DS_BY_COUNT; DS_AppData.FileStatus[FileIndex].FileCount = 1; - if (strlen(DS_MOVE_FILES) > 0) - { - DS_AppData.DestFileTblPtr->File[FileIndex].Movename[0] = '\0'; - } + DS_AppData.DestFileTblPtr->File[FileIndex].Movename[0] = '\0'; /* Set to fail header write, which will call OS_close and clear the handle */ if (DS_FILE_HEADER_TYPE == DS_FILE_HEADER_CFE) @@ -906,6 +903,7 @@ void DS_FileCloseDest_Test_PlatformConfigMoveFiles_Nominal(void) sizeof(DS_AppData.FileStatus[FileIndex].FileName)); strncpy(DS_AppData.DestFileTblPtr->File[FileIndex].Movename, "directory2/movename/", sizeof(DS_AppData.DestFileTblPtr->File[FileIndex].Movename)); + DS_AppData.EnableMoveFiles = DS_ENABLED; /* Execute the function being tested */ UtAssert_VOIDCALL(DS_FileCloseDest(FileIndex)); @@ -929,6 +927,7 @@ void DS_FileCloseDest_Test_PlatformConfigMoveFiles_MoveError(void) sizeof(DS_AppData.FileStatus[FileIndex].FileName)); strncpy(DS_AppData.DestFileTblPtr->File[FileIndex].Movename, "directory2/movename/", sizeof(DS_AppData.DestFileTblPtr->File[FileIndex].Movename)); + DS_AppData.EnableMoveFiles = DS_ENABLED; /* Set to generate error message DS_MOVE_FILE_ERR_EID */ UT_SetDefaultReturnValue(UT_KEY(OS_mv), -1); @@ -958,6 +957,7 @@ void DS_FileCloseDest_Test_PlatformConfigMoveFiles_FilenameTooLarge(void) DS_AppData.FileStatus[FileIndex].FileName[DS_TOTAL_FNAME_BUFSIZE - 1] = '\0'; strncpy(DS_AppData.DestFileTblPtr->File[FileIndex].Movename, "directory2/movename/", sizeof(DS_AppData.DestFileTblPtr->File[FileIndex].Movename)); + DS_AppData.EnableMoveFiles = DS_ENABLED; /* Execute the function being tested */ UtAssert_VOIDCALL(DS_FileCloseDest(FileIndex)); @@ -979,6 +979,7 @@ void DS_FileCloseDest_Test_PlatformConfigMoveFiles_FilenameNull(void) strncpy(DS_AppData.DestFileTblPtr->File[FileIndex].Movename, "directory2/movename", sizeof(DS_AppData.DestFileTblPtr->File[FileIndex].Movename)); + DS_AppData.EnableMoveFiles = DS_ENABLED; /* Execute the function being tested */ UtAssert_VOIDCALL(DS_FileCloseDest(FileIndex)); @@ -993,12 +994,31 @@ void DS_FileCloseDest_Test_PlatformConfigMoveFiles_FilenameNull(void) UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); } -void DS_FileCloseDest_Test_MoveFilesFalse(void) +void DS_FileCloseDest_Test_PlatformConfigMoveFiles_MovenameNull(void) +{ + int32 FileIndex = 0; + + /* Set up the handle */ + OS_OpenCreate(&DS_AppData.FileStatus[FileIndex].FileHandle, NULL, 0, 0); + + strncpy(DS_AppData.DestFileTblPtr->File[FileIndex].Movename, "", + sizeof(DS_AppData.DestFileTblPtr->File[FileIndex].Movename)); + DS_AppData.EnableMoveFiles = DS_ENABLED; + + /* Execute the function being tested */ + UtAssert_VOIDCALL(DS_FileCloseDest(FileIndex)); + + /* Verify results */ + UtAssert_STUB_COUNT(CFE_SB_MessageStringGet, 0); +} + +void DS_FileCloseDest_Test_PlatformConfigMoveFiles_EmptyMoveFilesTrigger(void) { int32 FileIndex = 0; /* Set up the handle */ OS_OpenCreate(&DS_AppData.FileStatus[FileIndex].FileHandle, NULL, 0, 0); + DS_AppData.EnableMoveFiles = DS_DISABLED; /* Execute the function being tested */ UtAssert_VOIDCALL(DS_FileCloseDest(FileIndex)); @@ -1304,17 +1324,12 @@ void UtTest_Setup(void) UT_DS_TEST_ADD(DS_FileUpdateHeader_Test_PlatformConfigCFE_SeekError); } - if (strlen(DS_MOVE_FILES) > 0) - { - UT_DS_TEST_ADD(DS_FileCloseDest_Test_PlatformConfigMoveFiles_Nominal); - UT_DS_TEST_ADD(DS_FileCloseDest_Test_PlatformConfigMoveFiles_MoveError); - UT_DS_TEST_ADD(DS_FileCloseDest_Test_PlatformConfigMoveFiles_FilenameTooLarge); - UT_DS_TEST_ADD(DS_FileCloseDest_Test_PlatformConfigMoveFiles_FilenameNull); - } - else - { - UT_DS_TEST_ADD(DS_FileCloseDest_Test_MoveFilesFalse); - } + UT_DS_TEST_ADD(DS_FileCloseDest_Test_PlatformConfigMoveFiles_Nominal); + UT_DS_TEST_ADD(DS_FileCloseDest_Test_PlatformConfigMoveFiles_MoveError); + UT_DS_TEST_ADD(DS_FileCloseDest_Test_PlatformConfigMoveFiles_FilenameTooLarge); + UT_DS_TEST_ADD(DS_FileCloseDest_Test_PlatformConfigMoveFiles_FilenameNull); + UT_DS_TEST_ADD(DS_FileCloseDest_Test_PlatformConfigMoveFiles_MovenameNull); + UT_DS_TEST_ADD(DS_FileCloseDest_Test_PlatformConfigMoveFiles_EmptyMoveFilesTrigger); UT_DS_TEST_ADD(DS_FileTestAge_Test_Nominal); UT_DS_TEST_ADD(DS_FileTestAge_Test_ExceedMaxAge);