1 /******************************************************************************
2 * Copyright (c) 2000-2016 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
14 * Szabo, Janos Zoltan – initial implementation
17 ******************************************************************************/
20 type record MyRecord { }
22 signature MyProc(in integer Par1,inout charstring Par2,out float Par3)
26 type MyProc2 MyProc2Alias; // testing type alias
27 signature MyProc3(in integer I) return float exception(integer);
28 signature MyProc4(in float F) noblock;
29 signature MyProc5(in integer A, in integer B)
30 return float exception(charstring, MyRecord);
31 signature s_StopPTC();
32 signature MyProc6(inout integer I);
34 template s_StopPTC StopPTC := { }
36 template MyProc5 MyProc5Template_any := {
41 template MyProc5 MyProc5TemplateP(integer pA,integer pB) := {
46 template MyProc3 MyProc3Template:={
50 template MyProc3 MyProc3Template_any:={I:=?}
52 template MyProc3 MyProc3TemplateP (integer P) := {
56 template MyProc MyProcTemplateP (integer i,charstring c,float f) := {
62 template MyProc MyProcTemplate:= {
68 template MyProc MyProcTemplate2:= {
74 template MyProc MyProcTemplate_any:= {
80 template MyProc2 MyProc2Template := { }
87 template address MyAddress(integer p1,integer p2) := {
92 type port PortAddress procedure {
93 inout MyProc,s_StopPTC;
95 } with { extension "address" }
97 type port ProcPort1 procedure
99 inout MyProc,s_StopPTC;
102 } with {extension "internal"}
104 type port ProcPort2 procedure
106 inout MyProc,s_StopPTC;
109 } with {extension "internal"}
111 type port ExtProcPort procedure
116 type port CompileOnlyPort procedure
125 type port CompileOnlyPortAddress procedure {
131 } with { extension "address" }
133 type port ProcPort3 procedure {
135 } with { extension "internal" }
137 type component ProcComponent
139 port ProcPort1 Port0;
142 type component ProcComponent2
144 port ProcPort2 Port1;
147 type component ProcComponentMultiPort
149 port ProcPort1 Port0;
150 port ProcPort2 Port1[4];
151 port ExtProcPort Port2;
152 port CompileOnlyPort Port3;
153 port PortAddress Port4;
156 type component eComponent
158 port ExtProcPort ePort;
161 type component addressComponent
166 type component ProcComponent3 {
170 function GetCall_behav1() runs on ProcComponent2 {
173 []Port1.getcall(MyProcTemplate_any) {
174 Port1.reply(MyProcTemplate2 value true);
176 []Port1.getcall(MyProc3Template_any) {
177 Port1.reply(MyProc3Template value 3.1415);
179 []Port1.getcall(StopPTC) {
180 Port1.reply(StopPTC);
187 function GetCall_behav2() runs on ProcComponent {
190 []Port0.getcall(MyProcTemplate2) {
191 Port0.raise(MyProc,integer:555);
193 []Port0.getcall(MyProcTemplate_any) {
194 Port0.reply(MyProcTemplate value false);
196 []Port0.getcall(MyProc2Template) {
197 Port0.reply(MyProc2Template);
199 []Port0.getcall(StopPTC) {
200 Port0.reply(StopPTC);
207 function GetCall_behav3() runs on ProcComponent2 {
210 []Port1.getcall(MyProcTemplate2) {
211 Port1.raise(MyProc,integer:272869);
213 []Port1.getcall(MyProcTemplate_any) {
214 Port1.reply(MyProcTemplateP(22,"G",199.99) value false);
216 []Port1.getcall(MyProc3Template_any) {
217 Port1.reply(MyProc3Template value 2.78);
219 []Port1.getcall(StopPTC) {
220 Port1.reply(StopPTC);
227 function Check_getcall_behav() runs on ProcComponent2 {
230 []Port1.check(getcall(MyProcTemplate2)) {
232 Port1.reply(MyProcTemplate value true);
234 []Port1.getcall(StopPTC) {
235 Port1.reply(StopPTC);
238 []Port1.check(getcall) {
240 Port1.reply(MyProcTemplate2 value false);
247 const integer c_CallParam := 10;
248 const integer c_ReplyParam := 19;
251 template integer t_getCall_invalidValue := -1;
252 template integer t_getCall_timeout := -2;
254 function GetCallParameters_behav() runs on ProcComponent3 {
259 [] pt.getcall(MyProc6:{?}) -> param (x) {
260 if (c_CallParam == x) { pt.reply(MyProc6:{c_ReplyParam}); }
261 else { pt.reply(MyProc6:{t_getCall_invalidValue}); }
263 [] t.timeout { pt.reply(MyProc6:{t_getCall_timeout}); }
267 testcase tc1_Call() runs on ProcComponent {
268 /* Non-blocking calls */
269 var ProcComponent2 PC2;
271 var boolean b:=false;
274 PC2:=ProcComponent2.create;
275 PC2.start(GetCall_behav1());
276 connect(self:Port0,PC2:Port1);
278 Port0.call(MyProcTemplate,nowait);
279 Port0.call(MyProc3Template,nowait);
282 []Port0.getreply(MyProcTemplate2) -> value b {
285 else {setverdict(fail);stop;}
287 setverdict(inconc);stop;
290 []Port0.getreply(MyProc3Template) -> value f {
291 if((i==1)and(f==3.1415)) {i:=2;}
292 else {log(f);setverdict(inconc);stop;}
300 if(i==2) {setverdict(pass);}
301 Port0.call(StopPTC,0.5) {
302 []Port0.getreply(StopPTC) { }
303 []Port0.catch(timeout) { }
305 disconnect(self:Port0,PC2:Port1);
308 testcase tc2_Call() runs on ProcComponent2 {
310 var ProcComponent PC;
312 PC:=ProcComponent.create;
313 PC.start(GetCall_behav2());
314 connect(self:Port1,PC:Port0);
315 Port1.call(MyProcTemplate,1.0) {
316 []Port1.getreply(MyProcTemplate value ?) -> value b{
317 Port1.call(MyProc2Template,0.7) {
318 []Port1.getreply(MyProc2Template) {
319 Port1.call(MyProcTemplate2,0.4) {
320 []Port1.catch(MyProc,integer:555) {
321 if(b==false) {setverdict(pass);}
322 else {setverdict(inconc);}
324 []Port1.catch(timeout) {
330 []Port1.catch(timeout) {
336 []Port1.catch(timeout) {
341 Port1.call(StopPTC,0.5) {
342 []Port1.getreply(StopPTC) { }
343 []Port1.catch(timeout) { }
347 testcase tc_extCall() runs on eComponent system eComponent {
348 map(self:ePort,system:ePort);
349 ePort.call(MyProc5TemplateP(128,32),0.5) {
350 []ePort.getreply(MyProc5Template_any value 4.0) {
353 []ePort.catch(timeout) {
354 setverdict(fail);stop;
357 unmap(self:ePort,system:ePort);
360 testcase tc_extCall_2() runs on eComponent system eComponent {
361 map(self:ePort,system:ePort);
362 ePort.call(MyProc5TemplateP(32,128),0.5) {
363 []ePort.getreply(MyProc5Template_any value 0.25) {
366 []ePort.catch(timeout) {
367 setverdict(fail);stop;
370 unmap(self:ePort,system:ePort);
373 testcase tc_extCall_3() runs on eComponent system eComponent {
374 map(self:ePort,system:ePort);
375 ePort.call(MyProc5TemplateP(128,0),0.5) {
376 []ePort.catch(MyProc5,charstring:"Divide by 0.") {
379 []ePort.catch(timeout) {
380 setverdict(fail);stop;
383 unmap(self:ePort,system:ePort);
386 testcase tc_Call_MultiPTC() runs on ProcComponent {
387 /* procedure based communication with multiple PTCs */
388 var ProcComponent2 PC1,PC2;
391 PC1:=ProcComponent2.create;
392 PC1.start(GetCall_behav1());
393 connect(self:Port0,PC1:Port1);
394 PC2:=ProcComponent2.create;
395 PC2.start(GetCall_behav3());
396 connect(self:Port0,PC2:Port1);
398 Port0.call(MyProcTemplate,nowait) to PC1;
399 Port0.call(MyProc3Template,nowait) to PC2;
402 []Port0.getreply(MyProcTemplate2 value true) from PC1 {
405 []Port0.getreply(MyProc3Template value 2.78) from PC2 {
409 setverdict(fail);stop;
414 Port0.call(StopPTC,0.5) to PC1 {
415 []Port0.getreply(StopPTC) from PC1 { }
416 []Port0.catch(timeout) { setverdict(fail);stop; }
418 Port0.call(StopPTC,0.5) to PC2 {
419 []Port0.getreply(StopPTC) from PC2 { }
420 []Port0.catch(timeout) { setverdict(fail);stop; }
422 disconnect(self:Port0,PC1:Port1);
423 disconnect(self:Port0,PC2:Port1);
426 testcase tc_Call_MultiPTC_anyport() runs on ProcComponentMultiPort {
427 /* testing any-port operations with multiple PTCs */
428 var ProcComponent2 PC1,PC2;
429 var ProcComponent2 sndr;
431 var boolean chk1:=true,chk2:=true;
433 PC1:=ProcComponent2.create;
434 PC1.start(GetCall_behav1());
435 connect(self:Port0,PC1:Port1);
436 PC2:=ProcComponent2.create;
437 PC2.start(GetCall_behav3());
438 connect(self:Port0,PC2:Port1);
440 Port0.call(MyProcTemplate,nowait) to PC1;
441 Port0.call(MyProc3Template,nowait) to PC2;
444 [chk1]any port.check {
447 log("any port.check OK");
449 [chk2]any port.check(getreply -> sender sndr) {
452 log("any port.check(getreply) OK, sender: ",sndr);
454 []any port.check(catch) {
455 log("any port.check(catch) matched --> fail");
456 setverdict(fail);stop;
459 log("any port.getcall matched --> fail");
460 setverdict(fail);stop;
462 []any port.getreply from PC1 {
463 log("any port.getreply from PC1 OK");
466 []any port.getreply from PC2 {
467 log("any port.getreply from PC2 OK");
471 setverdict(fail);stop;
476 Port0.call(StopPTC,0.5) to PC1 {
477 []Port0.getreply(StopPTC) from PC1 { }
478 []Port0.catch(timeout) { setverdict(fail);stop; }
480 Port0.call(StopPTC,0.5) to PC2 {
481 []Port0.getreply(StopPTC) from PC2 { }
482 []Port0.catch(timeout) { setverdict(fail);stop; }
484 disconnect(self:Port0,PC1:Port1);
485 disconnect(self:Port0,PC2:Port1);
488 testcase tc_Check_1() runs on ProcComponent {
489 var ProcComponent2 PC2;
491 PC2:=ProcComponent2.create;
492 PC2.start(GetCall_behav3());
493 connect(self:Port0,PC2:Port1);
494 Port0.call(MyProcTemplate2,nowait);
497 []Port0.check(catch) { }
504 []any port.check(catch) {
505 log("any port.check(catch) OK");
513 []Port0.check(catch(MyProc,integer:272869)) {
521 Port0.call(MyProcTemplate,nowait);
523 []Port0.check(getreply) { }
530 []Port0.check(getreply(MyProcTemplateP(22,"G",199.99) value false)){
539 Port0.call(StopPTC,0.5) {
540 []Port0.getreply(StopPTC) { }
541 []Port0.catch(timeout) { }
545 testcase tc_Check_2() runs on ProcComponent {
546 var ProcComponent2 PC2;
547 PC2:=ProcComponent2.create;
548 PC2.start(Check_getcall_behav());
549 connect(self:Port0,PC2:Port1);
550 Port0.call(MyProcTemplate2,1.0) {
551 []Port0.getreply(MyProcTemplate value true) { }
552 []Port0.catch(timeout) {
557 Port0.call(MyProcTemplate,1.0) {
558 []Port0.getreply(MyProcTemplate2 value false) {
561 []Port0.catch(timeout) {
566 Port0.call(StopPTC,0.5) {
567 []Port0.getreply(StopPTC) { }
568 []Port0.catch(timeout) { }
572 testcase tc_PortAddress_internal_usage() runs on ProcComponentMultiPort {
573 /* procedure based internal communication with address-supporting port */
574 var ProcComponent2 PC2;
576 PC2:=ProcComponent2.create;
577 PC2.start(GetCall_behav3());
578 connect(self:Port4,PC2:Port1);
579 Port4.call(MyProcTemplateP(11,"T",99.012),1.0) {
580 []Port4.getreply(MyProcTemplateP(22,"G",199.99) value false) {
583 []Port4.catch(timeout) {
584 setverdict(fail);stop;
587 Port4.call(MyProcTemplate2,1.0) {
588 []Port4.catch(MyProc,integer:272869) {
591 []Port4.catch(timeout) {
592 setverdict(fail);stop;
595 if(i==2){setverdict(pass);}
596 Port4.call(StopPTC,1.0) {
597 []Port4.getreply(StopPTC) { }
598 []Port4.catch(timeout) {
604 testcase tc_PortAddress_external_usage1() runs on addressComponent
605 system addressComponent {
606 map(self:P,system:P);
607 P.call(MyProcTemplate,1.0) to valueof(MyAddress(321,67)) {
608 []P.getreply(MyProcTemplate_any value true) from MyAddress(67,321) {
615 unmap(self:P,system:P);
618 testcase tc_PortAddress_external_usage2() runs on addressComponent
619 system addressComponent {
620 map(self:P,system:P);
621 P.call(MyProcTemplate,1.0) to valueof(MyAddress(321,68)) {
622 []P.catch(MyProc,integer:389) from MyAddress(68,321) {
629 unmap(self:P,system:P);
632 function signatureEncode(template MyProc par1, template MyProc par2) runs on addressComponent
637 // tests the 'param' directive in functions 'getcall' and 'getreply',
638 // specificly with signatures containing 'inout' parameters (HT93096)
639 testcase tc_GetReplyParameters() runs on ProcComponent3 {
640 var ProcComponent3 c := ProcComponent3.create;
641 connect(c:pt, self:pt);
642 c.start(GetCallParameters_behav());
645 pt.call(MyProc6:{c_CallParam}, 1.0) {
646 [] pt.getreply(MyProc6:{t_getCall_invalidValue}) { setverdict(fail, "invalid getcall parameter"); }
647 [] pt.getreply(MyProc6:{t_getCall_timeout}) { setverdict(fail, "getcall timed out"); }
648 [] pt.getreply(MyProc6:{?}) -> param (x) {
649 if (c_ReplyParam == x) { setverdict(pass); }
650 else { setverdict(fail, "invalid getreply parameter"); }
652 [] pt.catch(timeout) { setverdict(fail, "getreply timed out"); }
661 execute(tc_extCall());
662 execute(tc_extCall_2());
663 execute(tc_extCall_3());
664 execute(tc_Call_MultiPTC());
665 execute(tc_Call_MultiPTC_anyport());
666 execute(tc_Check_1());
667 execute(tc_Check_2());
668 execute(tc_PortAddress_internal_usage());
669 execute(tc_PortAddress_external_usage1());
670 execute(tc_PortAddress_external_usage2());
671 execute(tc_GetReplyParameters());