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 ******************************************************************************/
10 modulepar boolean tsp_cfgBoolean:=true;
11 import from Titan_LogTestDefinitions all;
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"
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)}
26 if(pl_recv){ setverdict(fail);} else {setverdict(pass)}
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"
36 // //[] external_port.receive(charstring:*)-> value vl_received_msg { setverdict(pass)}
37 // [] t.timeout { setverdict(pass);}
40 //======= Altsteps ==========
42 altstep as_1() runs on MTCType {
43 [] internal_port.receive(*) {}
47 //======= Testcases ==========
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
54 testcase tc_action() runs on MTCType {
55 action("This is an action"); //EXECUTOR_EXTCOMMAND
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
65 t1.start(0.2); //TIMEROP_START
66 alt { //DEFAULTOP_EXIT
67 [] t1.timeout { //TIMEROP_TIMEOUT
68 setverdict(fail); //default altstep expected //VERDICTOP_SETVERDICT
71 deactivate(vd_mydefault); //DEFAULTOP_DEACTIVATE //PARALLEL_PTC
72 setverdict(pass); //VERDICTOP_SETVERDICT
78 testcase tc_error1() runs on MTCType {
80 log(">>>tc_error1: last line before DTE<<<");
81 a:=b; //runtime error //executor: Performing error recovery.
88 testcase tc_ex_runtime() runs on MTCType {
89 log(">>tc_ex_runtime");
90 setverdict(none);// executor runtime: Waiting for PTCs to finish.
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
97 // EXECUTOR_UNQUALIFIED
98 // EXECUTOR_CONFIGDATA
101 //executor config data
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 }
106 //executor ext command
107 //Running of external command: See log lines with "Starting external command"
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.
114 //executor logoptions
115 // See the second line of the log file !!! "TTCN Logger v2.2 options"
117 //executor unqualified
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.
123 //=== FUNCTION LOG ===
126 testcase tc_function_rnd() runs on MTCType {
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.
134 //function unqualified
139 //PTC creation and finishing, starting and finishing a function
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));
154 log("tc_parallel_portconn done finished");
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);
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 ????
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:
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
197 unmap(vc_comp1:external_port, system:external_port);
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
212 //TIMEROP_GUARD --???
213 //TIMEROP_UNQUALIFIED -- ???
214 testcase tc_timer() runs on MTCType {
217 []t.timeout { setverdict(pass)};
220 t1.start;//TIMEROP_START
221 var float mytime:=t1.read;
222 log("Mytime: ", mytime, " s")
223 var boolean mytimerrunning:=t1.running;
225 if(mytimerrunning) {setverdict(pass)} else{setverdict(fail)};
227 mytimerrunning:=t1.running;
228 if(not mytimerrunning) {setverdict(pass)} else{setverdict(fail)}
234 testcase tc_UserLog() runs on MTCType {
235 log("This is a UserLog");
239 type charstring String6_8 length(6..8);
240 template String6_8 t_string6_8 := pattern "mystring";
242 type union PDU_Dummy {
245 } with { variant "TAG (
250 type record MyArray {
253 } with { extension "encode(RAW)"}
255 template MyArray t_myArray:= { ?, "a"}
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 }
263 //===TTCN_VERDICTOP===
264 //VERDICTOP_GETVERDICT
265 //VERDICTOP_SETVERDICT
267 //VERDICTOP_UNQUALIFIED ???
268 testcase tc_verdict() runs on MTCType {
269 var verdicttype myverdict:=getverdict;
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).
276 //===TTCN_MATCHING===
277 //see tc_parallel_portconn
278 //MATCHING_MCSUCCESS: see tc_parallel_portconn
279 //MATCHING_MCUNSUCC: see tc_parallel_portconn
282 //see tc_parallel_portmap
283 //DEBUG_ENCDEC see tc_encdec
284 //DEBUG_TESTPORT: ??? TODO
285 //DEBUG_UNQUALIFIED - see tc_parallel_portmap
287 external function f_encMyArray(in MyArray p_myArray) return octetstring
288 with { extension "prototype(convert) encode(RAW)"}
290 external function f_decMyArray(in octetstring p_stream) return MyArray
291 with { extension "prototype(convert) decode(RAW)"}
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); }
300 //EXECUTOR_EXTCOMMAND
302 var verdicttype vl_verdict:=none;
303 execute(tc_action());
304 execute(tc_default());
305 vl_verdict :=execute(tc_error1());
307 execute(tc_ex_runtime());
308 execute(tc_function_rnd());
309 execute(tc_parallel_portconn());
310 execute(tc_parallel_portmap());
311 execute(tc_portevent());
313 execute(tc_UserLog());
314 execute(tc_matching());
315 execute(tc_verdict());
316 execute(tc_encdec());
320 } with{ encode "RAW"}