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.

A1<br />

A2<br />

Advanced Topics 273<br />

a R(0) b R(1) c R(4) d<br />

e R(2) f R(3) g<br />

Figure 16.7. Example of a partial order of events of two agents A1 and A2.<br />

An event x happens before an event z if either x happens immediately before z<br />

or if there is an event y such that x happens before y and y happens before z. The<br />

happens-before relation is a strict partial order of events. Two events x and y are<br />

incomparable with respect to the happens-before order if neither x happens before<br />

y nor y happens before x.<br />

For example, c happens before d in Figure 16.7. The order is clearly partial; for<br />

example, c and e are incomparable, even though both c and e happen before d.<br />

A sequence of events is a linearization of a given happens-before order of events<br />

if for all events x and y such that x occurs before y in the sequence, either x happens<br />

before y or x and y are incomparable.<br />

For example,<br />

(a,R(0),b,R(1),c,e,R(2),f,R(3),g,R(4),d)<br />

is a linearization of the partial order of events depicted in Figure 16.7.<br />

16.6.1 Multiplexing<br />

Multiplexing is a technique that produces a single sequence of events generated<br />

by multiple agents that is a linearization of the happens-before relation. It relies<br />

on additional assumptions about the IUT. In particular, this technique assumes an<br />

instrumentation of the IUT in such a way that all shared resource usage events are<br />

observed.<br />

The multiplexing algorithm (or multiplexer) works as follows. It consumes events<br />

from multiple incoming event queues, one queue per agent, and outputs the events<br />

in an order that is consistent with the happens-before relation. It is assumed that all<br />

events from an agent are enqueued into the event queue of that agent in the same<br />

order the events occur in that agent. For each shared resource R the multiplexer<br />

records the expected usage count kR that is initially 0. An event E is dequeued from<br />

some event queue, if<br />

1. E is not a resource usage event, or<br />

2. E is a resource usage event R(k) for some shared resource R, and k = kR. In<br />

this case, kR is incremenetd by one.<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!