27.03.2014 Views

SEKE 2012 Proceedings - Knowledge Systems Institute

SEKE 2012 Proceedings - Knowledge Systems Institute

SEKE 2012 Proceedings - Knowledge Systems Institute

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

condition of a transitio n is a logical form ula built from<br />

arithmetic or relational operations. A transition m ay be<br />

associated with a list of variables as its form al parameters. A<br />

marking is a set of tokens distri buted in all places. A token is a<br />

tuple of constants. W e represent t oken in p as<br />

p(V 1 , …, V n ). No-argument token ( , or little solid circle or<br />

dot in traditional Petri nets) in p is simply denoted as p. Figure<br />

1 shows an example, where initial marking is {p 1 (0), p 4 (0)}.<br />

pstop [x>=5]<br />

x<br />

p 1<br />

<br />

x<br />

produce[x<<br />

5, y=x+1]<br />

y y<br />

y<br />

put<br />

p 2<br />

z<br />

y<br />

p 3<br />

Figure 1. A test model for producer/consumer<br />

z<br />

cstop [x>=5]<br />

x<br />

<br />

x<br />

get[xM 1 [t 2 θ 2 >M 2 …[t n θ n >M n , or sim ply t 1 θ 1 t 2 θ 2 …t n θ n ,<br />

where firing transition t i with substitution θ i (1≤i≤n) under M i-1<br />

leads to M i (1≤i≤n). A marking M is said to be reachable from<br />

M 0 if there is such a firing sequence that leads to M from M 0 .<br />

A function net captures system behaviors through state<br />

transitions from a given initial state (m arking). An initial<br />

marking determines the entry point (s), i.e., w hat transitions<br />

can be fired at the initial state. We also allow a function net to<br />

have one or more “ sink” transitions, sim ilar to term ination<br />

states or exi t points in other models such as finite state<br />

machines and activity diagrams. The behaviors of a function<br />

net can be interpreted by its reachability tree (graph). To<br />

facilitate test generation from different data sets, our approach<br />

allows a function net to be a ssociated with multiple initial<br />

markings. Therefore, the root of a reachability tree represents<br />

p 4<br />

p 5<br />

y,z<br />

y<br />

a dummy state, whose child nodes are built from the given<br />

initial markings. The construction of a reachability tree starts<br />

with expanding each initial marking node. Each node is<br />

expanded as follows: (1) find all possible firings t i θ j under the<br />

marking of the current node under expansion; (2) for each<br />

firing t i θ j , create a new child node according to the new<br />

marking. The edge from the current node to the new child is<br />

labeled with t i θ j . (3) if t i is not a sink transition and the new<br />

marking has not yet expanded in the sub -tree of the same<br />

initial marking, then expand the new child node.<br />

In MISTA, partial ordering of concurrent (or independent<br />

firings) and pairwise combina tion of input values are two<br />

techniques for reducing the com plexity of reachability tree.<br />

When the partial ordering of concurrent firings is used, step (2)<br />

only selects one firing from a se t of concurrent firings. W hen<br />

pairwise combination is used , all pairs (rather than all<br />

combinations) of input values are used to derive firings in step<br />

(1). We use a region to represent a collection of events in the<br />

same thread (or process) of a concurrent system. For example,<br />

region (consumer)={get , consume, cstop}. Building the<br />

reachability tree for a region uses the transitions listed in the<br />

given region.<br />

B. Function Nets as Test Models<br />

Function nets can represent various building blocks of<br />

software models, such as sequence, condition (choice),<br />

repetition (loop), concurrency, synchronization and m utual<br />

exclusion, structured data, arithmetic and relational operations,<br />

and modularization (hierarchy). These building blocks can be<br />

used to compose complex test models of concurrent programs.<br />

Consider bounded buffer as an exam ple. A bounded buffer is<br />

shared by different producer and consumer threads. A producer<br />

thread puts data into the shared buffer, whe reas a consumer<br />

thread gets data from the shared buffer. To function correctly,<br />

the implementation of bounded buffer must synchronize the<br />

concurrent “put” and “ get” actions from different threads.<br />

Figure 1 shows a test model of bounded buffer, where a<br />

producer produces and puts five items to the buffer and<br />

consumer gets and consumes five items from the buffer. The<br />

producer is not intended to put any item to the buffer if the<br />

buffer is not empty. The consumer is not intended to get an<br />

item from the buffer unless the buffer has an item . The<br />

“produce” and “ put” actions in the producer thread are<br />

sequential; the “ get” and “ consume” actions in the consumer<br />

thread are sequential. They are represented by two sequential<br />

structures. They are included in the two loo p structures,<br />

respectively. “put” has two postconditions: updating the loop<br />

control value and depositing the produced item into the buffer<br />

(place p 3 ). Producer and consumer have concurrent actions<br />

(e.g., produce and consume). They are synchronized because of<br />

the shared buffer.<br />

Although building a test m odel depends on what needs to<br />

be tested against a specific sy stem under test (SUT), there are<br />

two different perspectives: whitebox and blackbox. A white<br />

test model is similar to the design m odel of a SU T – what is<br />

described in the model is suppos ed to be implemented by the<br />

SUT. For example, Figure 1 w ould be a whitebox test model<br />

for the producer/consumer program if a SUT has im plemented<br />

the producer and consumer threads and these threads are the<br />

a<br />

347

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

Saved successfully!

Ooh no, something went wrong!