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