07.01.2013 Views

Lecture Notes in Computer Science 3472

Lecture Notes in Computer Science 3472

Lecture Notes in Computer Science 3472

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.

12 Technology of Test-Case Generation 337<br />

l = nil ✟❍<br />

✟<br />

✟ ❍❍❍❍❍❍❍❍<br />

l �= nil<br />

✟<br />

✷ m =1✟ ✟ m > 1<br />

✟<br />

✟<br />

n > 1 ✟<br />

✟❍<br />

✟<br />

✟ ❍❍❍❍❍❍❍❍<br />

n =1 ✷<br />

✟<br />

✷ cdr(l) =nil ✟<br />

✟ cdr(l) �= nil<br />

✟<br />

✟<br />

✷ ✷<br />

Fig. 12.3. Proof structure of select<br />

ysis is then reflected <strong>in</strong> the structure of the result<strong>in</strong>g formal proof. Thus, the<br />

partition<strong>in</strong>g of the <strong>in</strong>put doma<strong>in</strong> <strong>in</strong> order to obta<strong>in</strong> sub-doma<strong>in</strong>s which satisfy a<br />

uniformity hypothesis is done as by-product of the proof process, i.e., the doma<strong>in</strong><br />

analysis is implicitly available <strong>in</strong> the proof structure and need not to be done<br />

by special test case generation procedures as usual. Test cases extracted from<br />

correctness proofs can then be used for verify<strong>in</strong>g the SUT.<br />

A small case study to justify this approach was also presented by Maharaj<br />

[Mah99]. It discusses a small program implement<strong>in</strong>g the function select<br />

which, given a list and two <strong>in</strong>tegers m and n, returns the sublist from the mth<br />

element to the n-th element. The specification of this function is given by<br />

two properties. We consider the first of them which specifies the length of the<br />

returned sublist:<br />

∀ l :List•∀m, n : N • (0 < m ≤ n) ∧ (n ≤ length(l)) (12.7)<br />

⇒ length(select(l, m, n)) = n − m +1<br />

The function has to be implemented <strong>in</strong> a high-level programm<strong>in</strong>g or specification<br />

language about which it is easy to reason. In the case study, the functional<br />

programm<strong>in</strong>g language Miranda was used. The result<strong>in</strong>g program can be seen as<br />

an executable specification of a low-level language implementation that has to<br />

be tested. The theorem prover PVS [ORS92] was used to prove the correctness<br />

of the Miranda implementation regard<strong>in</strong>g both specified properties.<br />

Property (12.7) was proved by <strong>in</strong>duction on the length of the list. The correspond<strong>in</strong>g<br />

proof structure is shown <strong>in</strong> Fig. 12.3, where cdr : List → List is a<br />

function that maps a list to its tail. This structure arises from the case dist<strong>in</strong>ctions<br />

dur<strong>in</strong>g the proof process. S<strong>in</strong>ce the proof is done by <strong>in</strong>duction on the list<br />

length, the first branch<strong>in</strong>g dist<strong>in</strong>guishes between the <strong>in</strong>duction start (l = nil)<br />

and the <strong>in</strong>duction step (l �= nil). The other branch<strong>in</strong>gs result from the proof of<br />

the <strong>in</strong>duction step.<br />

The test cases can be extracted from this tree by comb<strong>in</strong><strong>in</strong>g the conditions<br />

on the variables that occur on the branches from the root to the leaves. S<strong>in</strong>ce<br />

each branch represents a test case, we obta<strong>in</strong> five test cases. For <strong>in</strong>stance, the<br />

test case correspond<strong>in</strong>g to the right most branch is given by:<br />

{0 < m ≤ n, n ≤ length(l), l �= nil, m > 1}

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

Saved successfully!

Ooh no, something went wrong!