Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Haug2015-07-07 06:22:28 -0400
committerJuergen Haug2015-07-07 09:43:51 -0400
commitf5d819988ab66b24df4f247a93e0b7fd43fbc198 (patch)
tree1f831ce304034a5755a8d8238b31cdbe585aa4cb
parentb43132eebb34507bf5436b5f19d8d0a645a33a21 (diff)
downloadorg.eclipse.etrice-f5d819988ab66b24df4f247a93e0b7fd43fbc198.tar.gz
org.eclipse.etrice-f5d819988ab66b24df4f247a93e0b7fd43fbc198.tar.xz
org.eclipse.etrice-f5d819988ab66b24df4f247a93e0b7fd43fbc198.zip
[etUnit] added etunit for modellib + fixes
-rw-r--r--runtime/org.eclipse.etrice.modellib.c/model/etUnit/Tests.room145
-rw-r--r--runtime/org.eclipse.etrice.modellib.c/model/etUnit/diagrams/room.basic.etunit.TestCaseActor.behavior280
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/etUnit/etUnit.c42
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/etunit/EtUnit.java12
4 files changed, 458 insertions, 21 deletions
diff --git a/runtime/org.eclipse.etrice.modellib.c/model/etUnit/Tests.room b/runtime/org.eclipse.etrice.modellib.c/model/etUnit/Tests.room
new file mode 100644
index 000000000..a25b65d02
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib.c/model/etUnit/Tests.room
@@ -0,0 +1,145 @@
+RoomModel room.basic.etunit {
+
+ import room.basic.service.timing.* from "../TimingService.room"
+ import room.basic.types.* from "../Types.room"
+
+ abstract ActorClass TestSuiteActor {
+ Structure { }
+ Behavior {
+ Operation closeTestSuite(){
+ "etUnit_closeTestSuite();"
+ "etUnit_close();"
+ }
+ Operation startTestSuite(logPath: charPtr, logFileName : charPtr, testSuiteName : charPtr) {
+ "etUnit_open(logPath, logFileName);"
+ "etUnit_openTestSuite(testSuiteName);"
+ }
+
+ }
+ }
+
+ abstract async ActorClass TestCaseActor {
+ Structure {
+ SAP tcLifecycle : PTestLifecycle
+ SAP tcTimer : PTimer
+ Attribute tcTimeoutIgnore : boolean
+ Attribute tcCaseId : int16
+ }
+ Behavior {
+ Operation startTimeout(time: uint32){
+ "tcTimeoutIgnore = false;"
+ "tcTimer.startTimeout(time);"
+ }
+ Operation invalidateTimeout(){
+ "tcTimeoutIgnore = true;"
+ }
+ StateMachine {
+ Transition init: initial -> tpEnter of testing {
+ action {
+ "invalidateTimeout();"
+ "tcCaseId = etUnit_openTestCase(self->constData->instName);"
+ "tcLifecycle.startTestCase(tcCaseId);"
+ }
+ }
+ Transition trFinish: tpFinish of testing -> finish
+ Transition trTimeout: testing -> timeout {
+ triggers {
+ <timeout: tcTimer guard {
+ "!tcTimeoutIgnore"
+ }>
+ }
+ action {
+ "invalidateTimeout();"
+ }
+ }
+ State testing {
+ subgraph {
+ EntryPoint tpEnter
+ ExitPoint tpFinish
+ }
+ }
+ State timeout {
+ entry {
+ "EXPECT_FALSE(tcCaseId, \"timeout\", true);"
+ "etUnit_closeTestCase(tcCaseId);"
+ "tcLifecycle.finishedTestCase(tcCaseId);"
+ }
+ }
+ State finish {
+ entry {
+ "etUnit_closeTestCase(tcCaseId);"
+ "tcLifecycle.finishedTestCase(tcCaseId);"
+ }
+ }
+ }
+ }
+ }
+
+ ActorClass TestLifecycleActor {
+ Interface {
+ SPP fct: PTestLifecycle
+ }
+ Structure {
+ ServiceImplementation of fct
+ SAP timer : PTimer
+ Attribute tcCount : int32 = "0"
+ }
+ Behavior {
+ StateMachine {
+ Transition init: initial -> idle {
+ action {
+ "timer.startTimeout(5000);"
+ }
+ }
+ Transition tr0: idle -> idle {
+ triggers {
+ <startTestCase: fct>
+ }
+ action {
+ "tcCount++;"
+ }
+ }
+ Transition tr1: idle -> cp cp0 {
+ triggers {
+ <finishedTestCase: fct>
+ }
+ action {
+ "tcCount--;"
+ }
+ }
+ Transition tr2: idle -> terminate {
+ triggers {
+ <timeout: timer>
+ }
+ }
+ Transition tr3: cp cp0 -> idle
+ Transition tr4: cp cp0 -> terminate {
+ cond {
+ "tcCount==0"
+ }
+ }
+ Transition tr5: cp cp0 -> error {
+ cond {
+ "tcCount < 0"
+ }
+ }
+ ChoicePoint cp0
+ State idle
+ State terminate {
+ entry {
+ "etUnit_testFinished(-1);"
+ }
+ }
+ State error
+ }
+ }
+ }
+
+ ProtocolClass PTestLifecycle {
+ incoming {
+ Message startTestCase(id : int16)
+ Message finishedTestCase(id : int16)
+ }
+ }
+
+} \ No newline at end of file
diff --git a/runtime/org.eclipse.etrice.modellib.c/model/etUnit/diagrams/room.basic.etunit.TestCaseActor.behavior b/runtime/org.eclipse.etrice.modellib.c/model/etUnit/diagrams/room.basic.etunit.TestCaseActor.behavior
new file mode 100644
index 000000000..ff0471623
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib.c/model/etUnit/diagrams/room.basic.etunit.TestCaseActor.behavior
@@ -0,0 +1,280 @@
+<?xml version="1.0" encoding="ASCII"?>
+<pi:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:al="http://eclipse.org/graphiti/mm/algorithms" xmlns:pi="http://eclipse.org/graphiti/mm/pictograms" visible="true" gridUnit="10" diagramTypeId="room.behavior" name="Behavior of TestCaseActor" pictogramLinks="//@link //@children.0/@link //@children.0/@children.1/@link //@children.0/@children.2/@link //@children.0/@children.3/@link //@children.0/@children.4/@link //@children.1/@link //@children.1/@children.1/@link //@children.0/@children.2/@children.1/@link //@children.1/@children.2/@link //@children.0/@children.2/@children.2/@link //@connections.0/@link //@connections.1/@link //@connections.2/@link" verticalGridUnit="10" version="0.11.0">
+ <graphicsAlgorithm xsi:type="al:Rectangle" background="//@colors.1" foreground="//@colors.0" lineWidth="1" transparency="0.0" width="1000" height="1000"/>
+ <link>
+ <businessObjects href="../Tests.room#ActorClass:TestCaseActor"/>
+ </link>
+ <children xsi:type="pi:ContainerShape" visible="true" active="true">
+ <properties key="obj-type" value="sg"/>
+ <graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="880" height="580" x="40" y="40">
+ <graphicsAlgorithmChildren xsi:type="al:RoundedRectangle" background="//@colors.1" foreground="//@colors.2" lineWidth="4" transparency="0.5" width="800" height="500" x="40" y="40" cornerHeight="20" cornerWidth="20"/>
+ <graphicsAlgorithmChildren xsi:type="al:RoundedRectangle" foreground="//@colors.2" lineWidth="4" filled="false" transparency="0.0" width="800" height="500" x="40" y="40" cornerHeight="20" cornerWidth="20"/>
+ </graphicsAlgorithm>
+ <link>
+ <businessObjects href="../Tests.room#StateGraph:TestCaseActor$sg"/>
+ </link>
+ <children visible="true">
+ <graphicsAlgorithm xsi:type="al:Text" background="//@colors.2" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0" width="800" height="80" y="40" font="//@fonts.1" horizontalAlignment="ALIGNMENT_RIGHT" verticalAlignment="ALIGNMENT_TOP" value="/"/>
+ </children>
+ <children xsi:type="pi:ContainerShape" visible="true" active="true">
+ <properties key="obj-type" value="trp"/>
+ <graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="40" height="40" x="100" y="100">
+ <graphicsAlgorithmChildren xsi:type="al:Ellipse" background="//@colors.1" foreground="//@colors.2" lineWidth="2" transparency="0.0" width="20" height="20" x="10" y="10"/>
+ </graphicsAlgorithm>
+ <link>
+ <businessObjects href="../Tests.room#StateGraph:TestCaseActor$sg"/>
+ </link>
+ <anchors xsi:type="pi:ChopboxAnchor" outgoingConnections="//@connections.0" referencedGraphicsAlgorithm="//@children.0/@children.1/@graphicsAlgorithm/@graphicsAlgorithmChildren.0"/>
+ <children visible="true">
+ <graphicsAlgorithm xsi:type="al:Text" background="//@colors.2" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0" width="40" height="20" y="10" font="//@fonts.0" horizontalAlignment="ALIGNMENT_CENTER" value="I"/>
+ </children>
+ </children>
+ <children xsi:type="pi:ContainerShape" visible="true" active="true">
+ <properties key="obj-type" value="state"/>
+ <graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="208" height="133" x="225" y="190">
+ <graphicsAlgorithmChildren xsi:type="al:RoundedRectangle" background="//@colors.3" foreground="//@colors.2" lineWidth="1" transparency="0.0" width="148" height="73" x="30" y="30" cornerHeight="20" cornerWidth="20">
+ <graphicsAlgorithmChildren xsi:type="al:RoundedRectangle" foreground="//@colors.2" lineWidth="1" filled="false" lineVisible="true" transparency="0.0" width="15" height="8" x="123" y="3" cornerHeight="5" cornerWidth="5"/>
+ <graphicsAlgorithmChildren xsi:type="al:Polygon" foreground="//@colors.2" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" x="74" y="67">
+ <points x="-3" y="-3"/>
+ <points x="-3" y="3"/>
+ <points x="-11" y="3"/>
+ </graphicsAlgorithmChildren>
+ <graphicsAlgorithmChildren xsi:type="al:Polygon" foreground="//@colors.2" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" x="74" y="67">
+ <points x="3" y="-3"/>
+ <points x="3" y="3"/>
+ <points x="11" y="3"/>
+ </graphicsAlgorithmChildren>
+ <graphicsAlgorithmChildren xsi:type="al:Polygon" foreground="//@colors.2" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" x="74" y="67">
+ <points x="-2" y="-3"/>
+ <points x="-2" y="3"/>
+ <points x="2" y="3"/>
+ <points x="2" y="-3"/>
+ </graphicsAlgorithmChildren>
+ </graphicsAlgorithmChildren>
+ </graphicsAlgorithm>
+ <link>
+ <businessObjects href="../Tests.room#SimpleState:TestCaseActor$testing"/>
+ </link>
+ <anchors xsi:type="pi:ChopboxAnchor" outgoingConnections="//@connections.2" referencedGraphicsAlgorithm="//@children.0/@children.2/@graphicsAlgorithm/@graphicsAlgorithmChildren.0"/>
+ <children visible="true">
+ <graphicsAlgorithm xsi:type="al:Text" background="//@colors.2" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0" width="148" height="73" x="30" y="30" font="//@fonts.0" horizontalAlignment="ALIGNMENT_CENTER" value="testing"/>
+ </children>
+ <children xsi:type="pi:ContainerShape" visible="true" active="true">
+ <properties key="obj-type" value="trp"/>
+ <properties key="item-kind" value="entp"/>
+ <graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="60" height="60" x="20">
+ <graphicsAlgorithmChildren xsi:type="al:Ellipse" background="//@colors.1" foreground="//@colors.2" lineWidth="1" transparency="0.0" width="11" height="11" x="25" y="25"/>
+ <graphicsAlgorithmChildren xsi:type="al:Polyline" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0">
+ <points x="27" y="33"/>
+ <points x="33" y="27"/>
+ </graphicsAlgorithmChildren>
+ <graphicsAlgorithmChildren xsi:type="al:Polyline" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0">
+ <points x="27" y="27"/>
+ <points x="33" y="33"/>
+ </graphicsAlgorithmChildren>
+ </graphicsAlgorithm>
+ <link>
+ <businessObjects href="../Tests.room#EntryPoint:TestCaseActor$testing$tpEnter"/>
+ </link>
+ <anchors xsi:type="pi:ChopboxAnchor" incomingConnections="//@connections.0"/>
+ <children visible="true">
+ <graphicsAlgorithm xsi:type="al:Text" background="//@colors.2" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0" width="60" height="22" font="//@fonts.0" verticalAlignment="ALIGNMENT_BOTTOM" value="tpEnter"/>
+ </children>
+ </children>
+ <children xsi:type="pi:ContainerShape" visible="true" active="true">
+ <properties key="obj-type" value="trp"/>
+ <properties key="item-kind" value="extp"/>
+ <graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="60" height="60" x="118" y="73">
+ <graphicsAlgorithmChildren xsi:type="al:Ellipse" background="//@colors.1" foreground="//@colors.2" lineWidth="1" transparency="0.0" width="11" height="11" x="25" y="25"/>
+ <graphicsAlgorithmChildren xsi:type="al:Polygon" background="//@colors.1" foreground="//@colors.2" lineWidth="1" filled="true" transparency="0.0" x="25" y="25">
+ <points x="5"/>
+ <points x="11" y="5"/>
+ <points x="5" y="11"/>
+ <points y="5"/>
+ </graphicsAlgorithmChildren>
+ </graphicsAlgorithm>
+ <link>
+ <businessObjects href="../Tests.room#ExitPoint:TestCaseActor$testing$tpFinish"/>
+ </link>
+ <anchors xsi:type="pi:ChopboxAnchor" outgoingConnections="//@connections.1"/>
+ <children visible="true">
+ <graphicsAlgorithm xsi:type="al:Text" background="//@colors.2" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0" width="60" height="22" y="37" font="//@fonts.0" horizontalAlignment="ALIGNMENT_RIGHT" verticalAlignment="ALIGNMENT_TOP" value="tpFinish"/>
+ </children>
+ </children>
+ </children>
+ <children xsi:type="pi:ContainerShape" visible="true" active="true">
+ <properties key="obj-type" value="state"/>
+ <graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="120" height="90" x="630" y="212">
+ <graphicsAlgorithmChildren xsi:type="al:RoundedRectangle" background="//@colors.3" foreground="//@colors.2" lineWidth="1" transparency="0.0" width="60" height="30" x="30" y="30" cornerHeight="20" cornerWidth="20">
+ <graphicsAlgorithmChildren xsi:type="al:RoundedRectangle" foreground="//@colors.2" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="15" height="8" x="35" y="3" cornerHeight="5" cornerWidth="5"/>
+ <graphicsAlgorithmChildren xsi:type="al:Polygon" foreground="//@colors.2" lineWidth="1" filled="false" lineVisible="true" transparency="0.0" x="30" y="24">
+ <points x="-3" y="-3"/>
+ <points x="-3" y="3"/>
+ <points x="-11" y="3"/>
+ </graphicsAlgorithmChildren>
+ <graphicsAlgorithmChildren xsi:type="al:Polygon" foreground="//@colors.2" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" x="30" y="24">
+ <points x="3" y="-3"/>
+ <points x="3" y="3"/>
+ <points x="11" y="3"/>
+ </graphicsAlgorithmChildren>
+ <graphicsAlgorithmChildren xsi:type="al:Polygon" foreground="//@colors.2" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" x="30" y="24">
+ <points x="-2" y="-3"/>
+ <points x="-2" y="3"/>
+ <points x="2" y="3"/>
+ <points x="2" y="-3"/>
+ </graphicsAlgorithmChildren>
+ </graphicsAlgorithmChildren>
+ </graphicsAlgorithm>
+ <link>
+ <businessObjects href="../Tests.room#SimpleState:TestCaseActor$timeout"/>
+ </link>
+ <anchors xsi:type="pi:ChopboxAnchor" incomingConnections="//@connections.2" referencedGraphicsAlgorithm="//@children.0/@children.3/@graphicsAlgorithm/@graphicsAlgorithmChildren.0"/>
+ <children visible="true">
+ <graphicsAlgorithm xsi:type="al:Text" background="//@colors.2" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0" width="60" height="30" x="30" y="30" font="//@fonts.0" horizontalAlignment="ALIGNMENT_CENTER" value="timeout"/>
+ </children>
+ </children>
+ <children xsi:type="pi:ContainerShape" visible="true" active="true">
+ <properties key="obj-type" value="state"/>
+ <graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="120" height="90" x="313" y="435">
+ <graphicsAlgorithmChildren xsi:type="al:RoundedRectangle" background="//@colors.3" foreground="//@colors.2" lineWidth="1" transparency="0.0" width="60" height="30" x="30" y="30" cornerHeight="20" cornerWidth="20">
+ <graphicsAlgorithmChildren xsi:type="al:RoundedRectangle" foreground="//@colors.2" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="15" height="8" x="35" y="3" cornerHeight="5" cornerWidth="5"/>
+ <graphicsAlgorithmChildren xsi:type="al:Polygon" foreground="//@colors.2" lineWidth="1" filled="false" lineVisible="true" transparency="0.0" x="30" y="24">
+ <points x="-3" y="-3"/>
+ <points x="-3" y="3"/>
+ <points x="-11" y="3"/>
+ </graphicsAlgorithmChildren>
+ <graphicsAlgorithmChildren xsi:type="al:Polygon" foreground="//@colors.2" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" x="30" y="24">
+ <points x="3" y="-3"/>
+ <points x="3" y="3"/>
+ <points x="11" y="3"/>
+ </graphicsAlgorithmChildren>
+ <graphicsAlgorithmChildren xsi:type="al:Polygon" foreground="//@colors.2" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" x="30" y="24">
+ <points x="-2" y="-3"/>
+ <points x="-2" y="3"/>
+ <points x="2" y="3"/>
+ <points x="2" y="-3"/>
+ </graphicsAlgorithmChildren>
+ </graphicsAlgorithmChildren>
+ </graphicsAlgorithm>
+ <link>
+ <businessObjects href="../Tests.room#SimpleState:TestCaseActor$finish"/>
+ </link>
+ <anchors xsi:type="pi:ChopboxAnchor" incomingConnections="//@connections.1" referencedGraphicsAlgorithm="//@children.0/@children.4/@graphicsAlgorithm/@graphicsAlgorithmChildren.0"/>
+ <children visible="true">
+ <graphicsAlgorithm xsi:type="al:Text" background="//@colors.2" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0" width="60" height="30" x="30" y="30" font="//@fonts.0" horizontalAlignment="ALIGNMENT_CENTER" value="finish"/>
+ </children>
+ </children>
+ </children>
+ <children xsi:type="pi:ContainerShape" active="true">
+ <properties key="obj-type" value="sg"/>
+ <graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="880" height="580" x="40" y="40">
+ <graphicsAlgorithmChildren xsi:type="al:RoundedRectangle" background="//@colors.1" foreground="//@colors.2" lineWidth="4" transparency="0.5" width="800" height="500" x="40" y="40" cornerHeight="20" cornerWidth="20"/>
+ <graphicsAlgorithmChildren xsi:type="al:RoundedRectangle" foreground="//@colors.2" lineWidth="4" filled="false" transparency="0.0" width="800" height="500" x="40" y="40" cornerHeight="20" cornerWidth="20"/>
+ </graphicsAlgorithm>
+ <link>
+ <businessObjects href="../Tests.room#StateGraph:TestCaseActor$testing$sg"/>
+ </link>
+ <children>
+ <graphicsAlgorithm xsi:type="al:Text" background="//@colors.2" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0" width="800" height="80" y="40" font="//@fonts.1" horizontalAlignment="ALIGNMENT_RIGHT" verticalAlignment="ALIGNMENT_TOP" value="/testing"/>
+ </children>
+ <children xsi:type="pi:ContainerShape" active="true">
+ <properties key="obj-type" value="trp"/>
+ <properties key="item-kind" value="entp"/>
+ <graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="80" height="80" x="54">
+ <graphicsAlgorithmChildren xsi:type="al:Ellipse" background="//@colors.1" foreground="//@colors.2" lineWidth="2" transparency="0.0" width="20" height="20" x="30" y="30"/>
+ <graphicsAlgorithmChildren xsi:type="al:Polyline" foreground="//@colors.2" lineWidth="2" filled="false" transparency="0.0">
+ <points x="33" y="47"/>
+ <points x="47" y="33"/>
+ </graphicsAlgorithmChildren>
+ <graphicsAlgorithmChildren xsi:type="al:Polyline" foreground="//@colors.2" lineWidth="2" filled="false" transparency="0.0">
+ <points x="33" y="33"/>
+ <points x="47" y="47"/>
+ </graphicsAlgorithmChildren>
+ </graphicsAlgorithm>
+ <link>
+ <businessObjects href="../Tests.room#EntryPoint:TestCaseActor$testing$tpEnter"/>
+ </link>
+ <anchors xsi:type="pi:ChopboxAnchor"/>
+ <children>
+ <graphicsAlgorithm xsi:type="al:Text" background="//@colors.2" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0" width="80" height="30" font="//@fonts.0" horizontalAlignment="ALIGNMENT_CENTER" verticalAlignment="ALIGNMENT_BOTTOM" value="tpEnter"/>
+ </children>
+ </children>
+ <children xsi:type="pi:ContainerShape" active="true">
+ <properties key="obj-type" value="trp"/>
+ <properties key="item-kind" value="extp"/>
+ <graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="80" height="80" x="708" y="500">
+ <graphicsAlgorithmChildren xsi:type="al:Ellipse" background="//@colors.1" foreground="//@colors.2" lineWidth="2" transparency="0.0" width="20" height="20" x="30" y="30"/>
+ <graphicsAlgorithmChildren xsi:type="al:Polygon" background="//@colors.1" foreground="//@colors.2" lineWidth="2" filled="true" transparency="0.0" x="30" y="30">
+ <points x="10"/>
+ <points x="20" y="10"/>
+ <points x="10" y="20"/>
+ <points y="10"/>
+ </graphicsAlgorithmChildren>
+ </graphicsAlgorithm>
+ <link>
+ <businessObjects href="../Tests.room#ExitPoint:TestCaseActor$testing$tpFinish"/>
+ </link>
+ <anchors xsi:type="pi:ChopboxAnchor"/>
+ <children>
+ <graphicsAlgorithm xsi:type="al:Text" background="//@colors.2" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0" width="80" height="30" y="50" font="//@fonts.0" horizontalAlignment="ALIGNMENT_CENTER" verticalAlignment="ALIGNMENT_TOP" value="tpFinish"/>
+ </children>
+ </children>
+ </children>
+ <connections xsi:type="pi:FreeFormConnection" visible="true" active="true" start="//@children.0/@children.1/@anchors.0" end="//@children.0/@children.2/@children.1/@anchors.0">
+ <properties key="obj-type" value="trans"/>
+ <graphicsAlgorithm xsi:type="al:Polyline" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0"/>
+ <link>
+ <businessObjects href="../Tests.room#InitialTransition:TestCaseActor$initial"/>
+ </link>
+ <connectionDecorators visible="true" locationRelative="true" location="1.0">
+ <graphicsAlgorithm xsi:type="al:Polygon" background="//@colors.2" foreground="//@colors.2" lineWidth="1" filled="true" transparency="0.0">
+ <points x="-15" y="5"/>
+ <points/>
+ <points x="-15" y="-5"/>
+ </graphicsAlgorithm>
+ </connectionDecorators>
+ <connectionDecorators visible="true" active="true" locationRelative="true" location="0.5">
+ <graphicsAlgorithm xsi:type="al:Text" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0" x="10" font="//@fonts.0" value="init"/>
+ </connectionDecorators>
+ </connections>
+ <connections xsi:type="pi:FreeFormConnection" visible="true" active="true" start="//@children.0/@children.2/@children.2/@anchors.0" end="//@children.0/@children.4/@anchors.0">
+ <properties key="obj-type" value="trans"/>
+ <graphicsAlgorithm xsi:type="al:Polyline" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0"/>
+ <link>
+ <businessObjects href="../Tests.room#ContinuationTransition:TestCaseActor$trFinish"/>
+ </link>
+ <connectionDecorators visible="true" locationRelative="true" location="1.0">
+ <graphicsAlgorithm xsi:type="al:Polygon" background="//@colors.1" foreground="//@colors.2" lineWidth="1" filled="true" transparency="0.0">
+ <points x="-15" y="5"/>
+ <points/>
+ <points x="-15" y="-5"/>
+ </graphicsAlgorithm>
+ </connectionDecorators>
+ <connectionDecorators visible="true" active="true" locationRelative="true" location="0.5">
+ <graphicsAlgorithm xsi:type="al:Text" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0" x="10" font="//@fonts.0" value="trFinish: "/>
+ </connectionDecorators>
+ </connections>
+ <connections xsi:type="pi:FreeFormConnection" visible="true" active="true" start="//@children.0/@children.2/@anchors.0" end="//@children.0/@children.3/@anchors.0">
+ <properties key="obj-type" value="trans"/>
+ <graphicsAlgorithm xsi:type="al:Polyline" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0"/>
+ <link>
+ <businessObjects href="../Tests.room#TriggeredTransition:TestCaseActor$trTimeout"/>
+ </link>
+ <connectionDecorators visible="true" locationRelative="true" location="1.0">
+ <graphicsAlgorithm xsi:type="al:Polygon" background="//@colors.2" foreground="//@colors.2" lineWidth="1" filled="true" transparency="0.0">
+ <points x="-15" y="5"/>
+ <points/>
+ <points x="-15" y="-5"/>
+ </graphicsAlgorithm>
+ </connectionDecorators>
+ <connectionDecorators visible="true" active="true" locationRelative="true" location="0.5">
+ <graphicsAlgorithm xsi:type="al:Text" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0" x="10" font="//@fonts.0" value="trTimeout: &lt;timeout:..."/>
+ </connectionDecorators>
+ </connections>
+ <colors red="227" green="238" blue="249"/>
+ <colors red="255" green="255" blue="255"/>
+ <colors/>
+ <colors red="200" green="200" blue="200"/>
+ <fonts name="Arial" size="8"/>
+ <fonts name="Arial" size="9" bold="true"/>
+</pi:Diagram>
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/etUnit/etUnit.c b/runtime/org.eclipse.etrice.runtime.c/src/common/etUnit/etUnit.c
index 6690371db..544ffaf8f 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/etUnit/etUnit.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/etUnit/etUnit.c
@@ -17,6 +17,7 @@
#include "debugging/etLogger.h"
#include "osal/etSema.h"
#include "runtime/etRuntime.h"
+#include "helpers/etTimeHelpers.h"
/*** member variables */
@@ -33,8 +34,7 @@ static etBool etUnit_testcaseSuccess[ETUNIT_MAX_TEST_CASES];
#define ETUNIT_FAILURE_TEXT_LEN 256
/* time measuring */
-static clock_t etUnit_startTime = 0;
-static clock_t etUnit_currentTime = 0;
+static etTime etUnit_startTime;
/* order */
#define ETUNIT_ORDER_MAX 16
@@ -46,6 +46,15 @@ typedef struct OrderInfo {
} OrderInfo;
static OrderInfo etUnit_orderInfo[ETUNIT_ORDER_MAX];
+static OrderInfo* getOrderInfo(etInt16 id) {
+ int i;
+ for (i = 0; i < ETUNIT_ORDER_MAX; ++i)
+ if (etUnit_orderInfo[i].id == id)
+ return etUnit_orderInfo + i;
+
+ return NULL;
+}
+
/* forward declarations of private functions */
static void expect_equal_int(etInt16 id, const char* message, etInt32 expected, etInt32 actual, const char* file, int line);
static void expect_range_int(etInt16 id, const char* message, etInt32 min, etInt32 max, etInt32 actual, const char* file, int line);
@@ -87,9 +96,8 @@ void etUnit_open(const char* testResultPath, const char* testFileName) {
}
/* prepare time measurement */
- etUnit_startTime = clock();
- etUnit_currentTime = clock();
- etLogger_logInfoF("Start Time: %ld", etUnit_startTime);
+ getTimeFromTarget(&etUnit_startTime);
+ etLogger_logInfoF("Start Time: %ld", etTimeHelpers_convertToMSec(&etUnit_startTime));
}
@@ -133,11 +141,20 @@ etInt16 etUnit_openTestCase(const char* testCaseName) {
}
void etUnit_closeTestCase(etInt16 id) {
- clock_t time = clock() - etUnit_currentTime;
- etUnit_currentTime = clock();
+ etTime time;
+ getTimeFromTarget(&time);
+ etTimeHelpers_subtract(&time, &etUnit_startTime);
+
+ OrderInfo* info = getOrderInfo(id);
+ if(info != NULL){
+ if (info->currentIndex != info->size) {
+ char testresult[ETUNIT_FAILURE_TEXT_LEN];
+ etUnit_handleExpect(id, ET_FALSE, "EXPECT_ORDER was not completed", NULL, NULL, 0, 0);
+ }
+ }
if (etUnit_reportfile != NULL) {
- etLogger_fprintf(etUnit_reportfile, "tc end %d: %d\n", id, time);
+ etLogger_fprintf(etUnit_reportfile, "tc end %d: %d\n", id, etTimeHelpers_convertToMSec(&time));
}
}
@@ -230,15 +247,6 @@ void expectRangeFloat64(etInt16 id, const char* message, etFloat64 min, etFloat6
expect_range_float(id, message, min, max, actual, file, line);
}
-static OrderInfo* getOrderInfo(etInt16 id) {
- int i;
- for (i = 0; i < ETUNIT_ORDER_MAX; ++i)
- if (etUnit_orderInfo[i].id == id)
- return etUnit_orderInfo + i;
-
- return NULL;
-}
-
void expectOrderStart(etInt16 id, etInt16* list, etInt16 size, const char* file, int line) {
int i;
for (i = 0; i < ETUNIT_ORDER_MAX; ++i)
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/etunit/EtUnit.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/etunit/EtUnit.java
index 1854a101e..a35241119 100644
--- a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/etunit/EtUnit.java
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/etunit/EtUnit.java
@@ -37,7 +37,6 @@ public class EtUnit {
private static BufferedWriter out = null;
private static long etUnit_startTime;
- private static long etUnit_currentTime;
private static int etUnit_nextCaseId = 1;
private static HashSet<Integer> failed = new HashSet<Integer>();
private static HashMap<Integer, OrderInfo> orderInfo = new HashMap<Integer, OrderInfo>();
@@ -65,7 +64,6 @@ public class EtUnit {
}
etUnit_startTime = System.currentTimeMillis();
- etUnit_currentTime = etUnit_startTime;
System.out.println("Start time: "+etUnit_startTime);
}
@@ -113,9 +111,15 @@ public class EtUnit {
}
public static void etUnit_closeTestCase(int id) {
- long time = System.currentTimeMillis() - etUnit_currentTime;
- etUnit_currentTime = System.currentTimeMillis();
+ long time = System.currentTimeMillis() - etUnit_startTime;
+ OrderInfo info = orderInfo.get(id);
+ if (info!=null) {
+ if (info.current != info.list.length) {
+ etUnit_handleExpect(id, false, "EXPECT_ORDER was not completed", null, null);
+ }
+ }
+
if (out!=null) {
try {
out.write("tc end "+id+": "+time+"\n");

Back to the top