Commit | Line | Data |
---|---|---|
970ed795 | 1 | /****************************************************************************** |
3abe9331 | 2 | * Copyright (c) 2000-2015 Ericsson Telecom AB |
970ed795 EL |
3 | * All rights reserved. This program and the accompanying materials |
4 | * are made available under the terms of the Eclipse Public License v1.0 | |
5 | * which accompanies this distribution, and is available at | |
6 | * http://www.eclipse.org/legal/epl-v10.html | |
7 | ******************************************************************************/ | |
8 | module testerlanc { | |
9 | ||
10 | type component mycomptype { | |
11 | port myporttype Aport, Bport | |
12 | } | |
13 | ||
14 | type port myporttype message { | |
15 | inout charstring; | |
16 | } with { extension "internal" } | |
17 | ||
18 | type record starter { | |
19 | charstring str optional | |
20 | } | |
21 | ||
22 | function f(in starter init, in float tout, in mycomptype dest) | |
23 | runs on mycomptype { | |
24 | var charstring c; | |
25 | timer t := tout; | |
26 | ||
27 | t.start; | |
28 | if(ispresent(init.str)) { | |
29 | Aport.send(charstring:init.str); | |
30 | } | |
31 | alt { | |
32 | [] Bport.receive(charstring:?) -> value c | |
33 | { | |
34 | if(dest.running) { | |
35 | Aport.send(c); | |
36 | repeat; | |
37 | } | |
38 | } | |
39 | [] t.timeout { setverdict(pass); stop; } | |
40 | } | |
41 | } | |
42 | ||
43 | testcase tc(in charstring str, in float tout) runs on mycomptype { | |
44 | var mycomptype ptc[100]; | |
45 | var integer r; | |
46 | var starter init := { str := str }; | |
47 | var starter noinit := { str := omit }; | |
48 | ||
49 | ptc[0] := mycomptype.create; | |
50 | for(r := 1; r < N; r := r + 1) { | |
51 | ptc[r] := mycomptype.create; | |
52 | connect(ptc[r]:Aport, ptc[r-1]:Bport) | |
53 | ptc[r].start(f(noinit, tout, ptc[r-1])); | |
54 | } | |
55 | connect(ptc[0]:Aport, ptc[N-1]:Bport) | |
56 | ptc[0].start(f(init, tout, ptc[N-1])); | |
57 | ||
58 | all component.done; | |
59 | setverdict(pass); | |
60 | } | |
61 | ||
62 | const integer N := 100; | |
63 | ||
64 | control { | |
65 | execute(tc("Hello!", 30)); | |
66 | } | |
67 | ||
68 | } |