1 /******************************************************************************
2 * Copyright (c) 2000-2015 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 type record MyRecord { }
12 signature MyProc(in integer Par1,inout charstring Par2,out float Par3)
16 type MyProc2 MyProc2Alias; // testing type alias
17 signature MyProc3(in integer I) return float exception(integer);
18 signature MyProc4(in float F) noblock;
19 signature MyProc5(in integer A, in integer B)
20 return float exception(charstring, MyRecord);
21 signature s_StopPTC();
22 signature MyProc6(inout integer I);
24 template s_StopPTC StopPTC := { }
26 template MyProc5 MyProc5Template_any := {
31 template MyProc5 MyProc5TemplateP(integer pA,integer pB) := {
36 template MyProc3 MyProc3Template:={
40 template MyProc3 MyProc3Template_any:={I:=?}
42 template MyProc3 MyProc3TemplateP (integer P) := {
46 template MyProc MyProcTemplateP (integer i,charstring c,float f) := {
52 template MyProc MyProcTemplate:= {
58 template MyProc MyProcTemplate2:= {
64 template MyProc MyProcTemplate_any:= {
70 template MyProc2 MyProc2Template := { }
77 template address MyAddress(integer p1,integer p2) := {
82 type port PortAddress procedure {
83 inout MyProc,s_StopPTC;
85 } with { extension "address" }
87 type port ProcPort1 procedure
89 inout MyProc,s_StopPTC;
92 } with {extension "internal"}
94 type port ProcPort2 procedure
96 inout MyProc,s_StopPTC;
99 } with {extension "internal"}
101 type port ExtProcPort procedure
106 type port CompileOnlyPort procedure
115 type port CompileOnlyPortAddress procedure {
121 } with { extension "address" }
123 type port ProcPort3 procedure {
125 } with { extension "internal" }
127 type component ProcComponent
129 port ProcPort1 Port0;
132 type component ProcComponent2
134 port ProcPort2 Port1;
137 type component ProcComponentMultiPort
139 port ProcPort1 Port0;
140 port ProcPort2 Port1[4];
141 port ExtProcPort Port2;
142 port CompileOnlyPort Port3;
143 port PortAddress Port4;
146 type component eComponent
148 port ExtProcPort ePort;
151 type component addressComponent
156 type component ProcComponent3 {
160 function GetCall_behav1() runs on ProcComponent2 {
163 []Port1.getcall(MyProcTemplate_any) {
164 Port1.reply(MyProcTemplate2 value true);
166 []Port1.getcall(MyProc3Template_any) {
167 Port1.reply(MyProc3Template value 3.1415);
169 []Port1.getcall(StopPTC) {
170 Port1.reply(StopPTC);
177 function GetCall_behav2() runs on ProcComponent {
180 []Port0.getcall(MyProcTemplate2) {
181 Port0.raise(MyProc,integer:555);
183 []Port0.getcall(MyProcTemplate_any) {
184 Port0.reply(MyProcTemplate value false);
186 []Port0.getcall(MyProc2Template) {
187 Port0.reply(MyProc2Template);
189 []Port0.getcall(StopPTC) {
190 Port0.reply(StopPTC);
197 function GetCall_behav3() runs on ProcComponent2 {
200 []Port1.getcall(MyProcTemplate2) {
201 Port1.raise(MyProc,integer:272869);
203 []Port1.getcall(MyProcTemplate_any) {
204 Port1.reply(MyProcTemplateP(22,"G",199.99) value false);
206 []Port1.getcall(MyProc3Template_any) {
207 Port1.reply(MyProc3Template value 2.78);
209 []Port1.getcall(StopPTC) {
210 Port1.reply(StopPTC);
217 function Check_getcall_behav() runs on ProcComponent2 {
220 []Port1.check(getcall(MyProcTemplate2)) {
222 Port1.reply(MyProcTemplate value true);
224 []Port1.getcall(StopPTC) {
225 Port1.reply(StopPTC);
228 []Port1.check(getcall) {
230 Port1.reply(MyProcTemplate2 value false);
237 const integer c_CallParam := 10;
238 const integer c_ReplyParam := 19;
241 template integer t_getCall_invalidValue := -1;
242 template integer t_getCall_timeout := -2;
244 function GetCallParameters_behav() runs on ProcComponent3 {
249 [] pt.getcall(MyProc6:{?}) -> param (x) {
250 if (c_CallParam == x) { pt.reply(MyProc6:{c_ReplyParam}); }
251 else { pt.reply(MyProc6:{t_getCall_invalidValue}); }
253 [] t.timeout { pt.reply(MyProc6:{t_getCall_timeout}); }
257 testcase Call_tc1() runs on ProcComponent {
258 /* Non-blocking calls */
259 var ProcComponent2 PC2;
261 var boolean b:=false;
264 PC2:=ProcComponent2.create;
265 PC2.start(GetCall_behav1());
266 connect(self:Port0,PC2:Port1);
268 Port0.call(MyProcTemplate,nowait);
269 Port0.call(MyProc3Template,nowait);
272 []Port0.getreply(MyProcTemplate2) -> value b {
275 else {setverdict(fail);stop;}
277 setverdict(inconc);stop;
280 []Port0.getreply(MyProc3Template) -> value f {
281 if((i==1)and(f==3.1415)) {i:=2;}
282 else {log(f);setverdict(inconc);stop;}
290 if(i==2) {setverdict(pass);}
291 Port0.call(StopPTC,0.5) {
292 []Port0.getreply(StopPTC) { }
293 []Port0.catch(timeout) { }
295 disconnect(self:Port0,PC2:Port1);
298 testcase Call_tc2() runs on ProcComponent2 {
300 var ProcComponent PC;
302 PC:=ProcComponent.create;
303 PC.start(GetCall_behav2());
304 connect(self:Port1,PC:Port0);
305 Port1.call(MyProcTemplate,1.0) {
306 []Port1.getreply(MyProcTemplate value ?) -> value b{
307 Port1.call(MyProc2Template,0.7) {
308 []Port1.getreply(MyProc2Template) {
309 Port1.call(MyProcTemplate2,0.4) {
310 []Port1.catch(MyProc,integer:555) {
311 if(b==false) {setverdict(pass);}
312 else {setverdict(inconc);}
314 []Port1.catch(timeout) {
320 []Port1.catch(timeout) {
326 []Port1.catch(timeout) {
331 Port1.call(StopPTC,0.5) {
332 []Port1.getreply(StopPTC) { }
333 []Port1.catch(timeout) { }
337 testcase extCall_tc1() runs on eComponent system eComponent {
338 map(self:ePort,system:ePort);
339 ePort.call(MyProc5TemplateP(128,32),0.5) {
340 []ePort.getreply(MyProc5Template_any value 4.0) {
343 []ePort.catch(timeout) {
344 setverdict(fail);stop;
347 unmap(self:ePort,system:ePort);
350 testcase extCall_tc2() runs on eComponent system eComponent {
351 map(self:ePort,system:ePort);
352 ePort.call(MyProc5TemplateP(32,128),0.5) {
353 []ePort.getreply(MyProc5Template_any value 0.25) {
356 []ePort.catch(timeout) {
357 setverdict(fail);stop;
360 unmap(self:ePort,system:ePort);
363 testcase extCall_tc3() runs on eComponent system eComponent {
364 map(self:ePort,system:ePort);
365 ePort.call(MyProc5TemplateP(128,0),0.5) {
366 []ePort.catch(MyProc5,charstring:"Divide by 0.") {
369 []ePort.catch(timeout) {
370 setverdict(fail);stop;
373 unmap(self:ePort,system:ePort);
376 testcase Call_MultiPTC_tc() runs on ProcComponent {
377 /* procedure based communication with multiple PTCs */
378 var ProcComponent2 PC1,PC2;
381 PC1:=ProcComponent2.create;
382 PC1.start(GetCall_behav1());
383 connect(self:Port0,PC1:Port1);
384 PC2:=ProcComponent2.create;
385 PC2.start(GetCall_behav3());
386 connect(self:Port0,PC2:Port1);
388 Port0.call(MyProcTemplate,nowait) to PC1;
389 Port0.call(MyProc3Template,nowait) to PC2;
392 []Port0.getreply(MyProcTemplate2 value true) from PC1 {
395 []Port0.getreply(MyProc3Template value 2.78) from PC2 {
399 setverdict(fail);stop;
404 Port0.call(StopPTC,0.5) to PC1 {
405 []Port0.getreply(StopPTC) from PC1 { }
406 []Port0.catch(timeout) { setverdict(fail);stop; }
408 Port0.call(StopPTC,0.5) to PC2 {
409 []Port0.getreply(StopPTC) from PC2 { }
410 []Port0.catch(timeout) { setverdict(fail);stop; }
412 disconnect(self:Port0,PC1:Port1);
413 disconnect(self:Port0,PC2:Port1);
416 testcase Call_MultiPTC_anyport_tc() runs on ProcComponentMultiPort {
417 /* testing any-port operations with multiple PTCs */
418 var ProcComponent2 PC1,PC2;
419 var ProcComponent2 sndr;
421 var boolean chk1:=true,chk2:=true;
423 PC1:=ProcComponent2.create;
424 PC1.start(GetCall_behav1());
425 connect(self:Port0,PC1:Port1);
426 PC2:=ProcComponent2.create;
427 PC2.start(GetCall_behav3());
428 connect(self:Port0,PC2:Port1);
430 Port0.call(MyProcTemplate,nowait) to PC1;
431 Port0.call(MyProc3Template,nowait) to PC2;
434 [chk1]any port.check {
437 log("any port.check OK");
439 [chk2]any port.check(getreply -> sender sndr) {
442 log("any port.check(getreply) OK, sender: ",sndr);
444 []any port.check(catch) {
445 log("any port.check(catch) matched --> fail");
446 setverdict(fail);stop;
449 log("any port.getcall matched --> fail");
450 setverdict(fail);stop;
452 []any port.getreply from PC1 {
453 log("any port.getreply from PC1 OK");
456 []any port.getreply from PC2 {
457 log("any port.getreply from PC2 OK");
461 setverdict(fail);stop;
466 Port0.call(StopPTC,0.5) to PC1 {
467 []Port0.getreply(StopPTC) from PC1 { }
468 []Port0.catch(timeout) { setverdict(fail);stop; }
470 Port0.call(StopPTC,0.5) to PC2 {
471 []Port0.getreply(StopPTC) from PC2 { }
472 []Port0.catch(timeout) { setverdict(fail);stop; }
474 disconnect(self:Port0,PC1:Port1);
475 disconnect(self:Port0,PC2:Port1);
478 testcase Check_tc1() runs on ProcComponent {
479 var ProcComponent2 PC2;
481 PC2:=ProcComponent2.create;
482 PC2.start(GetCall_behav3());
483 connect(self:Port0,PC2:Port1);
484 Port0.call(MyProcTemplate2,nowait);
487 []Port0.check(catch) { }
494 []any port.check(catch) {
495 log("any port.check(catch) OK");
503 []Port0.check(catch(MyProc,integer:272869)) {
511 Port0.call(MyProcTemplate,nowait);
513 []Port0.check(getreply) { }
520 []Port0.check(getreply(MyProcTemplateP(22,"G",199.99) value false)){
529 Port0.call(StopPTC,0.5) {
530 []Port0.getreply(StopPTC) { }
531 []Port0.catch(timeout) { }
535 testcase Check_tc2() runs on ProcComponent {
536 var ProcComponent2 PC2;
537 PC2:=ProcComponent2.create;
538 PC2.start(Check_getcall_behav());
539 connect(self:Port0,PC2:Port1);
540 Port0.call(MyProcTemplate2,1.0) {
541 []Port0.getreply(MyProcTemplate value true) { }
542 []Port0.catch(timeout) {
547 Port0.call(MyProcTemplate,1.0) {
548 []Port0.getreply(MyProcTemplate2 value false) {
551 []Port0.catch(timeout) {
556 Port0.call(StopPTC,0.5) {
557 []Port0.getreply(StopPTC) { }
558 []Port0.catch(timeout) { }
562 testcase PortAddress_internal_usage() runs on ProcComponentMultiPort {
563 /* procedure based internal communication with address-supporting port */
564 var ProcComponent2 PC2;
566 PC2:=ProcComponent2.create;
567 PC2.start(GetCall_behav3());
568 connect(self:Port4,PC2:Port1);
569 Port4.call(MyProcTemplateP(11,"T",99.012),1.0) {
570 []Port4.getreply(MyProcTemplateP(22,"G",199.99) value false) {
573 []Port4.catch(timeout) {
574 setverdict(fail);stop;
577 Port4.call(MyProcTemplate2,1.0) {
578 []Port4.catch(MyProc,integer:272869) {
581 []Port4.catch(timeout) {
582 setverdict(fail);stop;
585 if(i==2){setverdict(pass);}
586 Port4.call(StopPTC,1.0) {
587 []Port4.getreply(StopPTC) { }
588 []Port4.catch(timeout) {
594 testcase PortAddress_external_usage1() runs on addressComponent
595 system addressComponent {
596 map(self:P,system:P);
597 P.call(MyProcTemplate,1.0) to valueof(MyAddress(321,67)) {
598 []P.getreply(MyProcTemplate_any value true) from MyAddress(67,321) {
605 unmap(self:P,system:P);
608 testcase PortAddress_external_usage2() runs on addressComponent
609 system addressComponent {
610 map(self:P,system:P);
611 P.call(MyProcTemplate,1.0) to valueof(MyAddress(321,68)) {
612 []P.catch(MyProc,integer:389) from MyAddress(68,321) {
619 unmap(self:P,system:P);
622 function signatureEncode(template MyProc par1, template MyProc par2) runs on addressComponent
627 // tests the 'param' directive in functions 'getcall' and 'getreply',
628 // specificly with signatures containing 'inout' parameters (HT93096)
629 testcase GetReplyParameters_tc() runs on ProcComponent3 {
630 var ProcComponent3 c := ProcComponent3.create;
631 connect(c:pt, self:pt);
632 c.start(GetCallParameters_behav());
635 pt.call(MyProc6:{c_CallParam}, 1.0) {
636 [] pt.getreply(MyProc6:{t_getCall_invalidValue}) { setverdict(fail, "invalid getcall parameter"); }
637 [] pt.getreply(MyProc6:{t_getCall_timeout}) { setverdict(fail, "getcall timed out"); }
638 [] pt.getreply(MyProc6:{?}) -> param (x) {
639 if (c_ReplyParam == x) { setverdict(pass); }
640 else { setverdict(fail, "invalid getreply parameter"); }
642 [] pt.catch(timeout) { setverdict(fail, "getreply timed out"); }
651 execute(extCall_tc1());
652 execute(extCall_tc2());
653 execute(extCall_tc3());
654 execute(Call_MultiPTC_tc());
655 execute(Call_MultiPTC_anyport_tc());
656 execute(Check_tc1());
657 execute(Check_tc2());
658 execute(PortAddress_internal_usage());
659 execute(PortAddress_external_usage1());
660 execute(PortAddress_external_usage2());
661 execute(GetReplyParameters_tc());