15.11.2014 Views

Cause-effect graphing

Cause-effect graphing

Cause-effect graphing

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Test and Verification Lecture 4<br />

<strong>Cause</strong>-<strong>effect</strong> <strong>graphing</strong><br />

& test generation from<br />

predicates<br />

Ulrik Nyman<br />

ulrik@cs.aau.dk<br />

1


Plan for today<br />

<br />

<br />

<strong>Cause</strong>-<strong>effect</strong> <strong>graphing</strong><br />

<br />

<br />

<br />

Purpose<br />

Notation<br />

Decision table and test generation<br />

Test generation from predicates<br />

<br />

<br />

<br />

Predicates and Boolean expressions<br />

Fault model<br />

Relation to cause <strong>effect</strong> <strong>graphing</strong><br />

2


<strong>Cause</strong>-<strong>effect</strong> <strong>graphing</strong><br />

<br />

<br />

A.k.a. Dependency modeling<br />

Purpose:<br />

<br />

<br />

<br />

Model relationships between<br />

<strong>Cause</strong>s and<br />

Effects<br />

3


Steps<br />

<br />

<br />

<br />

<br />

1) Identify causes and <strong>effect</strong>s by reading<br />

requirements.<br />

2) Express relationship between causes<br />

and <strong>effect</strong>s<br />

3) Transform graph to decision table<br />

4) Generate tests from decision table<br />

4


Notation<br />

<br />

C implies Ef<br />

C<br />

Ef<br />

<br />

Not C implies Ef<br />

C<br />

Ef<br />

<br />

Ef when C1 and C2<br />

and C3<br />

C1<br />

C2<br />

^<br />

Ef<br />

C3<br />

5


Notation<br />

<br />

Ef when C1 or C2<br />

C1<br />

v<br />

Ef<br />

C2<br />

6


Notation<br />

<br />

Exclusive: either<br />

C1 or C2 or C3<br />

E<br />

C1<br />

C2<br />

C3<br />

<br />

Inclusive: at least<br />

C1 or C2<br />

I<br />

C1<br />

C2<br />

7


Notation<br />

<br />

C1 requires C2<br />

C1<br />

C2<br />

<br />

One and only one<br />

of C1 and C2<br />

O<br />

C1<br />

C2<br />

8


Notation<br />

<br />

<br />

Ef1 masks Ef2<br />

Example:<br />

<br />

<br />

<br />

Ef1: Shipping<br />

invoice<br />

Ef2: Order not<br />

shipped letter<br />

Both <strong>effect</strong>s cannot<br />

occur in the same<br />

test.<br />

Ef1<br />

Ef2<br />

9


Example<br />

<br />

<br />

<br />

Online sales system<br />

<br />

Possible configurations<br />

CPU 1, 2, 3<br />

Printer PR 1, 2<br />

Monitor M 20, 23, 30<br />

<br />

RAM 256, 512, 1G<br />

Windows: Items, Free and Price<br />

Read requirements<br />

10


Example<br />

<br />

<strong>Cause</strong>s<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

C1: Purchase CPU1<br />

C2: Purchase CPU2<br />

C3: Purchase CPU3<br />

C4: Purchase PR1<br />

C5: Purchase PR2<br />

C6: Purchase M20<br />

C7: Purchase M23<br />

C8: Purchase M30<br />

11


Example<br />

<br />

Effects in Free display window<br />

<br />

RAM 256<br />

<br />

<br />

<br />

RAM 512 and PR1<br />

RAM 1G and PR2<br />

No giveaway with this item<br />

12


Example<br />

E<br />

C1<br />

C2<br />

Ef1<br />

C3<br />

C4<br />

v<br />

Ef2<br />

C5<br />

^<br />

Ef3<br />

R<br />

C6<br />

C7<br />

1<br />

Ef4<br />

C8<br />

13


Decision table<br />

C1 C2 C3 C4 Ef 1<br />

<br />

1 1 1 0 0 1<br />

<br />

2 0 0 1 0 1<br />

<br />

3 1 0 1 0 0<br />

<br />

4 0 1 0 1 0<br />

14


DT from CE graph<br />

<br />

<br />

<br />

CEGDT<br />

