-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Tracking implementation for MC/DC #124144
Copy link
Copy link
Open
0 / 20 of 2 issues completedLabels
A-code-coverageArea: Source-based code coverage (-Cinstrument-coverage)Area: Source-based code coverage (-Cinstrument-coverage)B-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCF-coverage-mcdcMC/DC coverage via -Cinstrument-coverage with -Zcoverage-options=mcdcMC/DC coverage via -Cinstrument-coverage with -Zcoverage-options=mcdcS-tracking-impl-incompleteStatus: The implementation is incomplete.Status: The implementation is incomplete.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-code-coverageArea: Source-based code coverage (-Cinstrument-coverage)Area: Source-based code coverage (-Cinstrument-coverage)B-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCF-coverage-mcdcMC/DC coverage via -Cinstrument-coverage with -Zcoverage-options=mcdcMC/DC coverage via -Cinstrument-coverage with -Zcoverage-options=mcdcS-tracking-impl-incompleteStatus: The implementation is incomplete.Status: The implementation is incomplete.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
View all comments
Introduction
Modified condition/decision coverage (MC/DC) is a code coverage criterion used widely in safety critical software components and is required by standards such as DO-178B and ISO26262.
Terminology
condition: boolean expressions that have no binary logical operators. For example,
a || bis not "condition" because it has an or operator whilea==bis.decision: longest boolean expressions composed of conditions and binary boolean expressions only.
MC/DC requires each condition in a decision is shown to independently affect the outcome of the decision.
e.g Suppose we have code like
Here
(a || b) && cis a decision anda,b,care conditions.(a=true, b=false, c=true)and(a=false, b=false, c=true), we sayacan independently affect the decision because the value of decision is changed asachanges while keepbandcunchanged. So that we get 1/3 MC/DC here (1 foraand 3 fora,b,c).(a=false, b=true, c=true)and(a=false, b=false, c=false)also showbcan independently affect the decision. Though in the later casecis also changed but it is short-circuited and has no impacts (thus we can view it as same asc=true). Whilecis not acknowledged due to change ofb. Plus the two cases before we get 2/3 MC/DC.(a=true,b=false,c=true)and(a=true,b=false,c=false)showccan do the same. By now we get 3/3.Notice that there are duplicate cases, so test cases collection {
(a=true, b=false, c=true),(a=false, b=false, c=true),(a=false, b=true, c=true),(a=false, b=false, c=false),(a=true,b=false,c=false)} are sufficient to prove 3/3 MC/DC.In fact we can use at least n+1 cases to prove 100% MC/DC of decision with n conditions. (In this example, {
(a=true,b=false,c=true),(a=false,b=false,c=true),(a=false,b=true,c=true),(a=true,b=false,c=false)} are enough)Progress
A basic implementation for MC/DC is filed on #123409 , which has some limits. There are still several cases need to handle:
let val = a || b. Done atcoverage: Optionally instrument the RHS of lazy logical operators #125756
MCDC Coverage: instrument last boolean RHS operands from condition coverage #125766
Draft: Support mcdc analysis for pattern matching #124278
if (a || b) || inner_decision(c || d). Done at MCDC coverage: support nested decision coverage #124255[Coverage][MCDC] Adapt mcdc to llvm 19 #126733
Known Issues