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

SB missing branch coverage in CFE_SB_DeletePipeFull, CFE_SB_SubscribeFull, CFE_SB_UnsubscribeFull: PendingEventID != 0 when status == CFE_SUCCESS #1914

Open
skliper opened this issue Aug 30, 2021 · 1 comment

Comments

@skliper
Copy link
Contributor

skliper commented Aug 30, 2021

Is your feature request related to a problem? Please describe.
PendingEventID is always set, so can't hit false case:

     447         [ +  - ]:          3 :     else if (PendingEventID != 0)
     448                 :            :     {
     449                 :          3 :         CFE_SB_Global.HKTlmMsg.Payload.CreatePipeErrorCounter++;
     450                 :            :     }

here:

else if (PendingEventID != 0)
{
CFE_SB_Global.HKTlmMsg.Payload.CreatePipeErrorCounter++;
}

Same pattern in CFE_SB_SubscribeFull (although inverted):

    1115         [ +  - ]:        438 :     else if (Status == CFE_SUCCESS)
    1116                 :            :     {
    1117                 :            :         /* If no other event pending, send a debug event indicating success */
    1118                 :        876 :         CFE_EVS_SendEventWithAppID(CFE_SB_SUBSCRIPTION_RCVD_EID, CFE_EVS_EventType_DEBUG, CFE_SB_Global.AppId,
    1119                 :            :                                    "Subscription Rcvd:MsgId 0x%x on PipeId %lu,app %s",
    1120                 :        438 :                                    (unsigned int)CFE_SB_MsgIdToValue(MsgId), CFE_RESOURCEID_TO_ULONG(PipeId),
    1121                 :            :                                    CFE_SB_GetAppTskName(TskId, FullName));
    1122                 :            :     }

here:

else if (Status == CFE_SUCCESS)
{
/* If no other event pending, send a debug event indicating success */
CFE_EVS_SendEventWithAppID(CFE_SB_SUBSCRIPTION_RCVD_EID, CFE_EVS_EventType_DEBUG, CFE_SB_Global.AppId,
"Subscription Rcvd:MsgId 0x%x on PipeId %lu,app %s",
(unsigned int)CFE_SB_MsgIdToValue(MsgId), CFE_RESOURCEID_TO_ULONG(PipeId),
CFE_SB_GetAppTskName(TskId, FullName));
}

Again in CFE_SB_UnsubscribeFull:

    1310         [ +  - ]:         10 :     else if (Status == CFE_SUCCESS)
    1311                 :            :     {
    1312                 :            :         /* if no other event pending, send a debug event for successful unsubscribe */
    1313                 :         20 :         CFE_EVS_SendEventWithAppID(CFE_SB_SUBSCRIPTION_REMOVED_EID, CFE_EVS_EventType_DEBUG, CFE_SB_Global.AppId,
    1314                 :            :                                    "Subscription Removed:Msg 0x%x on pipe %lu,app %s",
    1315                 :         10 :                                    (unsigned int)CFE_SB_MsgIdToValue(MsgId), CFE_RESOURCEID_TO_ULONG(PipeId),
    1316                 :            :                                    CFE_SB_GetAppTskName(TskId, FullName));
    1317                 :            :     }

here:

else if (Status == CFE_SUCCESS)
{
/* if no other event pending, send a debug event for successful unsubscribe */
CFE_EVS_SendEventWithAppID(CFE_SB_SUBSCRIPTION_REMOVED_EID, CFE_EVS_EventType_DEBUG, CFE_SB_Global.AppId,
"Subscription Removed:Msg 0x%x on pipe %lu,app %s",
(unsigned int)CFE_SB_MsgIdToValue(MsgId), CFE_RESOURCEID_TO_ULONG(PipeId),
CFE_SB_GetAppTskName(TskId, FullName));
}

Describe the solution you'd like
Consider just else? Anything that isn't a SUCCESS should increment the error counter.

Describe alternatives you've considered
None.

Additional context
None

Requester Info
Jacob Hageman - NASA/GSFC

@skliper skliper changed the title SB missing branch coverage in CFE_SB_DeletePipeFull, PendingEventID never 0 SB missing branch coverage in CFE_SB_DeletePipeFull and CFE_SB_SubscribeFull, PendingEventID != 0 when status == CFE_SUCCESS Aug 30, 2021
@skliper skliper changed the title SB missing branch coverage in CFE_SB_DeletePipeFull and CFE_SB_SubscribeFull, PendingEventID != 0 when status == CFE_SUCCESS SB missing branch coverage in CFE_SB_DeletePipeFull, CFE_SB_SubscribeFull, CFE_SB_UnsubscribeFull: PendingEventID != 0 when status == CFE_SUCCESS Aug 30, 2021
@avan989
Copy link
Contributor

avan989 commented Jun 8, 2023

Code coverage is not possible. If Status != CFE_SUCCESS then PendingEventID != 0 (Always set). Recommend just following @skliper solution and use an if/else statement.
This would:

  1. make the branch possible
  2. make it consistence with how the other function implements this part of the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants