27.07.2013 Views

2 Why We Need Model-Based Testing

2 Why We Need Model-Based Testing

2 Why We Need Model-Based Testing

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.

32<br />

3 <strong>Why</strong> <strong>We</strong> <strong>Need</strong><br />

<strong>Model</strong>-<strong>Based</strong><br />

Analysis<br />

This chapter demonstrates why we need model-based analysis. <strong>We</strong> exhibit a program<br />

with design errors that cause safety violations (where the program reaches forbidden<br />

states), deadlocks (where the program seems to stop running and stops responding to<br />

events), and livelocks (where the program cycles endlessly but can’t make progress).<br />

<strong>We</strong> preview our analysis and visualization techniques and show how they can reveal<br />

the design errors, even before beginning any testing.<br />

3.1 Reactive system<br />

Suppose we are developing a process control program that runs on an embedded<br />

computer connected to sensors, timers, and a supervisor program (Figure 3.1).<br />

The temperature monitor discussed in Chapter 2 could be a component of this<br />

system; here we consider a higher level of integration. This is a reactive system that<br />

responds to events in its environment. In this chapter we consider just one of its<br />

features: the temperature-calibration factor. The controlled process depends on the<br />

temperature. In order to control the process accurately, the control program must<br />

obtain a temperature reading from a sensor and use it to compute the calibration<br />

factor. The calibration factor is then used in subsequent process control computations<br />

(which we do not discuss here).<br />

The temperature in the process can change continuously, so the control program<br />

must sample the temperature often. The control program frequently polls the sensor<br />

(requests a sample). The sensor usually responds with a message that contains the<br />

most recently measured temperature. <strong>We</strong> distinguish controllable actions that the<br />

program commands from observable actions that originate in the attached equipment.<br />

All that the program can do in regard to observable actions is to wait for them<br />

(and observe them). Polling is a controllable action and message arrival is an observable<br />

action. Observable actions are prefixed with a question mark ? in Figure 3.1.A<br />

reactive system is any system that includes observable actions. Sometimes reactive<br />

more free ebooks download links at:<br />

http://www.ebook-x.com

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

Saved successfully!

Ooh no, something went wrong!