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

Create successful ePaper yourself

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

Timer<br />

Temperature<br />

sensor<br />

Overview 33<br />

StartTimer,<br />

CancelTimer<br />

✛<br />

✲<br />

?Timeout<br />

✛<br />

?Message<br />

Reset,<br />

Poll<br />

✲<br />

Figure 3.1. Process controller, a reactive system.<br />

Controller<br />

✛<br />

?Command,<br />

?Exit<br />

Supervisor<br />

systems are called event-driven systems. Reactive systems include embedded control<br />

systems, operating systems, and most user interfaces. Reactive systems contrast<br />

with closed systems, where all actions are controllable.<br />

The supervisor program, acting on its own schedule, frequently commands the<br />

control program to compute the calibration factor. The control program responds by<br />

computing the calibration with the most recently obtained temperature sample. The<br />

arrival of a calibrate command is another observable action. The control program<br />

cannot predict which observable action will occur next, or when it will occur.<br />

Observable actions are nondeterministic.<br />

The control program schedules each polling action by starting a timer (a controllable<br />

action); when the timer times out (an observable action), the program polls the<br />

sensor (controllable) and begins waiting for a message. When the message arrives<br />

(observable), the program starts the timer again and the cycle begins over. The interval<br />

that the timer waits before timing out determines the approximate frequency<br />

at which polling occurs. It is not required that polling be exactly periodic.<br />

The control program should continue working despite occasional faulty behavior<br />

by the sensor. It is possible that the sensor may not respond when polled. In order to<br />

prevent waiting indefinitely for an unresponsive sensor, each time the program polls,<br />

it starts the timer again (a controllable action). After some time, either a message<br />

arrives (an observable action) or the timer times out (another observable action); this<br />

is another example of nondeterminism. If the time-out occurs, the control program<br />

commands the sensor to reset, which may clear the problem. If it does, the sensor<br />

sends back a message with a temperature sample.<br />

It is possible that a faulty sensor may report an incorrect temperature. The control<br />

program attempts to detect this. The temperature may vary over a wide range, so<br />

a simple check that the temperature lies within this range would not be sound; an<br />

incorrect temperature might be accepted. Instead, we rely on the fact that the temperature<br />

in this system cannot change too rapidly. <strong>We</strong> require that each temperature<br />

sample be close to the previous sample. If a sample differs from the previous sample<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!