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 ******************************************************************************/
13 } with { encode "RAW"; variant "" }
15 type record Errorneous_PDU {
17 octetstring fo optional
21 variant (fo) "PRESENCE(fi=1)"
25 type port PCOType message
35 type boolean Bool with { encode "TEXT" variant "TEXT_CODING(length=5)" }
37 function f_encode_int(in integer i, out charstring cs)
43 extension "prototype(fast)"
46 function f_encode_float(in float f) return charstring
52 extension "prototype(convert)"
55 type port UserPort message
59 out integer, boolean, float, bitstring, octetstring;
63 extension "user PCOType
64 in ( charstring -> charstring : simple;
65 octetstring -> MyPDU : decode(RAW) errorbehavior(ALL:WARNING),
67 out ( charstring -> charstring : simple;
68 integer -> charstring : function(f_encode_int);
69 Bool -> charstring : encode(TEXT);
70 float -> charstring : function(f_encode_float);
71 octetstring -> -:discard;
72 MyPDU -> octetstring : encode(RAW);
73 bitstring -> charstring : function(f_encode_bitstr)
77 type port UserPort2 message
80 out Errorneous_PDU, octetstring;
84 extension "user PCOType
85 in ( charstring -> charstring : simple;
86 octetstring -> - : discard )
87 out ( charstring -> charstring : simple;
88 octetstring -> - : discard;
89 Errorneous_PDU -> octetstring : encode(RAW) errorbehavior (ALL:WARNING)
94 function f_encode_bitstr(in bitstring bs := ''B) return charstring
96 return "Bit string = " & bit2str(bs);
100 extension "prototype(convert)"
103 type component MTCType
108 type component MyComp extends MTCType
113 type component MyComp2 extends MTCType
118 external function decode_MyPDU(in octetstring os, out MyPDU pdu) return integer
120 extension "prototype(backtrack)"
121 extension "decode(RAW)"
122 extension "errorbehavior(ALL:WARNING)"
126 function f_PReceiveCharstring(charstring p_message, float p_time) runs on MyComp
134 [] P.receive(p_message)
151 function f_PReceiveNone(float p_time) runs on MyComp
169 testcase ImplicitMsgEnc1() runs on MyComp system MTCType
171 var MyPDU mypdu := {i := 10, f := 3.14};
173 map(mtc:P, system:MyPCO);
175 //the TLV of first octetstring has error -> the
176 //octetstring needs to be discarded.
177 //see user_map for more details
180 P.send("Hello, world!");
181 f_PReceiveCharstring("Hello, world!", 1.0);
183 f_PReceiveCharstring("123", 1.0);
185 f_PReceiveCharstring("false", 1.0);
187 f_PReceiveCharstring("true", 1.0);
189 f_PReceiveCharstring("3.140000", 1.0);
191 P.receive(?) -> value mypdu;
195 //octetstring to send must be discarded
199 P.send('1010101010'B);
200 f_PReceiveCharstring("Bit string = 1010101010", 1.0);
202 // f_PReceiveCharstring("Hello, TTCN-3!", 4.0);
204 unmap(mtc:P, system:MyPCO);
207 testcase ImplicitMsgEnc2() runs on MyComp2 system MTCType
209 var Errorneous_PDU myErrPDU := {fi := omit, fo := 'AA'O};
212 map(mtc:P2, system:MyPCO);
217 [] P2.receive {t.stop; setverdict(fail);}
218 [] t.timeout {setverdict(pass)}
221 unmap(mtc:P2, system:MyPCO);
226 execute(ImplicitMsgEnc1());
227 execute(ImplicitMsgEnc2());