Commit | Line | Data |
---|---|---|
970ed795 EL |
1 | /****************************************************************************** |
2 | * Copyright (c) 2000-2014 Ericsson Telecom AB | |
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 Tsenderos | |
9 | { | |
10 | import from Datatypes all; | |
11 | ||
12 | type port PT_DefOpt message | |
13 | { | |
14 | inout Deff; | |
15 | inout Opt | |
16 | } | |
17 | ||
18 | type component CT_test | |
19 | { | |
20 | port PT_DefOpt port_do; | |
21 | } | |
22 | ||
23 | function send_d_recv_o( in Deff d, in template Opt t) runs on CT_test | |
24 | { | |
25 | map(self:port_do, system:port_do); | |
26 | port_do.send(d); | |
27 | ||
28 | timer patience := 3.0; | |
29 | patience.start; | |
30 | alt { | |
31 | [] port_do.receive(t) { setverdict(pass); } | |
32 | [] port_do.receive { setverdict(fail); } | |
33 | [] patience.timeout { setverdict(inconc); } | |
34 | } | |
35 | ||
36 | unmap(self:port_do, system:port_do); | |
37 | } | |
38 | ||
39 | function send_o_recv_d( in Opt o, in template Deff t) runs on CT_test | |
40 | { | |
41 | map(self:port_do, system:port_do); | |
42 | port_do.send(o); | |
43 | ||
44 | timer patience := 3.0; | |
45 | patience.start; | |
46 | alt { | |
47 | [] port_do.receive(t) { setverdict(pass); } | |
48 | [] port_do.receive { setverdict(fail); } | |
49 | [] patience.timeout { setverdict(inconc); } | |
50 | } | |
51 | ||
52 | unmap(self:port_do, system:port_do); | |
53 | } | |
54 | ||
55 | ||
56 | testcase tc_def_send() runs on CT_test system CT_test | |
57 | { | |
58 | // Send a concrete value instead of the default | |
59 | send_d_recv_o( {1,2,3}, {1,2,3} ); | |
60 | } | |
61 | ||
62 | testcase tc_def_send_def() runs on CT_test system CT_test | |
63 | { | |
64 | // Send the default | |
65 | send_d_recv_o( {1,13,3}, {1,13,3} ); | |
66 | } | |
67 | ||
68 | testcase tc_def_send_not() runs on CT_test system CT_test | |
69 | { | |
70 | send_d_recv_o( {1,omit,3}, {1,omit,3} ); // requires -d | |
71 | //send_d_recv_o( {1,13,3}, {1,omit,3} ); | |
72 | } | |
73 | ||
74 | ||
75 | testcase tc_opt_send() runs on CT_test system CT_test | |
76 | { | |
77 | // send a concrete value | |
78 | send_o_recv_d( {1,2,3}, {1,2,3} ); | |
79 | } | |
80 | ||
81 | testcase tc_opt_send_def() runs on CT_test system CT_test | |
82 | { | |
83 | // send the default | |
84 | send_o_recv_d( {1,13,3}, {1,13,3} ); | |
85 | } | |
86 | ||
87 | testcase tc_opt_send_not() runs on CT_test system CT_test | |
88 | { | |
89 | // do not send the optional value | |
90 | send_o_recv_d( {1,omit,3}, {1,omit,3} ); | |
91 | } | |
92 | ||
93 | ||
94 | testcase tc1() runs on CT_test system CT_test | |
95 | { | |
96 | map(self:port_do, system:port_do); | |
97 | ||
98 | var Deff d123 := {1,2,3}, d1_3 := {1,13,3}; | |
99 | var Opt o123 := {1,2,3}, o1_3 := {1,-,3}; | |
100 | ||
101 | port_do.send(d123); | |
102 | port_do.send(d1_3); | |
103 | ||
104 | port_do.send(o123); | |
105 | port_do.send(o1_3); | |
106 | ||
107 | setverdict(pass); | |
108 | unmap(self:port_do, system:port_do); | |
109 | } | |
110 | ||
111 | ||
112 | type component IOTestComponent {} | |
113 | ||
114 | /*--- IMPLICIT OMIT --------------------------------------------------*/ | |
115 | ||
116 | type record IO_rectype1 { | |
117 | integer a, | |
118 | boolean b optional | |
119 | } | |
120 | type record IO_rectype2 { | |
121 | IO_rectype1 m | |
122 | } | |
123 | ||
124 | const IO_rectype1 constrec := { a := 3 } with {optional "implicit omit"}; | |
125 | ||
126 | ||
127 | template IO_rectype1 t1 := { a := ?, b := omit }; | |
128 | template IO_rectype1 omit1 := { a := ? } with {optional "implicit omit"}; | |
129 | ||
130 | template IO_rectype2 t2 := { m := { a := ?, b := omit } }; | |
131 | template IO_rectype2 omit2 := { m := { a := ? } } with {optional "implicit omit"}; | |
132 | ||
133 | template IO_rectype2 t3 := { m := omit1 }; | |
134 | template IO_rectype2 omit3 := { m := omit1 } with {optional "implicit omit"}; | |
135 | ||
136 | ||
137 | testcase implicit_omit() runs on IOTestComponent { | |
138 | ||
139 | var IO_rectype1 rec1 := { a := 3, b := omit }; | |
140 | var IO_rectype2 rec2 := { m := { a := 3, b := omit } }; | |
141 | ||
142 | if (match(rec1, omit1)) {setverdict(pass);} else {setverdict(fail);} | |
143 | if (match(rec1, t1)) {setverdict(pass);} else {setverdict(fail);} | |
144 | ||
145 | if (match(rec2, omit2)) {setverdict(pass);} else {setverdict(fail);} | |
146 | if (match(rec2, t2)) {setverdict(pass);} else {setverdict(fail);} | |
147 | ||
148 | if (match(rec2, omit3)) {setverdict(pass);} else {setverdict(fail);} | |
149 | if (match(rec2, t3)) {setverdict(pass);} else {setverdict(fail);} | |
150 | ||
151 | if (match(rec1, constrec)) {setverdict(pass);} else {setverdict(fail);} | |
152 | ||
153 | ||
154 | } with {optional "implicit omit"}; | |
155 | ||
156 | ||
157 | ||
158 | control | |
159 | { | |
160 | //execute( tc1() ); | |
161 | execute( tc_def_send() ); | |
162 | execute( tc_def_send_def() ); | |
163 | execute( tc_def_send_not() ); | |
164 | execute( tc_opt_send() ); | |
165 | execute( tc_opt_send_def() ); | |
166 | execute( tc_opt_send_not() ); | |
167 | execute (implicit_omit()); | |
168 | } | |
169 | ||
170 | } |