![Page 1: Ch6: Software Verification. 1 White-box testing Structural testing: (In)adequacy criteria Control flow coverage criteria](https://reader030.vdocuments.us/reader030/viewer/2022032702/56649cec5503460f949b8ba0/html5/thumbnails/1.jpg)
Ch6: Software Verification
![Page 2: Ch6: Software Verification. 1 White-box testing Structural testing: (In)adequacy criteria Control flow coverage criteria](https://reader030.vdocuments.us/reader030/viewer/2022032702/56649cec5503460f949b8ba0/html5/thumbnails/2.jpg)
2
White-box testing
Structural testing:
(In)adequacy criteria
Control flow coverage criteria
![Page 3: Ch6: Software Verification. 1 White-box testing Structural testing: (In)adequacy criteria Control flow coverage criteria](https://reader030.vdocuments.us/reader030/viewer/2022032702/56649cec5503460f949b8ba0/html5/thumbnails/3.jpg)
3
Statement coverage criterion
Informally:
Formally:
Difficult to minimize the number of test cases and still ensure the execution of all statements
![Page 4: Ch6: Software Verification. 1 White-box testing Structural testing: (In)adequacy criteria Control flow coverage criteria](https://reader030.vdocuments.us/reader030/viewer/2022032702/56649cec5503460f949b8ba0/html5/thumbnails/4.jpg)
4
Statement coverage criterion (contd..)
Example
read (x); read (y);if x > 0 then
write ("1");else
write ("2");end if;if y > 0 then
write ("3");else
write ("4");end if;
{<x = 2, y = 3>, <x = - 13, y = 51>, <x = 97, y = 17>, <x = - 1, y = - 1>}covers all statements
{<x = - 13, y = 51>, <x = 2, y = - 3>} is minimal
![Page 5: Ch6: Software Verification. 1 White-box testing Structural testing: (In)adequacy criteria Control flow coverage criteria](https://reader030.vdocuments.us/reader030/viewer/2022032702/56649cec5503460f949b8ba0/html5/thumbnails/5.jpg)
5
Statement coverage criterion
if x < 0 then x := -x;end if z = :x;
This may be rewritten as:
if x < 0 then x := -x;else null;end ifz := x;
![Page 6: Ch6: Software Verification. 1 White-box testing Structural testing: (In)adequacy criteria Control flow coverage criteria](https://reader030.vdocuments.us/reader030/viewer/2022032702/56649cec5503460f949b8ba0/html5/thumbnails/6.jpg)
6
Edge coverage criterion
Criterion:
What is a control flow graph, and how to construct it?
Finer than statement coverage criterion
![Page 7: Ch6: Software Verification. 1 White-box testing Structural testing: (In)adequacy criteria Control flow coverage criteria](https://reader030.vdocuments.us/reader030/viewer/2022032702/56649cec5503460f949b8ba0/html5/thumbnails/7.jpg)
7
Control graph construction rules
I/O, assignment, or procedure call
G G1 2
if-then-else
G1
if-then
G1
while loop
G1
G 2
two sequential statements
![Page 8: Ch6: Software Verification. 1 White-box testing Structural testing: (In)adequacy criteria Control flow coverage criteria](https://reader030.vdocuments.us/reader030/viewer/2022032702/56649cec5503460f949b8ba0/html5/thumbnails/8.jpg)
8
Simplification
A sequence of edges can be collapsed into just one edge
. . .n n nnn k-1 k1 2 3
n1 nk
![Page 9: Ch6: Software Verification. 1 White-box testing Structural testing: (In)adequacy criteria Control flow coverage criteria](https://reader030.vdocuments.us/reader030/viewer/2022032702/56649cec5503460f949b8ba0/html5/thumbnails/9.jpg)
9
Example: Euclid’s algorithm
beginread (x); read (y);while x ≠ y loop
if x > y then x := x - y;
else y := y - x;
end if;end loop;gcd : = x;
end;
![Page 10: Ch6: Software Verification. 1 White-box testing Structural testing: (In)adequacy criteria Control flow coverage criteria](https://reader030.vdocuments.us/reader030/viewer/2022032702/56649cec5503460f949b8ba0/html5/thumbnails/10.jpg)
10
Weakness of edge coverage criterion
found := false; counter := 1;while (not found) and counter < number_of_items loop
if table (counter) = desired_element then found := true;
end if;counter := counter + 1;
end loop;if found then
write ("the desired element is in the table");else
write ("the desired element is not in the table");end if; test cases: (1) empty table, (2) table with 3 items, second of
which is the item to look for
![Page 11: Ch6: Software Verification. 1 White-box testing Structural testing: (In)adequacy criteria Control flow coverage criteria](https://reader030.vdocuments.us/reader030/viewer/2022032702/56649cec5503460f949b8ba0/html5/thumbnails/11.jpg)
11
Condition coverage criterion
Condition coverage:
Finer than edge coverage
![Page 12: Ch6: Software Verification. 1 White-box testing Structural testing: (In)adequacy criteria Control flow coverage criteria](https://reader030.vdocuments.us/reader030/viewer/2022032702/56649cec5503460f949b8ba0/html5/thumbnails/12.jpg)
12
Weakness of condition coverage criterion
if x ≠ 0 then
y := 5; else
z := z - x; end if;if z > 1 then
z := z / x; else
z := 0; end if;
{<x = 0, z = 1>, <x = 1, z = 3>} causes the execution of all edges, but fails to expose the risk of a division by zero
![Page 13: Ch6: Software Verification. 1 White-box testing Structural testing: (In)adequacy criteria Control flow coverage criteria](https://reader030.vdocuments.us/reader030/viewer/2022032702/56649cec5503460f949b8ba0/html5/thumbnails/13.jpg)
13
Path-coverage criterion
Path coverage criteria:
Finer than previous kinds of coverage Issues with path coverage criteria
Path coverage criterion may be used as a guide to determining a few critical paths.
![Page 14: Ch6: Software Verification. 1 White-box testing Structural testing: (In)adequacy criteria Control flow coverage criteria](https://reader030.vdocuments.us/reader030/viewer/2022032702/56649cec5503460f949b8ba0/html5/thumbnails/14.jpg)
14
White-box testing (contd..)
Guidelines for testing loops:
Guidelines for IF and CASE statements
Once a criterion has been chosen, actual input values may be chosen. How do you decide which criterion to use? Can (and should) different criterion be applied to different
modules in the same system?
![Page 15: Ch6: Software Verification. 1 White-box testing Structural testing: (In)adequacy criteria Control flow coverage criteria](https://reader030.vdocuments.us/reader030/viewer/2022032702/56649cec5503460f949b8ba0/html5/thumbnails/15.jpg)
15
White-box testing (contd..)
The presence of unreachable statements may mean that 100% coverage is not achieved.
In summary, whatever coverage criterion we decide, human intervention is needed to solve problems (reachability, etc.)
![Page 16: Ch6: Software Verification. 1 White-box testing Structural testing: (In)adequacy criteria Control flow coverage criteria](https://reader030.vdocuments.us/reader030/viewer/2022032702/56649cec5503460f949b8ba0/html5/thumbnails/16.jpg)
16
White-box testing (contd..)
Problems with white-box testing:
![Page 17: Ch6: Software Verification. 1 White-box testing Structural testing: (In)adequacy criteria Control flow coverage criteria](https://reader030.vdocuments.us/reader030/viewer/2022032702/56649cec5503460f949b8ba0/html5/thumbnails/17.jpg)
17
Black-box testing
What is black-box testing:
![Page 18: Ch6: Software Verification. 1 White-box testing Structural testing: (In)adequacy criteria Control flow coverage criteria](https://reader030.vdocuments.us/reader030/viewer/2022032702/56649cec5503460f949b8ba0/html5/thumbnails/18.jpg)
18
Black-box testing (contd..)
The program receives as input a record describing an invoice. (A detailed description of the format of the record is given.) The invoice must be inserted into a file of invoices that is sorted by date. The invoice must be inserted in the appropriate position: If other invoices exist in the file with the same date, then the invoice should be inserted after the last one. Also, some consistency checks must be performed: The program should verify whether the customer is already in a corresponding file of customers, whether the customer’s data in the two files match, etc.
Example specification
![Page 19: Ch6: Software Verification. 1 White-box testing Structural testing: (In)adequacy criteria Control flow coverage criteria](https://reader030.vdocuments.us/reader030/viewer/2022032702/56649cec5503460f949b8ba0/html5/thumbnails/19.jpg)
19
Black-box testing (contd..)
Did you consider these cases?
• An invoice whose date is the current date• An invoice whose date is before the current date
(This might be even forbidden by law)This case, in turn, can be split into the two following subcases: • An invoice whose date is the same as that
some existing invoice • An invoice whose date does not exist in any
previously recorded invoice• Several incorrect invoices, checking different types of
inconsistencies
![Page 20: Ch6: Software Verification. 1 White-box testing Structural testing: (In)adequacy criteria Control flow coverage criteria](https://reader030.vdocuments.us/reader030/viewer/2022032702/56649cec5503460f949b8ba0/html5/thumbnails/20.jpg)
20
Systematic black-box techniques
Syntax-driven testing Decision table based testing Cause-effect graph based testing
![Page 21: Ch6: Software Verification. 1 White-box testing Structural testing: (In)adequacy criteria Control flow coverage criteria](https://reader030.vdocuments.us/reader030/viewer/2022032702/56649cec5503460f949b8ba0/html5/thumbnails/21.jpg)
21
Syntax driven testing
Applicability:
Role of formal specification:
![Page 22: Ch6: Software Verification. 1 White-box testing Structural testing: (In)adequacy criteria Control flow coverage criteria](https://reader030.vdocuments.us/reader030/viewer/2022032702/56649cec5503460f949b8ba0/html5/thumbnails/22.jpg)
22
Syntax driven testing (contd..)
Example
Consider testing an interpreter of the following language
<expression> ::= <expression> + <term>|<expression> - <term> | <term>
<term> ::= <term> * <factor> | <term> / <factor> | <factor>
<factor> ::= ident | ( <expression>)
![Page 23: Ch6: Software Verification. 1 White-box testing Structural testing: (In)adequacy criteria Control flow coverage criteria](https://reader030.vdocuments.us/reader030/viewer/2022032702/56649cec5503460f949b8ba0/html5/thumbnails/23.jpg)
23
Syntax driven testing (contd..)
How to complete coverage principle:
Automated generation of test cases:
Minimal test set: