Logic Coverage in Software Testing

 
I
n
t
r
o
d
u
c
t
i
o
n
 
t
o
 
S
o
f
t
w
a
r
e
 
T
e
s
t
i
n
g
C
h
a
p
t
e
r
 
3
.
3
L
o
g
i
c
 
C
o
v
e
r
a
g
e
 
f
r
o
m
 
S
o
u
r
c
e
 
C
o
d
e
 
Paul Ammann & Jeff Offutt
Paul Ammann & Jeff Offutt
 
 
L
o
g
i
c
 
E
x
p
r
e
s
s
i
o
n
s
 
f
r
o
m
 
S
o
u
r
c
e
 
Predicates are derived from 
Predicates are derived from 
decision
decision
 statements in programs
 statements in programs
In programs, most predicates have 
In programs, most predicates have 
less than four
less than four
 clauses
 clauses
Wise programmers actively strive to keep predicates simple
Wise programmers actively strive to keep predicates simple
When a predicate only has one clause, COC, ACC, ICC, and CC all
When a predicate only has one clause, COC, ACC, ICC, and CC all
collapse to 
collapse to 
predicate coverage
predicate coverage
 (PC)
 (PC)
Applying logic criteria to program source is hard because of
Applying logic criteria to program source is hard because of
reachability
reachability
 and 
 and 
controllability
controllability
:
:
Reachability
Reachability
 : Before applying the criteria on a predicate at a particular statement,
 : Before applying the criteria on a predicate at a particular statement,
we have to get to that statement
we have to get to that statement
Controllability
Controllability
 : We have to find input values that indirectly assign values to the
 : We have to find input values that indirectly assign values to the
variables in the predicates
variables in the predicates
Variables in the predicates that are not inputs to the program are called 
Variables in the predicates that are not inputs to the program are called 
internal
internal
variables
variables
These issues are illustrated through the triangle example in the
These issues are illustrated through the triangle example in the
following slides …
following slides …
 
2
 
 
undefined
 
3
 
 
 
 
3
0
 
 
p
r
i
v
a
t
e
 
s
t
a
t
i
c
 
i
n
t
 
T
r
i
a
n
g
 
(
i
n
t
 
s
1
,
 
i
n
t
 
s
2
,
 
i
n
t
 
s
3
)
 
 
 
