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

cFE_SB line/branch coverage not 100% #2252

Open
dmknutsen opened this issue Mar 9, 2023 · 3 comments
Open

cFE_SB line/branch coverage not 100% #2252

dmknutsen opened this issue Mar 9, 2023 · 3 comments
Milestone

Comments

@dmknutsen
Copy link
Contributor

dmknutsen commented Mar 9, 2023

Is your feature request related to a problem? Please describe.
Currently CFE_SB is not seeing full code coverage during the unit tests. There are two conditions that seem to be causing this:

  1. In various functions there are checks for - PendingEventId != 0 and Status = CFE_SUCCESS. However, both of these variables are being changed together, such that conditions are mutually exclusive. The end results is that there is no path for PendingEvent to still be non-0 if the status does not equal CFE_SUCCESS.

Example (cfe_sb_api.c line 428):

if (Status == CFE_SUCCESS)
{
    CFE_SB_PipeDescSetFree(PipeDscPtr);
    --CFE_SB_Global.StatTlmMsg.Payload.PipesInUse;
}
else if (PendingEventID != 0)
{
    CFE_SB_Global.HKTlmMsg.Payload.CreatePipeErrorCounter++;
}
  1. Another issue that is occurring is in all usages of switch statements. Without a default case capturing an unknown event ID, SB assumes that the case will always fall within the defined EIDs - which causes an issue with gcov coverage statistics.

Example:

    switch (PendingEventID)
    {
        case CFE_SB_DEL_PIPE_ERR1_EID:
            CFE_EVS_SendEventWithAppID(CFE_SB_DEL_PIPE_ERR1_EID, CFE_EVS_EventType_ERROR, CFE_SB_Global.AppId,
                                       "Pipe Delete Error:Bad Argument,PipedId %ld,Requestor %s",
                                       CFE_RESOURCEID_TO_ULONG(PipeId), FullName);
            break;
        case CFE_SB_DEL_PIPE_ERR2_EID:
            CFE_EVS_SendEventWithAppID(CFE_SB_DEL_PIPE_ERR2_EID, CFE_EVS_EventType_ERROR, CFE_SB_Global.AppId,
                                       "Pipe Delete Error:Caller(%s) is not the owner of pipe %ld", FullName,
                                       CFE_RESOURCEID_TO_ULONG(PipeId));
            break;
    }

Describe the solution you'd like
I believe these were already adjudicated as part of the coverage analysis. However, they were pointed out by JSC SA and it is likely the non100% coverage statistics will keep coming up such that it would be worthwhile to revisit/fix or document why we think the branch coverage meets requirements. Further, we may want to audit our branch coverage for the other core apps as well.

Requester Info
Dan Knutsen
NASA GSFC

@dmknutsen dmknutsen changed the title cFE_SB branch coverage not 100% cFE_SB line/branch coverage not 100% Mar 9, 2023
@dmknutsen dmknutsen added this to the Equuleus milestone Mar 9, 2023
@dmknutsen
Copy link
Contributor Author

It turns out that this info used to be tracked within the cFE VDD. It looks like we dropped the info in the latest release and will need to output a version B VDD for Draco-rc4

@chillfig
Copy link
Contributor

chillfig commented Mar 9, 2023

It turns out that this info used to be tracked within the cFE VDD. It looks like we dropped the info in the latest release and will need to output a version B VDD for Draco-rc4

An updated VDD for Draco-rc4 including dispositions about missing line/function/branch code coverage is uploaded and can be found here: https://github.com/nasa/cFE/releases/download/draco-rc4/cFE_VDD_draco_rc4_revB.docx

@thnkslprpt
Copy link
Contributor

thnkslprpt commented May 2, 2023

@dmknutsen - Would something like this be a valid solution to these issues?

Screenshot 2023-05-02 16 41 42

Even though it's a hack, this would both improve coverage, and add the missing default cases for all switch blocks, which is preferred by the relevant coding standards anyway. As long as there are clear comments it seems low/no-risk in terms of introducing bugs in the future.

Or is the last case falling through to default, when that's not actually the intended logic, even worse than leaving these lines uncovered?

Another option:
https://github.com/nasa/MD/blob/116d2986500101551beb32bcd3fa30de4cfd39b9/fsw/src/md_app.c#L613-L623
Although honestly, this last option seems more confusing/dangerous than it's worth.

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

3 participants