From 0a1610f4425d74e020771d8624084114b9ed3e0e Mon Sep 17 00:00:00 2001 From: ebensza <bence.janos.szabo@ericsson.com> Date: Mon, 2 May 2016 09:42:46 +0200 Subject: [PATCH] added checkstate operation (artf724009) Signed-off-by: ebensza <bence.janos.szabo@ericsson.com> --- compiler2/Value.cc | 107 +++++- compiler2/Value.hh | 6 +- compiler2/ttcn3/compiler.l | 1 + compiler2/ttcn3/compiler.y | 16 +- core/Port.cc | 40 +++ core/Port.hh | 6 + regression_test/checkstate/Makefile | 55 +++ .../checkstate/PortCheckstate.ttcn | 317 ++++++++++++++++++ 8 files changed, 545 insertions(+), 3 deletions(-) create mode 100644 regression_test/checkstate/Makefile create mode 100644 regression_test/checkstate/PortCheckstate.ttcn diff --git a/compiler2/Value.cc b/compiler2/Value.cc index 8ecfcc88a..19e09801b 100644 --- a/compiler2/Value.cc +++ b/compiler2/Value.cc @@ -298,6 +298,11 @@ namespace Common { u.expr.r1=p.u.expr.r1->clone(); u.expr.v2=p.u.expr.v2?p.u.expr.v2->clone():0; break; + case OPTYPE_CHECKSTATE_ANY: // [r1] v2 + case OPTYPE_CHECKSTATE_ALL: + u.expr.r1=p.u.expr.r1?p.u.expr.r1->clone():0; + u.expr.v2=p.u.expr.v2->clone(); + break; case OPTYPE_COMP_CREATE: // r1 [v2] [v3] u.expr.r1=p.u.expr.r1->clone(); u.expr.v2=p.u.expr.v2?p.u.expr.v2->clone():0; @@ -611,6 +616,11 @@ namespace Common { delete u.expr.r1; delete u.expr.v2; break; + case OPTYPE_CHECKSTATE_ANY: // [r1] v2 + case OPTYPE_CHECKSTATE_ALL: + delete u.expr.r1; + delete u.expr.v2; + break; case OPTYPE_COMP_CREATE: // r1 [v2] [v3] b4 delete u.expr.r1; delete u.expr.v2; @@ -997,7 +1007,7 @@ namespace Common { } } - // r1 [v2] + // r1 [v2] or [r1] v2 Value::Value(operationtype_t p_optype, Ttcn::Ref_base *p_r1, Value *p_v2) : GovernedSimple(S_V), valuetype(V_EXPR), my_governor(0) { @@ -1009,6 +1019,12 @@ namespace Common { u.expr.r1=p_r1; u.expr.v2=p_v2; break; + case OPTYPE_CHECKSTATE_ANY: + case OPTYPE_CHECKSTATE_ALL: + if(!p_v2) FATAL_ERROR("Value::Value()"); + u.expr.r1=p_r1; // may be null if any port or all port + u.expr.v2=p_v2; + break; default: FATAL_ERROR("Value::Value()"); } // switch @@ -1646,6 +1662,10 @@ namespace Common { case OPTYPE_ANY2UNISTR: u.expr.logargs->set_fullname(p_fullname+".<logarg>"); break; + case OPTYPE_CHECKSTATE_ANY: // [r1] v2 + case OPTYPE_CHECKSTATE_ALL: + u.expr.v2->set_fullname(p_fullname+".<operand1>"); + break; default: FATAL_ERROR("Value::set_fullname_expr()"); } // switch @@ -1798,6 +1818,11 @@ namespace Common { u.expr.r1->set_my_scope(p_scope); if(u.expr.v2) u.expr.v2->set_my_scope(p_scope); break; + case OPTYPE_CHECKSTATE_ANY: // [r1] v2 + case OPTYPE_CHECKSTATE_ALL: + if(u.expr.r1) u.expr.r1->set_my_scope(p_scope); + u.expr.v2->set_my_scope(p_scope); + break; case OPTYPE_COMP_CREATE: // r1 [v2] [v3] u.expr.r1->set_my_scope(p_scope); if(u.expr.v2) u.expr.v2->set_my_scope(p_scope); @@ -2118,6 +2143,11 @@ namespace Common { u.expr.r1->set_code_section(p_code_section); if(u.expr.v2) u.expr.v2->set_code_section(p_code_section); break; + case OPTYPE_CHECKSTATE_ANY: // [r1] v2 + case OPTYPE_CHECKSTATE_ALL: + if(u.expr.r1) u.expr.r1->set_code_section(p_code_section); + u.expr.v2->set_code_section(p_code_section); + break; case OPTYPE_COMP_CREATE: // r1 [v2] [v3] b4 u.expr.r1->set_code_section(p_code_section); if(u.expr.v2) u.expr.v2->set_code_section(p_code_section); @@ -2899,6 +2929,8 @@ namespace Common { case OPTYPE_ISVALUE: case OPTYPE_ISBOUND: case OPTYPE_PROF_RUNNING: + case OPTYPE_CHECKSTATE_ANY: + case OPTYPE_CHECKSTATE_ALL: return Type::T_BOOL; case OPTYPE_GETVERDICT: return Type::T_VERDICT; @@ -3400,6 +3432,18 @@ namespace Common { return "getverdict()"; case OPTYPE_TESTCASENAME: return "testcasename()"; + case OPTYPE_CHECKSTATE_ANY: + if (u.expr.r1) { + return "port.checkstate()"; + } else { + return "any port.checkstate()"; + } + case OPTYPE_CHECKSTATE_ALL: + if (u.expr.r1) { + return "port.checkstate()"; + } else { + return "all port.checkstate()"; + } case OPTYPE_UNARYPLUS: // v1 return "unary +"; case OPTYPE_UNARYMINUS: @@ -7062,6 +7106,18 @@ error: chk_expr_operand_activate(u.expr.r1, the, opname); chk_expr_dynamic_part(exp_val, true); break; + case OPTYPE_CHECKSTATE_ANY: // [r1] v2 + case OPTYPE_CHECKSTATE_ALL: + chk_expr_dynamic_part(exp_val, false); + v2=u.expr.v2; + if(v2) { + Error_Context cntxt(this, "In the first operand of operation `%s'", opname); + v2->set_lowerid_to_ref(); + tt2=v2->get_expr_returntype(exp_val); + chk_expr_operandtype_cstr(tt2, first, opname, v2); + chk_expr_eval_value(v2, t_chk, refch, exp_val); + } + break; case OPTYPE_ACTIVATE_REFD:{ //v1 t_list2 Ttcn::ActualParList *parlist = new Ttcn::ActualParList; chk_expr_operand_activate_refd(u.expr.v1,u.expr.t_list2->get_tis(), parlist, the, @@ -7210,6 +7266,8 @@ error: case OPTYPE_DECODE_BASE64: case OPTYPE_ENCVALUE_UNICHAR: case OPTYPE_DECVALUE_UNICHAR: + case OPTYPE_CHECKSTATE_ANY: + case OPTYPE_CHECKSTATE_ALL: break; case OPTYPE_TESTCASENAME: { // - if (!my_scope) FATAL_ERROR("Value::evaluate_value()"); @@ -8508,6 +8566,8 @@ error: case OPTYPE_DECODE_BASE64: case OPTYPE_ENCVALUE_UNICHAR: case OPTYPE_DECVALUE_UNICHAR: + case OPTYPE_CHECKSTATE_ANY: + case OPTYPE_CHECKSTATE_ALL: return true; case OPTYPE_COMP_NULL: // - return false; @@ -10031,6 +10091,8 @@ error: case OPTYPE_TMR_RUNNING_ANY: // - case OPTYPE_GETVERDICT: // - case OPTYPE_PROF_RUNNING: // - + case OPTYPE_CHECKSTATE_ANY: + case OPTYPE_CHECKSTATE_ALL: break; // nothing to do case OPTYPE_MATCH: // v1 t2 @@ -10694,6 +10756,22 @@ error: return u.expr.r1->get_dispname() + ".running"; case OPTYPE_TMR_RUNNING_ANY: return string("any timer.running"); + case OPTYPE_CHECKSTATE_ANY: + case OPTYPE_CHECKSTATE_ALL: { + string ret_val(""); + if (u.expr.r1) { + ret_val += "port"; + } else { + if (u.expr.v_optype == OPTYPE_CHECKSTATE_ANY) { + ret_val += "any port"; + } else if (u.expr.v_optype == OPTYPE_CHECKSTATE_ALL) { + ret_val += "all port"; + } + } + ret_val += "checkstate("; + ret_val += u.expr.v2->get_stringRepr(); + ret_val += ")"; + return ret_val; } case OPTYPE_GETVERDICT: return string("getverdict"); case OPTYPE_ACTIVATE: { @@ -12017,6 +12095,10 @@ error: case OPTYPE_ACTIVATE: // r1 generate_code_expr_activate(expr); break; + case OPTYPE_CHECKSTATE_ANY: // [r1] v2 + case OPTYPE_CHECKSTATE_ALL: + generate_code_expr_checkstate(expr); + break; case OPTYPE_ACTIVATE_REFD: // v1 ap_list2 generate_code_expr_activate_refd(expr); break; @@ -12818,6 +12900,27 @@ void Value::generate_code_expr_encvalue_unichar(expression_struct *expr) Code::free_expr(&expr2); } + void Value::generate_code_expr_checkstate(expression_struct *expr) + { + if (u.expr.r1) { + // It is a port if r1 is not null + u.expr.r1->generate_code_const_ref(expr); + expr->expr = mputstr(expr->expr, "."); + } else { + // it is an any or all port if r1 is null + if (u.expr.v_optype == OPTYPE_CHECKSTATE_ANY) { + expr->expr = mputstr(expr->expr, "PORT::any_"); + } else if (u.expr.v_optype == OPTYPE_CHECKSTATE_ALL) { + expr->expr = mputstr(expr->expr, "PORT::all_"); + } else { + FATAL_ERROR("Value::generate_code_expr_checkstate()"); + } + } + expr->expr = mputstr(expr->expr, "check_port_state("); + u.expr.v2->generate_code_expr_mandatory(expr); + expr->expr = mputstr(expr->expr, ")"); + } + char* Value::generate_code_char_coding_check(expression_struct *expr, Value *v, const char *name) { expression_struct expr2; @@ -13494,6 +13597,8 @@ void Value::generate_code_expr_encvalue_unichar(expression_struct *expr) case OPTYPE_GETVERDICT: case OPTYPE_TESTCASENAME: case OPTYPE_PROF_RUNNING: + case OPTYPE_CHECKSTATE_ANY: + case OPTYPE_CHECKSTATE_ALL: return true; case OPTYPE_ENCODE: case OPTYPE_DECODE: diff --git a/compiler2/Value.hh b/compiler2/Value.hh index 549ad1abe..d3c744fde 100644 --- a/compiler2/Value.hh +++ b/compiler2/Value.hh @@ -265,6 +265,8 @@ namespace Common { OPTYPE_DECVALUE_UNICHAR, // r1 r2 [v3] OPTYPE_ANY2UNISTR, // logarg, length = 1 + OPTYPE_CHECKSTATE_ANY, // [r1] v2, port or any + OPTYPE_CHECKSTATE_ALL, // [r1] v2, port or all NUMBER_OF_OPTYPES // must be last }; @@ -411,7 +413,7 @@ namespace Common { /** OPTYPE_EXECUTE_REFD */ Value(operationtype_t p_optype, Value *p_v1, Ttcn::ParsedActualParameters *p_t_list2, Value *p_v3); - /** Constructor used by V_EXPR "r1 [v2]": EXECUTE */ + /** Constructor used by V_EXPR "r1 [v2]": EXECUTE or [r1] v2 */ Value(operationtype_t p_optype, Ttcn::Ref_base *p_r1, Value *v2); /** Constructor used by V_EXPR "r1 [v2] [v3] b4": COMP_CREATE */ Value(operationtype_t p_optype, Ttcn::Ref_base *p_r1, Value *p_v2, @@ -923,6 +925,8 @@ namespace Common { void generate_code_expr_decvalue_unichar(expression_struct *expr); + void generate_code_expr_checkstate(expression_struct *expr); + char* generate_code_char_coding_check(expression_struct *expr, Value *v, const char *name); /** Helper function for \a generate_code_init(). It handles the diff --git a/compiler2/ttcn3/compiler.l b/compiler2/ttcn3/compiler.l index 210fe7d3b..730ab7037 100644 --- a/compiler2/ttcn3/compiler.l +++ b/compiler2/ttcn3/compiler.l @@ -380,6 +380,7 @@ case RETURN(CaseKeyword); catch RETURN_DOT(CatchOpKeyword); char { BEGIN(SC_charkeyword); RETURN(CharKeyword); } charstring RETURN(CharStringKeyword); +checkstate RETURN_DOT(CheckStateKeyword); check RETURN_DOT(CheckOpKeyword); clear RETURN_DOT(ClearOpKeyword); complement RETURN(ComplementKeyword); diff --git a/compiler2/ttcn3/compiler.y b/compiler2/ttcn3/compiler.y index 435af7d73..42c3cb2ba 100644 --- a/compiler2/ttcn3/compiler.y +++ b/compiler2/ttcn3/compiler.y @@ -595,6 +595,7 @@ static const string anyname("anytype"); %token CharKeyword %token CharStringKeyword %token CheckOpKeyword +%token CheckStateKeyword %token ClearOpKeyword %token ComplementKeyword %token ComponentKeyword @@ -751,6 +752,7 @@ static const string anyname("anytype"); %token DotCallOpKeyword %token DotCatchOpKeyword %token DotCheckOpKeyword +%token DotCheckStateKeyword %token DotClearOpKeyword %token DotCreateKeyword %token DotDoneKeyword @@ -5806,7 +5808,7 @@ CommunicationStatements: // 353 | ClearStatement {$$ = $1;} | StartStatement {$$ = $1;} | StopStatement {$$ = $1;} -| HaltStatement { $$ = $1; } +| HaltStatement {$$ = $1;} ; SendStatement: // 354 @@ -8456,6 +8458,18 @@ OpCall: // 611 $$->set_location(infile, @$); } | ProfilerRunningOp { $$ = $1; } +| PortOrAny DotCheckStateKeyword '(' SingleExpression ')' + { + $$ = new Value(Value::OPTYPE_CHECKSTATE_ANY, $1, $4); + $$->set_location(infile, @$); + } +// PortOrAll would cause a conflict +| AllKeyword PortKeyword DotCheckStateKeyword '(' SingleExpression ')' + { + Ttcn::Reference *r = NULL; + $$ = new Value(Value::OPTYPE_CHECKSTATE_ALL, r, $5); + $$->set_location(infile, @$); + } ; PredefinedOps: diff --git a/core/Port.cc b/core/Port.cc index 7c8a88ce7..de87bf3fa 100644 --- a/core/Port.cc +++ b/core/Port.cc @@ -15,6 +15,7 @@ * Pandi, Krisztian * Raduly, Csaba * Szabados, Kristof + * Szabo, Bence Janos * Szabo, Janos Zoltan – initial implementation * Szalai, Gabor * Tatarka, Gabor @@ -2426,3 +2427,42 @@ void PORT::unmap_port(const char *component_port, const char *system_port) if (!TTCN_Runtime::is_single()) TTCN_Communication::send_unmapped(component_port, system_port); } + +bool PORT::check_port_state(const CHARSTRING& type) const +{ + if (type == "Started") { + return is_started; + } else if (type == "Halted") { + return is_halted; + } else if (type == "Stopped") { + return (!is_started && !is_halted); + } else if (type == "Connected") { + return connection_list_head != NULL; + } else if (type == "Mapped") { + return n_system_mappings > 0; + } else if (type == "Linked") { + return (connection_list_head != NULL || n_system_mappings > 0); + } + TTCN_error("%s is not an allowed parameter of checkstate().", (const char*)type); +} + +bool PORT::any_check_port_state(const CHARSTRING& type) +{ + bool result = false; + for (PORT *port = list_head; port != NULL; port = port->list_next) { + result = port->check_port_state(type); + if (result) { + return true; + } + } + return false; +} + +bool PORT::all_check_port_state(const CHARSTRING& type) +{ + bool result = true; + for (PORT *port = list_head; port != NULL && result; port = port->list_next) { + result = port->check_port_state(type); + } + return result; +} \ No newline at end of file diff --git a/core/Port.hh b/core/Port.hh index 3ddda1622..9727e1c10 100644 --- a/core/Port.hh +++ b/core/Port.hh @@ -12,6 +12,7 @@ * Feher, Csaba * Raduly, Csaba * Szabados, Kristof + * Szabo, Bence Janos * Szabo, Janos Zoltan – initial implementation * Tatarka, Gabor * @@ -30,6 +31,7 @@ class COMPONENT; class COMPONENT_template; class Text_Buf; class OCTETSTRING; +class CHARSTRING; extern const COMPONENT_template& any_compref; @@ -126,6 +128,10 @@ public: static void all_stop(); void halt(); static void all_halt(); + + bool check_port_state(const CHARSTRING& type) const; + static bool any_check_port_state(const CHARSTRING& type); + static bool all_check_port_state(const CHARSTRING& type); virtual alt_status receive(const COMPONENT_template& sender_template = any_compref, COMPONENT *sender_ptr = NULL); diff --git a/regression_test/checkstate/Makefile b/regression_test/checkstate/Makefile new file mode 100644 index 000000000..462c4d95d --- /dev/null +++ b/regression_test/checkstate/Makefile @@ -0,0 +1,55 @@ +############################################################################## +# 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: +# Szabo, Bence Janos +# +############################################################################## +TOPDIR := .. +include $(TOPDIR)/Makefile.regression + +.SUFFIXES: .ttcn .hh +.PHONY: all clean dep run + +TTCN3_LIB = ttcn3$(RT2_SUFFIX)-parallel$(DYNAMIC_SUFFIX) + +TTCN3_MODULES = PortCheckstate.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)) +endif + +USER_SOURCES = + +OBJECTS = $(GENERATED_SOURCES:.cc=.o) $(USER_SOURCES:.cc=.o) + +TARGET = PortCheckstate$(EXESUFFIX) + +all: $(TARGET) + +$(TARGET): $(GENERATED_SOURCES) $(USER_SOURCES) + $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@ $^ -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) $^ + +clean distclean: + -rm -f $(TARGET) $(OBJECTS) $(GENERATED_HEADERS) \ + $(GENERATED_SOURCES) *.log Makefile.bak + +dep: $(GENERATED_SOURCES) + makedepend $(CPPFLAGS) $(GENERATED_SOURCES) + +run: $(TARGET) + $(TTCN3_DIR)/bin/ttcn3_start $^ + + diff --git a/regression_test/checkstate/PortCheckstate.ttcn b/regression_test/checkstate/PortCheckstate.ttcn new file mode 100644 index 000000000..0dd071b0d --- /dev/null +++ b/regression_test/checkstate/PortCheckstate.ttcn @@ -0,0 +1,317 @@ +/****************************************************************************** + * 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: + * Szabo, Bence Janos + * + ******************************************************************************/ + +module PortCheckstate +{ + type port MyPort message + { + inout charstring + } with { extension "internal" } + + type component MyMTCType + { + port MyPort MyPCO1; + port MyPort MyPCO2; + } + + type component MTCType + { + port MyPort MyPCO3; + port MyPort MyPCO4; + } + + testcase tc_checkstate() runs on MyMTCType system MTCType + { + var boolean myPortState; + var charstring started := "Started"; + myPortState := MyPCO1.checkstate(started) and MyPCO2.checkstate("Started"); + if(myPortState == true) { + setverdict(pass); + }else { + setverdict(fail); + } + + myPortState := MyPCO1.checkstate("Linked"); + if(myPortState == false) { + setverdict(pass); + }else { + setverdict(fail); + } + + map(mtc:MyPCO2, system:MyPCO4); + + myPortState := MyPCO2.checkstate("Linked"); + if(myPortState == true) { + setverdict(pass); + }else { + setverdict(fail); + } + + myPortState := MyPCO2.checkstate("Mapped"); + if(myPortState == true) { + setverdict(pass); + }else { + setverdict(fail); + } + + myPortState := MyPCO2.checkstate("Connected"); + if(myPortState == false) { + setverdict(pass); + }else { + setverdict(fail); + } + + var MyMTCType myComp1 := MyMTCType.create; + connect(myComp1:MyPCO2, mtc:MyPCO2); + + myPortState := MyPCO2.checkstate("Connected"); + if(myPortState == true) { + setverdict(pass); + }else { + setverdict(fail); + } + + disconnect(myComp1:MyPCO2, mtc:MyPCO2); + + myPortState := MyPCO2.checkstate("Connected"); + if(myPortState == false) { + setverdict(pass); + }else { + setverdict(fail); + } + + unmap(mtc:MyPCO2, system:MyPCO4); + + myPortState := MyPCO2.checkstate("Mapped"); + if(myPortState == false) { + setverdict(pass); + }else { + setverdict(fail); + } + + myPortState := MyPCO2.checkstate("Linked"); + if(myPortState == false) { + setverdict(pass); + }else { + setverdict(fail); + } + + all port.stop; + + if(MyPCO2.checkstate("Stopped")) { + setverdict(pass); + } else { + setverdict(fail); + } + } + + testcase tc_any_checkstate() runs on MyMTCType system MTCType + { + var boolean myPortState; + myPortState := any port.checkstate("Started"); + if(myPortState == true) { + setverdict(pass); + }else { + setverdict(fail); + } + + myPortState := any port.checkstate("Linked"); + if(myPortState == false) { + setverdict(pass); + }else { + setverdict(fail); + } + + map(mtc:MyPCO2, system:MyPCO4); + + myPortState := any port.checkstate("Linked"); + if(myPortState == true) { + setverdict(pass); + }else { + setverdict(fail); + } + + myPortState := any port.checkstate("Mapped"); + if(myPortState == true) { + setverdict(pass); + }else { + setverdict(fail); + } + + myPortState := any port.checkstate("Connected"); + if(myPortState == false) { + setverdict(pass); + }else { + setverdict(fail); + } + + var MyMTCType myComp1 := MyMTCType.create; + connect(myComp1:MyPCO2, mtc:MyPCO2); + + myPortState := any port.checkstate("Connected"); + if(myPortState == true) { + setverdict(pass); + }else { + setverdict(fail); + } + + disconnect(myComp1:MyPCO2, mtc:MyPCO2); + + myPortState := any port.checkstate("Connected"); + if(myPortState == false) { + setverdict(pass); + }else { + setverdict(fail); + } + + unmap(mtc:MyPCO2, system:MyPCO4); + + myPortState := any port.checkstate("Mapped"); + if(myPortState == false) { + setverdict(pass); + }else { + setverdict(fail); + } + + myPortState := any port.checkstate("Linked"); + if(myPortState == false) { + setverdict(pass); + }else { + setverdict(fail); + } + + all port.stop; + + if(any port.checkstate("Stopped")) { + setverdict(pass); + } else { + setverdict(fail); + } + } + + testcase tc_all_checkstate() runs on MyMTCType system MTCType + { + var boolean myPortState := all port.checkstate("Started"); + if(myPortState == true) { + setverdict(pass); + }else { + setverdict(fail); + } + + myPortState := all port.checkstate("Linked"); + if(myPortState == false) { + setverdict(pass); + }else { + setverdict(fail); + } + + map(mtc:MyPCO1, system:MyPCO3); + + myPortState := all port.checkstate("Linked"); + if(myPortState == false) { + setverdict(pass); + }else { + setverdict(fail); + } + + myPortState := all port.checkstate("Mapped"); + if(myPortState == false) { + setverdict(pass); + }else { + setverdict(fail); + } + + map(mtc:MyPCO2, system:MyPCO4); + + myPortState := all port.checkstate("Linked"); + if(myPortState == true) { + setverdict(pass); + }else { + setverdict(fail); + } + + myPortState := all port.checkstate("Mapped"); + if(myPortState == true) { + setverdict(pass); + }else { + setverdict(fail); + } + + myPortState := all port.checkstate("Connected"); + if(myPortState == false) { + setverdict(pass); + }else { + setverdict(fail); + } + + var MyMTCType myComp1 := MyMTCType.create; + connect(myComp1:MyPCO1, mtc:MyPCO1); + + myPortState := all port.checkstate("Connected"); + if(myPortState == false) { + setverdict(pass); + }else { + setverdict(fail); + } + + var MyMTCType myComp2 := MyMTCType.create; + connect(myComp2:MyPCO2, mtc:MyPCO2); + + myPortState := all port.checkstate("Connected"); + if(myPortState == true) { + setverdict(pass); + }else { + setverdict(fail); + } + + disconnect(myComp1:MyPCO1, mtc:MyPCO1); + + myPortState := all port.checkstate("Connected"); + if(myPortState == false) { + setverdict(pass); + }else { + setverdict(fail); + } + + unmap(mtc:MyPCO2, system:MyPCO4); + + myPortState := all port.checkstate("Mapped"); + if(myPortState == false) { + setverdict(pass); + }else { + setverdict(fail); + } + + unmap(mtc:MyPCO1, system:MyPCO3); + myPortState := all port.checkstate("Linked"); + if(myPortState == false) { + setverdict(pass); + }else { + setverdict(fail); + } + + all port.stop; + + if(all port.checkstate("Stopped")) { + setverdict(pass); + } else { + setverdict(fail); + } + } + + control + { + execute(tc_checkstate()); + execute(tc_any_checkstate()); + execute(tc_all_checkstate()); + } +} -- GitLab