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 Titan_LogTest { | |
9 | ||
10 | modulepar boolean tsp_cfgBoolean:=true; | |
11 | import from Titan_LogTestDefinitions all; | |
12 | ||
13 | //===Functions=== | |
14 | ||
15 | function f_behavior(boolean pl_recv:=true) runs on MTCType2 { | |
16 | var charstring vl_received_msg:=""; | |
17 | internal_port.send( "This is the sent message");//PORTEVENT_MMSEND Titan_LogTest.ttcn:41 Sent on external_port to system charstring : "This is the sent message" | |
18 | t.start(0.5); | |
19 | alt{ | |
20 | [pl_recv] internal_port.receive(charstring:"This")-> value vl_received_msg { setverdict(pass)} //MATCHING_MCUNSUCC | |
21 | [pl_recv] internal_port.receive(charstring:*)-> value vl_received_msg { setverdict(pass)} | |
22 | //PORTEVENT_MCRECV | |
23 | //MATCHING_MCSUCCESS | |
24 | ||
25 | [] t.timeout { | |
26 | if(pl_recv){ setverdict(fail);} else {setverdict(pass)} | |
27 | } | |
28 | } | |
29 | } | |
30 | ||
31 | function f_behavior_send_rec() runs on MTCTypeExternal { | |
32 | var charstring vl_received_msg:=""; | |
33 | external_port.send( "This is the sent message");//PORTEVENT_MMSEND Titan_LogTest.ttcn:41 Sent on external_port to system charstring : "This is the sent message" | |
34 | // t.start(0.5); | |
35 | // alt{ | |
36 | // //[] external_port.receive(charstring:*)-> value vl_received_msg { setverdict(pass)} | |
37 | // [] t.timeout { setverdict(pass);} | |
38 | // } | |
39 | } | |
40 | //======= Altsteps ========== | |
41 | ||
42 | altstep as_1() runs on MTCType { | |
43 | [] internal_port.receive(*) {} | |
44 | [] t.timeout { } | |
45 | } | |
46 | ||
47 | //======= Testcases ========== | |
48 | ||
49 | //Thease are manual tests- the tester shall check the logfile manually. | |
50 | //TODO: to change this for automated checking | |
51 | // Comparison between 2 versions: logtest.sh | |
52 | ||
53 | //===ACTION=== | |
54 | testcase tc_action() runs on MTCType { | |
55 | action("This is an action"); //EXECUTOR_EXTCOMMAND | |
56 | setverdict(pass); | |
57 | } | |
58 | ||
59 | //===DEFAULT=== | |
60 | testcase tc_default() runs on MTCType { | |
61 | var default vd_mydefault:= null; | |
62 | vd_mydefault:= activate(as_1()); //DEFAULTOP_ACTIVATE | |
63 | t.start(0.1); //TIMEROP_START | |
64 | timer t1; | |
65 | t1.start(0.2); //TIMEROP_START | |
66 | alt { //DEFAULTOP_EXIT | |
67 | [] t1.timeout { //TIMEROP_TIMEOUT | |
68 | setverdict(fail); //default altstep expected //VERDICTOP_SETVERDICT | |
69 | }; | |
70 | } | |
71 | deactivate(vd_mydefault); //DEFAULTOP_DEACTIVATE //PARALLEL_PTC | |
72 | setverdict(pass); //VERDICTOP_SETVERDICT | |
73 | ||
74 | } | |
75 | ||
76 | //===ERROR LOG=== | |
77 | ||
78 | testcase tc_error1() runs on MTCType { | |
79 | var integer a,b; | |
80 | log(">>>tc_error1: last line before DTE<<<"); | |
81 | a:=b; //runtime error //executor: Performing error recovery. | |
82 | setverdict(pass); | |
83 | } | |
84 | ||
85 | //===EXECUTOR LOG=== | |
86 | ||
87 | //executor runtime | |
88 | testcase tc_ex_runtime() runs on MTCType { | |
89 | log(">>tc_ex_runtime"); | |
90 | setverdict(none);// executor runtime: Waiting for PTCs to finish. | |
91 | } | |
92 | //see also in tc_parallel_conn: | |
93 | //EXECUTOR_RUNTIME - Connected to MC. | |
94 | //EXECUTOR_COMPONENT - TTCN-3 Parallel Test Component finished. | |
95 | // EXECUTOR_UNQUALIFIED | |
96 | // EXECUTOR_RUNTIME | |
97 | // EXECUTOR_UNQUALIFIED | |
98 | // EXECUTOR_CONFIGDATA | |
99 | // EXECUTOR_RUNTIME | |
100 | ||
101 | //executor config data | |
102 | //see the log file: | |
103 | //12:51:55.161925 - Processing configuration data received from MC. | |
104 | //12:51:55.162954 - Module Titan_LogTest has the following parameters: { tsp_cfgBoolean := true } | |
105 | ||
106 | //executor ext command | |
107 | //Running of external command: See log lines with "Starting external command" | |
108 | ||
109 | //executor componenent | |
110 | //Starting and stopping MTC and HCs | |
111 | //14:39:24.116611 - TTCN-3 Main Test Component started on ehubuux110. Version: 1.8.pre3 build 4. | |
112 | //14:39:25.440605 - TTCN-3 Main Test Component finished. | |
113 | ||
114 | //executor logoptions | |
115 | // See the second line of the log file !!! "TTCN Logger v2.2 options" | |
116 | ||
117 | //executor unqualified | |
118 | //e.g in hc log: | |
119 | //12:48:04.345342 - The address of MC was set to ehubuux110[159.107.193.33]:50532. | |
120 | //12:48:04.345759 - The local IP address of the control connection to MC is 159.107.193.33. | |
121 | //12:48:04.347014 - This host supports UNIX domain sockets for local communication. | |
122 | ||
123 | //=== FUNCTION LOG === | |
124 | ||
125 | //function rnd | |
126 | testcase tc_function_rnd() runs on MTCType { | |
127 | var float vl:=rnd(); | |
128 | //log: | |
129 | //14:32:00.300458 Titan_LogTest.ttcn:124->Titan_LogTest.ttcn:102 Random number generator was initialized with seed 1.300365: srand48(1435748778). | |
130 | //14:32:00.300696 Titan_LogTest.ttcn:124->Titan_LogTest.ttcn:102 Function rnd() returned 0.717026. | |
131 | setverdict(pass); | |
132 | } | |
133 | ||
134 | //function unqualified | |
135 | //???? | |
136 | ||
137 | //===PARALLEL=== | |
138 | //parallel_ptc | |
139 | //PTC creation and finishing, starting and finishing a function | |
140 | //see tc_portevent | |
141 | ||
142 | //parallel_portconn | |
143 | testcase tc_parallel_portconn() runs on MTCType { | |
144 | var MTCType2 vc_comp1 := MTCType2.create; | |
145 | var MTCType2 vc_comp2 := MTCType2.create; | |
146 | log("Creates finished"); | |
147 | connect(vc_comp1:internal_port, vc_comp2:internal_port); //this is logged as | |
148 | //15:33:17.693413 PARALLEL Titan_LogTest.ttcn:158->Titan_LogTest.ttcn:135 Connect operation on 6:internal_port and 7:internal_port finished. | |
149 | log("Connect finished"); | |
150 | vc_comp1.start(f_behavior(true)); | |
151 | vc_comp2.start(f_behavior(false)); | |
152 | vc_comp1.done; | |
153 | vc_comp2.done; | |
154 | log("tc_parallel_portconn done finished"); | |
155 | setverdict(pass); | |
156 | } | |
157 | ||
158 | //parallel_portmap | |
159 | testcase tc_parallel_portmap() runs on MTCType system MTCTypeExternal{ | |
160 | var MTCTypeExternal vc_comp1 := MTCTypeExternal.create; | |
161 | map(vc_comp1:external_port, system:external_port); //this is logged as "Map operation of 6:internal_port to system:internal_port finished" | |
162 | //5 WARNING_UNQUALIFIED Warning: This is a Warning in the port | |
163 | //5 DEBUG_UNQUALIFIED This is a TTCN_DEBUG log in the port | |
164 | //5 WARNING_UNQUALIFIED This is a TTCN_WARNING log in the port | |
165 | //5 ERROR_UNQUALIFIED This is a TTCN_ERROR log in the port | |
166 | //5 DEBUG_UNQUALIFIED This is a log_event | |
167 | unmap(vc_comp1:external_port, system:external_port); | |
168 | vc_comp1.stop; | |
169 | setverdict(none) | |
170 | } | |
171 | ||
172 | //===Testcase=== | |
173 | //TESTCASE_START Titan_LogTest.ttcn:169->Titan_LogTest.ttcn:51 Test case tc_action started. | |
174 | //TESTCASE_FINISH Titan_LogTest.ttcn:169->Titan_LogTest.ttcn:53 Test case tc_action finished. Verdict: pass | |
175 | //TESTCASE_UNQUALIFIED ???? | |
176 | ||
177 | //===TTCN_PORTEVENT=== | |
178 | //tc_portevent covers: | |
179 | //PORTEVENT_STATE eg: | |
180 | //16:18:16.004974 PORTEVENT_STATE Port internal_port was started. | |
181 | //16:18:16.005240 PORTEVENT_STATE Port internal_port was stopped. | |
182 | //PORTEVENT_MMSEND Titan_LogTest.ttcn:41 Sent on external_port to system charstring : "This is the sent message" | |
183 | // see also tc_parallel_portconn: | |
184 | //PORTEVENT_MCRECV | |
185 | //MATCHING_MCSUCCESS | |
186 | //PORTEVENT_MQUEUE | |
187 | //PORTEVENT_UNQUALIFIED | |
188 | //PORTEVENT_STATE - Port internal_port was stopped. | |
189 | testcase tc_portevent() runs on MTCTypeExternal system MTCTypeExternal{ | |
190 | //PORTEVENT_STATE Port external_port was started. | |
191 | //PARALLEL_PTC Component type Titan_LogTest.MTCTypeExternal was initialized. | |
192 | var MTCTypeExternal vc_comp1 := MTCTypeExternal.create; | |
193 | map(vc_comp1:external_port, system:external_port);// PARALLEL_UNQUALIFIED Mapping port 6:external_port to system:external_port. | |
194 | //this is logged as "Map operation of 6:internal_port to system:internal_port finished" | |
195 | vc_comp1.start(f_behavior_send_rec()); //PARALLEL_PTC | |
196 | vc_comp1.done; | |
197 | unmap(vc_comp1:external_port, system:external_port); | |
198 | setverdict(none) | |
199 | } | |
200 | ||
201 | //===STATISTICS== | |
202 | //STATISTICS_UNQUALIFIED - ok: Titan_LogTest.ttcn:217 Execution of control part in module Titan_LogTest finished | |
203 | //STATISTICS_VERDICT -ok: | |
204 | //STATISTICS_VERDICT - Verdict statistics: 2 none (20.00 %), 6 pass (60.00 %), 0 inconc (0.00 %), 0 fail (0.00 %), 2 error (20.00 %) | |
205 | //STATISTICS_VERDICT - Test execution summary: 10 test cases were executed. Overall verdict: error | |
206 | ||
207 | //==TIMEROP== | |
208 | //TIMEROP_START | |
209 | //TIMEROP_TIMEOUT | |
210 | //TIMEROP_READ | |
211 | //TIMEROP_STOP | |
212 | //TIMEROP_GUARD --??? | |
213 | //TIMEROP_UNQUALIFIED -- ??? | |
214 | testcase tc_timer() runs on MTCType { | |
215 | t.start(0.2); | |
216 | alt{ | |
217 | []t.timeout { setverdict(pass)}; | |
218 | } | |
219 | timer t1:=0.1; | |
220 | t1.start;//TIMEROP_START | |
221 | var float mytime:=t1.read; | |
222 | log("Mytime: ", mytime, " s") | |
223 | var boolean mytimerrunning:=t1.running; | |
224 | log(mytimerrunning); | |
225 | if(mytimerrunning) {setverdict(pass)} else{setverdict(fail)}; | |
226 | t1.stop; | |
227 | mytimerrunning:=t1.running; | |
228 | if(not mytimerrunning) {setverdict(pass)} else{setverdict(fail)} | |
229 | t1.start; | |
230 | } | |
231 | ||
232 | //==TTCN_USER | |
233 | //USER_UNQUALIFIED | |
234 | testcase tc_UserLog() runs on MTCType { | |
235 | log("This is a UserLog"); | |
236 | setverdict(pass); | |
237 | } | |
238 | ||
239 | type charstring String6_8 length(6..8); | |
240 | template String6_8 t_string6_8 := pattern "mystring"; | |
241 | ||
242 | type union PDU_Dummy { | |
243 | MyArray firstOption, | |
244 | MyArray secondOption | |
245 | } with { variant "TAG ( | |
246 | firstOption, i = 0; | |
247 | secondOption, i = 1 | |
248 | )" } | |
249 | ||
250 | type record MyArray { | |
251 | integer i, | |
252 | charstring c | |
253 | } with { extension "encode(RAW)"} | |
254 | ||
255 | template MyArray t_myArray:= { ?, "a"} | |
256 | ||
257 | testcase tc_matching() runs on MTCType { | |
258 | var MyArray myArray:={1,"a"} | |
259 | if(match(myArray,t_myArray)) | |
260 | {setverdict(pass)} else{setverdict(fail)} | |
261 | log(match(myArray,t_myArray));//USER_UNQUALIFIED Titan_LogTest.ttcn:302->Titan_LogTest.ttcn:281 { i := 1 with * matched, c := "a" with "a" matched } | |
262 | } | |
263 | //===TTCN_VERDICTOP=== | |
264 | //VERDICTOP_GETVERDICT | |
265 | //VERDICTOP_SETVERDICT | |
266 | //VERDICTOP_FINAL | |
267 | //VERDICTOP_UNQUALIFIED ??? | |
268 | testcase tc_verdict() runs on MTCType { | |
269 | var verdicttype myverdict:=getverdict; | |
270 | setverdict(pass); | |
271 | } | |
272 | ||
273 | //===TTCN_WARNING | |
274 | //11:50:56.113567 WARNING_UNQUALIFIED Titan_LogTest.ttcn:259->Titan_LogTest.ttcn:69 Warning: External command `'echo This is the BeginTestCase' Titan_LogTest.tc_action' returned unsuccessful exit status (1). | |
275 | ||
276 | //===TTCN_MATCHING=== | |
277 | //see tc_parallel_portconn | |
278 | //MATCHING_MCSUCCESS: see tc_parallel_portconn | |
279 | //MATCHING_MCUNSUCC: see tc_parallel_portconn | |
280 | ||
281 | //===DEBUG=== | |
282 | //see tc_parallel_portmap | |
283 | //DEBUG_ENCDEC see tc_encdec | |
284 | //DEBUG_TESTPORT: ??? TODO | |
285 | //DEBUG_UNQUALIFIED - see tc_parallel_portmap | |
286 | ||
287 | external function f_encMyArray(in MyArray p_myArray) return octetstring | |
288 | with { extension "prototype(convert) encode(RAW)"} | |
289 | ||
290 | external function f_decMyArray(in octetstring p_stream) return MyArray | |
291 | with { extension "prototype(convert) decode(RAW)"} | |
292 | ||
293 | //DEBUG_ENCDEC | |
294 | testcase tc_encdec() runs on MTCType { | |
295 | var MyArray pl_myArray:={ 1,"a"} | |
296 | var octetstring vl_encodedPDU:= f_encMyArray(pl_myArray) | |
297 | var MyArray vl_decodedPDU := f_decMyArray(vl_encodedPDU); | |
298 | if(vl_decodedPDU==pl_myArray) { setverdict(pass);} else { setverdict(fail); } | |
299 | } | |
300 | //EXECUTOR_EXTCOMMAND | |
301 | control { | |
302 | var verdicttype vl_verdict:=none; | |
303 | execute(tc_action()); | |
304 | execute(tc_default()); | |
305 | vl_verdict :=execute(tc_error1()); | |
306 | log(vl_verdict); | |
307 | execute(tc_ex_runtime()); | |
308 | execute(tc_function_rnd()); | |
309 | execute(tc_parallel_portconn()); | |
310 | execute(tc_parallel_portmap()); | |
311 | execute(tc_portevent()); | |
312 | execute(tc_timer()); | |
313 | execute(tc_UserLog()); | |
314 | execute(tc_matching()); | |
315 | execute(tc_verdict()); | |
316 | execute(tc_encdec()); | |
317 | ||
318 | } | |
319 | ||
320 | } with{ encode "RAW"} |