Input: <strong>Cause</strong> <strong>effect</strong> graph with<br />

<br />

<br />

C1, C2, ... CP<br />

Ef1, Ef2, ... EfQ<br />

Output:<br />

<br />

<br />

DT with P + Q rows<br />

Variable number of columns<br />

15


Steps<br />

<br />

<br />

<br />

Process Effects one by one<br />

Find combinations of causes that lead to<br />

the current Effect<br />

<br />

Possibly apply heuristics<br />

Update decision table<br />

16


Heuristics<br />

C1<br />

<br />

Or node<br />

<br />

Desired state: 0<br />

C2<br />

v<br />

Ef<br />

<br />

H1: Enumerate all<br />

combinations of inputs to<br />

C1 and C2 such that<br />

C1 = C2 = 0<br />

17


Heuristics<br />

C1<br />

<br />

Or node<br />

<br />

Desired state: 1<br />

C2<br />

v<br />

Ef<br />

<br />

H2: Enumerate all<br />

combinations of inputs to<br />

C1 and C2 other than<br />

those for which<br />

C1 = C2 = 1<br />

18


Heuristics<br />

C1<br />

<br />

And node<br />

<br />

Desired state: 0<br />

C2<br />

^<br />

Ef<br />

<br />

H3: Enumerate one<br />

combination for each of<br />

<br />

(0,0)<br />

<br />

(1,0)<br />

<br />

(0,1)<br />

19


Heuristics<br />

C1<br />

<br />

And node<br />

<br />

Desired state: 1<br />

C2<br />

^<br />

Ef<br />

<br />

H4: Enumerate all<br />

combinations on input of<br />

C1 and C2 such that<br />

C1 = C2 = 1<br />

20


Predicates<br />

<br />

<br />

<br />

Boolean expressions<br />

Bop – Boolean operator<br />

<br />

And, Or, Xor, Not<br />

Relop – Relational operator<br />

<br />

, =, =, =/=<br />

21


Singular<br />

<br />

Singular boolean expression<br />

<br />

Each literal only appears once<br />

22


Fault model<br />

<br />

Boolean operator fault<br />

<br />

<br />

<br />

Incorrect Boolean operator(s)<br />

Incorrect negation<br />

Incorrect Boolean variable<br />

23


Fault model<br />

<br />

<br />

Relational operator fault<br />

<br />

<br />

<br />

Incorrect relational operator<br />

Two relational faults<br />

Relational and boolean fault<br />

Arithmetic expression fault<br />

<br />

Off-by-* faults<br />

24


Fault model<br />

<br />

<br />

Not guaranteed to be detected<br />

<br />

<br />

Missing Boolean variable<br />

Extra Boolean variable<br />

Guaranteed to be detected<br />

<br />

<br />

Not a real “guarantee”<br />

If we arrive at the test location<br />

25


Testing criteria<br />

<br />

<br />

<br />

BOR: Boolean operator<br />

BRO: Boolean and relational operator<br />

BRE: Boolean and relational expression<br />

26


Generating<br />

<br />

We left out this part<br />

<br />

Generating BOR, BRO and BRE adequate<br />

test sets<br />

27


Fault propagation<br />

<br />

The generation algorithms ensure that<br />

certain types of faults are propagated to<br />

the root node<br />

Does not propagate<br />

N6 v true<br />

N6 v true<br />

N4 ^ true<br />

fault<br />

false<br />

N4 v true<br />

false<br />

28


Fault propagation<br />

<br />

The generation algorithms ensure that<br />

certain types of faults are propagated to<br />

the root node<br />

Does propagate<br />

N6 v false<br />

N6 v true<br />

N4 ^ false<br />

fault<br />

false<br />

N4 v false<br />

false<br />

29


CEG and Predicate testing<br />

<br />

<br />

<br />

Relationship among causes can be seen<br />

as predicates<br />

Effects can be used to generate oracle<br />

BOR-CSET vs. CEGDT<br />

<br />

<br />

BOR-CSET slightly less <strong>effect</strong>ive<br />

BOR-CSET significantly smaller test sets<br />

30


White box<br />

<br />

Program based predicate test generation<br />

<br />

In practice it is hard to find input which<br />

exercises the chosen combinations<br />

31

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!