• No results found

Modified Condition/Decision Coverage (MC/DC)

4.6 Summary

5.1.4 Modified Condition/Decision Coverage (MC/DC)

Modified Condition/Decision Coverage (MC/DC) [Hayhurst et al., 2001] is a method of ensuring adequate testing for safety-critical software. At its core is the idea that if a choice can be made, all the possible factors (conditions) that contribute to that choice (decision) must be tested. For traditional software, both conditions and the decision are usually Boolean variables or Boolean expressions.

Example 7 The decision

d ⇐⇒ ((a >3)∨(b= 0))∧(c6= 4) (25)

contains the three conditions (a >3), (b= 0)and (c6= 4). The following six test cases provide 100% MC/DC coverage:

1. (a >3)=false,(b= 0)=true,(c6= 4)=false

2. (a >3)=true,(b= 0)=false,(c6= 4)=true

3. (a >3)=false,(b= 0)=false,(c6= 4)=true

4. (a >3)=false,(b= 0)=true,(c6= 4)=true

The first two test cases already satisfy both condition coverage(i.e., all possibilities of the conditions are exploited) and decision coverage (i.e., all possibilities of the decision are exploited). The other two cases are needed because, for MC/DC each condition should evaluate totrueandfalseat least once, and should independently affect the decision outcome

Motivated by the MC/DC testing for traditional software, an MC/DC vari- ant for DNNs are initially proposed in [Sun et al., 2018a], which is further refined in [Sun et al., 2018b]. Different from these criteria in [Pei et al., 2017a, Ma et al., 2018a] that only consider individual neurons’ activations, the criteria in [Sun et al., 2018a, Sun et al., 2018b] take into account the causal relation between features in DNNs: the core idea is to ensure that not only the presence of a feature needs to be tested but also the effects of less complex features on a more complex feature must be tested.

We let Ψk be a set of subsets of nodes at layerk. Without loss of generality,

each element of Ψk, i.e., a subset of nodes in thek-th layer, represents afeature

learned at layerk.

At first, different from the Boolean case, where changes of conditions and decisions are straightforwardly switches of true/falsevalues, the change observed on a feature can be either a sign change or a value change.

Definition 26 (Sign Change) Given a featureψk,l and two test casesx1 and

x2, the sign change of ψk,l is exploited byx1 and x2, denoted as sc(ψk,l, x1, x2),

if

• sign(nk,j, x1)6=sign(nk,j, x2)for all nk,j∈ψk,l.

Moreover, we writensc(ψk,l, x1, x2)if

• sign(nk,j, x1) =sign(nk,j, x2)for all nk,j∈ψk,l.

Note that nsc(ψk,l, x1, x2)=6 ¬sc(ψk,l, x1, x2). When the ReLU activation

function is assumed, the sign change of a feature represents switch of the two cases, in which neuron activations of this feature are and are not propagated to the next layer.

A feature’s sign change is sometimes too restrictive and its value change compensates this. We can denote a value function asg : Ψk×DL1×DL1 →

{true,false}. Simply speaking, it expresses the DNN developer’s intuition (or knowledge) on what contributes as a significant change on the featureψk,l, by

specifying the difference between two vectorsψk,l[x1] andψk,l[x2]. The following

are a few examples.

Example 8 For a singleton setψk,l={nk,j}, the function g(ψk,l, x1, x2) can

express e.g.,|uk,j[x1]−uk,j[x2]| ≥d(absolute change), or

uk,j[x1]

uk,j[x2] > d∨

uk,j[x1]

uk,j[x2] < 1/d (relative change), etc. It can also express the constraint on one of the values

uk,j[x2] such asuk,j[x2]> d(upper boundary).

Example 9 For the general case, the function g(ψk,l, x1, x2) can express the

distance between two vectorsψk,l[x1] andψk,l[x2]by e.g., norm-based distances

||ψk,l[x1]−ψk,l[x2]||p ≤d for a real number d and a distance measureLp, or

structural similarity distances such as SSIM [Wang et al., 2003]. It can also express constraints between nodes of the same layer such as V

j6=ivk,i[x1] ≥

Consequently, the value change of a feature is defined as follows.

Definition 27 (Value Change) Given a feature ψk,l, two test cases x1 and

x2, and a value functiong, the value change ofψk,l is exploited by x1 andx2

with respect tog, denoted as vc(g, ψk,l, x1, x2), if

• g(ψk,l, x1, x2)=true.

Moreover, we write¬vc(g, ψk,l, x1, x2)when the condition is not satisfied.

Based on the concept of sign changes and value changes, a family of four coverage criteria are proposed in [Sun et al., 2018a, Sun et al., 2018b], i.e., the MC/DC variant for DNNs, to exploit the causal relationship between the changes of features at consecutive layers of the neural network.

Definition 28 (Sign-Sign Coverage, or SS Coverage) A feature pairα= (ψk,i, ψk+1,j) is SS-covered by two test casesx1, x2, denoted asSS(α, x1, x2), if

the following conditions are satisfied by the DNN instancesN[x1]and N[x2]:

• sc(ψk,i, x1, x2)andnsc(Pk\ψk,i, x1, x2);

• sc(ψk+1,j, x1, x2).

wherePk is the set of nodes in layer k.

Definition 29 (Sign-Value Coverage, or SV Coverage) Given a value func- tiong, a feature pairα= (ψk,i, ψk+1,j) is SV-covered by two test casesx1, x2,

denoted asSVg(α, x1, x2), if the following conditions are satisfied by the DNN

instancesN[x1] andN[x2]:

• sc(ψk,i, x1, x2)andnsc(Pk\ψk,i, x1, x2);

• vc(g, ψk+1,j, x1, x2) andnsc(ψk+1,j, x1, x2).

Definition 30 (Value-Sign Coverage, or VS Coverage) Given a value func- tiong, a feature pairα= (ψk,i, ψk+1,j) is VS-covered by two test casesx1, x2,

denoted asV Sg(α, x1, x2), if the following conditions are satisfied by the DNN

instancesN[x1] andN[x2]:

• vc(g, ψk,i, x1, x2)andnsc(Lk, x1, x2);

• sc(ψk+1,j, x1, x2).

Definition 31 (Value-Value Coverage, or VV Coverage) Given two value functionsg1 andg2, a feature pairα= (ψk,i, ψk+1,j)is VV-covered by two test

casesx1, x2, denoted asV Vg1,g2(α, x1, x2), if the following conditions are satis-

fied by the DNN instancesN[x1]andN[x2]:

• vc(g1, ψk,i, x1, x2)andnsc(Lk, x1, x2);

For all the above, each test case is a pair of inputs, i.e., T ⊆DL1×DL1. The test objectivesOis a set of feature pairs, provided by the user or computed automatically according to the structure of the DNN. The covering methodscov has been defined in the above definitions.

For the test case generation, [Sun et al., 2018a] develops an algorithm based on liner programming (LP). This is complemented with an adaptive gradient descent (GD) search algorithm in [Sun et al., 2018b] and a concolic testing algorithm in [Sun et al., 2018c].

Related documents