Structural Coverage Analysis and MC/DC for DO-178C
How DO-178C structural coverage analysis works, from statement and decision coverage to Modified Condition/Decision Coverage (MC/DC) at Level A, and how to measure it on the software that flies.
First published
By James Lawson, Federal Aviation Administration (FAA) Designated Engineering Representative (DER)
What is structural coverage analysis?
DO-178C requires two kinds of coverage analysis after requirements-based testing. Requirements-based test coverage analysis (section 6.4.4.1) confirms that the tests exercise every software requirement. Structural coverage analysis (section 6.4.4.2) confirms that the same tests exercise the code structure, and identifies any code they did not exercise.
The two analyses answer different questions. Requirements coverage shows the software does what it should. Structural coverage shows there is no code whose behavior the requirements-based tests have not examined: code without a requirement, a requirement too vague to test fully, or a test that missed a path. Structural coverage is therefore a measure of the tests and requirements, not a goal in itself. Tests written only to execute code, with no requirement behind them, do not satisfy the objective.
The reference most engineers start from is NASA’s A Practical Tutorial on Modified Condition/Decision Coverage (NASA/TM-2001-210876), written by NASA, Rockwell Collins, Boeing, and the FAA. The tutorial was written for DO-178B. This guide applies the same principles to DO-178C.
Coverage required by software level
DO-178C Table A-7 sets the structural coverage objectives by software level. Each level adds to the coverage required by the level below it.
| Table A-7 objective | Level A | Level B | Level C | Level D |
|---|---|---|---|---|
| Statement coverage | ✓ | ✓ | ✓ | |
| Decision coverage | ✓ | ✓ | ||
| Modified Condition/Decision Coverage (MC/DC) | ✓ | |||
| Data coupling and control coupling | ✓ | ✓ | ✓ | |
| Verification of additional code not traceable to Source Code | ✓ |
Level D software has no structural coverage objectives, and Level E software has no DO-178C objectives at all.
Types of structural coverage
The NASA tutorial describes six types of structural coverage. DO-178C uses three of them, and the other three explain why MC/DC was chosen.
| Coverage type | What it requires | Used by DO-178C |
|---|---|---|
| Statement coverage | Every statement in the program has executed at least once. | Levels A to C |
| Decision coverage | Every decision has taken both outcomes, true and false, and every entry and exit point has been invoked. | Levels A and B |
| Condition coverage | Every condition in a decision has taken both values, true and false. | No |
| Condition/decision coverage | Both condition coverage and decision coverage. | No |
| MC/DC | Condition/decision coverage, and each condition has been shown to independently affect the outcome of its decision. | Level A |
| Multiple condition coverage | Every combination of condition values in each decision has been tested. | No |
A decision is a Boolean expression that controls the flow of the program, such as the expression in an if statement. A condition is a Boolean expression containing no Boolean operator, such as altitude > limit. A decision with N conditions has 2ᴺ combinations, so multiple condition coverage quickly becomes impractical. MC/DC needs as few as N + 1 tests, while still showing that every condition matters.
MC/DC explained
MC/DC asks one question of every condition: does this condition, on its own, change the outcome of the decision? A condition shows this independence through a pair of tests in which only that condition changes and the decision outcome changes with it.
Take the decision (A and B) or C, with three conditions. Multiple condition coverage would need all eight combinations. MC/DC needs four tests:
| Test | A | B | C | Outcome | Shows independence of |
|---|---|---|---|---|---|
| 1 | T | T | F | T | A with test 2, B with test 3 |
| 2 | F | T | F | F | A with test 1 |
| 3 | T | F | F | F | B with test 1, C with test 4 |
| 4 | T | F | T | T | C with test 3 |
- A: tests 1 and 2 differ only in A, and the outcome changes from true to false.
- B: tests 1 and 3 differ only in B, and the outcome changes.
- C: tests 3 and 4 differ only in C, and the outcome changes.
The same pattern gives the minimum tests for the basic operators. An and of N conditions needs the all-true test, and one test for each condition with only that condition false. An or of N conditions needs the all-false test, and one test for each condition with only that condition true. The NASA tutorial builds every other construct, including xor, comparators, and loops, from these building blocks.
Unique-cause and masking MC/DC
The example above is unique-cause MC/DC: in each pair, every other condition holds the same value. Unique-cause pairs are impossible for some decisions, for example where two conditions are coupled because they read the same variable.
Masking MC/DC relaxes the rule. The other conditions may change, provided the logic of the decision prevents them from affecting the outcome. In (A and B) or C, when C is true the outcome is true whatever A and B are, so C masks A and B. DO-178C accepts both forms: its definition of MC/DC allows the other conditions to be held fixed, or only those conditions that could affect the outcome. The certification authorities explained the rationale for masking MC/DC in position paper CAST-6.
Short-circuit logic and object code
Languages such as C use short-circuit evaluation: in A && B, B is not evaluated when A is false. A compiler therefore turns each condition of a decision into a separate branch in the object code. Short-circuit logic simplifies MC/DC in one way, because each condition maps to its own branch, but it also means the value of an unevaluated condition is undefined, so the analysis must treat it as masked.
DO-178C section 6.4.4.2.b allows structural coverage analysis on the Source Code, the object code, or the Executable Object Code. For Level A, if the compiler, linker, or other means generates code that does not trace directly to Source Code statements, additional verification establishes the correctness of that code. Examples are run-time checks, compiler-generated helper routines, and decisions the compiler implements without a branch. Coverage measured on the object code sees what the processor executes, so it finds this code directly.
Instrumented versus non-intrusive coverage
Many coverage tools instrument the code: they insert probes that record which statements and conditions execute. Instrumentation changes the software under test. The instrumented build has different memory use, timing, and object code from the build that flies, so the applicant must show that the results still apply to the released software, often by running the tests twice.
Non-intrusive coverage uses the processor’s own hardware trace to record the execution path of the released Executable Object Code, without changing it. The tested software is byte-for-byte the software that flies, and timing is unaffected.
Hover’s verification environment measures coverage this way. Requirements-based tests execute on the H-series target hardware, the processor’s hardware trace records every branch in real time, and the analysis reconstructs each source decision from the object code to determine statement coverage, decision coverage, and MC/DC. The Hover Software Development Kit (H-SDK) is compatible with this environment, so software applications developed on the H-series IMA platform are verified on the Executable Object Code that flies.
Data coupling and control coupling
Table A-7 also requires analysis of data coupling and control coupling for Levels A, B, and C. Data coupling is the dependence of a software component on data not exclusively under its control. Control coupling is the way one software component influences the execution of another. The analysis confirms that the requirements-based tests exercised the interfaces between components, not only the code inside each one. The certification authorities discussed the objective in position paper CAST-19.
Resolving coverage gaps
DO-178C section 6.4.4.3 describes what to do when structural coverage analysis finds code the tests did not exercise. Each gap has one of four causes, and each cause has a different resolution:
| Cause | Resolution |
|---|---|
| Shortcomings in requirements-based tests | Add or change test cases for the existing requirements. |
| Inadequate requirements | Change the requirements, then add tests for the changed requirements. |
| Extraneous code, including dead code | Remove the code and assess the effect and the need for reverification. |
| Deactivated code | Show the code cannot be executed in the configuration that flies, or verify it against its own requirements. |
Common mistakes
| Mistake | Why it matters |
|---|---|
| Writing tests to reach coverage, not to verify requirements | Coverage must come from requirements-based tests. A test with no requirement behind it hides a missing requirement. |
| Treating 100 percent branch coverage as MC/DC | Branch coverage does not show that each condition independently affects its decision. |
| Measuring an instrumented build without showing equivalence | The results describe a different build from the one that flies. |
| Ignoring compiler-generated code at Level A | Code with no direct trace to Source Code needs additional verification under section 6.4.4.2.b. |
| Leaving coverage analysis to the end of the program | Gaps found late mean new requirements, new tests, and rework when the schedule has least room for them. |
| Using a coverage tool without qualification | A tool whose output is not otherwise verified needs DO-330 qualification before its results earn credit. |
| Forgetting data coupling and control coupling | The objective applies from Level C upwards and is reviewed separately from statement and decision coverage. |
Frequently asked questions about structural coverage analysis
What is MC/DC?
Modified Condition/Decision Coverage (MC/DC) is the structural coverage criterion DO-178C requires for Level A software. Every condition and decision takes every outcome, and each condition is shown to independently affect the outcome of its decision.
How many tests does MC/DC need?
A decision with N conditions needs at least N + 1 tests, and at most 2N for most decisions. Multiple condition coverage would need 2ᴺ tests.
Is MC/DC required for Level B software?
No. Level B requires statement coverage and decision coverage. MC/DC applies to Level A only.
Can structural coverage be measured on object code?
Yes. DO-178C section 6.4.4.2.b allows the analysis on Source Code, object code, or Executable Object Code. At Level A, code that does not trace directly to Source Code needs additional verification wherever the analysis is performed.
Does the coverage tool need qualification?
A coverage tool is a verification tool. If its output is not otherwise verified, it is qualified under DO-330, typically at Tool Qualification Level 5 (TQL-5).
What is masking MC/DC?
Masking MC/DC lets other conditions change between the two tests of a pair, provided the decision’s logic prevents them from affecting the outcome. DO-178C accepts both masking and unique-cause MC/DC.
What happens to code the tests did not reach?
The cause is identified and resolved under DO-178C section 6.4.4.3: tests are added, requirements are changed, extraneous code is removed, or deactivated code is shown to be safe.
Sources
- NASA/TM-2001-210876, A Practical Tutorial on Modified Condition/Decision Coverage, Hayhurst, Veerhusen, Chilenski, and Rierson, May 2001
- RTCA DO-178C, Software Considerations in Airborne Systems and Equipment Certification, December 2011
- RTCA DO-330, Software Tool Qualification Considerations, December 2011
- RTCA DO-248C, Supporting Information for DO-178C and DO-278A, December 2011
- Certification Authorities Software Team (CAST) position paper CAST-6, Rationale for Accepting Masking MC/DC in Certification Projects
- CAST-12, Guidelines for Approving Source Code to Object Code Traceability
- CAST-19, Clarification of Structural Coverage Analyses of Data Coupling and Control Coupling