diff options
author | Juergen Haug | 2013-10-22 14:38:32 +0000 |
---|---|---|
committer | Juergen Haug | 2013-11-02 12:47:30 +0000 |
commit | 23d82fb0ffe9ee58e75156c51805cb0658d480fa (patch) | |
tree | 039370fa7284033763809974005c3949dc960d22 /tests | |
parent | 51329b70ff39b6ce3b74e87d720fb1b7604a7a65 (diff) | |
download | org.eclipse.etrice-23d82fb0ffe9ee58e75156c51805cb0658d480fa.tar.gz org.eclipse.etrice-23d82fb0ffe9ee58e75156c51805cb0658d480fa.tar.xz org.eclipse.etrice-23d82fb0ffe9ee58e75156c51805cb0658d480fa.zip |
[tests] added extended choice point test
Change-Id: Ifee0c8f519e5f7a14581e6d59c7cb2378cd861b0
Diffstat (limited to 'tests')
8 files changed, 597 insertions, 2 deletions
diff --git a/tests/org.eclipse.etrice.generator.c.tests/make.xml b/tests/org.eclipse.etrice.generator.c.tests/make.xml index 28301f8c9..75186023b 100644 --- a/tests/org.eclipse.etrice.generator.c.tests/make.xml +++ b/tests/org.eclipse.etrice.generator.c.tests/make.xml @@ -279,6 +279,45 @@ <arg value="-lrt"/> </exec> + <!-- compile and link ChoicepointTestExtended --> + <mkdir dir="bin/ChoicePointTestExtended"/> + <exec dir="bin/ChoicePointTestExtended" executable="${gcc.path}/gcc" failonerror="true" output="${output}/build.txt" append="true"> + <arg value="-I../../src-gen/"/> + <arg value="-I${c-runtime.path}/src/common"/> + <arg value="-I${c-runtime.path}/src/config"/> + <arg value="-I${c-runtime.path}/src/platforms/${runtime.platform}"/> + <arg value="-c"/> + <arg value="-g3"/> + <arg value="-O0"/> + <arg value="-Wall"/> + <!--<arg value="-ansi"/>--> + <arg value="../../src-gen/ChoicePointTestExtended/Testee_event.c"/> + <arg value="../../src-gen/ChoicePointTestExtended/Testee_inherited_event.c"/> + <arg value="../../src-gen/ChoicePointTestExtended/Tester_event.c"/> + <arg value="../../src-gen/ChoicePointTestExtended/node6_cpExtTest.c"/> + <arg value="../../src-gen/ChoicePointTestExtended/node6_cpExtTest_Runner.c"/> + <arg value="../../src-gen/ChoicePointTestExtended/CPTestProtocol_event.c"/> + <arg value="../../src-gen/ChoicePointTestExtended/CPTestProtocol_inherited_event.c"/> + <arg value="../../src-gen/ChoicePointTestExtended/NavigationProtocol_event.c"/> + </exec> + <exec dir="bin/ChoicePointTestExtended" executable="${gcc.path}/gcc" failonerror="true" output="${output}/build.txt" append="true"> + <arg value="-L${c-runtime.path}/bin"/> + <arg value="-oChoicePointTestExtended.exe"/> + <arg value="Tester_event.o"/> + <arg value="Testee_inherited_event.o"/> + <arg value="Testee_event.o"/> + <arg value="node6_cpExtTest.o"/> + <arg value="node6_cpExtTest_Runner.o"/> + <arg value="CPTestProtocol_event.o"/> + <arg value="CPTestProtocol_inherited_event.o"/> + <arg value="NavigationProtocol_event.o"/> + + <!-- library has to be in the last position --> + <arg value="-lorg.eclipse.etrice.runtime.c"/> + <arg value="-lpthread"/> + <arg value="-lrt"/> + </exec> + <!-- compile and link SendingDataTestC --> <mkdir dir="bin/SendingDataTestC"/> <exec dir="bin/SendingDataTestC" executable="${gcc.path}/gcc" failonerror="true" output="${output}/build.txt" append="true"> diff --git a/tests/org.eclipse.etrice.generator.common.tests/models/ChoicePointTestExtended.room b/tests/org.eclipse.etrice.generator.common.tests/models/ChoicePointTestExtended.room new file mode 100644 index 000000000..154176106 --- /dev/null +++ b/tests/org.eclipse.etrice.generator.common.tests/models/ChoicePointTestExtended.room @@ -0,0 +1,532 @@ +RoomModel ChoicePointTestExtended { + + import room.basic.types.* from "Types.room" + + SubSystemClass SubSystem_CPTestExtended { + ActorRef tester_event: Tester_event + LogicalThread defaultThread + } + + abstract ActorClass Testee_event { + Interface { + Port navPort : NavigationProtocol_event + Port testPort0 : CPTestProtocol_event + Port testPort1 : CPTestProtocol_inherited_event + } + Structure { + external Port navPort + external Port testPort0 + external Port testPort1 + Attribute caseId : int32 + Attribute testValue : int32 + } + Behavior { + StateMachine { + Transition init: initial -> waiting { } + Transition tr0: waiting -> testSubState { + triggers { + <testInitialCP0: testPort0> + } + action { + "testValue = value;" + } + } + Transition tr1: waiting -> waiting { + triggers { + <setCaseId: navPort> + } + action { + "caseId = id;" + } + } + State testSubState { + subgraph { + Transition init: initial -> cp cp0 { } + Transition tr0: cp cp0 -> state2 + Transition tr1: cp cp0 -> state0 { + cond { + "testValue == 0" + } + } + Transition tr2: cp cp0 -> state1 { + cond { + "testValue == 1" + } + } + Transition tr3: my tp0 -> cp cp0 { + triggers { + <testTrCP0: testPort0> + } + action { + "testValue = value;" + } + } + + Transition tr6: my tp0 -> cp cp0 { + triggers { + <testTrCP0: testPort1> + } + action { + "testValue = value;" + } + } + Transition tr7: my tp0 -> cp cp0 { + triggers { + <testTrCP1: testPort1> + } + action { + "testValue = value;" + } + } + + + ChoicePoint cp0 + TransitionPoint tp0 + + State state0 { + entry { + "navPort.resultCP(1000);" + "testValue = -1;" + } + } + State state1 { + entry { + "navPort.resultCP(1001);" + "testValue = -1;" + } + } + State state2 { + entry { + "EXPECT_TRUE(caseId, \"testValue error\", testValue > 0);" + "navPort.resultCP(1002);" + "testValue = -1;" + } + } + + } + } + State waiting + } + } + } + + ActorClass Testee_inherited_event extends Testee_event{ + Structure { } + Behavior { + StateMachine { + RefinedState testSubState { + subgraph { + Transition tr4: my tp1 -> simpleState { + triggers { + <toNode: navPort guard { + "id == 1" + }> + } + } + Transition tr5: simpleState -> cp cp0 { + triggers { + <testCP0: testPort0> + } + action { + "testValue = value;" + "" + "navPort.onProtocol(10);" + "navPort.onMessage(100);" + } + } + Transition tr8: simpleState -> cp cp0 { + triggers { + <testCP0: testPort1> + } + action { + "testValue = value;" + "" + "navPort.onProtocol(11);" + "navPort.onMessage(100);" + } + } + Transition tr9: simpleState -> cp cp0 { + triggers { + <testCP1: testPort1> + } + action { + "testValue = value;" + "" + "navPort.onProtocol(11);" + "navPort.onMessage(101);" + } + } + Transition tr10: subState -> cp cp0 { + triggers { + <testCP0: testPort0> + } + action { + "testValue = value;" + "" + "navPort.onProtocol(10);" + "navPort.onMessage(100);" + } + } + Transition tr11: subState -> cp cp0 { + triggers { + <testCP0: testPort1> + } + action { + "testValue = value;" + "" + "navPort.onProtocol(11);" + "navPort.onMessage(100);" + } + } + Transition tr12: subState -> cp cp0 { + triggers { + <testCP1: testPort1> + } + action { + "testValue = value;" + "" + "navPort.onProtocol(11);" + "navPort.onMessage(101);" + } + } + Transition tr13: my tp1 -> subState { + triggers { + <toNode: navPort guard { + "id == 2" + }> + } + } + Transition tr14: my tp1 -> tp1 of exitPoints { + triggers { + <toNode: navPort guard { + "id == 3" + }> + } + } + Transition tr15: tp0 of exitPoints -> cp cp0 + Transition tr16: my tp1 -> choicePoint { + triggers { + <toNode: navPort guard { + "id==4" + }> + } + } + Transition tr17: cp cp1 -> cp cp0 + Transition tr18: choicePoint -> cp cp1 { + triggers { + <testCP0: testPort0> + } + action { + "testValue = value;" + "" + "navPort.onProtocol(10);" + "navPort.onMessage(100);" + } + } + Transition tr19: cp cp1 -> wrong { + cond { + "1 == 0" + } + } + Transition tr20: cp cp0 -> wrong { + cond { + "1 == 0" + } + } + Transition tr21: choicePoint -> cp cp1 { + triggers { + <testCP0: testPort1> + } + action { + "testValue = value;" + "" + "navPort.onProtocol(11);" + "navPort.onMessage(100);" + } + } + Transition tr22: choicePoint -> cp cp1 { + triggers { + <testCP1: testPort1> + } + action { + "testValue = value;" + "" + "navPort.onProtocol(11);" + "navPort.onMessage(101);" + } + } + ChoicePoint cp1 + TransitionPoint tp1 + State simpleState { + entry { + "navPort.onNode(1);" + } + } + State subState { + entry { + "navPort.onNode(2);" + } + subgraph { + Transition init: initial -> state0 { } + State state0 + } + } + State exitPoints { + subgraph { + Transition tr0: my tp1 -> state0 + Transition tr1: state0 -> my tp0 { + triggers { + <testCP0: testPort0> + } + action { + "testValue = value;" + "" + "navPort.onProtocol(10);" + "navPort.onMessage(100);" + } + } + Transition tr2: state0 -> my tp0 { + triggers { + <testCP0: testPort1> + } + action { + "testValue = value;" + "" + "navPort.onProtocol(11);" + "navPort.onMessage(100);" + } + } + Transition tr3: state0 -> my tp0 { + triggers { + <testCP1: testPort1> + } + action { + "testValue = value;" + "" + "navPort.onProtocol(11);" + "navPort.onMessage(101);" + } + } + ExitPoint tp0 + EntryPoint tp1 + State state0 { + entry { + "navPort.onNode(3);" + } + } + } + } + State choicePoint { + entry { + "navPort.onNode(4);" + } + } + State wrong + } + } + } + } + } + + ActorClass Tester_event { + Structure { + conjugated Port navPort : NavigationProtocol_event + conjugated Port testPort0 : CPTestProtocol_event + conjugated Port testPort1 : CPTestProtocol_inherited_event + ActorRef testee: Testee_inherited_event + Binding navPort and testee.navPort + Binding testPort0 and testee.testPort0 + Binding testPort1 and testee.testPort1 + Attribute caseId : int32 + Attribute nodeId : int32 = "1" + Attribute protocolId : int32 = "0" + Attribute messageId : int32 = "0" + Attribute testValue : int32= "0" + + Attribute testOrder[148] : int16 = "{ 1001, 1000, 1002, 1, 10, 100, 1000, 1, 10, 100, 1001, 1, 10, 100, 1002, 1, 11, 100, 1000, 1, 11, 100, 1001, 1, 11, 100, 1002, 1, 11, 101, 1000, 1, 11, 101, 1001, 1, 11, 101, 1002, 2, 10, 100, 1000, 2, 10, 100, 1001, 2, 10, 100, 1002, 2, 11, 100, 1000, 2, 11, 100, 1001, 2, 11, 100, 1002, 2, 11, 101, 1000, 2, 11, 101, 1001, 2, 11, 101, 1002, 3, 10, 100, 1000, 3, 10, 100, 1001, 3, 10, 100, 1002, 3, 11, 100, 1000, 3, 11, 100, 1001, 3, 11, 100, 1002, 3, 11, 101, 1000, 3, 11, 101, 1001, 3, 11, 101, 1002, 4, 10, 100, 1000, 4, 10, 100, 1001, 4, 10, 100, 1002, 4, 11, 100, 1000, 4, 11, 100, 1001, 4, 11, 100, 1002, 4, 11, 101, 1000, 4, 11, 101, 1001, 4, 11, 101, 1002, 99 }" + Attribute testOrderSize : int32 = "148" + Attribute testNodes : int32 = "4" + } + Behavior { + Operation test(){ + " + if(protocolId == 0) + testPort0.testCP0(testValue); + else if(protocolId == 1){ + if(messageId == 0) + testPort1.testCP0(testValue); + else if(messageId == 1) + testPort1.testCP1(testValue); + } + testValue++; + " + } + Operation next(){ + " + if(testValue > 2){ + testValue = 0; + messageId++; + if(protocolId == 0 && messageId > 0){ + protocolId++; + messageId = 0; + } + if(protocolId == 1 && messageId > 1){ + protocolId = 0; + messageId = 0; + nodeId++; + } + } + if(nodeId <= testNodes) + navPort.toNode(nodeId); + else { + EXPECT_ORDER_END(caseId, \"<|MODEL_LOCATION|>\", 99); + etUnit_testFinished(caseId); + } + " + } + Operation check(value : int32){ + "EXPECT_ORDER(caseId, \"<|MODEL_LOCATION|>\", value);" + } + Operation Tester_event() { + "caseId = etUnit_openAll(\"tmp\", \"ChoicePointTestExtended\", \"org.eclipse.etrice.generator.common.tests.ChoicePointTestExtended\", \"ChoicePointTest_case\");" + } + Operation ~Tester_event() { + "etUnit_closeAll(caseId);" + } + StateMachine { + Transition init: initial -> testInitial { + action { + "navPort.setCaseId(caseId);" + "EXPECT_ORDER_START(caseId, testOrder, testOrderSize);" + } + } + Transition tr0: testInitial -> testTr { + triggers { + <resultCP: navPort> + } + action { + "check(value);" + } + } + Transition tr7: testTr -> testTr1 { + triggers { + <resultCP: navPort> + } + action { + "check(value);" + } + } + Transition tr8: testTr1 -> testTr2 { + triggers { + <resultCP: navPort> + } + action { + "check(value);" + } + } + Transition tr1: testTr2 -> triggerTest { + triggers { + <onNode: navPort> + } + action { + "check(id);" + } + } + Transition tr4: testPath -> testPath { + triggers { + <onMessage: navPort> + } + action { + "check(id);" + } + } + Transition tr5: testPath -> onCP { + triggers { + <resultCP: navPort> + } + action { + "check(value);" + } + } + Transition tr9: onCP -> triggerTest { + triggers { + <onNode: navPort> + } + action { + "check(id);" + } + } + Transition tr10: triggerTest -> testPath { + triggers { + <onProtocol: navPort> + } + action { + "check(id);" + } + } + State testInitial { + entry { + "testPort0.testInitialCP0(1);" + } + } + State testTr { + entry { + "testPort0.testTrCP0(0);" + } + } + State triggerTest { + entry { + "test();" + } + } + State testTr1 { + entry { + "testPort1.testTrCP0(2);" + } + } + State testTr2 { + entry { + "next();" + } + } + State testPath + State onCP { + entry { + "next();" + } + } + } + } + } + + ProtocolClass NavigationProtocol_event { + incoming { + Message toNode(id: int32) + Message setCaseId(id : int32) + } + outgoing { + Message onNode(id: int32) + Message onProtocol(id : int32) + Message onMessage(id : int32) + Message resultCP(value: int32) + } + } + + ProtocolClass CPTestProtocol_event { + incoming { + Message testCP0(value: int32) + Message testTrCP0(value : int32) + Message testInitialCP0(value : int32) + } + + } + + ProtocolClass CPTestProtocol_inherited_event extends CPTestProtocol_event{ + incoming{ + Message testCP1(value: int32) + Message testTrCP1(value : int32) + } + } + + +}
\ No newline at end of file diff --git a/tests/org.eclipse.etrice.generator.common.tests/models/generator.c.tests.etmap b/tests/org.eclipse.etrice.generator.common.tests/models/generator.c.tests.etmap index 33600088e..220aebc1c 100644 --- a/tests/org.eclipse.etrice.generator.common.tests/models/generator.c.tests.etmap +++ b/tests/org.eclipse.etrice.generator.common.tests/models/generator.c.tests.etmap @@ -19,6 +19,8 @@ MappingModel CGenTest { SubSystemMapping scTest -> node5 { ThreadMapping dflt_thread -> DfltThread } - + SubSystemMapping cpExtTest -> node6 { + ThreadMapping defaultThread -> DfltThread + } } }
\ No newline at end of file diff --git a/tests/org.eclipse.etrice.generator.common.tests/models/generator.c.tests.room b/tests/org.eclipse.etrice.generator.common.tests/models/generator.c.tests.room index 782246258..ad93807d1 100644 --- a/tests/org.eclipse.etrice.generator.common.tests/models/generator.c.tests.room +++ b/tests/org.eclipse.etrice.generator.common.tests/models/generator.c.tests.room @@ -1,6 +1,7 @@ RoomModel CGenTests { import ChoicePointTest.* from "ChoicePointTest.room" + import ChoicePointTestExtended.* from "ChoicePointTestExtended.room" import DataDrivenTest.* from "DataDrivenTest.room" import HandlerTest.* from "HandlerTest.room" import SendingDataTestC.* from "SendingDataTestC.room" @@ -8,6 +9,7 @@ RoomModel CGenTests { LogicalSystem CGenTests { SubSystemRef cpTest: SubSystem_CPTest + SubSystemRef cpExtTest : SubSystem_CPTestExtended SubSystemRef ddTest: SubSystem_DataDriven SubSystemRef hdTest: SubSystem_HandlerTest SubSystemRef sdTest: SubSystem_SendingData diff --git a/tests/org.eclipse.etrice.generator.common.tests/models/generator.java.tests.etmap b/tests/org.eclipse.etrice.generator.common.tests/models/generator.java.tests.etmap index ba6b29eeb..a07bf9b80 100644 --- a/tests/org.eclipse.etrice.generator.common.tests/models/generator.java.tests.etmap +++ b/tests/org.eclipse.etrice.generator.common.tests/models/generator.java.tests.etmap @@ -58,5 +58,8 @@ MappingModel JavaGenTest { SubSystemMapping da7Test -> node16 { ThreadMapping dflt_thread -> DfltThread } + SubSystemMapping cpExtTest -> node17 { + ThreadMapping defaultThread -> DfltThread + } } }
\ No newline at end of file diff --git a/tests/org.eclipse.etrice.generator.common.tests/models/generator.java.tests.room b/tests/org.eclipse.etrice.generator.common.tests/models/generator.java.tests.room index d1c76070a..0d6365e27 100644 --- a/tests/org.eclipse.etrice.generator.common.tests/models/generator.java.tests.room +++ b/tests/org.eclipse.etrice.generator.common.tests/models/generator.java.tests.room @@ -2,6 +2,7 @@ RoomModel JavaGenTests { import HandlerTest.* from "HandlerTest.room" import ChoicePointTest.* from "ChoicePointTest.room" + import ChoicePointTestExtended.* from "ChoicePointTestExtended.room" import PingPongThreadTest.* from "PingPongThreadTest.room" import PingPongThreadTestReplPort.* from "PingPongThreadReplPortTest.room" import SendingDataTestJava.* from "SendingDataTestJava.room" @@ -20,6 +21,7 @@ RoomModel JavaGenTests { LogicalSystem JavaGenTests { SubSystemRef hdTest: SubSystem_HandlerTest SubSystemRef cpTest: SubSystem_CPTest + SubSystemRef cpExtTest : SubSystem_CPTestExtended SubSystemRef ppTest: SubSystem_PingPong SubSystemRef prTest: SubSystem_PingPongReplPort SubSystemRef sdTest: SubSystem_SendingData diff --git a/tests/org.eclipse.etrice.generator.common.tests/models/standard.etphys b/tests/org.eclipse.etrice.generator.common.tests/models/standard.etphys index f9c2453a4..66cb75180 100644 --- a/tests/org.eclipse.etrice.generator.common.tests/models/standard.etphys +++ b/tests/org.eclipse.etrice.generator.common.tests/models/standard.etphys @@ -17,6 +17,7 @@ PhysicalModel Standard { NodeRef node14: PC NodeRef node15: PC NodeRef node16: PC + NodeRef node17: PC } NodeClass PC { diff --git a/tests/org.eclipse.etrice.generator.java.tests/make.xml b/tests/org.eclipse.etrice.generator.java.tests/make.xml index 896bbbb8c..189c74afe 100644 --- a/tests/org.eclipse.etrice.generator.java.tests/make.xml +++ b/tests/org.eclipse.etrice.generator.java.tests/make.xml @@ -5,7 +5,7 @@ results into xunit xml. To work locally you should define in your environment - ETRICE_TARGET_PLATFORM=path to the eclipse folder of your Juno installation + ETRICE_TARGET_PLATFORM=path to the eclipse installation folder @author Henrik Rentz-Reichert --> @@ -157,6 +157,12 @@ <classpath path="${bin.path};${runtime.path}/bin;${modellib.path}/bin"/> </java> <echo>end ChoicePointTest</echo> + <echo>start ChoicePointTestExtended</echo> + <java output="${output}/runChoicePointTestExtended.txt" classname="ChoicePointTestExtended.Node_node17_cpExtTestRunner" fork="true" failonerror="true"> + <arg value="-headless"/> + <classpath path="${bin.path};${runtime.path}/bin;${modellib.path}/bin"/> + </java> + <echo>end ChoicePointTestExtended</echo> <echo>start PingPongThreadTest</echo> <java output="${output}/runPingPongThreadTest.txt" classname="PingPongThreadTest.Node_node6_ppTestRunner" fork="true" failonerror="true"> <arg value="-headless"/> @@ -263,6 +269,13 @@ <arg value="./tmp/ChoicePointTest.etu"/> <classpath refid="clspath"/> </java> + + <java output="${output}/convert.txt" classname="org.eclipse.etrice.etunit.converter.EtUnitReportConverter" fork="true" failonerror="true"> + <arg value="-suite"/> + <arg value="org.eclipse.etrice.generator.java.tests.ChoicePointTestExtended"/> + <arg value="./tmp/ChoicePointTestExtended.etu"/> + <classpath refid="clspath"/> + </java> <java output="${output}/convert.txt" append="true" classname="org.eclipse.etrice.etunit.converter.EtUnitReportConverter" fork="true" failonerror="true"> <arg value="-suite"/> @@ -376,6 +389,7 @@ <target name="copy_results" depends="set_tr"> <move file="./tmp/HandlerTest.xml" tofile="./tmp/JavaHandlerTest.xml"/> <move file="./tmp/ChoicePointTest.xml" tofile="./tmp/JavaChoicePointTest.xml"/> + <move file="./tmp/ChoicePointTestExtended.xml" tofile="./tmp/JavaChoicePointTestExtended.xml"/> <move file="./tmp/StaticConfigTest.xml" tofile="./tmp/JavaStaticConfigTest.xml"/> <move file="./tmp/DynamicConfigTest.xml" tofile="./tmp/JavaDynamicConfigTest.xml"/> <move file="./tmp/DataDrivenTest.xml" tofile="./tmp/JavaDataDrivenTest.xml"/> |