Commit 30e53cc7 authored by Botond Baranyi's avatar Botond Baranyi
Browse files

Moved multiple value redirects and redirects of partial values to RT2 (artf789088)



Change-Id: I720bba46aa71e2a41342d20613faff691d11efb5
Signed-off-by: Botond Baranyi's avatarBotond Baranyi <botond.baranyi@ericsson.com>
parent e4305e8e
......@@ -2232,24 +2232,26 @@ void Type::generate_code_done(output_struct *target)
const string& dispname = get_typename();
const char *dispname_str = dispname.c_str();
// value redirect base class (interface)
target->header.class_decls = mputprintf(target->header.class_decls,
"class %s_Redirect_Interface;\n", genname_str);
target->header.class_defs = mputprintf(target->header.class_defs,
"class %s_Redirect_Interface {\n"
"public:\n"
"virtual void set_values(const %s&) = 0;\n"
"virtual ~%s_Redirect_Interface() { }\n"
"};\n\n", genname_str, genname_str, genname_str);
if (use_runtime_2) {
target->header.class_decls = mputprintf(target->header.class_decls,
"class %s_Redirect_Interface;\n", genname_str);
target->header.class_defs = mputprintf(target->header.class_defs,
"class %s_Redirect_Interface {\n"
"public:\n"
"virtual void set_values(const %s&) = 0;\n"
"virtual ~%s_Redirect_Interface() { }\n"
"};\n\n", genname_str, genname_str, genname_str);
}
// the done function
target->header.function_prototypes = mputprintf
(target->header.function_prototypes,
"extern alt_status done(const COMPONENT& component_reference, "
"const %s_template& value_template, %s_Redirect_Interface *value_redirect);\n",
genname_str, genname_str);
"const %s_template& value_template, %s%s *value_redirect);\n",
genname_str, genname_str, use_runtime_2 ? "_Redirect_Interface" : "");
target->source.function_bodies = mputprintf
(target->source.function_bodies,
"alt_status done(const COMPONENT& component_reference, "
"const %s_template& value_template, %s_Redirect_Interface *value_redirect)\n"
"const %s_template& value_template, %s%s *value_redirect)\n"
"{\n"
"if (!component_reference.is_bound()) "
"TTCN_error(\"Performing a done operation on an unbound component "
......@@ -2263,9 +2265,18 @@ void Type::generate_code_done(output_struct *target)
"%s return_value;\n"
"return_value.decode_text(*text_buf);\n"
"if (value_template.match(return_value)) {\n"
"if (value_redirect != NULL) {\n"
"value_redirect->set_values(return_value);\n"
"delete value_redirect;\n"
"if (value_redirect != NULL) {\n", genname_str, genname_str,
use_runtime_2 ? "_Redirect_Interface" : "", dispname_str, genname_str);
if (use_runtime_2) {
target->source.function_bodies = mputstr(target->source.function_bodies,
"value_redirect->set_values(return_value);\n"
"delete value_redirect;\n");
}
else {
target->source.function_bodies = mputstr(target->source.function_bodies,
"*value_redirect = return_value;\n");
}
target->source.function_bodies = mputprintf(target->source.function_bodies,
"}\n"
"TTCN_Logger::begin_event(TTCN_Logger::PARALLEL_PTC);\n"
"TTCN_Logger::log_event_str(\"PTC with component reference \");\n"
......@@ -2289,8 +2300,7 @@ void Type::generate_code_done(output_struct *target)
"}\n"
"} else return ret_val;\n"
"}\n\n",
genname_str, genname_str, dispname_str, genname_str, dispname_str,
dispname_str, omit_in_value_list ? ", TRUE" : "");
dispname_str, dispname_str, omit_in_value_list ? ", TRUE" : "");
}
bool Type::ispresent_anyvalue_embedded_field(Type* t,
......
This diff is collapsed.
......@@ -1116,6 +1116,8 @@ namespace Ttcn {
* If multiple whole-value-redirects of separate types are found, then an
* error is displayed. */
Type* get_type() const;
/** Checks Runtime1 restrictions and returns false if they are not met. */
bool chk_RT1_restrictions() const;
/** Performs semantic analysis on the value redirect without knowing the
* type of the redirected value. Called when the value's type cannot be
* determined or is erroneous. */
......
......@@ -565,12 +565,13 @@ static void generate_receive(char **def_ptr, char **src_ptr,
}
def = mputprintf(def, "alt_status %s(const %s_template& value_template, "
"%s_Redirect_Interface *value_redirect, const %s_template& sender_template, %s "
"%s%s *value_redirect, const %s_template& sender_template, %s "
"*sender_ptr);\n", function_name, message_type->name,
message_type->name_w_no_prefix, sender_type, sender_type);
use_runtime_2 ? message_type->name_w_no_prefix : message_type->name,
use_runtime_2 ? "_Redirect_Interface" : "", sender_type, sender_type);
src = mputprintf(src, "alt_status %s::%s(const %s_template& "
"value_template, %s_Redirect_Interface *value_redirect, const %s_template& "
"value_template, %s%s *value_redirect, const %s_template& "
"sender_template, %s *sender_ptr)\n"
"{\n"
"if (value_template.get_selection() == ANY_OR_OMIT) "
......@@ -585,7 +586,9 @@ static void generate_receive(char **def_ptr, char **src_ptr,
"return ALT_NO;\n"
"}\n"
"} else ", class_name, function_name, message_type->name,
message_type->name_w_no_prefix, sender_type, sender_type, operation_name);
use_runtime_2 ? message_type->name_w_no_prefix : message_type->name,
use_runtime_2 ? "_Redirect_Interface" : "", sender_type, sender_type,
operation_name);
if (is_address) {
src = mputprintf(src, "if (my_head->sender_component != "
"SYSTEM_COMPREF) {\n"
......@@ -660,13 +663,20 @@ static void generate_receive(char **def_ptr, char **src_ptr,
if (is_trigger) src = mputstr(src, "remove_msg_queue_head();\n");
src = mputprintf(src, "return %s;\n"
"} else {\n"
"if (value_redirect != NULL) {\n"
"value_redirect->set_values(*my_head->message_%lu);\n"
"delete value_redirect;\n"
"if (value_redirect != NULL) {\n", failed_status);
if (use_runtime_2) {
src = mputprintf(src,
"value_redirect->set_values(*my_head->message_%lu);\n"
"delete value_redirect;\n", (unsigned long) message_index);
}
else {
src = mputprintf(src,
"*value_redirect = *my_head->message_%lu;\n", (unsigned long) message_index);
}
src = mputprintf(src,
"}\n"
"if (sender_ptr != NULL) *sender_ptr = %smy_head->%s;\n",
failed_status, (unsigned long) message_index, is_address ? "*" : "",
is_address ? "sender_address" : "sender_component");
is_address ? "*" : "", is_address ? "sender_address" : "sender_component");
if (is_address) {
src = mputprintf(src,
......@@ -1577,7 +1587,7 @@ void defPortClass(const port_def* pdef, output_struct* output)
def = mputstr(def, "public:\n");
/* value redirect base classes (interfaces) */
if (has_msg_queue) {
if (use_runtime_2 && has_msg_queue) {
for (i = 0; i < pdef->msg_in.nElements; ++i) {
def = mputprintf(def,
"class %s_Redirect_Interface {\n"
......
......@@ -330,7 +330,7 @@ void defSignatureClasses(const signature_def *sdef, output_struct *output)
/* class definition */
def = mputprintf(def, "class %s_reply_redirect {\n", name);
if (sdef->return_type != NULL) {
if (use_runtime_2 && sdef->return_type != NULL) {
/* value redirect base class (interface) for the return value */
def = mputprintf(def,
"public:\n"
......@@ -345,8 +345,9 @@ void defSignatureClasses(const signature_def *sdef, output_struct *output)
/* parameter pointers */
if (sdef->return_type != NULL) {
def = mputprintf(def, "%s_Redirect_Interface *ret_val_redir;\n",
sdef->return_type_w_no_prefix);
def = mputprintf(def, "%s%s *ret_val_redir;\n",
use_runtime_2 ? sdef->return_type_w_no_prefix : sdef->return_type,
use_runtime_2 ? "_Redirect_Interface" : "");
}
for (i = 0; i < sdef->parameters.nElements; i++) {
if (sdef->parameters.elements[i].direction != PAR_IN) {
......@@ -363,8 +364,9 @@ void defSignatureClasses(const signature_def *sdef, output_struct *output)
/* constructor */
def = mputprintf(def, "%s_reply_redirect(", name);
if (sdef->return_type != NULL) {
def = mputprintf(def, "%s_Redirect_Interface *return_redirect",
sdef->return_type_w_no_prefix);
def = mputprintf(def, "%s%s *return_redirect",
use_runtime_2 ? sdef->return_type_w_no_prefix : sdef->return_type,
use_runtime_2 ? "_Redirect_Interface" : "");
first_param = FALSE;
}
for (i = 0; i < sdef->parameters.nElements; i++) {
......@@ -396,7 +398,7 @@ void defSignatureClasses(const signature_def *sdef, output_struct *output)
}
/* otherwise constructor is not needed */
if (sdef->return_type != NULL) {
if (use_runtime_2 && sdef->return_type != NULL) {
/* destructor (only the return redirect object needs to be deleted) */
def = mputprintf(def, "~%s_reply_redirect() { "
"if (ret_val_redir != NULL) delete ret_val_redir; }\n", name);
......@@ -420,8 +422,13 @@ void defSignatureClasses(const signature_def *sdef, output_struct *output)
}
}
if (sdef->return_type!=NULL) {
src = mputstr(src, "if (ret_val_redir != NULL) "
"ret_val_redir->set_values(reply_par.return_value());\n");
src = mputstr(src, "if (ret_val_redir != NULL) ");
if (use_runtime_2) {
src = mputstr(src, "ret_val_redir->set_values(reply_par.return_value());\n");
}
else {
src = mputstr(src, "*ret_val_redir = reply_par.return_value();\n");
}
}
src = mputstr(src, "}\n\n");
}
......@@ -686,16 +693,18 @@ void defSignatureClasses(const signature_def *sdef, output_struct *output)
"class %s_exception_template {\n"
"public:\n", name);
/* value redirect base classes (interfaces) */
for (i = 0; i < sdef->exceptions.nElements; i++) {
def = mputprintf(def,
"class %s_Redirect_Interface {\n"
"public:\n"
"virtual void set_values(const %s&) = 0;\n"
"virtual ~%s_Redirect_Interface() { }\n"
"};\n", sdef->exceptions.elements[i].name_w_no_prefix,
sdef->exceptions.elements[i].name,
sdef->exceptions.elements[i].name_w_no_prefix);
if (use_runtime_2) {
/* value redirect base classes (interfaces) */
for (i = 0; i < sdef->exceptions.nElements; i++) {
def = mputprintf(def,
"class %s_Redirect_Interface {\n"
"public:\n"
"virtual void set_values(const %s&) = 0;\n"
"virtual ~%s_Redirect_Interface() { }\n"
"};\n", sdef->exceptions.elements[i].name_w_no_prefix,
sdef->exceptions.elements[i].name,
sdef->exceptions.elements[i].name_w_no_prefix);
}
}
/* data members */
......@@ -714,8 +723,10 @@ void defSignatureClasses(const signature_def *sdef, output_struct *output)
/* union of all possible value redirect objects */
def = mputstr(def, "union {\n");
for (i = 0; i < sdef->exceptions.nElements; i++) {
def = mputprintf(def, "%s_Redirect_Interface *%s_redir;\n",
sdef->exceptions.elements[i].name_w_no_prefix,
def = mputprintf(def, "%s%s *%s_redir;\n",
use_runtime_2 ? sdef->exceptions.elements[i].name_w_no_prefix :
sdef->exceptions.elements[i].name,
use_runtime_2 ? "_Redirect_Interface" : "",
sdef->exceptions.elements[i].altname);
}
def = mputstr(def, "};\n"
......@@ -723,42 +734,48 @@ void defSignatureClasses(const signature_def *sdef, output_struct *output)
/* constructors (for all possible template + redirect object pairs) */
for (i = 0; i < sdef->exceptions.nElements; i++) {
def = mputprintf(def, "%s_exception_template(const %s_template& "
"init_template, %s_Redirect_Interface *value_redirect = NULL);\n", name,
"init_template, %s%s *value_redirect = NULL);\n", name,
sdef->exceptions.elements[i].name,
sdef->exceptions.elements[i].name_w_no_prefix);
use_runtime_2 ? sdef->exceptions.elements[i].name_w_no_prefix :
sdef->exceptions.elements[i].name,
use_runtime_2 ? "_Redirect_Interface" : "");
src = mputprintf(src, "%s_exception_template::%s_exception_template"
"(const %s_template& init_template, %s_Redirect_Interface *value_redirect)\n"
"(const %s_template& init_template, %s%s *value_redirect)\n"
"{\n"
"exception_selection = %s_%s;\n"
"field_%s = &init_template;\n"
"%s_redir = value_redirect;\n"
"}\n\n", name, name, sdef->exceptions.elements[i].name,
sdef->exceptions.elements[i].name_w_no_prefix, selection_prefix,
use_runtime_2 ? sdef->exceptions.elements[i].name_w_no_prefix :
sdef->exceptions.elements[i].name,
use_runtime_2 ? "_Redirect_Interface" : "", selection_prefix,
sdef->exceptions.elements[i].altname,
sdef->exceptions.elements[i].altname,
sdef->exceptions.elements[i].altname);
}
/* destructor */
def = mputprintf(def, "~%s_exception_template();\n", name);
src = mputprintf(src,
"%s_exception_template::~%s_exception_template()\n"
"{\n"
"switch (exception_selection) {\n", name, name);
for (i = 0; i < sdef->exceptions.nElements; i++) {
if (use_runtime_2) {
/* destructor, RT2 only */
def = mputprintf(def, "~%s_exception_template();\n", name);
src = mputprintf(src,
"%s_exception_template::~%s_exception_template()\n"
"{\n"
"switch (exception_selection) {\n", name, name);
for (i = 0; i < sdef->exceptions.nElements; i++) {
src = mputprintf(src,
"case %s_%s:\n"
"if (%s_redir != NULL) delete %s_redir;\n"
"break;", selection_prefix, sdef->exceptions.elements[i].altname,
sdef->exceptions.elements[i].altname,
sdef->exceptions.elements[i].altname);
}
src = mputprintf(src,
"case %s_%s:\n"
"if (%s_redir != NULL) delete %s_redir;\n"
"break;", selection_prefix, sdef->exceptions.elements[i].altname,
sdef->exceptions.elements[i].altname,
sdef->exceptions.elements[i].altname);
"default:\n"
"TTCN_error(\"Internal error: Invalid selector when deleting exception "
"object for signature %s.\");\n"
"}\n"
"}\n\n", dispname);
}
src = mputprintf(src,
"default:\n"
"TTCN_error(\"Internal error: Invalid selector when deleting exception "
"object for signature %s.\");\n"
"}\n"
"}\n\n", dispname);
/* match function */
def = mputprintf(def, "boolean match(const %s_exception& other_value,"
......@@ -837,12 +854,20 @@ void defSignatureClasses(const signature_def *sdef, output_struct *output)
"switch (exception_selection) {\n", name, name);
for (i = 0; i < sdef->exceptions.nElements; i++) {
src = mputprintf(src, "case %s_%s:\n"
"if (%s_redir != NULL) %s_redir->set_values(source_value.%s_field());\n"
"return;\n", selection_prefix,
sdef->exceptions.elements[i].altname,
sdef->exceptions.elements[i].altname,
"if (%s_redir != NULL) ", selection_prefix,
sdef->exceptions.elements[i].altname,
sdef->exceptions.elements[i].altname);
if (use_runtime_2) {
src = mputprintf(src, "%s_redir->set_values(source_value.%s_field());\n",
sdef->exceptions.elements[i].altname,
sdef->exceptions.elements[i].altname);
}
else {
src = mputprintf(src, "*%s_redir = source_value.%s_field();\n",
sdef->exceptions.elements[i].altname,
sdef->exceptions.elements[i].altname);
}
src = mputstr(src, "return;\n");
}
src = mputprintf(src, "default:\n"
"break;\n"
......
......@@ -29,6 +29,10 @@ TTCN3_LIB_SINGLE = ttcn3$(RT2_SUFFIX)$(DYNAMIC_SUFFIX)
TTCN3_MODULES = TcommMessage.ttcn HS41022.ttcn
ifdef RT2
TTCN3_MODULES += TmultipleRedirects.ttcn
endif
ASN1_MODULES = ImplMsgEncData.asn
GENERATED_SOURCES = $(TTCN3_MODULES:.ttcn=.cc) $(ASN1_MODULES:.asn=.cc)
......@@ -70,9 +74,9 @@ dep: $(GENERATED_SOURCES)
run: run-single run-parallel
run-single: $(TARGET_SINGLE) config.cfg
run-single: $(TARGET_SINGLE) config$(RT2_SUFFIX).cfg
./$^
run-parallel: $(TARGET)
$(TTCN3_DIR)/bin/ttcn3_start $(TARGET) config_parallel.cfg
$(TTCN3_DIR)/bin/ttcn3_start $(TARGET) config_parallel$(RT2_SUFFIX).cfg
......@@ -1474,141 +1474,6 @@ testcase commMessageDualFacedPorts2() runs on ImplicitMessageEncodingComponent {
rc.stop;
}
// test for value redirect with multiple variable references and field assignments
testcase commMessageMultiValueRedirect() runs on commMessage_comp3 {
connect(mtc:Port3, mtc:Port3);
var commMessage_trecord rec_val := { x1 := 3, x2 := -1.0 };
Port3.send(rec_val);
var commMessage_trecord redir_rec;
var integer redir_int;
var float redir_float;
timer tmr := 1.0;
tmr.start;
alt {
[] Port3.receive(rec_val) -> value (redir_rec, redir_int := x1, redir_float := x2) {
if (redir_rec != rec_val) { setverdict(fail, "Invalid record value: ", redir_rec); }
if (redir_int != rec_val.x1) { setverdict(fail, "Invalid integer value: ", redir_int); }
if (redir_float != rec_val.x2) { setverdict(fail, "Invalid float value: ", redir_float); }
}
[] Port3.receive(commMessage_trecord:?) { setverdict(fail, "Incorrect value received."); }
[] tmr.timeout { setverdict(fail, "Timeout."); }
}
setverdict(pass);
}
type record commMessage_tPayloadRecord {
bitstring bs optional,
hexstring hs optional,
octetstring os optional,
charstring cs optional,
universal charstring ucs optional
}
type record commMessage_tDecoded {
integer num,
charstring str
}
with {
encode "JSON";
}
type port commMessage_port_dec message {
inout commMessage_tPayloadRecord
}
with { extension "internal" };
type component commMessage_comp_dec {
port commMessage_port_dec pt
}
// test for decoded value redirect
testcase commMessageDecodedValueRedirect() runs on commMessage_comp_dec {
connect(mtc:pt, mtc:pt);
var commMessage_tDecoded val := { num := 10, str := "abc" };
var bitstring bs_val := encvalue(val);
var hexstring hs_val := bit2hex(encvalue(val));
var octetstring os_val := bit2oct(encvalue(val));
var charstring cs_val := oct2char(bit2oct(encvalue(val)));
var universal charstring ucs_val := encvalue_unichar(val, "UTF-8");
pt.send(commMessage_tPayloadRecord: { bs_val, omit, omit, omit, omit });
pt.send(commMessage_tPayloadRecord: { omit, hs_val, omit, omit, omit });
pt.send(commMessage_tPayloadRecord: { omit, omit, os_val, omit, omit });
pt.send(commMessage_tPayloadRecord: { omit, omit, omit, cs_val, omit });
pt.send(commMessage_tPayloadRecord: { omit, omit, omit, omit, ucs_val });
timer tmr;
var commMessage_tDecoded redir[5];
tmr.start(1.0);
alt {
[] pt.receive(commMessage_tPayloadRecord: { decmatch val, *, *, *, * }) -> value (redir[0] := @decoded bs) {
if (redir[0] != val) { setverdict(fail, "Bitstring test - redirect failed: ", redir[0]); }
}
[] pt.receive(commMessage_tPayloadRecord: { bs_val, *, *, *, * }) {
setverdict(fail, "Bitstring test - decmatch failed.");
}
[] pt.receive(commMessage_tPayloadRecord:?) {
setverdict(fail, "Bitstring test - incorrect record received.");
}
[] tmr.timeout { setverdict(fail, "Bitstring test - timeout."); }
}
tmr.stop;
tmr.start(1.0);
alt {
[] pt.receive(commMessage_tPayloadRecord: { *, decmatch val, *, *, * }) -> value (redir[1] := @decoded hs) {
if (redir[1] != val) { setverdict(fail, "Hexstring test - redirect failed: ", redir[1]); }
}
[] pt.receive(commMessage_tPayloadRecord: { *, hs_val, *, *, * }) {
setverdict(fail, "Hexstring test - decmatch failed.");
}
[] pt.receive(commMessage_tPayloadRecord:?) {
setverdict(fail, "Hexstring test - incorrect record received.");
}
[] tmr.timeout { setverdict(fail, "Hexstring test - timeout."); }
}
tmr.stop;
tmr.start(1.0);
alt {
[] pt.receive(commMessage_tPayloadRecord: { *, *, decmatch val, *, * }) -> value (redir[2] := @decoded os) {
if (redir[2] != val) { setverdict(fail, "Octetstring test - redirect failed: ", redir[2]); }
}
[] pt.receive(commMessage_tPayloadRecord: { *, *, os_val, *, * }) {
setverdict(fail, "Octetstring test - decmatch failed.");
}
[] pt.receive(commMessage_tPayloadRecord:?) {
setverdict(fail, "Octetstring test - incorrect record received.");
}
[] tmr.timeout { setverdict(fail, "Octetstring test - timeout."); }
}
tmr.stop;
tmr.start(1.0);
alt {
[] pt.receive(commMessage_tPayloadRecord: { *, *, *, decmatch val, * }) -> value (redir[3] := @decoded cs) {
if (redir[3] != val) { setverdict(fail, "Charstring test - redirect failed: ", redir[3]); }
}
[] pt.receive(commMessage_tPayloadRecord: { *, *, *, cs_val, * }) {
setverdict(fail, "Charstring test - decmatch failed.");
}
[] pt.receive(commMessage_tPayloadRecord:?) {
setverdict(fail, "Charstring test - incorrect record received.");
}
[] tmr.timeout { setverdict(fail, "Charstring test - timeout."); }
}
tmr.stop;
tmr.start(1.0);
alt {
[] pt.receive(commMessage_tPayloadRecord: { *, *, *, *, decmatch("UTF-8") val }) -> value (redir[4] := @decoded("UTF-8") ucs) {
if (redir[4] != val) { setverdict(fail, "Universal charstring test - redirect failed: ", redir[4]); }
}
[] pt.receive(commMessage_tPayloadRecord: { *, *, *, *, ucs_val }) {
setverdict(fail, "Universal charstring test - decmatch failed.");
}
[] pt.receive(commMessage_tPayloadRecord:?) {
setverdict(fail, "Universal charstring test - incorrect record received.");
}
[] tmr.timeout { setverdict(fail, "Universal charstring test - timeout."); }
}
setverdict(pass);
}
// '*' is not allowed as a matching template in receive operations
testcase commMessageReceiveAnyOrOmit() runs on commMessage_comp1 {
connect(self:Port1, self:Port1);
......@@ -1688,8 +1553,6 @@ control {
execute(commMessageInterPTCLocalConnection2());
execute(commMessageDualFacedPorts1());
execute(commMessageDualFacedPorts2());
execute(commMessageMultiValueRedirect());
execute(commMessageDecodedValueRedirect());
execute(commMessageReceiveAnyOrOmit());
}
}
/******************************************************************************
* Copyright (c) 2000-2016 Ericsson Telecom AB
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Baranyi, Botond – initial implementation
*
******************************************************************************/
module TmultipleRedirects {
import from TcommMessage all;
// test for value redirect with multiple variable references and field assignments
testcase commMessageMultiValueRedirect() runs on commMessage_comp3 {
connect(mtc:Port3, mtc:Port3);
var commMessage_trecord rec_val := { x1 := 3, x2 := -1.0 };
Port3.send(rec_val);
var commMessage_trecord redir_rec;
var integer redir_int;
var float redir_float;
timer tmr := 1.0;
tmr.start;
alt {
[] Port3.receive(rec_val) -> value (redir_rec, redir_int := x1, redir_float := x2) {
if (redir_rec != rec_val) { setverdict(fail, "Invalid record value: ", redir_rec); }
if (redir_int != rec_val.x1) { setverdict(fail, "Invalid integer value: ", redir_int); }
if (redir_float != rec_val.x2) { setverdict(fail, "Invalid float value: ", redir_float); }
}
[] Port3.receive(commMessage_trecord:?) { setverdict(fail, "Incorrect value received."); }
[] tmr.timeout { setverdict(fail, "Timeout."); }
}
setverdict(pass);
}
type record commMessage_tPayloadRecord {
bitstring bs optional,
hexstring hs optional,
octetstring os optional,
charstring cs optional,
universal charstring ucs optional
}
type record commMessage_tDecoded {
integer num,
charstring str
}
with {
encode "JSON";
}
type port commMessage_port_dec message {
inout commMessage_tPayloadRecord
}
with { extension "internal" };
type component commMessage_comp_dec {
port commMessage_port_dec pt
}
// test for decoded value redirect
testcase commMessageDecodedValueRedirect() runs on commMessage_comp_dec {
connect(mtc:pt, mtc:pt);
var commMessage_tDecoded val := { num := 10, str := "abc" };
var bitstring bs_val := encvalue(val);
var hexstring hs_val := bit2hex(encvalue(val));
var octetstring os_val := bit2oct(encvalue(val));
var charstring cs_val := oct2char(bit2oct(encvalue(val)));
var universal charstring ucs_val := encvalue_unichar(val, "UTF-8");
pt.send(commMessage_tPayloadRecord: { bs_val, omit, omit, omit, omit });
pt.send(commMessage_tPayloadRecord: { omit, hs_val, omit, omit, omit });
pt.send(commMessage_tPayloadRecord: { omit, omit, os_val, omit, omit });
pt.send(commMessage_tPayloadRecord: { omit, omit, omit, cs_val, omit });
pt.send(commMessage_tPayloadRecord: { omit, omit, omit, omit, ucs_val });