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.

350 Levi Lúcio and Marko Samer<br />

cases not from an abstract model as the ones described <strong>in</strong> 12.3.2, but from Java<br />

code directly. We chose to take this detour from the ma<strong>in</strong> topic of this section<br />

<strong>in</strong> order to discuss a technique that:<br />

• generates test cases from “real code” <strong>in</strong> a modern programm<strong>in</strong>g language;<br />

• takes advantage of a model checker (Java PathF<strong>in</strong>der) to overcome some of<br />

the difficulties of symbolic execution;<br />

• takes advantage of symbolic execution to overcome some of the difficulties<br />

of model check<strong>in</strong>g.<br />

Java PathF<strong>in</strong>der is a model checker (see Sec. 12.4) built specifically for Java.<br />

As all model checkers, it allows verify<strong>in</strong>g that a model of an application (or, <strong>in</strong><br />

this case the application itself) satisfies a set of logic formulas specify<strong>in</strong>g given<br />

properties of the application. An <strong>in</strong>terest<strong>in</strong>g property to be verified with Java<br />

PathF<strong>in</strong>der is for example that no exception is left unhandled <strong>in</strong> a given method.<br />

As a result of the model check<strong>in</strong>g we can obta<strong>in</strong> either execution trace witnesses<br />

of the validity of the formulas or execution trace counter-examples if the formulas<br />

do not hold. Clearly, witnesses are positive test cases and counter examples are<br />

negative ones.<br />

There is a fundamental difference between this approach and the ones described<br />

before. In fact, all the previous frameworks were based on the fact that<br />

a model of the application, assumed correct, existed. The implementation could<br />

then be verified aga<strong>in</strong>st that model. In the present case, the model does not<br />

exist explicitly: it is provided implicitly with the temporal logic formulas. The<br />

expected correct and <strong>in</strong>correct behaviors of the implementation are described<br />

by the test eng<strong>in</strong>eer us<strong>in</strong>g temporal logic. The simple fact that the witnesses or<br />

counterexamples to these formulas exist already provides <strong>in</strong>formation about the<br />

correctness of the implementation.<br />

One of the ma<strong>in</strong> issues around model check<strong>in</strong>g software applications is the<br />

state space explosion problem. In order to be model checked efficiently, an application<br />

needs to be bounded on its <strong>in</strong>put variables. Symbolic execution may help<br />

<strong>in</strong> this po<strong>in</strong>t, by replac<strong>in</strong>g explicitly valued states by symbolic states represent<strong>in</strong>g<br />

large doma<strong>in</strong>s.<br />

On the other hand, model check<strong>in</strong>g provides a number of built-<strong>in</strong> facilities<br />

that allows explor<strong>in</strong>g a state space efficiently. In particular, goodies like the handl<strong>in</strong>g<br />

of loops, recursion or method <strong>in</strong>vocation can be hidden from the symbolic<br />

execution part. The handl<strong>in</strong>g of <strong>in</strong>f<strong>in</strong>ite execution trees is handled by the model<br />

checker by explor<strong>in</strong>g the state space us<strong>in</strong>g either iterative deepen<strong>in</strong>g depth first<br />

or breadth first techniques. Heuristic based search is also supported.<br />

In what concerns the technique itself, it requires that the Java code passes<br />

through a first <strong>in</strong>strumentation phase. S<strong>in</strong>ce Java PathF<strong>in</strong>der takes <strong>in</strong> pure Java<br />

code, the model check<strong>in</strong>g is done over all possible values of <strong>in</strong>put variables of the<br />

system. In order for the model checker to be able to manipulate symbols rather<br />

than real values the code needs to be <strong>in</strong>strumented. This is done at three levels:

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

Saved successfully!

Ooh no, something went wrong!