3
1
 
 
{
 
 
 
3
2
 
 
 
 
 
i
n
t
 
t
r
i
_
o
u
t
;
 
 
 
3
3
 
 
 
3
4
 
 
 
 
 
/
/
 
t
r
i
_
o
u
t
 
i
s
 
o
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 
 
 
 
 
4
F
 
 
F
 
 
F
 
 
f
 
 
 
2
 
 
 
3
 
 
 
4
 
 
 
 
 
 
1
f
 
 
 
T
 
 
 
f
 
 
t
 
 
 
6
 
 
 
2
 
 
 
3
 
 
 
 
 
 
4
f
 
 
 
f
 
 
 
T
 
 
t
 
 
 
2
 
 
 
6
 
 
 
3
 
 
 
 
 
 
4
T
 
 
T
 
 
 
 
 
 
t
 
 
 
2
 
 
 
2
 
 
 
3
 
 
 
 
 
 
2
F
 
 
 
t
 
 
 
 
 
 
f
 
 
 
2
 
 
 
3
 
 
 
3
 
 
 
 
 
 
2
t
 
 
 
F
 
 
 
 
 
 
f
 
 
 
2
 
 
 
2
 
 
 
5
 
 
 
 
 
 
4
T
 
 
T
 
 
 
 
 
 
t
 
 
 
2
 
 
 
3
 
 
 
2
 
 
 
 
 
 
2
F
 
 
 
t
 
 
 
 
 
 
f
 
 
 
2
 
 
 
3
 
 
 
3
 
 
 
 
 
 
2
t
 
 
 
F
 
 
 
 
 
 
f
 
 
 
2
 
 
 
5
 
 
 
2
 
 
 
 
 
 
4
T
 
 
T
 
 
 
 
 
 
t
 
 
 
3
 
 
 
2
 
 
 
2
 
 
 
 
 
 
2
F
 
 
 
t
 
 
 
 
 
 
f
 
 
 
1
 
 
 
2
 
 
 
2
 
 
 
 
 
 
4
t
 
 
 
F
 
 
 
 
 
 
f
 
 
 
5
 
 
 
2
 
 
 
2
 
 
 
 
 
 
4
P
 
s
1
 
s
2
 
s
3
 
 
 
E
O
s
1
=
s
2
 
&
&
 
s
1
!
=
s
3
 
&
&
 
s
2
!
=
s
3
 
 
 
S
u
m
m
a
r
y
 
:
 
L
o
g
i
c
 
C
o
v
e
r
a
g
e
 
f
o
r
 
S
o
u
r
c
e
 
C
o
d
e
 
Predicates
 
appear in decision statements
 
if, while, for, etc.
Most predicates have less than 
four clauses
But some applications have predicates with many clauses
The hard part of applying logic criteria to source is resolving the 
internal
variables
Non-local variables 
(class, global, etc.) are also input variables if they are
used
If an input variable is changed within a method, it is treated as an
 
internal
variable
 
thereafter
To maximize effect of logic coverage criteria:
Avoid transformations that hide predicate structure
 
 
 
11
 
 
Slide Note
Embed
Share

Logic coverage from source code involves deriving predicates from decision statements in programs, where most predicates have less than four clauses. Wise programmers aim to keep predicates simple, as they affect coverage criteria such as COC, ACC, ICC, and CC, which collapse to predicate coverage (PC) when a predicate has only one clause. Applying logic criteria to program source is challenging due to reachability and controllability concerns, illustrated through examples like triangle verification routines.

  • Software Testing
  • Logic Coverage
  • Source Code
  • Program Predicates
  • Reachability

Uploaded on Oct 03, 2024 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. Introduction to Software Testing Chapter 3.3 Logic Coverage from Source Code Paul Ammann & Jeff Offutt

  2. Logic Expressions from Source Predicates are derived from decision statements in programs In programs, most predicates have less than four clauses Wise programmers actively strive to keep predicates simple When a predicate only has one clause, COC, ACC, ICC, and CC all collapse to predicate coverage (PC) Applying logic criteria to program source is hard because of reachability and controllability: Reachability : Before applying the criteria on a predicate at a particular statement, we have to get to that statement Controllability : We have to find input values that indirectly assign values to the variables in the predicates Variables in the predicates that are not inputs to the program are called internal variables These issues are illustrated through the triangle example in the following slides 2

  3. 30 private static int Triang (int s1, int s2, int s3) 31 { 32 int tri_out; 33 34 // tri_out is output from the routine: 35 // tri_out = 1 if triangle is scalene 36 // tri_out = 2 if triangle is isosceles 37 // tri_out = 3 if triangle is equilateral 38 // tri_out = 4 if not a triangle 39 40 // After a quick confirmation that it s a legal 41 // triangle, detect any sides of equal length 42 if (s1 <= 0 || s2 <= 0 || s3 <= 0) 43 { 44 tri_out = 4; 45 return (tri_out); 46 } 47 48 tri_out = 0; 49 if (s1 == s2) 50 tri_out = tri_out + 1; 51 if (s1 == s3) 52 tri_out = tri_out + 2; 53 if (s2 == s3) 54 tri_out = tri_out + 3; 55 if (tri_out == 0) 56 { // Confirm it s a legal triangle before declaring 57 // it to be scalene 59 if (s1+s2<=s3||s2+s3 <= s1 60 || s1+s3 <= s2) 61 tri_out = 4; 62 else 63 tri_out = 1; 64 return (tri_out); 65 } 67 /* Confirm it s a legal triangle before declaring 68 it to be isosceles or equilateral */ 69 70 if (tri_out > 3) 71 tri_out = 3; 72 else if (tri_out == 1 && s1+s2 > s3) 73 tri_out = 2; 74 else if (tri_out == 2 && s1+s3 > s2) 75 tri_out = 2; 76 else if (tri_out == 3 && s2+s3 > s1) 77 tri_out = 2; 78 else 79 tri_out = 4; 80 return (tri_out); 81 } // end Triang 3

  4. Ten Triangle Predicates 42: (s1 <= 0 || s2 <= 0 || s3 <= 0) 49: (s1 == s2) 51: (s1 == s3) 53: (s2 == s3) 55: (triOut == 0) 59: (s1+s2 <= s3 || s2+s3 <= s1 || s1+s3 <= s2) 70: (triOut > 3) 72: (triOut == 1 && s1+s2 > s3) 74: (triOut == 2 && s1+s3 > s2) 76: (triOut == 3 && s2+s3 > s1) 4

  5. Reachability for Triang Predicates 42: True 49: P1 = s1>0 && s2>0 && s3>0 51: P1 53: P1 55: P1 59: P1 && triOut = 0 62: P1 && triOut = 0 && (s1+s2 > s3) && (s2+s3 > s1) && (s1+s3 > s2) 70: P1 && triOut != 0 72: P1 && triOut != 0 && triOut <= 3 74: P1 && triOut != 0 && triOut <= 3 && (triOut !=1 || s1+s2<=s3) 76: P1 && triOut != 0 && triOut <= 3 && (triOut !=1 || s1+s2<=s3) && (triOut !=2 || s1+s3<=s2) 78: P1 && triOut != 0 && triOut <= 3 && (triOut !=1 || s1+s2<=s3) && (triOut !=2 || s1+s3 <= s2) && (triOut !=3 || s2+s3 <= s1) Need to solve for the internal variable triOut 5

  6. Solving for Internal Variable triOut At line 55, triOut has a value in the range (0 .. 6) triOut = 0 s1!=s2 && s1!=s3 && s2!=s3 1 s1=s2 && s1!=s3 && s2!=s3 2 s1!=s2 && s1=s3 && s2!=s3 3 s1!=s2 && s1!=s3 && s2=s3 4 s1=s2 && s1!=s3 && s2=s3 5 s1!=s2 && s1=s3 && s2=s3 6 s1=s2 && s1=s3 && s2=s3 Contradiction Contradiction 6

  7. Reachability for Triang Predicates (solved for triOut reduced) 42: True 49: P1 = s1>0 && s2>0 && s3>0 51: P1 53: P1 55: P1 59: P1 && s1 != s2 && s2 != s3 && s2 != s3 (triOut = 0) 62: P1 && s1 != s2 && s2 != s3 && s2 != s3 (triOut = 0) && (s1+s2 > s3) && (s2+s3 > s1) && (s1+s3 > s2) 70: P1 && P2 = (s1=s2 || s1=s3 || s2=s3) (triOut != 0) 72: P1 && P2 && P3 = (s1!=s2 || s1!=s3 || s2!=s3) (triOut <= 3) 74: P1 && P2 && P3 && (s1 != s2 || s1+s2<=s3) 76: P1 && P2 && P3 && (s1 != s2 || s1+s2<=s3) && (s1 != s3 || s1+s3<=s2) 78: P1 && P2 && P3 && (s1 != s2 || s1+s2<=s3) && (s1 != s3 || s1+s3<=s2) && (s2 != s3 || s2+s3<=s1) Looks complicated, but a lot of redundancy 7

  8. Predicate Coverage These values are don t care , needed to complete the test. T F s1 s2 s3 s1 s2 s3 0 0 0 1 1 1 1 1 1 1 2 2 1 1 1 1 2 2 1 1 1 2 1 2 1 2 3 1 1 1 p42: (s1 <= 0 || s2 <= 0 || s3 <= 0) p49: (s1 == s2) p51: (s1 == s3) p53: (s2 == s3) p55: (triOut == 0) p59: (s1+s2 <= s3 || s2+s3 <= s1 || s1+s3 <= s2) p70: (triOut > 3) p72: (triOut == 1 && s1+s2 > s3) p74: (triOut == 2 && s1+s3 > s2) p76: (triOut == 3 && s2+s3 > s1) 1 2 3 2 3 4 1 1 1 2 2 3 2 2 3 2 2 4 2 3 2 2 4 2 3 2 2 4 2 2 8

  9. Clause Coverage T F s1 s2 s3 EO s1 s2 s3 EO 0 1 1 4 1 1 1 3 1 0 1 4 1 1 1 3 1 1 0 4 1 1 1 3 2 3 6 4 2 3 4 1 6 2 3 4 2 3 4 1 2 6 3 4 2 3 4 1 2 2 3 2 2 3 2 2 2 2 3 2 2 2 5 4 2 3 2 2 3 2 2 2 2 3 2 2 2 5 2 4 3 2 2 2 1 2 1 4 3 2 2 2 5 2 2 4 p42: (s1 <= 0) (s2 <= 0 ) (s3 <= 0) p59: (s1+s2 <= s3 ) (s2+s3 <= s1) (s1+s3 <= s2) p72: (triOut == 1) (s1+s2 > s3) p74: (triOut == 2) (s1+s3 > s2) p76: (triOut == 3) (s2+s3 > s1) 9

  10. Correlated Active Clause Coverage P s1 s2 s3 EO T f f t 0 1 1 4 F F F f 1 1 1 3 f T f t 1 0 1 4 f f T t 1 1 0 4 T f f t 2 3 6 4 F F F f 2 3 4 1 f T f t 6 2 3 4 f f T t 2 6 3 4 T T t 2 2 3 2 F t f 2 3 3 2 t F f 2 2 5 4 T T t 2 3 2 2 F t f 2 3 3 2 t F f 2 5 2 4 T T t 3 2 2 2 F t f 1 2 2 4 t F f 5 2 2 4 p42: (s1 <= 0 || s2 <= 0 || s3 <= 0) p59: (s1+s2 <= s3 || s2+s3 <= s1 || s1+s3 <= s2) p72: (triOut == 1 && s1+s2 > s3) s1=s2 && s1!=s3 && s2!=s3 p74: (triOut == 2 && s1+s3 > s2) s1!=s2 && s1=s3 && s2!=s3 p76: (triOut == 3 && s2+s3 > s1) s1!=s2 && s1!=s3 && s2=s3 10

  11. Summary : Logic Coverage for Source Code Predicates appear in decision statements if, while, for, etc. Most predicates have less than four clauses But some applications have predicates with many clauses The hard part of applying logic criteria to source is resolving the internal variables Non-local variables (class, global, etc.) are also input variables if they are used If an input variable is changed within a method, it is treated as an internal variable thereafter To maximize effect of logic coverage criteria: Avoid transformations that hide predicate structure 11

More Related Content

giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#