Skip to content
Snippets Groups Projects
Commit 61eb2822 authored by Botond Baranyi's avatar Botond Baranyi
Browse files

Added regression tests for parameter default values containing references to...

Added regression tests for parameter default values containing references to component variables (#587)

Signed-off-by: default avatarBotond Baranyi <botond.baranyi@ericsson.com>
parent 812e8418
No related branches found
No related tags found
1 merge request!478Added regression tests for parameter default values containing references to...
......@@ -51,7 +51,8 @@ selectUnion templateExclusiveRange any_from templatePatternRef indexWithRecofArr
connectMapOperTest fuzzy portTranslation ischosen functionSubref done \
nondeterministicDefaultParam predefFunction2 realtime portTranslationCentralStorage \
locale references unicharstrToCharstr map_param reverseOrderInit \
controlFunction lazyFuzzyVar any_type_param portReference timerReference
controlFunction lazyFuzzyVar any_type_param portReference timerReference \
paramDefval
ifdef DYN
DIRS += loggerplugin junitlogger
......
paramDefval
paramDefval.exe
paramDefval*.cc
paramDefval*.hh
paramDefval*.log
##############################################################################
# Copyright (c) 2000-2024 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
#
##############################################################################
TOPDIR := ..
include $(TOPDIR)/Makefile.regression
.SUFFIXES: .ttcn .hh
.PHONY: all clean dep run
TTCN3_LIB = ttcn3$(RT2_SUFFIX)-parallel$(DYNAMIC_SUFFIX)
TTCN3_MODULES = paramDefval.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
OBJECTS = $(GENERATED_SOURCES:.cc=.o)
TARGET = paramDefval$(EXESUFFIX)
all: $(TARGET)
$(TARGET): $(GENERATED_SOURCES) $(USER_SOURCES)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@ $^ -L$(TTCN3_DIR)/lib -l$(TTCN3_LIB) -L$(OPENSSL_DIR)/$(OPENSSL_LIB_DIR) -lcrypto $($(PLATFORM)_LIBS)
.ttcn.cc .ttcn.hh:
$(TTCN3_COMPILER) $<
clean distclean:
-rm -f $(TARGET) $(OBJECTS) $(GENERATED_HEADERS) \
$(GENERATED_SOURCES) *.log Makefile.bak
dep: $(GENERATED_SOURCES)
makedepend $(CPPFLAGS) $(GENERATED_SOURCES)
run: $(TARGET) config.cfg
$(TTCN3_DIR)/bin/ttcn3_start $^
.NOTPARALLEL:
###############################################################################
# Copyright (c) 2000-2024 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
#
###############################################################################
[LOGGING]
FileMask := TTCN_ERROR | TTCN_TESTCASE | TTCN_STATISTICS | TTCN_VERDICTOP | USER
ConsoleMask := TTCN_ERROR | TTCN_TESTCASE | TTCN_STATISTICS | TTCN_VERDICTOP | USER
SourceInfoFormat := Stack
LogEventTypes := Detailed
MatchingHints := Detailed
[EXECUTE]
paramDefval.control
/******************************************************************************
* Copyright (c) 2000-2024 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
*
******************************************************************************/
module paramDefval {
type record Rec {
integer num,
charstring str
}
type component CT {
var integer cv := 3;
var template charstring cvt := "xy";
timer ctmr := 0.5;
}
function f1(integer p := 2) {
if (p != 2) {
setverdict(fail, "f1: ", p);
}
}
function f2(integer p := cv) runs on CT return integer {
if (p != 3) {
setverdict(fail, "f2: ", p);
}
return p;
}
function f3(charstring p := "a" & valueof(cvt)) runs on CT {
if (p != "axy") {
setverdict(fail, "f3: ", p);
}
}
function f4(octetstring p := int2oct(f2(), 1)) runs on CT {
if (p != '03'O) {
setverdict(fail, "f4: ", p);
}
}
function f5(Rec p := { 1 - f2(), "ab" }) runs on CT {
if (p != { -2, "ab" }) {
setverdict(fail, "f5: ", p);
}
}
testcase tc_function_param_defval() runs on CT {
f1();
f2();
f3();
f4();
f5();
setverdict(pass);
}
testcase tc_function_ptc_param_defval() runs on CT {
var CT v_ct := CT.create;
v_ct.start(f4());
v_ct.done;
setverdict(pass);
}
altstep as1(integer p := -cv) runs on CT {
[] ctmr.timeout {
if (p != -3) {
setverdict(fail, "as1: ", p);
}
}
}
template charstring as2_p_new := ? length (1..2);
altstep as2(template charstring pt := cvt) runs on CT {
[] ctmr.timeout {
if (log2str(pt) != log2str(as2_p_new)) {
setverdict(fail, "as2: ", pt);
}
}
}
testcase tc_altstep_param_defval() runs on CT {
ctmr.start;
alt {
[] as1();
}
ctmr.stop;
cvt := as2_p_new;
ctmr.start;
as2();
ctmr.stop;
setverdict(pass);
}
template integer t1(integer p := 2) := p + 1;
template integer t2 := t1;
testcase tc_template_param_defval() runs on CT {
var template integer t1_exp := 3;
if (log2str(t1) != log2str(t1_exp)) {
setverdict(fail, "t1: ", t1);
}
var template integer t2_exp := 3;
if (log2str(t2) != log2str(t2_exp)) {
setverdict(fail, "t2: ", t2);
}
setverdict(pass);
}
control {
execute(tc_function_param_defval());
execute(tc_function_ptc_param_defval());
execute(tc_altstep_param_defval());
execute(tc_template_param_defval());
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment