Commit b03248f2 authored by balaskoa's avatar balaskoa
Browse files

Hexstring support in test + OER excluded


Signed-off-by: default avatarbalaskoa <Jeno.Balasko@ericsson.com>
parent 66f6a253
......@@ -117,6 +117,13 @@
<ExcludeFromBuild>true</ExcludeFromBuild>
</FolderProperties>
</FolderResource>
<FolderResource>
<FolderPath>src/EncodeDecode/OER/OER_BasicTest</FolderPath>
<FolderProperties>
<CentralStorage>false</CentralStorage>
<ExcludeFromBuild>true</ExcludeFromBuild>
</FolderProperties>
</FolderResource>
<FolderResource>
<FolderPath>src/cfgFile/testport_parameters</FolderPath>
<FolderProperties>
......
......@@ -140,7 +140,11 @@ JsonBasicASN1EncDecTest1
JsonBasicAttributeTest
JsonBasicEncDecTest_bs #2 error --see in bugs
JsonBasicEncDecTest_os #e error - see in bugs
##TODO: move here the json folder!
##TODO:JsonComplexTest
#JsonTestcases.control #55 pass (75.342 %), 0 inconc (0 %), 2 fail (2.74 %), 16 error (21.918 %)
#AttributeTestcases.control #5 pass (21.739 %), 0 inconc (0 %), 1 fail (4.348 %), 17 error (73.913 %)
#Bson
#Cbor
#enumOper:
TenumOper.control
......@@ -288,8 +292,8 @@ TtemplateEnum.control
#templateExclusiveRange: see [ORDERED_INCLUDE]
#TODO: New testcases without these functions
TtemplateFloat.control
#TtemplateHexstr //TODO: decmatch + JSON, XML encoding is not ready in it!
#TODO: real hexstring test shall be written!
TtemplateHexstr //TODO: decmatch + JSON, XML encoding is not ready in it!
#TODO: real hexstring test shall be written!!!
TtemplateInt.control
#templateIstemplatekind
IsTemplateKind #pass, fixed compilation error
......
/******************************************************************************
* 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:
* Baranyi, Botond – initial implementation
*
******************************************************************************/
module TtemplateHexstr {
type component templateHexstr_mycomp {};
type record templateHexstr_rec {
hexstring x1,
hexstring x2,
hexstring x3 optional
}
with {
encode "JSON";
variant(x1) "JSON: name as first";
variant(x2) "JSON: name as second";
variant(x3) "JSON: name as third";
}
type record decmatch_rec {
integer i,
charstring s
}
with {
encode "JSON";
}
type record of integer decmatch_list
with {
encode "XML";
variant "list";
}
type union decmatch_uni {
integer i,
charstring s
}
with {
encode "RAW";
variant(i) "FIELDLENGTH(16)";
}
template decmatch_uni decmatch_tUnion := { i := ? };
template decmatch_rec decmatch_tRecord := { i := (0..infinity), s := ? };
template templateHexstr_rec templateHexstr_tDecmatch := { // decoded content match
x1 := decmatch decmatch_list: { (1..10), (11..20), (21..30) },
x2 := decmatch decmatch_tUnion,
x3 := decmatch modifies decmatch_tRecord := { s := "abc" }
};
template templateHexstr_rec templateHexstr_tDecmatchSelfRef := { // decoded content match with self-reference
x1 := '01A'H,
x2 := decmatch templateHexstr_tDecmatchSelfRef.x1,
x3 := decmatch templateHexstr_rec: { x1 := templateHexstr_tDecmatchSelfRef.x1, x2 := ?, x3 := * }
};
testcase templateHexstrDecmatch() runs on templateHexstr_mycomp {
var decmatch_rec bad_rec, good_rec;
bad_rec := { i := 11, s := "xyz" };
good_rec := { i := 3, s := "abc" };
var decmatch_list bad_list, good_list;
bad_list := { 4, 7, 10 };
good_list := { 2, 15, 28 };
var decmatch_uni bad_uni, good_uni;
bad_uni := { s := "five" };
good_uni := { i := 5 };
var hexstring bad_rec_enc, good_rec_enc, bad_list_enc, good_list_enc, bad_uni_enc, good_uni_enc;
bad_rec_enc := bit2hex(encvalue(bad_rec));
good_rec_enc := bit2hex(encvalue(good_rec));
bad_list_enc := bit2hex(encvalue(bad_list));
good_list_enc := bit2hex(encvalue(good_list));
bad_uni_enc := bit2hex(encvalue(bad_uni));
good_uni_enc := bit2hex(encvalue(good_uni));
var templateHexstr_rec r1, r2, r3, r4, r5;
r1 := { x1 := good_list_enc, x2 := good_uni_enc, x3 := good_rec_enc };
r2 := { x1 := bad_list_enc, x2 := good_uni_enc, x3 := good_rec_enc };
r3 := { x1 := good_list_enc, x2 := bad_uni_enc, x3 := good_rec_enc };
r4 := { x1 := good_list_enc, x2 := good_uni_enc, x3 := bad_rec_enc };
r5 := { x1 := good_list_enc, x2 := good_uni_enc, x3 := '00FF'H };
// match: all 3 are good
if (match(r1, templateHexstr_tDecmatch)) { setverdict(pass); }
else { setverdict(fail, 1); }
// no match: decoded list does not match
if (not match(r2, templateHexstr_tDecmatch)) { setverdict(pass); }
else { setverdict(fail, 2); }
// no match: decoded union does not match
if (not match(r3, templateHexstr_tDecmatch)) { setverdict(pass); }
else { setverdict(fail, 3); }
// no match: decoded record does not match
if (not match(r4, templateHexstr_tDecmatch)) { setverdict(pass); }
else { setverdict(fail, 4); }
// no match: x3 is not a valid encoded record value
if (not match(r5, templateHexstr_tDecmatch)) { setverdict(pass); }
else { setverdict(fail, 5); }
// match r1 with the same template declared as an in-line template
if (match(r1, templateHexstr_rec: {
x1 := decmatch decmatch_list: { (1..10), (11..20), (21..30) },
x2 := decmatch decmatch_tUnion,
x3 := decmatch modifies decmatch_tRecord := { s := "abc" }
})) { setverdict(pass); }
else { setverdict(fail, 6); }
}
external function ef_enc_rec_x1(in templateHexstr_rec.x1 x) return octetstring
with { extension "prototype(convert) encode(JSON)" }
testcase templateHexstrDecmatchSelfRef() runs on templateHexstr_mycomp {
// global self-referencing template
var templateHexstr_rec.x1 bad_hs, good_hs;
bad_hs := 'FE98'H;
good_hs := '01A'H;
var templateHexstr_rec bad_rec, good_rec;
bad_rec := { x1 := 'D01'H, x2 := 'D02'H, x3 := 'D03'H };
good_rec := { x1 := '01A'H, x2 := 'D02'H, x3 := 'D03'H };
var hexstring bad_hs_enc, good_hs_enc, bad_rec_enc, good_rec_enc;
bad_hs_enc := oct2hex(ef_enc_rec_x1(bad_hs));
good_hs_enc := oct2hex(ef_enc_rec_x1(good_hs));
bad_rec_enc := bit2hex(encvalue(bad_rec));
good_rec_enc := bit2hex(encvalue(good_rec));
var templateHexstr_rec r1, r2, r3;
r1 := { x1 := '01A'H, x2 := good_hs_enc, x3 := good_rec_enc };
r2 := { x1 := '01A'H, x2 := bad_hs_enc, x3 := good_rec_enc };
r3 := { x1 := '01A'H, x2 := good_hs_enc, x3 := bad_rec_enc };
// match: all 2 are good
if (match(r1, templateHexstr_tDecmatchSelfRef)) { setverdict(pass); }
else { setverdict(fail, 1); }
// no match: decoded octetstring does not match
if (not match(r2, templateHexstr_tDecmatchSelfRef)) { setverdict(pass); }
else { setverdict(fail, 2); }
// no match: decoded record does not match
if (not match(r3, templateHexstr_tDecmatchSelfRef)) { setverdict(pass); }
else { setverdict(fail, 3); }
// local self-referencing template
var template templateHexstr_rec t := { x1 := '01A'H, x2 := ?, x3 := ? };
t.x1 := decmatch t;
var templateHexstr_rec r4, r5;
r4 := { x1 := good_rec_enc, x2 := 'A1'H, x3 := 'A2'H };
r5 := { x1 := bad_rec_enc, x2 := 'A1'H, x3 := 'A2'H };
if (match(r4, t)) { setverdict(pass); }
else { setverdict(fail, 4); }
if (not match(r5, t)) { setverdict(pass); }
else { setverdict(fail, 5); }
}
control {
execute(templateHexstrDecmatch());
execute(templateHexstrDecmatchSelfRef());
}
}
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