diff --git a/TcUnit/TcUnit/GVLs/GVL_TcUnit.TcGVL b/TcUnit/TcUnit/GVLs/GVL_TcUnit.TcGVL index a5393bb..d4cab43 100644 --- a/TcUnit/TcUnit/GVLs/GVL_TcUnit.TcGVL +++ b/TcUnit/TcUnit/GVLs/GVL_TcUnit.TcGVL @@ -5,12 +5,16 @@ {attribute 'qualified_only'} VAR_GLOBAL TcUnitRunner : FB_TcUnitRunner; + TimeoutWatcher : FB_TimeoutWatcher; (* Indication of whether the last instantiated test suite has an assert instance created *) TestSuiteIsRegistered : BOOL; (* Pointer to current test suite being called *) CurrentTestSuiteBeingCalled : POINTER TO FB_TestSuite; + + (* Reference to current test being called *) + CurrentTestBeingCalled : REFERENCE TO FB_Test; (* Current name of test being called *) CurrentTestNameBeingCalled : Tc2_System.T_MaxString; diff --git a/TcUnit/TcUnit/POUs/FB_Test.TcPOU b/TcUnit/TcUnit/POUs/FB_Test.TcPOU index 96cf10e..c760c04 100644 --- a/TcUnit/TcUnit/POUs/FB_Test.TcPOU +++ b/TcUnit/TcUnit/POUs/FB_Test.TcPOU @@ -20,6 +20,8 @@ VAR TestIsFailed : BOOL; // Indication of whether this test has at least one failed assert AssertionMessage : Tc2_System.T_MaxString; // Assertion message for the first assertion in this test AssertionType : E_AssertionType; // Assertion type for the first assertion in this test + {attribute 'hide'} + _timeStampOfStart : ULINT; END_VAR]]> @@ -144,5 +146,24 @@ END_VAR]]> + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/TcUnit/TcUnit/POUs/FB_TestSuite.TcPOU b/TcUnit/TcUnit/POUs/FB_TestSuite.TcPOU index d975183..87b94cd 100644 --- a/TcUnit/TcUnit/POUs/FB_TestSuite.TcPOU +++ b/TcUnit/TcUnit/POUs/FB_TestSuite.TcPOU @@ -42,12 +42,14 @@ VAR (* Number of ordered tests (created by TEST_ORDERED()) that this test suite contains *) NumberOfOrderedTests : UINT(0..GVL_Param_TcUnit.MaxNumberOfTestsForEachTestSuite); + + Utility : FB_Utility; END_VAR]]> - + + + + + + + + + + + 255 THEN + IF CpuCounterULINT >= GVL_TcUnit.CurrentTestBeingCalled.TimeStampOfStart + TimeoutAsULINT THEN + + // generate report message + TestSuiteInstancePath := GVL_TcUnit.CurrentTestSuiteBeingCalled^.InstancePath; + TestName := GVL_TcUnit.CurrentTestNameBeingCalled; + ReportMessage := CONCAT('| Timeout Reached. TestSuite Path=',TestSuiteInstancePath); + ReportMessage := CONCAT(ReportMessage,', Test Name=%s'); + // add report to FifoQueue for pipelines + AdsLogStringMessageFifoQueue.WriteLog(MsgCtrlMask:=ADSLOG_MSGTYPE_ERROR,MsgFmtStr:=ReportMessage,StrArg:=TestName); + // print report in error list for developers + ADSLOGSTR(MsgCtrlMask:=ADSLOG_MSGTYPE_ERROR,MsgFmtStr:=ReportMessage,StrArg:=TestName); + + StopCmd := TRUE; + END_IF +END_IF +PlcStop(NETID:='',PORT:=AdsPort,STOP:=stopCmd); +StopCmd := FALSE;]]> + + + \ No newline at end of file diff --git a/TcUnit/TcUnit/POUs/FB_Utility.TcPOU b/TcUnit/TcUnit/POUs/FB_Utility.TcPOU new file mode 100644 index 0000000..fb49475 --- /dev/null +++ b/TcUnit/TcUnit/POUs/FB_Utility.TcPOU @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/TcUnit/TcUnit/POUs/Functions/TEST.TcPOU b/TcUnit/TcUnit/POUs/Functions/TEST.TcPOU index ada271b..903c270 100644 --- a/TcUnit/TcUnit/POUs/Functions/TEST.TcPOU +++ b/TcUnit/TcUnit/POUs/Functions/TEST.TcPOU @@ -23,7 +23,7 @@ GVL_TcUnit.CurrentTestNameBeingCalled := TestName; FOR CounterTestSuiteAddress := 1 TO GVL_TcUnit.NumberOfInitializedTestSuites BY 1 DO (* Look for the test suite by comparing to the one that is currently running *) IF GVL_TcUnit.TestSuiteAddresses[CounterTestSuiteAddress] = GVL_TcUnit.CurrentTestSuiteBeingCalled THEN - GVL_TcUnit.TestSuiteAddresses[CounterTestSuiteAddress]^.AddTest(TestName := TestName, IsTestOrdered := FALSE); + GVL_TcUnit.CurrentTestBeingCalled REF= GVL_TcUnit.TestSuiteAddresses[CounterTestSuiteAddress]^.AddTest(TestName := TestName, IsTestOrdered := FALSE); GVL_TcUnit.CurrentTestIsFinished := GVL_TcUnit.TestSuiteAddresses[CounterTestSuiteAddress]^.IsTestFinished(TestName := TestName); RETURN; END_IF diff --git a/TcUnit/TcUnit/POUs/Functions/TEST_ORDERED.TcPOU b/TcUnit/TcUnit/POUs/Functions/TEST_ORDERED.TcPOU index 392eaa5..f2bd6ee 100644 --- a/TcUnit/TcUnit/POUs/Functions/TEST_ORDERED.TcPOU +++ b/TcUnit/TcUnit/POUs/Functions/TEST_ORDERED.TcPOU @@ -44,7 +44,7 @@ FOR CounterTestSuiteAddress := 1 TO GVL_TcUnit.NumberOfInitializedTestSuites BY (* Look for the test suite by comparing to the one that is currently running *) IF GVL_TcUnit.TestSuiteAddresses[CounterTestSuiteAddress] = GVL_TcUnit.CurrentTestSuiteBeingCalled THEN - GVL_TcUnit.TestSuiteAddresses[CounterTestSuiteAddress]^.AddTest(TestName := TestName, IsTestOrdered := TRUE); + GVL_TcUnit.CurrentTestBeingCalled REF= GVL_TcUnit.TestSuiteAddresses[CounterTestSuiteAddress]^.AddTest(TestName := TestName, IsTestOrdered := TRUE); GVL_TcUnit.CurrentTestIsFinished := GVL_TcUnit.TestSuiteAddresses[CounterTestSuiteAddress]^.IsTestFinished(TestName := TestName); (* Check that no previous code has set the currently running test to ignored (for example by setting the test to DISABLED *) diff --git a/TcUnit/TcUnit/POUs/Functions/TIMEOUT_FOR_EACH_TEST.TcPOU b/TcUnit/TcUnit/POUs/Functions/TIMEOUT_FOR_EACH_TEST.TcPOU new file mode 100644 index 0000000..30dd5c1 --- /dev/null +++ b/TcUnit/TcUnit/POUs/Functions/TIMEOUT_FOR_EACH_TEST.TcPOU @@ -0,0 +1,20 @@ + + + + + + + + + \ No newline at end of file diff --git a/TcUnit/TcUnit/TcUnit.plcproj b/TcUnit/TcUnit/TcUnit.plcproj index c3b39fd..df5ef27 100644 --- a/TcUnit/TcUnit/TcUnit.plcproj +++ b/TcUnit/TcUnit/TcUnit.plcproj @@ -32,7 +32,7 @@ Documentation and examples are available at www.tcunit.org www.tcunit.org Jakob Sagatowski and contributors - 1.2.1.0 + 1.2.2.0 @@ -112,6 +112,12 @@ Documentation and examples are available at www.tcunit.org Code + + Code + + + Code + Code @@ -181,6 +187,9 @@ Documentation and examples are available at www.tcunit.org Code + + Code + Code diff --git a/TcUnit/TcUnit/Version/Global_Version.TcGVL b/TcUnit/TcUnit/Version/Global_Version.TcGVL index 4d7d59f..b9e265d 100644 --- a/TcUnit/TcUnit/Version/Global_Version.TcGVL +++ b/TcUnit/TcUnit/Version/Global_Version.TcGVL @@ -7,7 +7,7 @@ // This function has been automatically generated from the project information. VAR_GLOBAL CONSTANT {attribute 'const_non_replaced'} - stLibVersion_TcUnit : ST_LibVersion := (iMajor := 1, iMinor := 2, iBuild := 1, iRevision := 0, sVersion := '1.2.1.0'); + stLibVersion_TcUnit : ST_LibVersion := (iMajor := 1, iMinor := 2, iBuild := 2, iRevision := 0, sVersion := '1.2.2.0'); END_VAR ]]>