/****************************************************************************** * Copyright (c) 2000-2014 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 ******************************************************************************/ module LogFiles { modulepar { StrList PTC_Names; StrList PTC_Severities; } type record of charstring StrList; external function readlogfile(in charstring filename) return StrList; type port MyPort message { inout charstring; } with { extension "internal" } type component MyComp { port MyPort p1; port MyPort p2; port MyProcPort p; } signature MySignature(in MyComp c) return MyComp; template MySignature MySignatureTemplate := { c:=? } type port MyProcPort procedure { inout MySignature; } with { extension "internal" } function myptcfn() runs on MyComp { var charstring msg; p1.receive(charstring:?) -> value msg; log(msg); p2.send(msg); setverdict(pass); } type record of MyComp MyCompList; testcase mytc() runs on MyComp { // create component ring with names from cfg file var integer i; var MyCompList comp_list := { }; for (i:=0; i value msg { log(msg); T.stop; } [] T.timeout { setverdict(fail); } } setverdict(pass); } function checkLineMatches(in charstring line, in charstring regexp_str) { var charstring match_regexp := "(" & regexp_str & ")"; var charstring matching_str := regexp(line, match_regexp, 0); if (lengthof(matching_str)==0) { setverdict(fail, "\nline=",line, "\nregexp=",match_regexp); } } function checkContainsMatchingLineCount(in StrList list, in charstring regexp_str, in integer required_matching_lines) { var charstring match_regexp := "(" & regexp_str & ")"; var integer number_of_lines_matching := 0; var integer i; for (i:=0; i=sizeof(PTC_Names)-1) { return "mtc"; } return PTC_Names[ptc_index+1] & "\\(\\d#(1,2)\\)"; } function checkLogFile_fn(in integer index) { log("Checking ", PTC_Names[index], ".log for ", PTC_Severities[index]); var StrList list := readlogfile(PTC_Names[index] & ".log"); // check only containes the specified severity var charstring mypattern := "* (" & PTC_Severities[index] & "_[A-Z]#(1,100)) *"; var integer i; for (i:=0; i pass"); checkLineMatches(list[1], "* VERDICTOP_FINAL *Final verdict of PTC: pass"); } } testcase checklogfiles_tc() runs on MyComp { var integer i; for (i:=0; i pass\\)", 1); } for (i:=0; i<=sizeof(PTC_Names); i:=i+1) { checkContainsMatchingLineCount(list, "* PARALLEL_PORTCONN *Connect operation on " & get_conn_p1_comp_name_pattern(i) & ":p2 and " & get_conn_p2_comp_name_pattern(i-1) & ":p1 finished.", 1); } setverdict(pass); } function myprocptcfn1() runs on MyComp { var MyComp vl_comp; p.call(MySignature:{self}) { [] p.getreply(MySignatureTemplate) -> value vl_comp; } log("Received component value: ", vl_comp); p2.send("ok."); setverdict(pass); } function myprocptcfn2() runs on MyComp { var MyComp vl_comp; p.getcall(MySignatureTemplate) -> param (vl_comp); p.reply(MySignatureTemplate value self); log("Received component value: ", vl_comp); p2.send("ok."); setverdict(pass); } // run from LogFilesProc.cfg (third invocation) testcase proc_tc() runs on MyComp { var MyComp c1, c2; c1 := MyComp.create("STAN"); c2 := MyComp.create("PAN"); connect(c1:p,c2:p); connect(mtc:p2,c1:p2); connect(mtc:p2,c2:p2); c1.start(myprocptcfn1()); c2.start(myprocptcfn2()); p2.receive(charstring:"ok."); p2.receive(charstring:"ok."); // check log file of STAN var StrList list := readlogfile("PROC_STAN.log"); checkLineMatches(list[0], "* PORTEVENT_PCOUT *Called on p to PAN\\(\\d#(1,3)\\) *"); checkLineMatches(list[1], "* PORTEVENT_PQUEUE *Reply enqueued on p from PAN\\(\\d#(1,3)\\) * value PAN\\(\\d#(1,3)\\) id 1"); checkLineMatches(list[2], "* MATCHING_PCSUCCESS *Matching on port p succeeded: * matched value PAN\\(\\d#(1,3)\\) with \\? matched"); checkLineMatches(list[3], "* PORTEVENT_PCIN *Getreply operation on port p succeeded, reply from PAN\\(\\d#(1,3)\\): * value PAN\\(\\d#(1,3)\\) id 1"); checkLineMatches(list[4], "* PORTEVENT_PQUEUE *Operation with id 1 was extracted from the queue of p."); checkLineMatches(list[5], "* USER_UNQUALIFIED *Received component value: PAN\\(\\d#(1,3)\\)"); // check log file of PAN list := readlogfile("PROC_PAN.log"); checkLineMatches(list[0], "* PORTEVENT_PQUEUE *Call enqueued on p from STAN\\(\\d#(1,3)\\) *.MySignature : \\{ c := STAN\\(\\d#(1,3)\\) \\} id 1"); checkLineMatches(list[1], "* MATCHING_PCSUCCESS *Matching on port p succeeded: \\{ c := STAN\\(\\d#(1,3)\\) with \\? matched \\}"); checkLineMatches(list[2], "* PORTEVENT_PCIN *Getcall operation on port p succeeded, call from STAN\\(\\d#(1,3)\\): *.MySignature : \\{ c := STAN\\(\\d#(1,3)\\) \\} id 1"); checkLineMatches(list[3], "* PORTEVENT_PQUEUE *Operation with id 1 was extracted from the queue of p."); checkLineMatches(list[4], "* PORTEVENT_PCOUT *Replied on p to STAN\\(\\d#(1,3)\\) *.MySignature : \\{ \\} value PAN\\(\\d#(1,3)\\)"); checkLineMatches(list[5], "* USER_UNQUALIFIED *Received component value: STAN\\(\\d#(1,3)\\)"); setverdict(pass); } // Tests for HM34022. function f_level2() { log("f_level2()"); } function f_level1() { f_level2(); } testcase checkifstackisstillworking_tc() runs on MyComp { f_level1(); var StrList list := readlogfile("MTC.log"); var charstring match_regexp := "(?*USER_UNQUALIFIED LogFiles.ttcn:\\d+\\(controlpart:LogFiles\\)->LogFiles.ttcn:\\d+\\(testcase:checkifstackisstillworking_tc\\)->LogFiles.ttcn:\\d+\\(function:f_level1\\)->LogFiles.ttcn:\\d+\\(function:f_level2\\) f_level2\\(?*)"; for (var integer i := 0; i < sizeof(list); i := i + 1) { var charstring match_str := regexp(list[i], match_regexp, 0); if (lengthof(match_str) != 0) { setverdict(pass); break; } } if (getverdict != pass) { setverdict(fail, "Something is wrong with the stack log..."); } } control // Executed from LogFiles.cfg (first invocation). { execute(mytc()); execute(checklogfiles_tc()); execute(checkifstackisstillworking_tc()); } }