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.

pstop [x>1]<br />

p 1<br />

x<br />

produce[x<<br />

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

y y<br />

Figure 2. A test model with independent regions<br />

When the regions are interdependent, we first generate<br />

deterministic sequences (sim ilar to Section III-A ) and<br />

transform them into concurrent sequences. For example,<br />

deterministic sequence , , , , , can be transformed into the following non -<br />

deterministic sequence: , .<br />

IV. AUTOMATED GENERATION OF TEST CODE<br />

We generate test code from nondeterministic sequences<br />

based on model-implementation mapping (MIM).<br />

A. MIM<br />

A MIM specification for a test model consists of the following<br />

components [3]:<br />

(1) ID is the identity of the SUT tested against the model.<br />

(2) f o is the object function that maps objects in the test model<br />

to objects in the SUT.<br />

(3) f e is the event (also called method) mapping function that<br />

maps events in the model to operations in the SUT.<br />

(4) f a is the accessor function that maps predicates in the test<br />

model to accessors in the SUT.<br />

(5) l h is the list of hidden predicates in the test model that<br />

produce no test code.<br />

(6) h is the helper code function that defines user -provided<br />

code to be included in the test code.<br />

ID refers to the system under test. The functions f o , f e , f a and<br />

f m map objects, events, and predicates to respective<br />

counterparts in the SUT. Operation for an event or accessor for<br />

a predicate is a block of code that can be executed . The helper<br />

code function allows the user to provide additional code<br />

required to make the generated tests executable.<br />

TABLE I.<br />

x<br />

<br />

y<br />

put<br />

p 2<br />

cstop [x>1]<br />

<br />

x<br />

get[xM 1[t 2θ 2>M 2 [t nθ n>M n, MIM<br />

(ID, f o, f e, f a, l h, h)<br />

Output: pthread function code named after region (pfcode)<br />

Declare: testInput is a string representing test input code<br />

testOracle is a string representing test oracle code<br />

newLine starts a new line<br />

1. begin<br />

2. pfcode ← “void *”+region+”(void * parm)”<br />

3. pfcode ← pfcode +”{”+ newLine<br />

4. for i=1 to n do<br />

5. if t i is not a hidden event, i.e., t i∉l h<br />

6. let t iθ i = t i (V 1., V k),V j is an actual parameter<br />

7. testInput ← f e(t i (f o(V 1),, f o(V k)));<br />

8. endif<br />

9. testOracle ← “”;<br />

10. for each p(V 1,, V k) in M i do<br />

11. if p∉l h<br />

12. testOralce ←testOracle + f a(p(f o(V 1),, f o(V k)));<br />

13. endif<br />

14. end for<br />

15. pfcode ← pfcode+testInput+testOralce<br />

16. end for<br />

17. pfcode ← pfcode+ newLine +”pthread_exit(0)”<br />

18. pfcode ← pfcode+ newLine +”}”<br />

19. end<br />

A firing sequence is a sequence of nodes ( [t i θ i >M i ) in a<br />

reachability tree. Line 2 creates the signature of the function.<br />

Lines 3 and 18 provide “{}” to enclose the function. Lines 4-16<br />

generates test inputs and oracles from the given firing<br />

349

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

Saved successfully!

Ooh no, something went wrong!