Commit ae09a766 authored by balaskoa's avatar balaskoa
Browse files

RAW_EncDec copied from titan.core into Regression_Test_java


Signed-off-by: default avatarbalaskoa <Jeno.Balasko@ericsson.com>
parent badb9892
......@@ -16,6 +16,7 @@
#"src/cfgFile/ordered_include/oi_after_list1.cfg" #Error while setting parameter field 'tsp_c' to '0': Type mismatch: charstring value was expected instead of null.
#!!!! "src/cfgFile/testport_parameters/array_index.cfg" #compiled, not runnining, it shall be excluded anyway!!!
"src/cfg_list_concat/everything.cfg"
"src/EncodeDecode/RAW/RAW_EncDec/RAW_EncDec.cfg"
"src/floatOper/config.cfg" #25 pass
"src/hexstrOper/config.cfg" #TODO: one testase is commented out (send())
"src/implicitOmit/config.cfg" #ok, 18 pass
......
###############################################################################
# Copyright (c) 2000-2019 Ericsson Telecom AB
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v2.0
# which accompanies this distribution, and is available at
# https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
#
# Contributors:
# Balasko, Jeno
# Hanko, Matyas
#
###############################################################################
[MODULE_PARAMETERS]
[LOGGING]
LogSourceInfo := Yes
Logfile := "Temp.log"
FileMask := LOG_ALL
ConsoleMask := TTCN_WARNING | TTCN_ERROR | TTCN_TESTCASE | TTCN_STATISTICS
[EXECUTE]
RAW_EncDec_1
RAW_EncDec_2
RAW_EncDec_3
RAW_EncDec_4
RAW_EncDec_5
RAW_EncDec_6
RAW_EncDec_7
RAW_EncDec_8
\ No newline at end of file
/******************************************************************************
* Copyright (c) 2000-2019 Ericsson Telecom AB
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
*
* Contributors:
* Szabados, Kristof *
******************************************************************************/
module RAW_EncDec_2 {
external function enc_RAW_PDU(in RAW_PDU pdu) return octetstring with { extension "prototype(convert) encode(RAW)" }
external function dec_RAW_PDU(in octetstring stream) return RAW_PDU with { extension "prototype(convert) decode(RAW)" }
type integer RAW_PDU
with { encode "RAW"; variant "FIELDLENGTH(1)"};
const RAW_PDU i := 15
const octetstring o := '0F'O
type component TempComp {}
testcase TC() runs on TempComp {
@try {
if ((enc_RAW_PDU(i) == o)and(dec_RAW_PDU(o) == i)) {setverdict(pass);}
else {setverdict(fail);}
} @catch (msg) {
var template charstring msg_exp := pattern "*While RAW-encoding type '@RAW_EncDec_2.RAW_PDU': There are insufficient bits to encode '@RAW_EncDec_2.RAW_PDU'*";
if (not match(msg, msg_exp)) {
setverdict(fail, "Invalid error message: ", msg);
} else {
setverdict(pass);
}
}
}
control {
execute (TC())
}
}
/******************************************************************************
* Copyright (c) 2000-2019 Ericsson Telecom AB
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
*
* Contributors:
* Szabados, Kristof *
******************************************************************************/
module RAW_EncDec_3 {
external function enc_RAW_PDU(in RAW_PDU pdu) return octetstring with { extension "prototype(convert) encode(RAW)" }
external function dec_RAW_PDU(in octetstring stream) return RAW_PDU with { extension "prototype(convert) decode(RAW)" }
type bitstring RAW_PDU
with { encode "RAW"; variant "FIELDLENGTH(4)"};
const RAW_PDU i := '11111111'B
const octetstring o := 'FF'O
type component TempComp {}
testcase TC() runs on TempComp {
@try {
if ((enc_RAW_PDU(i) == o)and(dec_RAW_PDU(o) == i)) {setverdict(pass);}
else {setverdict(fail);}
} @catch (msg) {
var template charstring msg_exp := pattern "*While RAW-encoding type '@RAW_EncDec_3.RAW_PDU': There is no sufficient bits to encode '@RAW_EncDec_3.RAW_PDU'*";
if (not match(msg, msg_exp)) {
setverdict(fail, "Invalid error message: ", msg);
} else {
setverdict(pass);
}
}
}
control {
execute (TC())
}
}
/******************************************************************************
* Copyright (c) 2000-2019 Ericsson Telecom AB
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
*
* Contributors:
* Szabados, Kristof *
******************************************************************************/
module RAW_EncDec_4 {
external function enc_RAW_PDU(in RAW_PDU pdu) return octetstring with { extension "prototype(convert) encode(RAW)" }
external function dec_RAW_PDU(in octetstring stream) return RAW_PDU with { extension "prototype(convert) decode(RAW)" }
type hexstring RAW_PDU
with {encode "RAW";
variant "FIELDLENGTH(2)"};
const RAW_PDU i := '1234'H
const octetstring o := '1234'O
type component TempComp {}
testcase TC() runs on TempComp {
@try {
if ((enc_RAW_PDU(i) == o)and(dec_RAW_PDU(o) == i)) {setverdict(pass);}
else {setverdict(fail);}
} @catch (msg) {
var template charstring msg_exp := pattern "*While RAW-encoding type '@RAW_EncDec_4.RAW_PDU': There is no sufficient bits to encode '@RAW_EncDec_4.RAW_PDU'*";
if (not match(msg, msg_exp)) {
setverdict(fail, "Invalid error message: ", msg);
} else {
setverdict(pass);
}
}
}
control {
execute (TC())
}
}
/******************************************************************************
* Copyright (c) 2000-2019 Ericsson Telecom AB
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
*
* Contributors:
* Szabados, Kristof *
******************************************************************************/
module RAW_EncDec_5 {
external function enc_RAW_PDU(in RAW_PDU pdu) return octetstring with { extension "prototype(convert) encode(RAW)" }
external function dec_RAW_PDU(in octetstring stream) return RAW_PDU with { extension "prototype(convert) decode(RAW)" }
type integer RAW_PDU
with { encode "RAW";
variant "FIELDLENGTH(8)" ;
variant "COMP( nosign ) "
};
const RAW_PDU i := -2
const octetstring o := '02'O
type component TempComp {}
testcase TC() runs on TempComp {
@try {
if ((enc_RAW_PDU(i) == o)and(dec_RAW_PDU(o) == i)) {setverdict(pass);}
else {setverdict(fail);}
} @catch (msg) {
var template charstring msg_exp := pattern "*While RAW-encoding type '@RAW_EncDec_5.RAW_PDU': Unsigned encoding of a negative number: @RAW_EncDec_5.RAW_PDU*";
if (not match(msg, msg_exp)) {
setverdict(fail, "Invalid error message: ", msg);
} else {
setverdict(pass);
}
}
}
control {
execute (TC())
}
}
/******************************************************************************
* Copyright (c) 2000-2019 Ericsson Telecom AB
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
*
* Contributors:
* Szabados, Kristof *
******************************************************************************/
module RAW_EncDec_6 {
type octetstring raw_pdu_octetstring with { encode "RAW"; variant "FIELDLENGTH(1)"};
external function enc_raw_pdu_octetstring(in raw_pdu_octetstring pdu) return octetstring with { extension "prototype(convert) encode(RAW)" }
external function dec_raw_pdu_octetstring(in octetstring stream) return raw_pdu_octetstring with { extension "prototype(convert) decode(RAW)" }
type component TempComp {}
testcase TC() runs on TempComp {
var raw_pdu_octetstring i;
const octetstring o := '0F'O;
@try {
if ((enc_raw_pdu_octetstring(i) == o)and(dec_raw_pdu_octetstring(o) == i)) {setverdict(pass);}
else {setverdict(fail,"enc_raw_pdu_octetstring(i)= ", enc_raw_pdu_octetstring(i), "; dec_raw_pdu_octetstring(o)= ", dec_raw_pdu_octetstring(o));}
} @catch (msg) {
var template charstring msg_exp := pattern "*While RAW-encoding type '@RAW_EncDec_6.raw_pdu_octetstring': Encoding an unbound value.*";
if (not match(msg, msg_exp)) {
setverdict(fail, "Invalid error message: ", msg);
} else {
setverdict(pass);
}
}
}
control {
execute (TC())
}
}
/******************************************************************************
* Copyright (c) 2000-2019 Ericsson Telecom AB
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
*
* Contributors:
* Szabados, Kristof *
******************************************************************************/
module RAW_EncDec_7 {
type component Test_CT{};
external function enc_PDU(in PDU pl_pdu) return octetstring
with {
extension "prototype(convert)"
extension "encode(RAW)"
};
external function dec_PDU(in octetstring pl_octetstring) return PDU
with {
extension "prototype(convert)"
extension "decode(RAW)"
}
type hexstring HEX1 length(1) with {encode "RAW";variant "FIELDLENGTH(1)"};
type hexstring HEX5 length(5) with {encode "RAW";variant "FIELDLENGTH(5)"};
type octetstring OCT1 length(1) with {encode "RAW";variant "FIELDLENGTH(1)"};
type record My_Type{
OCT1 id,
HEX1 spare,
HEX5 hex,
octetstring o
} with {
encode "RAW";
variant(spare,hex) "FIELDORDER(msb)";
}
type record PDU {
OCT1 msg_type,
U u
} with {
encode "RAW";
variant (u) "CROSSTAG(h1, msg_type = '01'O;
h5, msg_type = '02'O;
my_type, msg_type = '03'O;
unknown, OTHERWISE;)";
}
type union U {
HEX1 h1,
HEX5 h5,
My_Type my_type,
octetstring unknown
} with {encode "RAW";}
testcase TC_02() runs on Test_CT{
var PDU vl_pdu := {
msg_type := '03'O,
u := {
my_type := {
id := '01'O,
spare := 'F'H,
hex := 'ABCDE'H,
o := '123456'O
}
}
}
var octetstring vl_encoded := enc_PDU(vl_pdu);
var PDU vl_decoded := dec_PDU(vl_encoded);
log("Encoded pdu:",vl_encoded);
if(vl_pdu == vl_decoded){
setverdict(pass);
} else {
setverdict(fail);
log(match(vl_pdu, vl_decoded));
}
}
control{
execute(TC_02());
}
}
/******************************************************************************
* Copyright (c) 2000-2019 Ericsson Telecom AB
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
*
* Contributors:
* Szabados, Kristof *
******************************************************************************/
module RAW_EncDec_8 {
type component Test_CT{};
external function enc_U(in U pl_pdu) return octetstring
with {
extension "prototype(convert)"
extension "encode(RAW)"
};
external function dec_U(in octetstring pl_octetstring) return U
with {
extension "prototype(convert)"
extension "decode(RAW)"
}
type octetstring OCT2 length(2);
type record R1 {
integer f1,
octetstring f2,
integer f3
} with {
encode "RAW"
variant (f1) "FIELDLENGTH(64)"
variant (f1) "LENGTHTO(f2)"
}
type union U {
R1 u1,
octetstring u2 length(8)
} with {
encode "RAW"
variant ""
}
testcase TC_01() runs on Test_CT{
var U pl_u, pl_u_result;
pl_u.u2 := 'FFFFFFFFFFFFFFFF'O;
var octetstring os := enc_U(pl_u);
pl_u_result := dec_U(os);
if (pl_u != pl_u_result) {
setverdict(fail);
}
setverdict(pass);
}
control{
execute(TC_01());
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment