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 #1931 Support unimplemented features in MSG ft #1941

Merged
merged 1 commit into from
Sep 10, 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
45 changes: 32 additions & 13 deletions modules/cfe_testcase/src/msg_api_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ void TestMsgHeaderSecondaryApi(void)
CFE_TIME_SysTime_t msgTime;
bool isValid = true;
CFE_TIME_SysTime_t currentTime = {1000, 0xFFFF0000};
CFE_Status_t status;

memset(&cmd, 0, sizeof(cmd));
memset(&cmdTlm, 0xFF, sizeof(cmdTlm));
Expand All @@ -203,17 +204,25 @@ void TestMsgHeaderSecondaryApi(void)
UtAssert_INT32_EQ(CFE_MSG_SetType(&cmd2.Msg, CFE_MSG_Type_Cmd), CFE_SUCCESS);

/* test generate-checksum */
UtAssert_INT32_EQ(CFE_MSG_GenerateChecksum(NULL), CFE_MSG_BAD_ARGUMENT);
UtAssert_INT32_EQ(CFE_MSG_GenerateChecksum(&cmdTlm.Msg), CFE_MSG_WRONG_MSG_TYPE);
UtAssert_INT32_EQ(CFE_MSG_ValidateChecksum(&cmdTlm.Msg, &isValid), CFE_MSG_WRONG_MSG_TYPE);
UtAssert_INT32_EQ(CFE_MSG_ValidateChecksum(NULL, &isValid), CFE_MSG_BAD_ARGUMENT);
UtAssert_INT32_EQ(CFE_MSG_ValidateChecksum(&cmdTlm.Msg, NULL), CFE_MSG_BAD_ARGUMENT);

UtAssert_INT32_EQ(CFE_MSG_ValidateChecksum(&cmd.Msg, &isValid), CFE_SUCCESS);
UtAssert_True(!isValid, "Checksum isValid (%d) = false", isValid);
UtAssert_INT32_EQ(CFE_MSG_GenerateChecksum(&cmd.Msg), CFE_SUCCESS);
UtAssert_INT32_EQ(CFE_MSG_ValidateChecksum(&cmd.Msg, &isValid), CFE_SUCCESS);
UtAssert_True(isValid, "Checksum isValid (%d) = true", isValid);
status = CFE_MSG_GenerateChecksum(NULL);
if (status == CFE_MSG_NOT_IMPLEMENTED)
{
UtAssert_NA("CFE_MSG_GenerateChecksum not implemented");
}
else
{
UtAssert_INT32_EQ(CFE_MSG_GenerateChecksum(NULL), CFE_MSG_BAD_ARGUMENT);
UtAssert_INT32_EQ(CFE_MSG_GenerateChecksum(&cmdTlm.Msg), CFE_MSG_WRONG_MSG_TYPE);
UtAssert_INT32_EQ(CFE_MSG_ValidateChecksum(&cmdTlm.Msg, &isValid), CFE_MSG_WRONG_MSG_TYPE);
UtAssert_INT32_EQ(CFE_MSG_ValidateChecksum(NULL, &isValid), CFE_MSG_BAD_ARGUMENT);
UtAssert_INT32_EQ(CFE_MSG_ValidateChecksum(&cmdTlm.Msg, NULL), CFE_MSG_BAD_ARGUMENT);

UtAssert_INT32_EQ(CFE_MSG_ValidateChecksum(&cmd.Msg, &isValid), CFE_SUCCESS);
UtAssert_True(!isValid, "Checksum isValid (%d) = false", isValid);
UtAssert_INT32_EQ(CFE_MSG_GenerateChecksum(&cmd.Msg), CFE_SUCCESS);
UtAssert_INT32_EQ(CFE_MSG_ValidateChecksum(&cmd.Msg, &isValid), CFE_SUCCESS);
UtAssert_True(isValid, "Checksum isValid (%d) = true", isValid);
}

/* test get/set-fcn-code */
UtAssert_INT32_EQ(CFE_MSG_SetFcnCode(NULL, 4), CFE_MSG_BAD_ARGUMENT);
Expand All @@ -232,10 +241,20 @@ void TestMsgHeaderSecondaryApi(void)

UtAssert_INT32_EQ(CFE_MSG_GetMsgTime(NULL, &msgTime), CFE_MSG_BAD_ARGUMENT);
UtAssert_INT32_EQ(CFE_MSG_GetMsgTime(&cmd.Msg, NULL), CFE_MSG_BAD_ARGUMENT);
UtAssert_INT32_EQ(CFE_MSG_GetMsgTime(&cmd2.Msg, &msgTime), CFE_MSG_WRONG_MSG_TYPE);

CFE_Assert_STATUS_STORE(CFE_MSG_GetMsgTime(&cmd2.Msg, &msgTime));
if (!CFE_Assert_STATUS_MAY_BE(CFE_SUCCESS))
{
CFE_Assert_STATUS_MUST_BE(CFE_MSG_WRONG_MSG_TYPE);
}

UtAssert_INT32_EQ(CFE_MSG_SetMsgTime(NULL, currentTime), CFE_MSG_BAD_ARGUMENT);
UtAssert_INT32_EQ(CFE_MSG_SetMsgTime(&cmd2.Msg, currentTime), CFE_MSG_WRONG_MSG_TYPE);

CFE_Assert_STATUS_STORE(CFE_MSG_SetMsgTime(&cmd2.Msg, currentTime));
if (!CFE_Assert_STATUS_MAY_BE(CFE_SUCCESS))
{
CFE_Assert_STATUS_MUST_BE(CFE_MSG_WRONG_MSG_TYPE);
}

UtAssert_INT32_EQ(CFE_MSG_SetMsgTime(&cmd.Msg, currentTime), CFE_SUCCESS);
UtAssert_INT32_EQ(CFE_MSG_GetMsgTime(&cmd.Msg, &msgTime), CFE_SUCCESS);
Expand Down
7 changes: 6 additions & 1 deletion modules/cfe_testcase/src/sb_sendrecv_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,12 @@ void TestBasicTransmitRecv(void)
/* Attempt to send a msg which does not have a valid msgid */
memset(&CFE_FT_BigMsg, 0xFF, sizeof(CFE_FT_BigMsg));
CFE_MSG_SetSize(&CFE_FT_BigMsg.Hdr, sizeof(CFE_MSG_Message_t) + 4);
UtAssert_INT32_EQ(CFE_SB_TransmitMsg(&CFE_FT_BigMsg.Hdr, true), CFE_SB_BAD_ARGUMENT);

CFE_Assert_STATUS_STORE(CFE_SB_TransmitMsg(&CFE_FT_BigMsg.Hdr, true));
if (!CFE_Assert_STATUS_MAY_BE(CFE_SUCCESS))
{
CFE_Assert_STATUS_MUST_BE(CFE_SB_BAD_ARGUMENT);
}
Comment on lines +126 to +130
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@skliper I had to do this because every MID is valid for them, but I'm not convinced this is the right way to handle that scenario and I can't think of a better way.


/* Attempt to send a msg which is too big */
CFE_MSG_SetSize(&CFE_FT_BigMsg.Hdr, sizeof(CFE_FT_BigMsg));
Expand Down