主要内容

Troubleshoot Missing Review Data After Importing from Previous Coverage Results

R2026b

Issue

Using Polyspace® Test™, you can calculate how much of your C/C++ code is covered by existing tests. If your workflow requires justifying missing coverage that you do not plan to fix, you can add your comments and justifications in the coverage results and reuse them in future runs. In some cases, when you import from a previous coverage results set, your comments and justifications might not appear for specific results in the current results set.

This topic outlines some steps you can take to diagnose why previous review data did not get imported into a new result.

Possible Solutions

Check If Old and New Coverage Result Are Same

Check if the new coverage result where you expect your previous justifications to appear is the same as the previous result. When you import comments and justifications from previous coverage results, ones that do not apply to the new coverage results are ignored. The import tool follows a conservative approach when deciding to import older justifications to avoid incorrectly justifying a coverage result.

Review information is imported from an earlier results set to a new results set using these rules:

  • A justification and comment associated with a missing decision coverage result is imported to a new result only if the new result is associated with the same decision as the previous one. In other words, the decision must:

    • Involve the same expression.

    • Appear in the same file.

    • Have the same index relative to the start of its parent function. The first decision in a function is assigned the index 1, the second index 2, and so on.

  • A justification and comment associated with a missing condition coverage result is imported to a new result only if the new result is associated with the same condition as the previous one. In other words, the condition must:

    • Involve the same expression.

    • Appear in the same file.

    • Have the same index relative to the start of its parent decision and function.

Similar considerations apply to other kinds of coverage results.

For instance, suppose you justify the missing coverage of the decision here and save your justifications.

bool isGreaterThanSpeedLimit(uint32_t speedReading, uint32_t limit) {
     if (speedReading > limit + SPEED_LIMIT_TOLERANCE) {
         
     }
}
When you import the justification to the results of a future run, as long as the expression:
speedReading > limit + SPEED_LIMIT_TOLERANCE
Remains the first decision in the parent function isGreaterThanSpeedLimit(), the missing coverage of this decision remains justified.

Check Saved Review Information

To correctly identify expressions in future runs, review information from the current run is stored in a specific format. Check this saved review information to identify why your previous review data might not have been imported.

When you save your justifications and comments in the Polyspace Platform user interface, each justification is written as a rule in a justification filter file (.psprof.filter file) in XML format. For example:

  • This justification rule justifies all missing coverage in the file utils.c:

    <rule type="FILE" fileName="utils.c" mode="JUSTIFIED" rationale="Exempted from full coverage requirement"/>

  • This justification rule justifies the missing coverage of the first decision in the function isGreaterThanSpeedLimit() in the file utils.c:

    <filter>
        <rule type="DECISION" fileName="utils.c" functionName="isGreaterThanSpeedLimit" expr="speedReading &gt; limit + SPEED_LIMIT_TOLERANCE" index="1" mode="JUSTIFIED" rationale="Testable only on hardware failures"/>
    </filter>

  • This justification rule justifies the missing coverage of the first condition in the first decision in the function checkAgainstSpeedLimit() in the file utils.c:

    <rule type="CONDITION" fileName="utils.c" functionName="checkAgainstSpeedLimit" expr="speedReading &gt; SPEED_UPPER_BOUND || limit &gt; SPEED_UPPER_BOUND" index="1" condIndex="1" mode="JUSTIFIED" rationale="Defensive code"/>

In the justification filter file (.psprof.filter file), each justification rule appears as an XML <rule> element with these attributes:

  • type – Type of coverage result. Allowed values are FILE, FUNCTION, DECISION, CONDITION, CONDITION_OUTCOME, DECISION_OUTCOME, MCDC_OUTCOME, and RELBOUND_OUTCOME.

  • fileName, functionName – Name of the file and the function containing the result.

  • expr – Expression associated with a decision or condition coverage result.

  • index – Position (one-based index) of the decision relative to the start of its parent function.

  • condIndex – Position (one-based index) of the condition relative to its parent decision. This attribute appears for condition coverage results only.

  • mode – Whether the result is justified. Allowed values are NONE and JUSTIFIED.

  • rationale – Any comment that you add in support of justifying a result.

See Also

Topics