diff --git a/regression_test/EncodeDecode/RAW/Makefile b/regression_test/EncodeDecode/RAW/Makefile index 0f8eac6c758b6b171ce50b75b8661555031ae9ea..d90270765372eccd875b492da430538b600dc7c4 100644 --- a/regression_test/EncodeDecode/RAW/Makefile +++ b/regression_test/EncodeDecode/RAW/Makefile @@ -19,7 +19,7 @@ TOPDIR := ../../ include $(TOPDIR)/Makefile.regression RDIRS = Examples HN25015 HQ26535 HQ49956 HS16977 ustr Annex_E_variants Bug521125 \ - Lengthto_Offset Bug522656 RAW_integer RAW_bitstring RAW_EncDec ForceOmit Bug546231 \ + Lengthto_Offset Bug522656 RAW_bitstring RAW_EncDec RAW_integer RAW_repeat ForceOmit Bug546231 \ Bug547385 IntX CSN1_LH all dep clean run distclean: diff --git a/regression_test/EncodeDecode/RAW/RAW_repeat/.gitignore b/regression_test/EncodeDecode/RAW/RAW_repeat/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..2ab3212c9e90b71f3ea87a25e94e6f75489227c8 --- /dev/null +++ b/regression_test/EncodeDecode/RAW/RAW_repeat/.gitignore @@ -0,0 +1,7 @@ +RAW_repeat_test +RAW_repeat_test.exe +RAW_repeat_test*.cc +RAW_repeat_test*.hh +RAW_repeat_test*.log +compile +result.txt diff --git a/regression_test/EncodeDecode/RAW/RAW_repeat/Makefile b/regression_test/EncodeDecode/RAW/RAW_repeat/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..00bd1971d5a61994ecf99c559696f3f2462c17a6 --- /dev/null +++ b/regression_test/EncodeDecode/RAW/RAW_repeat/Makefile @@ -0,0 +1,65 @@ +############################################################################## +# Copyright (c) 2000-2020 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 +# +############################################################################## +TOPDIR := ../../.. +include $(TOPDIR)/Makefile.regression + +.PHONY: all clean dep run + +TTCN3_LIB = ttcn3$(RT2_SUFFIX)$(DYNAMIC_SUFFIX) + +TTCN3_MODULES = RAW_repeat_test.ttcn + +GENERATED_SOURCES = $(TTCN3_MODULES:.ttcn=.cc) +GENERATED_HEADERS = $(GENERATED_SOURCES:.cc=.hh) +ifdef CODE_SPLIT +GENERATED_SOURCES := $(foreach file, $(GENERATED_SOURCES:.cc=), $(addprefix $(file), .cc _seq.cc _set.cc _seqof.cc _setof.cc _union.cc)) +else ifdef SPLIT_TO_SLICES +POSTFIXES := $(foreach file, $(SPLIT_TO_SLICES), $(addsuffix $(file), _part_)) +POSTFIXES := $(foreach file, $(POSTFIXES), $(addprefix $(file), .cc)) +GENERATED_SOURCES2 := $(foreach file, $(GENERATED_SOURCES:.cc=), $(addprefix $(file), $(POSTFIXES))) +GENERATED_SOURCES += $(GENERATED_SOURCES2) +endif + +USER_SOURCES = + +# All object files needed for the executable test suite: +OBJECTS = $(GENERATED_SOURCES:.cc=.o) $(USER_SOURCES:.cc=.o) + +# The name of the executable test suite: +TARGET = RAW_repeat_test$(EXESUFFIX) + +all: $(TARGET) + +$(TARGET): $(OBJECTS) + $(CXX) $(LDFLAGS) -o $@ $(OBJECTS) -L$(TTCN3_DIR)/lib -l$(TTCN3_LIB) \ + -L$(OPENSSL_DIR)/lib -lcrypto $($(PLATFORM)_LIBS) + +$(GENERATED_SOURCES) $(GENERATED_HEADERS): compile + @if [ ! -f $@ ]; then $(RM) compile; $(MAKE) compile; fi + +compile: $(TTCN3_MODULES) $(ASN1_MODULES) + $(TTCN3_COMPILER) $(COMPILER_FLAGS) $^ + touch $@ + +clean distclean: + $(RM) $(TARGET) $(OBJECTS) $(GENERATED_HEADERS) \ + $(GENERATED_SOURCES) compile *.log + +dep: $(GENERATED_SOURCES) + makedepend $(CPPFLAGS) $(USER_SOURCES) $(GENERATED_SOURCES) + +run: $(TARGET) RAW_repeat_test.cfg + ./$^ 2> result.txt + cat result.txt + grep "Overall verdict: pass" result.txt + +# DO NOT DELETE diff --git a/regression_test/EncodeDecode/RAW/RAW_repeat/RAW_repeat_test.cfg b/regression_test/EncodeDecode/RAW/RAW_repeat/RAW_repeat_test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..d9bb1cbc66dfb3c26b5f1fd89a8528de31e94f4f --- /dev/null +++ b/regression_test/EncodeDecode/RAW/RAW_repeat/RAW_repeat_test.cfg @@ -0,0 +1,20 @@ +[LOGGING] + +LogFile := "%e.%h-%r.%s" +FileMask := LOG_ALL | DEBUG | MATCHING +ConsoleMask := ERROR | WARNING | TESTCASE | STATISTICS | PORTEVENT +LogSourceInfo := Yes +AppendFile := No +TimeStampFormat := DateTime +LogEventTypes := Yes +SourceInfoFormat := Single +LogEntityName := Yes + +[EXECUTE] +RAW_repeat_test.control + +[MAIN_CONTROLLER] +TCPPort := 0 +KillTimer := 10.0 +# NumHCs := 0 +# LocalAddress := diff --git a/regression_test/EncodeDecode/RAW/RAW_repeat/RAW_repeat_test.ttcn b/regression_test/EncodeDecode/RAW/RAW_repeat/RAW_repeat_test.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..52dd853ccef8bb5537c6644b59e1ba2e40f79c4e --- /dev/null +++ b/regression_test/EncodeDecode/RAW/RAW_repeat/RAW_repeat_test.ttcn @@ -0,0 +1,159 @@ +/****************************************************************************** +* Copyright (c) 2000-2020 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: +* Szalai, Gabor -first draft +* Balasko, Jeno -second version +******************************************************************************/ +// This test is based on Bug 568518, reported in Bugzilla at 2020.11.04 +// See https://bugs.eclipse.org/bugs/show_bug.cgi?id=568518 + +module RAW_repeat_test { + +type component CT {} + +type octetstring OCT1 length(1) + +type record IE1{ + OCT1 ie_type, + integer len, + octetstring data +} with { + variant "PRESENCE(ie_type = '01'O)" + variant (len) "LENGTHTO(data)" +} + +type record IE2{ + OCT1 ie_type, + integer len, + octetstring data +} with { + variant "PRESENCE(ie_type = '02'O)" + variant (len) "LENGTHTO(data)" +} + +type record unknown_IE{ + OCT1 ie_type, + integer len, + octetstring data +} with { + variant (len) "LENGTHTO(data)" +} + +type record of unknown_IE unknown_IE_list + +type set PDU{ + IE1 ie1_field, + IE2 ie2_field optional, + unknown_IE_list unknown_ies optional +} with { + variant (unknown_ies) "REPEATABLE(yes)" +} + +external function dec_PDU_backtrack(in octetstring stream, out PDU pdu) return integer +with { extension "prototype(backtrack) decode(RAW)" } + +// no spread record of +testcase tc_1() runs on CT { + var octetstring stream; + var PDU pdu_decoded; + var PDU pdu_expected := { + ie1_field := { ie_type := '01'O, len:=1, data := '00'O }, + ie2_field := { ie_type := '02'O, len:=1, data := '00'O }, + unknown_ies := { + { ie_type := '03'O, len:=1, data := '00'O}, + { ie_type := '04'O, len:=1, data := '00'O} + } + } + var integer result; + + stream := '010100020100030100040100'O // IE1, IE2, unknown IE + result:=dec_PDU_backtrack(stream,pdu_decoded); + log(stream); + log(result) // { ie1_field := { ie_type := '01'O, len := 1, data := '00'O }, ie2_field := { ie_type := '02'O, len := 1, data := '00'O }, unknown_ies := { { ie_type := '03'O, len := 1, data := '00'O }, { ie_type := '04'O, len := 1, data := '00'O } } } + log(pdu_decoded); + + if (result != 0) { + setverdict(fail, "decoding failed"); + } else if ( pdu_decoded != pdu_expected) { + setverdict(fail,"Unexpected decoding result:"); + log("Expected:", pdu_expected); + log("Got :", pdu_decoded); + } else { + setverdict(pass) + } +} + +// spread record of +testcase tc_2() runs on CT { + var octetstring stream := '010100030100020100040100'O // IE1, unknown IE, IE2 -> IE2 added to the unknown_ies + var PDU pdu_decoded; + var PDU pdu_expected := { + ie1_field := { ie_type := '01'O, len:=1, data := '00'O }, + ie2_field := { ie_type := '02'O, len:=1, data := '00'O }, + unknown_ies := { + { ie_type := '03'O, len:=1, data := '00'O}, + { ie_type := '04'O, len:=1, data := '00'O} + } + } + var integer result; + // stream := '010100030100020100040100'O // IE1, unknown IE, IE2 -> IE2 added to the unknown_ies + result:=dec_PDU_backtrack(stream,pdu_decoded); + log(stream) + log(result) // { ie1_field := { ie_type := '01'O, len := 1, data := '00'O }, ie2_field := omit, unknown_ies := { { ie_type := '03'O, len := 1, data := '00'O }, { ie_type := '02'O, len := 1, data := '00'O }, { ie_type := '04'O, len := 1, data := '00'O } } } + log(pdu_decoded) + if (result != 0) { + setverdict(fail, "decoding failed"); + } else if ( pdu_decoded != pdu_expected) { + setverdict(fail,"Unexpected decoding result:"); + log("Expected:", pdu_expected); + log("Got :", pdu_decoded); + } else { + setverdict(pass) + } +} + +// spread record of +testcase tc_3() runs on CT { + var octetstring stream := '010100030100020100020100040100020100'O; // IE1, unknown IE, IE2 , IE2, unknown IE, IE2 which should be at the unknown_ies list. The ie2_field is not repeatable + var PDU pdu_decoded; + var PDU pdu_expected := { + ie1_field := { ie_type := '01'O, len:=1, data := '00'O }, + ie2_field := { ie_type := '02'O, len:=1, data := '00'O }, + unknown_ies := { + { ie_type := '03'O, len:=1, data := '00'O}, + { ie_type := '02'O, len:=1, data := '00'O}, + { ie_type := '04'O, len:=1, data := '00'O}, + { ie_type := '02'O, len:=1, data := '00'O} + } + } + var integer result; + + result:=dec_PDU_backtrack(stream,pdu_decoded); + log(stream) + log(result) // { ie1_field := { ie_type := '01'O, len := 1, data := '00'O }, ie2_field := omit, unknown_ies := { { ie_type := '03'O, len := 1, data := '00'O }, { ie_type := '02'O, len := 1, data := '00'O }, { ie_type := '04'O, len := 1, data := '00'O } } } + log(pdu_decoded) + if (result != 0) { + setverdict(fail, "decoding failed"); + } else if ( pdu_decoded != pdu_expected) { + setverdict(fail,"Unexpected decoding result:"); + log("Expected:", pdu_expected); + log("Got :", pdu_decoded); + } else { + setverdict(pass) + } +} + +control{ + execute(tc_1()); + execute(tc_2()); + execute(tc_3()); +} + +} with { +encode "RAW" +}