2.4 Coverage criteria
2.4.2 Data flow coverage
Data flow analysis focuses on how variables are bound to values, and how these variables are to be used. Just as one would not feel confident about a program without executing
Figure 2.5: Subsumption relations among control flow coverage criteria [5].
every statement in it as part of some test, one should not feel confident about a program without having seen the effect of using the value produced by each and every computation. Traversing all paths does not guarantee that all errors will be detected. We must be aware that path selection criteria cannot ensure that a set of test data capable of uncovering all errors will be chosen, as it was demonstrated in [85,86].
2.4.2.1 The Rapps and Weyuker Family of Criteria
Both Rapps and Weyuker have defined a family of coverage criteria based on definitions and uses of variables. The first reports of said criteria can be consulted in [85,86].
Their idea was that in order to test a software correctly, we should focus on the flows of data values and try to ensure that the values created at one point in the program are not only created but also used correctly. This is done by focusing ondefinitions and uses
of values. Adefinition (def ) is a location where a value for a variable is stored into memory.
Ause is a location where a variable’s value is accessed. These data flow testing criteria
use the fact that values are carried fromdefs to uses. These are called the du-pairs - also
known asdefinition-uses, def-use, and du associations and the idea is to exercise du-pairs
in various ways [5].
Each variable occurrence is classified as being a definitional, computation-use, or predicate-use occurrence. Those are referred to asdef, c-use and p-use, respectively. Since defs have already been defined, the definitions of both c and p-use are as follow:
• p-uses occurs when a variable is used to evaluate wheater a predicate is true or false;
• c-uses occurs when a variable is used to compute the value of other variables, or
output values.
• y = f (x1, ..., xn) ⇒c-use of variables x1, ..., xnanddef of y;
• read x1, ..., xn ⇒def of variables x1, ..., xn;
• print x1, ..., xn ⇒c-uses of variables x
1, ..., xn;
• if p(x1, ..., xn) then goto m ⇒ p-uses of variables x1, ..., xn.
An important concept when discussing data flow criteria is that a def of a variable
may or may not reach a particularuse. The most obvious reason would be because no
path goes from the definition to any use. But, a more subtle reason is that the variable’s value may be changed by anotherdef before it reaches the use. Thus, a path from li to ljis
said to bedef-clear with respect to variable v if no location between li and lj changes the
value [85]. .
Next, the definitions of All-Defs, All-P-Uses, All-C-Uses/Some-P-Uses, All-P-Uses/Some- C-Uses, All-Uses, and All-du-Paths Coverage will be introduced.
All-Defs Coverage .
This criterion is satisfied if, for every variable defined, there is a path included in at least one of our test cases, that goes from the definition to a use. In a more informal way, each
def reaches at least one use.
All-P-Uses Coverage .
Here, we need to have, in at least one of our test cases, a path from every variable defini- tion to the set of all itsp-uses.
All-C-Uses/Some-P-Uses Coverage .
To accomplish all-c-uses/some-p-uses coverage it is required that everyc-use of all vari-
ables defined must be included in some path of our test cases. If there is no suchc-use,
then some p-use of the definition of the variable must be included. Thus to fulfill this
criterion, every definition which is ever used must have someuse included in the paths
of the test cases, with thec-uses particularly emphasized.
All-P-Uses/Some-C-Uses Coverage .
Similar to the previous criteria, only here we put the emphasis on thep-uses, and therefore,
everyp-use of all variables defined must be included in some path of our test cases. If
there is nop-use, then some c-use must be included.
All-Uses Coverage .
All-uses criterion is satisfied if, for every definition of a variable, there is a path in our test cases that includes adef-clear path from the definition to all its uses, both c-uses and
p-uses. In a more informal manner, this one requires that each def reaches all its possible uses.
All-du-Paths Coverage .
This one requires that eachdef reaches all possible uses through all possible du-paths.
Figure 2.6shows the subsumption relations, this time, between the criteria introduced by Rapps and Weyuker.
Figure 2.6: Subsumption relations among coverage criteria regarding uses and defs [85].
2.4.2.2 Ntafos’ Required k-Tuples Criteria
Ntafos uses data flow information to overcome the shortcomings of using control flow information alone to select paths defining a class of path selection criteria, based on data flow analysis, the Required k-Tuples. These criteria require that a path set cover
chains of alternating definitions and uses, called k-dr interactions. A k-dr interaction propagates information along a sub-path that is called an interaction sub-path for the k-dr interaction [3,19].
2.4.2.3 Laski’s and Korel’s Criteria
Laski and Korel define criteria that emphasize the fact that a given node may contain uses of several different variables, and that each use may be reached by several definitions occurring at different nodes. These criteria are concerned with selecting sub-paths along which the various combinations of definitions reach the node and they are referred to as the Context Coverage and Ordered Context Coverage criterion [19].