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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

14 Tools for Test Case Generation 403<br />

The test objective allows to state properties and path predicates. Safety properties<br />

are expressed with the assert keyword of Lustre. An asserted property<br />

must hold <strong>in</strong> each step of the generated test sequence. To state a path predicate,<br />

GATeL employs a slightly expanded Lustre syntax. GATeL allows to express<br />

path predicates with the additional keyword reach. The statement reach Exp<br />

means that Exp must be reached once with<strong>in</strong> the test sequence. More precisely,<br />

GATeL will try to f<strong>in</strong>d a test sequence which ends <strong>in</strong> a state where all expressions<br />

to be reached evaluate to true.<br />

The SUT and the environment are only allowed to conta<strong>in</strong> assertions. An<br />

assertion <strong>in</strong> the SUT is used by Lustre compilers to optimize the generated<br />

code. Assertions with<strong>in</strong> the environment description are used to constra<strong>in</strong> the<br />

possible behavior of the environment – as usual.<br />

As an example, consider the follow<strong>in</strong>g program and test objective. The node<br />

COUNT<br />

SIGNAL is count<strong>in</strong>g the number of cycles when signal is true. Let us further<br />

assume that signal is part of the <strong>in</strong>put.<br />

node COUNT_SIGNAL(signal : bool)<br />

returns (n : <strong>in</strong>t);<br />

let<br />

base = 0 -> pre(n);<br />

n = if signal then base + 1 else base;<br />

tel;<br />

assert true -> not ( signal and pre(signal) )<br />

reach COUNT_SIGNAL(signal)>1;<br />

The assertion requires signal to be true <strong>in</strong> two consecutive steps. The subsequent<br />

reach statement requires GATeL to generate a test sequence such that<br />

COUNT SIGNAL(signal) becomes greater than 2.<br />

Based on the SUT (or its specification) and the environment description,<br />

GATeL will try to f<strong>in</strong>d a test sequence which satisfies the path predicate expressed<br />

<strong>in</strong> the reach statement and which satisfies the asserted <strong>in</strong>variance expressions<br />

<strong>in</strong> every cycle. If such a test sequence can be found, it will be executed<br />

with the SUT. The output values computed by the SUT are compared with the<br />

correspond<strong>in</strong>g values of the precomputed test sequence. If the two sequences<br />

match, the test case passed, otherwise it failed.<br />

Test Sequence Generation<br />

Consider aga<strong>in</strong> the node COUNT SIGNAL with the test objective<br />

assert true -> not ( signal and pre(signal) );<br />

reach COUNT_SIGNAL(signal)>1;<br />

To f<strong>in</strong>d a sequence which satisfies the test objective, GATeL starts with the f<strong>in</strong>al<br />

cycle of the test sequence to be generated. Us<strong>in</strong>g the notation signal[N] to

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

Saved successfully!

Ooh no, something went wrong!