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 #1730, Explain FS Header offset & add offset functional tests. #1731

Merged
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
4 changes: 4 additions & 0 deletions modules/cfe_testcase/src/fs_header_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ void TestCreateHeader(void)

cFE_FTAssert_VOIDCALL(CFE_FS_InitHeader(&Header, TestDescription, CFE_FS_SubType_ES_ERLOG));
UtAssert_INT32_EQ(CFE_FS_WriteHeader(fd, &Header), sizeof(CFE_FS_Header_t));
UtAssert_INT32_EQ(OS_lseek(fd, 0, OS_SEEK_CUR), sizeof(CFE_FS_Header_t));

UtAssert_INT32_EQ(CFE_FS_WriteHeader(fd, NULL), CFE_FS_BAD_ARGUMENT);
cFE_FTAssert_NOT_CFE_SUCCESS(CFE_FS_WriteHeader(OS_OBJECT_ID_UNDEFINED, &Header));
Expand All @@ -80,6 +81,7 @@ void TestReadHeader(void)
cFE_FTAssert_VOIDCALL(CFE_FS_InitHeader(&Header, TestDescription, CFE_FS_SubType_ES_ERLOG));
UtAssert_INT32_EQ(CFE_FS_WriteHeader(fd, &Header), sizeof(CFE_FS_Header_t));
UtAssert_INT32_EQ(CFE_FS_ReadHeader(&ReadHeader, fd), sizeof(CFE_FS_Header_t));
UtAssert_INT32_EQ(OS_lseek(fd, 0, OS_SEEK_CUR), sizeof(CFE_FS_Header_t));

UtAssert_INT32_EQ(Header.ContentType, ReadHeader.ContentType);
UtAssert_INT32_EQ(Header.SubType, ReadHeader.SubType);
Expand All @@ -105,6 +107,8 @@ void TestTimeStamp(void)
cFE_FTAssert_VOIDCALL(CFE_FS_InitHeader(&Header, TestDescription, CFE_FS_SubType_ES_ERLOG));
UtAssert_INT32_EQ(CFE_FS_WriteHeader(fd, &Header), sizeof(CFE_FS_Header_t));
UtAssert_INT32_EQ(CFE_FS_SetTimestamp(fd, NewTimestamp), CFE_SUCCESS);
UtAssert_INT32_EQ(OS_lseek(fd, 0, OS_SEEK_CUR), (offsetof(CFE_FS_Header_t, TimeSeconds) + sizeof(NewTimestamp)));

UtAssert_INT32_EQ(CFE_FS_ReadHeader(&ReadHeader, fd), sizeof(CFE_FS_Header_t));

UtAssert_UINT32_EQ(0xFFFFFFFF, ReadHeader.TimeSeconds);
Expand Down
6 changes: 6 additions & 0 deletions modules/core_api/fsw/inc/cfe_fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
** \par Assumptions, External Events, and Notes:
** -# The File has already been successfully opened using #OS_OpenCreate and
** the caller has a legitimate File Descriptor.
** -# File offset behavior: Agnostic on entry since it will move the offset to the start of the file,
** on success the offset will be at the end of the header, undefined offset behavior for error cases.
**
** \param[in, out] Hdr Pointer to a variable of type #CFE_FS_Header_t that will be
** filled with the contents of the Standard cFE File Header. *Hdr is the contents of the
Expand Down Expand Up @@ -116,6 +118,8 @@ void CFE_FS_InitHeader(CFE_FS_Header_t *Hdr, const char *Description, uint32 Sub
** the caller has a legitimate File Descriptor.
** -# The \c SubType field has been filled appropriately by the Application.
** -# The \c Description field has been filled appropriately by the Application.
** -# File offset behavior: Agnostic on entry since it will move the offset to the start of the file,
** on success the offset will be at the end of the header, undefined offset behavior for error cases.
**
** \param[in] FileDes File Descriptor obtained from a previous call to #OS_OpenCreate
** that is associated with the file whose header is to be read.
Expand Down Expand Up @@ -144,6 +148,8 @@ CFE_Status_t CFE_FS_WriteHeader(osal_id_t FileDes, CFE_FS_Header_t *Hdr);
** -# The File has already been successfully opened using #OS_OpenCreate and
** the caller has a legitimate File Descriptor.
** -# The \c NewTimestamp field has been filled appropriately by the Application.
** -# File offset behavior: Agnostic on entry since it will move the offset,
** on success the offset will be at the end of the time stamp, undefined offset behavior for error cases.
**
** \param[in] FileDes File Descriptor obtained from a previous call to #OS_OpenCreate
** that is associated with the file whose header is to be read.
Expand Down