diff options
author | Jan Belle | 2017-09-13 14:56:05 +0000 |
---|---|---|
committer | Jan Belle | 2017-09-13 14:56:05 +0000 |
commit | d4cd43005dc9479d21b819f31dcc6cb51e020131 (patch) | |
tree | 3d25d79354000a7290ab59661aa79b24b2113466 | |
parent | 845441c200d2780920d2e1769e7a8758e2846c76 (diff) | |
download | org.eclipse.etrice-d4cd43005dc9479d21b819f31dcc6cb51e020131.tar.gz org.eclipse.etrice-d4cd43005dc9479d21b819f31dcc6cb51e020131.tar.xz org.eclipse.etrice-d4cd43005dc9479d21b819f31dcc6cb51e020131.zip |
[generator.tests] fixed gitignores and added missing models
13 files changed, 2920 insertions, 20 deletions
diff --git a/tests/org.eclipse.etrice.generator.c.tests/.gitignore b/tests/org.eclipse.etrice.generator.c.tests/.gitignore index 4f0e85af9..d2726d181 100644 --- a/tests/org.eclipse.etrice.generator.c.tests/.gitignore +++ b/tests/org.eclipse.etrice.generator.c.tests/.gitignore @@ -1,6 +1,2 @@ -bin -models -output -results -src-gen -log
\ No newline at end of file +src-gen/ +output/
\ No newline at end of file diff --git a/tests/org.eclipse.etrice.generator.c.tests/models/SendingDataTest.room b/tests/org.eclipse.etrice.generator.c.tests/models/SendingDataTest.room new file mode 100644 index 000000000..3494a48cf --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/models/SendingDataTest.room @@ -0,0 +1,605 @@ +RoomModel SendingDataTest { + + import room.basic.test.* from "../../../runtime/org.eclipse.etrice.modellib.c/model/Tests.room" + import room.basic.types.* from "../../../runtime/org.eclipse.etrice.modellib.c/model/Types.room" + import room.basic.language.* from "../../../runtime/org.eclipse.etrice.modellib.c/model/Language.room" + + ActorClass SendingDataTop { + @TestInstance + Structure { + ActorRef mrPing: MrPing + ActorRef mrPong: MrPong + Binding mrPong.PingPongPort and mrPing.PingPongPort + } + Behavior { } + } + + ActorClass MrPong { + Interface { + Port PingPongPort: PingPongProtocol + Port extTest: PCExternal + } + Structure { + external Port PingPongPort + external Port extTest + } + Behavior { + StateMachine { + Transition tr0: reply -> reply { + triggers { + <pingInt16: PingPongPort> + } + action { + "PingPongPort.pongInt16(d);" + } + } + Transition tr1: reply -> reply { + triggers { + <pingInt8: PingPongPort> + } + action { + "PingPongPort.pongInt8(d);" + } + } + Transition init: initial -> reply { } + Transition tr2: reply -> reply { + triggers { + <pingInt32: PingPongPort> + } + action { + "PingPongPort.pongInt32(d);" + } + } + Transition tr3: reply -> reply { + triggers { + <pingFloat32: PingPongPort> + } + action { + "PingPongPort.pongFloat32(d);" + } + } + Transition tr4: reply -> reply { + triggers { + <pingFloat64: PingPongPort> + } + action { + "PingPongPort.pongFloat64(d);" + } + } + Transition tr7: reply -> cp cp0 { + triggers { + <pingInt32Ref: PingPongPort guard { + "(*d)!=0" + }> + } + } + Transition tr8: cp cp0 -> reply { + action { + "PingPongPort.pongInt32((*d)+10);" + } + } + Transition tr6: cp cp0 -> reply { + cond { + "(*d)!=5" + } + action { + "PingPongPort.pongInt32(*d);" + } + } + Transition tr9: reply -> reply { + triggers { + <pingComplex: PingPongPort> + } + action { + "PingPongPort.pongComplex(d);" + } + } + Transition tr11: reply -> reply { + triggers { + <pingComplexRef: PingPongPort> + } + action { + "PingPongPort.pongComplex(d);" + } + } + Transition tr5: reply -> reply { + triggers { + <pingInt64: PingPongPort> + } + action { + "PingPongPort.pongInt64(d);" + } + } + Transition tr10: reply -> reply { + triggers { + <pingInt16Ref: PingPongPort> + } + action { + "PingPongPort.pongInt16(*d);" + } + } + Transition tr12: reply -> cp cp1 { + triggers { + <pingComplexRef: PingPongPort guard { + "d->i8ValPPD == 5" + }> + } + action { + "PingPongPort.pongComplex(d);" + } + } + Transition tr13: cp cp1 -> reply { + action { + "PingPongPort.pongComplex(d);" + } + } + Transition tr14: cp cp1 -> reply { + cond { + "d->i8ValPPD==7" + } + action { + "PingPongPort.pongComplex(d);" + } + } + Transition tr15: reply -> reply { + triggers { + <pingComplexDerived: PingPongPort> + } + action { + "PingPongPort.pongComplexDerived(d);" + } + } + Transition tr16: my tp0 -> my tp0 { + triggers { + <in1: extTest> + } + } + ChoicePoint cp0 + ChoicePoint cp1 + TransitionPoint tp0 + State reply + } + } + } + + ActorClass MrPing { + Interface { + conjugated Port PingPongPort: PingPongProtocol + } + Structure { + external Port PingPongPort + Attribute i8Val: int8="5" + Attribute i16Val:int16="19" + Attribute i32Val: int32 = "4711" + Attribute i64Val: int64 = "11470815" + Attribute i32Array [ 10 ]: int32="{0,1,2,3,4,5,6,7,8,9}" + Attribute f32Val: float32="3.14f" + Attribute f64Val: float64="7.987654321" + Attribute data: PingPongData + Attribute dataD: PingPongDataDerived + Attribute counter:int32 + Attribute caseId: int32 + Attribute lang: languageIndicator + Attribute resultlist [ 23 ]: int16 = "{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23}" + } + Behavior { + StateMachine { + Transition init: initial -> tp0 of state0 { + action { + "caseId = etUnit_openAll(\".\", \"SendingDataTest\", \"org.eclipse.etrice.generator.common.tests.SendingDataTest\", \"SendingDataTest_case\");" + "EXPECT_ORDER_START(caseId,resultlist,23);" + "EXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 1);" + "/* send the default values */" + "" + "PingPongPort.pingInt8(i8Val);" + "PingPongPort.pingInt16(i16Val);" + "PingPongPort.pingInt32(i32Val);" + "PingPongPort.pingInt64(i64Val);" + "PingPongPort.pingFloat32(f32Val);" + "PingPongPort.pingFloat64(f64Val);" + "PingPongPort.pingInt16Ref(&i16Val);" + "PingPongPort.pingInt32Ref(&i32Val);" + "i8Val++;" + "i16Val++;" + "i32Val++;" + "i64Val++;" + "f32Val+=10.1;" + "f64Val+=20.2;" + "PingPongPort.pingInt8(i8Val);" + "PingPongPort.pingInt16(i16Val);" + "PingPongPort.pingInt32(i32Val);" + "PingPongPort.pingInt64(i64Val);" + "PingPongPort.pingFloat32(f32Val);" + "PingPongPort.pingFloat64(f64Val);" + "PingPongPort.pingInt16Ref(&i16Val);" + "PingPongPort.pingInt32Ref(&i32Val);" + } + } + Transition tr0: tp1 of state0 -> tp0 of state1 + Transition tr1: tp1 of state1 -> test_finished + State state0 { + subgraph { + Transition tr0: my tp0 -> receiveFirst7 { + action { + "counter=0;" + } + } + Transition tr1: receiveFirst7 -> receiveFirst7 { + triggers { + <pongInt8: PingPongPort> + } + action { + "counter++;" + "if (d==5){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 2);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + Transition tr2: receiveFirst7 -> receiveFirst7 { + triggers { + <pongInt16: PingPongPort> + } + action { + "counter++;" + "if (d==19){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 3);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + Transition tr3: receiveFirst7 -> receiveFirst7 { + triggers { + <pongInt32: PingPongPort> + } + action { + "counter++;" + "if (d==4711){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 4);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + Transition tr4: receiveFirst7 -> receiveSecond7 { + triggers { + <pongInt32: PingPongPort guard { + "counter==7" + }> + } + action { + "counter=0;" + "if (lang == 1){" + "/* Java cannot send references of primitive types */" + "\tif (d==4711){\t" + "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 9);" + "\t}else{" + "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "\t}" + "} " + "if (lang == 2){" + "/* C */" + "\tif (d==4712){\t" + "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 9);" + "\t}else{" + "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "\t}" + "}" + } + } + Transition tr6: receiveFirst7 -> receiveFirst7 { + triggers { + <pongInt64: PingPongPort> + } + action { + "counter++;" + "if (d==11470815){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 5);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + Transition tr5: receiveFirst7 -> receiveFirst7 { + triggers { + <pongFloat32: PingPongPort> + } + action { + "counter++;" + "if ((d>3)&&(d<4)){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 6);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + Transition tr7: receiveFirst7 -> receiveFirst7 { + triggers { + <pongFloat64: PingPongPort> + } + action { + "counter++;" + "if ((d>7)&&(d<8)){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 7);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + Transition tr8: receiveSecond7 -> receiveSecond7 { + triggers { + <pongInt8: PingPongPort> + } + action { + "counter++;" + "if (d==6){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 10);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + Transition tr9: receiveSecond7 -> receiveSecond7 { + triggers { + <pongInt16: PingPongPort> + } + action { + "counter++;" + "if (d==20){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 11);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + Transition tr10: receiveSecond7 -> receiveSecond7 { + triggers { + <pongInt32: PingPongPort> + } + action { + "counter++;" + "if (d==4712){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 12);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + Transition tr11: receiveSecond7 -> receiveSecond7 { + triggers { + <pongInt64: PingPongPort> + } + action { + "counter++;" + "if (d==11470816){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 13);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + Transition tr12: receiveSecond7 -> receiveSecond7 { + triggers { + <pongFloat32: PingPongPort> + } + action { + "counter++;" + "if ((d>13)&&(d<14)){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 14);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + Transition tr13: receiveSecond7 -> receiveSecond7 { + triggers { + <pongFloat64: PingPongPort> + } + action { + "counter++;" + "if ((d>28)&&(d<29)){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 15);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + Transition tr14: receiveSecond7 -> my tp1 { + triggers { + <pongInt32: PingPongPort guard { + "counter==7" + }> + } + action { + "if (d==4712){\t" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 17);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + Transition tr15: receiveFirst7 -> receiveFirst7 { + triggers { + <pongInt16: PingPongPort guard { + "counter==6" + }> + } + action { + "counter++;" + "if (lang == 1){" + "/* Java cannot send references of primitive types */" + "\tif (d==19){\t" + "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 8);" + "\t}else{" + "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "\t}" + "} " + "if (lang == 2){" + "/* C */" + "\tif (d==20){\t" + "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 8);" + "\t}else{" + "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "\t}" + "}" + } + } + Transition tr16: receiveSecond7 -> receiveSecond7 { + triggers { + <pongInt16: PingPongPort guard { + "counter==6" + }> + } + action { + "counter++;" + "if (d==20){\t" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 16);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + EntryPoint tp0 + ExitPoint tp1 + State receiveFirst7 + State receiveSecond7 + } + } + State test_finished { + entry { + "EXPECT_ORDER_END(caseId,\"<|MODEL_LOCATION|>\", 23);" + "etUnit_closeAll(caseId);" + "etUnit_testFinished(caseId);" + } + } + State state1 { + subgraph { + Transition tr0: my tp0 -> state0 { + action { + "counter=0;" + "/* send default values */" + "PingPongPort.pingComplex(&(data));" + "PingPongPort.pingComplexRef(&(data));" + } + } + Transition tr1: state0 -> state1 { + triggers { + <pongComplex: PingPongPort guard { + "counter==1" + }> + } + action { + "counter=0;" + "if (d->i8ValPPD==10){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 19);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + "" + "if (d->complexVal.i32Val2PPDD==80){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 20);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + "" + "dataD.i8ValPPD=11;" + "PingPongPort.pingComplexDerived(&(dataD));" + } + } + Transition tr2: state0 -> state0 { + triggers { + <pongComplex: PingPongPort> + } + action { + "counter++;" + "if (d->i8ValPPD==10){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 18);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + Transition tr3: state1 -> my tp1 { + triggers { + <pongComplexDerived: PingPongPort> + } + action { + "if (d->i8ValPPD==11){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 21);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + "" + "if (d->i32Val3PPDe==150){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 22);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + EntryPoint tp0 + ExitPoint tp1 + State state0 + State state1 + } + } + } + } + } + + ProtocolClass PingPongProtocol { + incoming { + Message pingInt8(d: int8) + Message pingInt16(d: int16) + Message pingInt32(d: int32) + Message pingInt64(d: int64) + Message pingFloat32(d: float32) + Message pingFloat64(d: float64) + Message pingInt16Ref(d: int16 ref) + Message pingInt32Ref(d: int32 ref) + Message pingComplex(d: PingPongData) + Message pingComplexRef(d: PingPongData ref) + Message pingComplexDerived(d:PingPongDataDerived) + } + outgoing { + Message pongInt8(d: int8) + Message pongInt16(d: int16) + Message pongInt32(d: int32) + Message pongInt64(d:int64) + Message pongFloat32(d: float32) + Message pongFloat64(d: float64) + Message pongComplex(d: PingPongData) + Message pongComplexDerived(d: PingPongDataDerived) + } + } + + ProtocolClass PCExternal { + usercode1 { + "typedef int extMsg;" + } + incoming { + Message in1(can: DExtMsg) + } + } + + DataClass PingPongData { + Attribute i8ValPPD: int8 = "10" + Attribute i8ValRefPPD: int8 ref + Attribute i32ArrayPPD [ 3 ]: int32 = "{200,300,400}" + Attribute i8ArrayRefPPD [ 2 ]: int8 ref + Attribute complexVal: PingPongDataDeep + } + + DataClass PingPongDataDeep { + Attribute i32Val1PPDD: int32 + Attribute i32Val2PPDD: int32 = "80" + } + + DataClass PingPongDataDerived extends PingPongData { + Attribute i32Val3PPDe: int32 = "150" + } + + ExternalType DExtMsg -> "extMsg" +}
\ No newline at end of file diff --git a/tests/org.eclipse.etrice.generator.c.tests/models/StaticConfigTest.config b/tests/org.eclipse.etrice.generator.c.tests/models/StaticConfigTest.config new file mode 100644 index 000000000..426adc5e6 --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/models/StaticConfigTest.config @@ -0,0 +1,141 @@ +ConfigModel StaticTestConfig { + + import StaticConfigTest.* from "StaticConfigTest.room" + + ActorClassConfig Tester_ac { + // nothing + } + + ActorClassConfig Testee_1_ac { + Attr data_1 { + Attr bool_c = false + Attr bool_i = false + Attr int8_c = 24 + Attr int8_i = 24 + Attr int16_c = 48 + Attr int16_i = 48 + Attr int32_c = 96 + Attr int32_i = 96 + Attr int64_c = 192 + Attr int64_i = 192 + Attr float32_c = 9.6 + Attr float32_i = 9.6 + Attr float64_c = 19.2 + Attr float64_i = 19.2 + Attr char_c = "C" + Attr char_i = "C" + Attr string_c = ":)" + Attr string_i = ":)" + + Attr bool_array_c = true, false + Attr bool_array_i = true, false + Attr int8_array_c = 24, 48 + Attr int8_array_i = 24, 48 + Attr int16_array_c = 48, 96 + Attr int16_array_i = 48, 96 + Attr int32_array_c = 96, 192 + Attr int32_array_i = 96, 192 + Attr int64_array_c = 192, 384 + Attr int64_array_i = 192, 384 + Attr float32_array_c = 9.6 + Attr float32_array_i = 9.6 + Attr float64_array_c = 19.2 + Attr float64_array_i = 19.2 + Attr char_array_c = "Claz" + Attr char_array_i = "Claz" + + Attr data_2 { + Attr int32_c = 42 + Attr int32_i = 42 + } + } + Attr enumval1 = Enum_1.two + Attr enumval2 = Enum_2.three + } + + ActorClassConfig Testee_Super2_ac { + Attr float64_super_c = 2.2 + Attr float64_super_i = 2.2 + } + + ActorClassConfig Testee_2_ac { + Attr int32_own_c = 12 + Attr int32_own_i = 12 + } + + ProtocolClassConfig TestProtocolAttributes { + regular Port{ + Attr float_c = 3.0 + Attr float_i = 3.0 + } + conjugate Port { + Attr array2_c = 16, 32 + Attr array2_i = 16, 32 + } + } + + ProtocolClassConfig TestProtocolWithDataClass { + conjugate Port { + Attr sap_data_2{ + Attr int32_c = 2 + Attr int32_i = 2 + } + } + } + + ActorInstanceConfig System_StaticConfigTest/main/top/tester { + // nothing + } + + ActorInstanceConfig System_StaticConfigTest/main/top/testee_1 { + Attr data_1 { + Attr bool_i = true + Attr int8_i = 2 + Attr int16_i = 4 + Attr int32_i = 8 + Attr int64_i = 16 + Attr float32_i = 1.6 + Attr float64_i = 3.2 + Attr char_i = "I" + Attr string_i = ":]" + + Attr bool_array_i = true, true + Attr int8_array_i = 2, 6 + Attr int16_array_i = 4, 12 + Attr int32_array_i = 8, 24 + Attr int64_array_i = 16, 48 + Attr float32_array_i = 1.6 + Attr float64_array_i = 3.2 + Attr char_array_i = "Inst" + + Attr data_2 { + Attr int32_i = 43 + } + } + InterfaceItem conj_port { + Attr array2_i = 1, 2 + } + } + + + ActorInstanceConfig System_StaticConfigTest/main/top/tester/testee_super2{ + Attr float64_super_i = 3.3 + InterfaceItem reg_port { + Attr float_i = 25.0 + } + } + + ActorInstanceConfig System_StaticConfigTest/main/top/testee_1/testee_2 { + Attr float64_super_i = 4.4 + Attr int32_own_i = 13 + InterfaceItem reg_port { + Attr float_i = 50.0 + } + InterfaceItem sap { + Attr sap_data_2 { + Attr int32_i = 3 + } + } + } + +}
\ No newline at end of file diff --git a/tests/org.eclipse.etrice.generator.c.tests/models/StaticConfigTest.etmap b/tests/org.eclipse.etrice.generator.c.tests/models/StaticConfigTest.etmap new file mode 100644 index 000000000..c0f26f88d --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/models/StaticConfigTest.etmap @@ -0,0 +1,10 @@ +MappingModel StaticConfigTest { + + import StaticConfigTest.* from "StaticConfigTest.room" + import room.generic.physical.* from "../../org.eclipse.etrice.generator.common.tests/models/GenericPhysical.etphys" + + Mapping System_StaticConfigTest -> GenericPhysicalSystem { + SubSystemMapping main -> node {} + } + +}
\ No newline at end of file diff --git a/tests/org.eclipse.etrice.generator.c.tests/models/StaticConfigTest.room b/tests/org.eclipse.etrice.generator.c.tests/models/StaticConfigTest.room new file mode 100644 index 000000000..ac8dc0a46 --- /dev/null +++ b/tests/org.eclipse.etrice.generator.c.tests/models/StaticConfigTest.room @@ -0,0 +1,421 @@ +RoomModel StaticConfigTest { + + import room.basic.types.* from "../../../runtime/org.eclipse.etrice.modellib.c/model/Types.room" + import room.basic.service.timing.* from "../../../runtime/org.eclipse.etrice.modellib.c/model/TimingService.room" + + LogicalSystem System_StaticConfigTest { + SubSystemRef main : SubSystem_StaticConfigTest + } + + SubSystemClass SubSystem_StaticConfigTest { + LayerConnection ref top satisfied_by timer.timer + ActorRef top: Top_ac + ActorRef timer : ATimingService + } + + ActorClass Top_ac { + Structure { + ActorRef testee_1: Testee_1_ac + ActorRef tester: Tester_ac + LayerConnection ref testee_1 satisfied_by tester.spp + SAP timer : PTimer + } + Behavior { + ctor { + "etUnit_open(\".\", \"StaticConfigTest\");" + "etUnit_openTestSuite(\"org.eclipse.etrice.generator.common.tests.StaticConfigTest\");" + } + dtor { + "etUnit_closeTestSuite();" + "etUnit_close();" + } + StateMachine { + Transition init: initial -> state0 { + action { + "timer.startTimeout(1000);" + } + } + Transition tr0: state0 -> state0 { + triggers { + <timeout: timer> + } + action { + "etUnit_testFinished(-1);" + } + } + State state0 + } + } + } + + ActorClass Tester_ac { + Interface { + SPP spp: TestProtocolWithDataClass + } + Structure { + ServiceImplementation of spp + Attribute caseId: int32 + + // none config test + Attribute data_3: Data_3_dc + ActorRef testee_super2: Testee_Super2_ac + } + Behavior { + StateMachine { + Transition init: initial -> s1 { } + State s1 { + entry { + "caseId = etUnit_openTestCase(\"AttrConfigTest_case_Tester_ac\");" + "Data_3_dc_varCheck3(&(data_3), caseId);" + "etUnit_closeTestCase(caseId);" + } + } + } + } + } + + ActorClass Testee_1_ac { + Interface { + conjugated Port conj_port: TestProtocolAttributes + } + Structure { + usercode1 { + "#include \"etUnit/etUnit.h\"" + } + external Port conj_port + Attribute caseId: int32 + Attribute data_1: Data_1_dc + Attribute enumval1: Enum_1 = "one" + Attribute enumval2: Enum_2 = "four" + ActorRef testee_2: Testee_2_ac + } + Behavior { + StateMachine { + Transition init: initial -> s1 { } + State s1 { + entry { + "caseId = etUnit_openTestCase(\"AttrConfigTest_case_Testee_1_ac\");" + "Data_1_dc_varCheck1(&(data_1), caseId);" + "EXPECT_FALSE(caseId,\"testee_1:data_1:1\", data_1.bool_c);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:2\", data_1.int8_c == 24);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:3\", data_1.int16_c == 48);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:4\", data_1.int32_c == 96);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:5\", data_1.int64_c == 192);" + "EXPECT_EQUAL_FLOAT32(caseId,\"testee_1:data_1:6\", 9.6f, data_1.float32_c, 0.1f);" + "EXPECT_EQUAL_FLOAT64(caseId,\"testee_1:data_1:7\", 19.2, data_1.float64_c, 0.1);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:8\", data_1.char_c == \'C\');" + "EXPECT_TRUE(caseId,\"testee_1:varCheck:8.1\", strcmp(data_1.string_c, \":)\") == 0 );" + "EXPECT_TRUE(caseId,\"testee_1:data_1:10\", data_1.bool_i);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:11\", data_1.int8_i == 2);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:12\", data_1.int16_i == 4);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:13\", data_1.int32_i == 8);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:14\", data_1.int64_i == 16);" + "EXPECT_EQUAL_FLOAT32(caseId,\"testee_1:data_1:15\", 1.6f, data_1.float32_i, 0.1f);" + "EXPECT_EQUAL_FLOAT64(caseId,\"testee_1:data_1:16\", 3.2, data_1.float64_i, 0.1);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:17\", data_1.char_i == \'I\');" + "EXPECT_TRUE(caseId,\"testee_1:varCheck:18\", strcmp(data_1.string_i, \":]\") == 0 );" + + // Array + "EXPECT_TRUE(caseId,\"testee_1:data_1:19\", data_1.bool_array_c[0] == ET_TRUE && data_1.bool_array_c[1] == ET_FALSE);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:20\", data_1.int8_array_c[0] == 24 && data_1.int8_array_c[1] == 48);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:21\", data_1.int16_array_c[0] == 48 && data_1.int16_array_c[1] == 96);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:22\", data_1.int32_array_c[0] == 96 && data_1.int32_array_c[1] == 192);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:23\", data_1.int64_array_c[0] == 192 && data_1.int64_array_c[1] == 384);" + "EXPECT_EQUAL_FLOAT32(caseId, \"testee_1:data_1:24_1\", 9.6f, data_1.float32_array_c[0], 0.1f);" + "EXPECT_EQUAL_FLOAT32(caseId, \"testee_1:data_1:24_2\", 9.6f, data_1.float32_array_c[1], 0.1f);" + "EXPECT_EQUAL_FLOAT64(caseId, \"testee_1:data_1:25_1\", 19.2, data_1.float64_array_c[0], 0.1);" + "EXPECT_EQUAL_FLOAT64(caseId, \"testee_1:data_1:25_2\", 19.2, data_1.float64_array_c[1], 0.1);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:26\", strcmp(data_1.char_array_c, \"Claz\") == 0);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:27\", data_1.bool_array_i[0] == ET_TRUE && data_1.bool_array_i[1] == ET_TRUE);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:28\", data_1.int8_array_i[0] == 2 && data_1.int8_array_i[1] == 6);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:29\", data_1.int16_array_i[0] == 4 && data_1.int16_array_i[1] == 12);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:30\", data_1.int32_array_i[0] == 8 && data_1.int32_array_i[1] == 24);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:31\", data_1.int64_array_i[0] == 16 && data_1.int64_array_i[1] == 48);" + "EXPECT_EQUAL_FLOAT32(caseId, \"testee_1:data_1:32_1\", 1.6f, data_1.float32_array_i[0], 0.1f);" + "EXPECT_EQUAL_FLOAT32(caseId, \"testee_1:data_1:32_2\", 1.6f, data_1.float32_array_i[1], 0.1f);" + "EXPECT_EQUAL_FLOAT64(caseId, \"testee_1:data_1:33_1\", 3.2, data_1.float64_array_i[0], 0.1);" + "EXPECT_EQUAL_FLOAT64(caseId, \"testee_1:data_1:33_2\", 3.2, data_1.float64_array_i[1], 0.1);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:34\", strcmp(data_1.char_array_i, \"Inst\") == 0);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:35\", data_1.data_2.int32_c == 42);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:36\", data_1.data_2.int32_i == 43);" + + // conj_port + "EXPECT_TRUE(caseId,\"testee_1:conj_port:36\", ((TestProtocolAttributesConjPort_var*)self->constData->conj_port.varData)->array2_r[0] == 11);" + "EXPECT_TRUE(caseId,\"testee_1:conj_port:37\", ((TestProtocolAttributesConjPort_var*)self->constData->conj_port.varData)->array2_r[1] == 22);" + "EXPECT_TRUE(caseId,\"testee_1:conj_port:38\", ((TestProtocolAttributesConjPort_var*)self->constData->conj_port.varData)->array2_c[0] == 16);" + "EXPECT_TRUE(caseId,\"testee_1:conj_port:39\", ((TestProtocolAttributesConjPort_var*)self->constData->conj_port.varData)->array2_c[1] == 32);" + "EXPECT_TRUE(caseId,\"testee_1:conj_port:40\", ((TestProtocolAttributesConjPort_var*)self->constData->conj_port.varData)->array2_i[0] == 1);" + "EXPECT_TRUE(caseId,\"testee_1:conj_port:41\", ((TestProtocolAttributesConjPort_var*)self->constData->conj_port.varData)->array2_i[1] == 2);" + "etUnit_testFinished(caseId);" + + // enums + "EXPECT_TRUE(caseId,\"testee_1:enumval1\", enumval1 == Enum_1.two);" + "EXPECT_TRUE(caseId,\"testee_1:enumval2\", enumval2 == Enum_2.three);" + "etUnit_closeTestCase(caseId);" + } + } + } + } + } + + ActorClass Testee_Super2_ac { + Interface { + Port reg_port: TestProtocolAttributes + } + Structure { + usercode1 { + "#include \"etUnit/etUnit.h\"" + } + external Port reg_port + Attribute caseId: int32 + + // test + Attribute data_2: Data_2_dc + Attribute float64_super_r: float64 = "1.1" + Attribute float64_super_c: float64 = "1.1" + Attribute float64_super_i: float64 = "1.1" + } + Behavior { + ctor { + "testInstanceConfig();" + } + Operation testInstanceConfig(){ + "caseId = etUnit_openTestCase(\"AttrConfigTest_case_Testee_Super2_ac\");" + "EXPECT_EQUAL_FLOAT64(caseId, \"Testee_Super2_ac:1\", 1.1, float64_super_r, 0.1);" + "EXPECT_EQUAL_FLOAT64(caseId, \"Testee_Super2_ac:2\", 2.2, float64_super_c, 0.1);" + "EXPECT_EQUAL_FLOAT64(caseId, \"Testee_Super2_ac:3\", 3.3, float64_super_i, 0.1);" + "EXPECT_EQUAL_FLOAT32(caseId, \"Testee_Super2_ac:7\", 25.0f, ((TestProtocolAttributesPort_var*) self->constData->reg_port.varData)->float_i, 0.1f);" + // reg_port + "EXPECT_EQUAL_FLOAT32(caseId, \"Testee_Super2_ac:5\", 4.0f, ((TestProtocolAttributesPort_var*) self->constData->reg_port.varData)->float_r, 0.1f);" + "EXPECT_EQUAL_FLOAT32(caseId, \"Testee_Super2_ac:6\", 3.0f, ((TestProtocolAttributesPort_var*) self->constData->reg_port.varData)->float_c, 0.1f);" + "etUnit_closeTestCase(caseId);" + } + } + } + + ActorClass Testee_2_ac extends Testee_Super2_ac { + Structure { + SAP sap: TestProtocolWithDataClass + Attribute int32_own_r: int32 = "11" + Attribute int32_own_c: int32 = "11" + Attribute int32_own_i: int32 = "11" + } + Behavior { + override Operation testInstanceConfig(){ + "caseId = etUnit_openTestCase(\"AttrConfigTest_case_Testee_2_ac\");" + "EXPECT_EQUAL_FLOAT64(caseId, \"Testee_2_ac:2\", 4.4, float64_super_i, 0.1);" + "EXPECT_EQUAL_FLOAT32(caseId, \"Testee_2_ac:9\", 50.0f, ((TestProtocolAttributesPort_var*) self->constData->reg_port.varData)->float_i, 0.1f);" + } + StateMachine { + Transition init: initial -> s1 { } + State s1 { + entry { + "EXPECT_EQUAL_FLOAT64(caseId, \"Testee_2_ac:1\", 2.2, float64_super_c, 0.1);" + "EXPECT_TRUE(caseId, \"Testee_2_ac:3\", int32_own_r == 11);" + "EXPECT_TRUE(caseId, \"Testee_2_ac:4\", int32_own_c == 12);" + "EXPECT_TRUE(caseId, \"Testee_2_ac:5\", int32_own_i == 13);" + + // reg_port + "EXPECT_EQUAL_FLOAT32(caseId, \"Testee_2_ac:6\", 4.0f, ((TestProtocolAttributesPort_var*) self->constData->reg_port.varData)->float_r, 0.1f);" + "EXPECT_EQUAL_FLOAT32(caseId, \"Testee_2_ac:7\", 3.0f, ((TestProtocolAttributesPort_var*) self->constData->reg_port.varData)->float_c, 0.1f);" + + // sap + "Data_3_dc_varCheck3(&(((TestProtocolWithDataClassConjPort_var*)self->constData->sap.varData)->sap_data_3), caseId);" + "EXPECT_TRUE(caseId, \"Testee_2_ac:sap:10\", ((TestProtocolWithDataClassConjPort_var*)self->constData->sap.varData)->sap_data_2.int32_r == 1);" + "EXPECT_TRUE(caseId, \"Testee_2_ac:sap:11\", ((TestProtocolWithDataClassConjPort_var*)self->constData->sap.varData)->sap_data_2.int32_c == 2);" + "EXPECT_TRUE(caseId, \"Testee_2_ac:sap:12\", ((TestProtocolWithDataClassConjPort_var*)self->constData->sap.varData)->sap_data_2.int32_i == 3);" + "etUnit_closeTestCase(caseId);" + } + } + } + } + } + + ProtocolClass TestProtocolAttributes { + incoming { + Message dummy() + } + regular PortClass + { + Attribute float_r: float32 = "4" + Attribute float_c: float32 = "16" + Attribute float_i: float32 = "256" + } + conjugated PortClass + { + Attribute array2_r [ 2 ]: int64 = "{11,22}" + Attribute array2_c [ 2 ]: int64 = "{0,0}" + Attribute array2_i [ 2 ]: int64 = "{0,0}" + } + } + + ProtocolClass TestProtocolWithDataClass { + usercode1 { + "#include \"Data_2_dc.h\"" + "#include \"Data_3_dc.h\"" + } + incoming { + Message dummy() + } + + //SAP + conjugated PortClass + { + Attribute sap_data_2: Data_2_dc + + // none config test + Attribute sap_data_3: Data_3_dc + } + } + + ExternalType extType -> "int" default "999" + + DataClass Data_Super1_dc { + // PrimitiveType + Attribute bool_r: boolean = "false" + Attribute bool_c: boolean = "false" + Attribute bool_i: boolean = "false" + // Array + Attribute bool_array_r [ 2 ]: boolean = "{ ET_FALSE, false }" + Attribute bool_array_c [ 2 ]: boolean = "{ false, false }" + Attribute bool_array_i [ 2 ]: boolean = "{ false, false }" + } + + DataClass Data_1_dc extends Data_Super1_dc{ + usercode1 { + "#include \"etUnit/etUnit.h\"" + } + + Attribute int8_r: int8 = "8" + Attribute int8_c: int8 = "8" + Attribute int8_i: int8 = "8" + Attribute int16_r: int16 = "16" + Attribute int16_c: int16 = "16" + Attribute int16_i: int16 = "16" + Attribute int32_r: int32 = "32" + Attribute int32_c: int32 = "32" + Attribute int32_i: int32 = "32" + Attribute int64_r: int64 = "64" + Attribute int64_c: int64 = "64" + Attribute int64_i: int64 = "64" + Attribute float32_r: float32 = "3.2" + Attribute float32_c: float32 = "3.2" + Attribute float32_i: float32 = "3.2" + Attribute float64_r: float64 = "6.4" + Attribute float64_c: float64 = "6.4" + Attribute float64_i: float64 = "6.4" + Attribute char_r: char = "R" + Attribute char_c: char = 'R' + Attribute char_i: char = "R" + Attribute string_r: string = ":/" + Attribute string_c: string = ":/" + Attribute string_i: string = ":/" + + // Array + Attribute int8_array_r [ 2 ]: int8 = "{ 8, 16 }" + Attribute int8_array_c [ 2 ]: int8 = "{ 8, 16 }" + Attribute int8_array_i [ 2 ]: int8 = "{ 8, 16 }" + Attribute int16_array_r [ 2 ]: int16 = "{ 16, 32 }" + Attribute int16_array_c [ 2 ]: int16 = "{ 16, 32 }" + Attribute int16_array_i [ 2 ]: int16 = "{ 16, 32 }" + Attribute int32_array_r [ 2 ]: int32 = "{ 32, 64 }" + Attribute int32_array_c [ 2 ]: int32 = "{ 32, 64 }" + Attribute int32_array_i [ 2 ]: int32 = "{ 32, 64 }" + Attribute int64_array_r [ 2 ]: int64 = "{ 64, 128 }" + Attribute int64_array_c [ 2 ]: int64 = "{ 64, 128 }" + Attribute int64_array_i [ 2 ]: int64 = "{ 64, 128 }" + Attribute float32_array_r [ 2 ]: float32 = "{ 3.2, 6.4 }" + Attribute float32_array_c [ 2 ]: float32 = "{ 3.2, 6.4 }" + Attribute float32_array_i [ 2 ]: float32 = "{ 3.2, 6.4 }" + Attribute float64_array_r [ 2 ]: float64 = "{ 6.4, 12.8 }" + Attribute float64_array_c [ 2 ]: float64 = "{ 6.4, 12.8 }" + Attribute float64_array_i [ 2 ]: float64 = "{ 6.4, 12.8 }" + Attribute char_array_r [ 5 ]: char = "ROOM" + Attribute char_array_c [ 5 ]: char = "ROOM" + Attribute char_array_i [ 5 ]: char = "ROOM" + + // ComplexType + Attribute data_2: Data_2_dc + + Operation varCheck1(caseId: int32) { + "Data_2_dc_varCheck2(&(data_2), caseId);" + + // PrimitiveType + "EXPECT_TRUE(caseId,\"Data_1_dc:varCheck:1\", bool_r == ET_FALSE);" + "EXPECT_TRUE(caseId,\"Data_1_dc:varCheck:2\", int8_r == 8);" + "EXPECT_TRUE(caseId,\"Data_1_dc:varCheck:3\", int16_r == 16);" + "EXPECT_TRUE(caseId,\"Data_1_dc:varCheck:4\", int32_r == 32);" + "EXPECT_TRUE(caseId,\"Data_1_dc:varCheck:5\", int64_r == 64);" + "EXPECT_EQUAL_FLOAT32(caseId,\"Data_1_dc:varCheck:6\", 3.2f, float32_r, 0.1f);" + "EXPECT_EQUAL_FLOAT64(caseId,\"Data_1_dc:varCheck:7\", 6.4, float64_r, 0.1);" + "EXPECT_TRUE(caseId,\"Data_1_dc:varCheck:8\", char_r == \'R\');" + "EXPECT_TRUE(caseId,\"Data_1_dc:varCheck:8\", strcmp(string_r, \":/\") == 0 );" + + // Array + "EXPECT_TRUE(caseId,\"Data_1_dc:varCheck:10\", bool_array_r[0] == ET_FALSE && bool_array_r[1] == ET_FALSE);" + "EXPECT_TRUE(caseId,\"Data_1_dc:varCheck:11\", int8_array_r[0] == 8 && int8_array_r[1] == 16);" + "EXPECT_TRUE(caseId,\"Data_1_dc:varCheck:12\", int16_array_r[0] == 16 && int16_array_r[1] == 32);" + "EXPECT_TRUE(caseId,\"Data_1_dc:varCheck:13\", int32_array_r[0] == 32 && int32_array_r[1] == 64);" + "EXPECT_TRUE(caseId,\"Data_1_dc:varCheck:24\", int64_array_r[0] == 64 && int64_array_r[1] == 128);" + "EXPECT_EQUAL_FLOAT32(caseId, \"Data_1_dc:varCheck:25_1\", 3.2f, float32_array_r[0], 0.1f);" + "EXPECT_EQUAL_FLOAT32(caseId, \"Data_1_dc:varCheck:25_2\", 6.4f, float32_array_r[1], 0.1f);" + "EXPECT_EQUAL_FLOAT64(caseId, \"Data_1_dc:varCheck:26_1\", 6.4, float64_array_r[0], 0.1);" + "EXPECT_EQUAL_FLOAT64(caseId, \"Data_1_dc:varCheck:26_2\", 12.8, float64_array_r[1], 0.1);" + "EXPECT_TRUE(caseId,\"Data_1_dc:varCheck:27\", strcmp(char_array_r, \"ROOM\")==0);" + } + } + + DataClass Data_2_dc { + usercode1 { + "#include \"etUnit/etUnit.h\"" + } + Attribute int32_r: int32 = "1" + Attribute int32_c: int32 = "1" + Attribute int32_i: int32 = "1" + Operation varCheck2(caseId: int32): void { + "EXPECT_TRUE(caseId, \"Data_2_dc:1\", int32_r == 1);" + } + } + + DataClass Data_3_dc { + usercode1 { + "#include \"etUnit/etUnit.h\"" + } + + // none config test + Attribute primitive_ref: int32 ref + Attribute primitive_ref_array [ 2 ]: int32 ref + Attribute dataClass_array [ 2 ]: Data_2_dc + Attribute dataClass_ref: Data_2_dc ref + Attribute dataClass_ref_array [ 2 ]: Data_2_dc ref + Attribute ext_type: extType + Attribute ext_type_array [ 2 ]: extType + Attribute ext_type_ref: extType ref + Attribute ext_type_ref_array [ 2 ]: extType ref + Operation varCheck3(caseId: int32): void { + "EXPECT_TRUE(caseId, \"Data_3_dc:1\", primitive_ref == NULL);" + "EXPECT_TRUE(caseId, \"Data_3_dc:2\", primitive_ref_array[0] == NULL && primitive_ref_array[1] == NULL);" + "EXPECT_TRUE(caseId, \"Data_3_dc:3\", dataClass_ref == NULL);" + "EXPECT_TRUE(caseId, \"Data_3_dc:4\", dataClass_array[0].int32_r == 1 && dataClass_array[0].int32_c == 1 && dataClass_array[0].int32_i == 1);" + "EXPECT_TRUE(caseId, \"Data_3_dc:4\", dataClass_array[1].int32_r == 1 && dataClass_array[1].int32_c == 1 && dataClass_array[1].int32_i == 1);" + "EXPECT_TRUE(caseId, \"Data_3_dc:5\", dataClass_ref == NULL);" + "EXPECT_TRUE(caseId, \"Data_3_dc:6\", dataClass_ref_array[0] == NULL && dataClass_ref_array[1] == NULL);" + "EXPECT_TRUE(caseId, \"Data_3_dc:7\", ext_type == 999);" + "EXPECT_TRUE(caseId, \"Data_3_dc:8\", ext_type_array[0] == 999 && ext_type_array[1] == 999);" + "EXPECT_TRUE(caseId, \"Data_3_dc:9\", ext_type_ref == NULL);" + "EXPECT_TRUE(caseId, \"Data_3_dc:10\", ext_type_ref_array[0] == NULL && dataClass_ref_array[1] == NULL);" + } + } + + Enumeration Enum_1 { + zero, + one, + two + } + + Enumeration Enum_2 of int16 { + three=3, + four + } + +}
\ No newline at end of file diff --git a/tests/org.eclipse.etrice.generator.common.tests/.gitignore b/tests/org.eclipse.etrice.generator.common.tests/.gitignore new file mode 100644 index 000000000..d2726d181 --- /dev/null +++ b/tests/org.eclipse.etrice.generator.common.tests/.gitignore @@ -0,0 +1,2 @@ +src-gen/ +output/
\ No newline at end of file diff --git a/tests/org.eclipse.etrice.generator.cpp.tests/.gitignore b/tests/org.eclipse.etrice.generator.cpp.tests/.gitignore index 4f0e85af9..d2726d181 100644 --- a/tests/org.eclipse.etrice.generator.cpp.tests/.gitignore +++ b/tests/org.eclipse.etrice.generator.cpp.tests/.gitignore @@ -1,6 +1,2 @@ -bin -models -output -results -src-gen -log
\ No newline at end of file +src-gen/ +output/
\ No newline at end of file diff --git a/tests/org.eclipse.etrice.generator.cpp.tests/models/SendingDataTest.room b/tests/org.eclipse.etrice.generator.cpp.tests/models/SendingDataTest.room new file mode 100644 index 000000000..623003187 --- /dev/null +++ b/tests/org.eclipse.etrice.generator.cpp.tests/models/SendingDataTest.room @@ -0,0 +1,605 @@ +RoomModel SendingDataTest { + + import room.basic.test.* from "../../../runtime/org.eclipse.etrice.modellib.cpp/model/Tests.room" + import room.basic.types.* from "../../../runtime/org.eclipse.etrice.modellib.cpp/model/Types.room" + import room.basic.language.* from "../../../runtime/org.eclipse.etrice.modellib.cpp/model/Language.room" + + ActorClass SendingDataTop { + @TestInstance + Structure { + ActorRef mrPing: MrPing + ActorRef mrPong: MrPong + Binding mrPong.PingPongPort and mrPing.PingPongPort + } + Behavior { } + } + + ActorClass MrPong { + Interface { + Port PingPongPort: PingPongProtocol + Port extTest: PCExternal + } + Structure { + external Port PingPongPort + external Port extTest + } + Behavior { + StateMachine { + Transition tr0: reply -> reply { + triggers { + <pingInt16: PingPongPort> + } + action { + "PingPongPort.pongInt16(d);" + } + } + Transition tr1: reply -> reply { + triggers { + <pingInt8: PingPongPort> + } + action { + "PingPongPort.pongInt8(d);" + } + } + Transition init: initial -> reply { } + Transition tr2: reply -> reply { + triggers { + <pingInt32: PingPongPort> + } + action { + "PingPongPort.pongInt32(d);" + } + } + Transition tr3: reply -> reply { + triggers { + <pingFloat32: PingPongPort> + } + action { + "PingPongPort.pongFloat32(d);" + } + } + Transition tr4: reply -> reply { + triggers { + <pingFloat64: PingPongPort> + } + action { + "PingPongPort.pongFloat64(d);" + } + } + Transition tr7: reply -> cp cp0 { + triggers { + <pingInt32Ref: PingPongPort guard { + "(*d)!=0" + }> + } + } + Transition tr8: cp cp0 -> reply { + action { + "PingPongPort.pongInt32((*d)+10);" + } + } + Transition tr6: cp cp0 -> reply { + cond { + "(*d)!=5" + } + action { + "PingPongPort.pongInt32(*d);" + } + } + Transition tr9: reply -> reply { + triggers { + <pingComplex: PingPongPort> + } + action { + "PingPongPort.pongComplex(d);" + } + } + Transition tr11: reply -> reply { + triggers { + <pingComplexRef: PingPongPort> + } + action { + "PingPongPort.pongComplex(*d);" + } + } + Transition tr5: reply -> reply { + triggers { + <pingInt64: PingPongPort> + } + action { + "PingPongPort.pongInt64(d);" + } + } + Transition tr10: reply -> reply { + triggers { + <pingInt16Ref: PingPongPort> + } + action { + "PingPongPort.pongInt16(*d);" + } + } + Transition tr12: reply -> cp cp1 { + triggers { + <pingComplexRef: PingPongPort guard { + "d->i8ValPPD == 5" + }> + } + action { + "PingPongPort.pongComplex(*d);" + } + } + Transition tr13: cp cp1 -> reply { + action { + "PingPongPort.pongComplex(*d);" + } + } + Transition tr14: cp cp1 -> reply { + cond { + "d->i8ValPPD==7" + } + action { + "PingPongPort.pongComplex(*d);" + } + } + Transition tr15: reply -> reply { + triggers { + <pingComplexDerived: PingPongPort> + } + action { + "PingPongPort.pongComplexDerived(d);" + } + } + Transition tr16: my tp0 -> my tp0 { + triggers { + <in1: extTest> + } + } + ChoicePoint cp0 + ChoicePoint cp1 + TransitionPoint tp0 + State reply + } + } + } + + ActorClass MrPing { + Interface { + conjugated Port PingPongPort: PingPongProtocol + } + Structure { + external Port PingPongPort + Attribute i8Val: int8="5" + Attribute i16Val:int16="19" + Attribute i32Val: int32 = "4711" + Attribute i64Val: int64 = "11470815" + Attribute i32Array [ 10 ]: int32 = "{0,1,2,3,4,5,6,7,8,9}" + Attribute f32Val: float32="3.14f" + Attribute f64Val: float64="7.987654321" + Attribute data: PingPongData + Attribute dataD: PingPongDataDerived + Attribute counter:int32 + Attribute caseId: int32 + Attribute lang: languageIndicator + Attribute resultlist [ 23 ]: int16 = "{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23}" + } + Behavior { + StateMachine { + Transition init: initial -> tp0 of state0 { + action { + "caseId = etUnit_openAll(\".\", \"SendingDataTest\", \"org.eclipse.etrice.generator.common.tests.SendingDataTest\", \"SendingDataTest_case\");" + "EXPECT_ORDER_START(caseId,resultlist,23);" + "EXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 1);" + "/* send the default values */" + "" + "PingPongPort.pingInt8(i8Val);" + "PingPongPort.pingInt16(i16Val);" + "PingPongPort.pingInt32(i32Val);" + "PingPongPort.pingInt64(i64Val);" + "PingPongPort.pingFloat32(f32Val);" + "PingPongPort.pingFloat64(f64Val);" + "PingPongPort.pingInt16Ref(&i16Val);" + "PingPongPort.pingInt32Ref(&i32Val);" + "i8Val++;" + "i16Val++;" + "i32Val++;" + "i64Val++;" + "f32Val+=10.1;" + "f64Val+=20.2;" + "PingPongPort.pingInt8(i8Val);" + "PingPongPort.pingInt16(i16Val);" + "PingPongPort.pingInt32(i32Val);" + "PingPongPort.pingInt64(i64Val);" + "PingPongPort.pingFloat32(f32Val);" + "PingPongPort.pingFloat64(f64Val);" + "PingPongPort.pingInt16Ref(&i16Val);" + "PingPongPort.pingInt32Ref(&i32Val);" + } + } + Transition tr0: tp1 of state0 -> tp0 of state1 + Transition tr1: tp1 of state1 -> test_finished + State state0 { + subgraph { + Transition tr0: my tp0 -> receiveFirst7 { + action { + "counter=0;" + } + } + Transition tr1: receiveFirst7 -> receiveFirst7 { + triggers { + <pongInt8: PingPongPort> + } + action { + "counter++;" + "if (d==5){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 2);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + Transition tr2: receiveFirst7 -> receiveFirst7 { + triggers { + <pongInt16: PingPongPort> + } + action { + "counter++;" + "if (d==19){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 3);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + Transition tr3: receiveFirst7 -> receiveFirst7 { + triggers { + <pongInt32: PingPongPort> + } + action { + "counter++;" + "if (d==4711){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 4);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + Transition tr4: receiveFirst7 -> receiveSecond7 { + triggers { + <pongInt32: PingPongPort guard { + "counter==7" + }> + } + action { + "counter=0;" + "if (lang == 1){" + "/* Java cannot send references of primitive types */" + "\tif (d==4711){\t" + "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 9);" + "\t}else{" + "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "\t}" + "} " + "if (lang == 2){" + "/* C */" + "\tif (d==4712){\t" + "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 9);" + "\t}else{" + "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "\t}" + "}" + } + } + Transition tr6: receiveFirst7 -> receiveFirst7 { + triggers { + <pongInt64: PingPongPort> + } + action { + "counter++;" + "if (d==11470815){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 5);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + Transition tr5: receiveFirst7 -> receiveFirst7 { + triggers { + <pongFloat32: PingPongPort> + } + action { + "counter++;" + "if ((d>3)&&(d<4)){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 6);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + Transition tr7: receiveFirst7 -> receiveFirst7 { + triggers { + <pongFloat64: PingPongPort> + } + action { + "counter++;" + "if ((d>7)&&(d<8)){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 7);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + Transition tr8: receiveSecond7 -> receiveSecond7 { + triggers { + <pongInt8: PingPongPort> + } + action { + "counter++;" + "if (d==6){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 10);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + Transition tr9: receiveSecond7 -> receiveSecond7 { + triggers { + <pongInt16: PingPongPort> + } + action { + "counter++;" + "if (d==20){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 11);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + Transition tr10: receiveSecond7 -> receiveSecond7 { + triggers { + <pongInt32: PingPongPort> + } + action { + "counter++;" + "if (d==4712){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 12);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + Transition tr11: receiveSecond7 -> receiveSecond7 { + triggers { + <pongInt64: PingPongPort> + } + action { + "counter++;" + "if (d==11470816){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 13);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + Transition tr12: receiveSecond7 -> receiveSecond7 { + triggers { + <pongFloat32: PingPongPort> + } + action { + "counter++;" + "if ((d>13)&&(d<14)){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 14);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + Transition tr13: receiveSecond7 -> receiveSecond7 { + triggers { + <pongFloat64: PingPongPort> + } + action { + "counter++;" + "if ((d>28)&&(d<29)){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 15);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + Transition tr14: receiveSecond7 -> my tp1 { + triggers { + <pongInt32: PingPongPort guard { + "counter==7" + }> + } + action { + "if (d==4712){\t" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 17);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + Transition tr15: receiveFirst7 -> receiveFirst7 { + triggers { + <pongInt16: PingPongPort guard { + "counter==6" + }> + } + action { + "counter++;" + "if (lang == 1){" + "/* Java cannot send references of primitive types */" + "\tif (d==19){\t" + "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 8);" + "\t}else{" + "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "\t}" + "} " + "if (lang == 2){" + "/* C */" + "\tif (d==20){\t" + "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 8);" + "\t}else{" + "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "\t}" + "}" + } + } + Transition tr16: receiveSecond7 -> receiveSecond7 { + triggers { + <pongInt16: PingPongPort guard { + "counter==6" + }> + } + action { + "counter++;" + "if (d==20){\t" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 16);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + EntryPoint tp0 + ExitPoint tp1 + State receiveFirst7 + State receiveSecond7 + } + } + State test_finished { + entry { + "EXPECT_ORDER_END(caseId,\"<|MODEL_LOCATION|>\", 23);" + "etUnit_closeAll(caseId);" + "etUnit_testFinished(caseId);" + } + } + State state1 { + subgraph { + Transition tr0: my tp0 -> state0 { + action { + "counter=0;" + "/* send default values */" + "PingPongPort.pingComplex(data);" + "PingPongPort.pingComplexRef(&data);" + } + } + Transition tr1: state0 -> state1 { + triggers { + <pongComplex: PingPongPort guard { + "counter==1" + }> + } + action { + "counter=0;" + "if (d.i8ValPPD==10){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 19);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + "" + "if (d.complexVal.i32Val2PPDD==80){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 20);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + "" + "dataD.i8ValPPD=11;" + "PingPongPort.pingComplexDerived(dataD);" + } + } + Transition tr2: state0 -> state0 { + triggers { + <pongComplex: PingPongPort> + } + action { + "counter++;" + "if (d.i8ValPPD==10){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 18);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + Transition tr3: state1 -> my tp1 { + triggers { + <pongComplexDerived: PingPongPort> + } + action { + "if (d.i8ValPPD==11){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 21);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + "" + "if (d.i32Val3PPDe==150){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 22);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + EntryPoint tp0 + ExitPoint tp1 + State state0 + State state1 + } + } + } + } + } + + ProtocolClass PingPongProtocol { + incoming { + Message pingInt8(d: int8) + Message pingInt16(d: int16) + Message pingInt32(d: int32) + Message pingInt64(d: int64) + Message pingFloat32(d: float32) + Message pingFloat64(d: float64) + Message pingInt16Ref(d: int16 ref) + Message pingInt32Ref(d: int32 ref) + Message pingComplex(d: PingPongData) + Message pingComplexRef(d: PingPongData ref) + Message pingComplexDerived(d:PingPongDataDerived) + } + outgoing { + Message pongInt8(d: int8) + Message pongInt16(d: int16) + Message pongInt32(d: int32) + Message pongInt64(d:int64) + Message pongFloat32(d: float32) + Message pongFloat64(d: float64) + Message pongComplex(d: PingPongData) + Message pongComplexDerived(d: PingPongDataDerived) + } + } + + ProtocolClass PCExternal { + usercode1 { + "typedef int extMsg;" + } + incoming { + Message in1(can: DExtMsg) + } + } + + DataClass PingPongData { + Attribute i8ValPPD: int8 = "10" + Attribute i8ValRefPPD: int8 ref + Attribute i32ArrayPPD [ 3 ]: int32 = "{200,300,400}" + Attribute i8ArrayRefPPD [ 2 ]: int8 ref + Attribute complexVal: PingPongDataDeep + } + + DataClass PingPongDataDeep { + Attribute i32Val1PPDD: int32 + Attribute i32Val2PPDD: int32 = "80" + } + + DataClass PingPongDataDerived extends PingPongData { + Attribute i32Val3PPDe: int32 = "150" + } + + ExternalType DExtMsg -> "extMsg" +}
\ No newline at end of file diff --git a/tests/org.eclipse.etrice.generator.java.tests/.gitignore b/tests/org.eclipse.etrice.generator.java.tests/.gitignore index 074d50426..d2726d181 100644 --- a/tests/org.eclipse.etrice.generator.java.tests/.gitignore +++ b/tests/org.eclipse.etrice.generator.java.tests/.gitignore @@ -1,8 +1,2 @@ -bin -models -output -results -src-gen -log -/tmp/ -/*.obj +src-gen/ +output/
\ No newline at end of file diff --git a/tests/org.eclipse.etrice.generator.java.tests/models/SendingDataTest.room b/tests/org.eclipse.etrice.generator.java.tests/models/SendingDataTest.room new file mode 100644 index 000000000..ce9056bdb --- /dev/null +++ b/tests/org.eclipse.etrice.generator.java.tests/models/SendingDataTest.room @@ -0,0 +1,586 @@ +RoomModel SendingDataTest { + + import room.basic.test.* from "../../../runtime/org.eclipse.etrice.modellib.java/model/Tests.room" + import room.basic.types.* from "../../../runtime/org.eclipse.etrice.modellib.java/model/Types.room" + import room.basic.language.* from "../../../runtime/org.eclipse.etrice.modellib.java/model/Language.room" + + ActorClass SendingDataTop { + @TestInstance + Structure { + ActorRef mrPing: MrPing + ActorRef mrPong: MrPong + Binding mrPong.PingPongPort and mrPing.PingPongPort + } + Behavior { } + } + + ActorClass MrPong { + Interface { + Port PingPongPort: PingPongProtocol + } + Structure { + external Port PingPongPort + } + Behavior { + StateMachine { + Transition tr0: reply -> reply { + triggers { + <pingInt16: PingPongPort> + } + action { + "PingPongPort.pongInt16(d);" + } + } + Transition tr1: reply -> reply { + triggers { + <pingInt8: PingPongPort> + } + action { + "PingPongPort.pongInt8(d);" + } + } + Transition init: initial -> reply { } + Transition tr2: reply -> reply { + triggers { + <pingInt32: PingPongPort> + } + action { + "PingPongPort.pongInt32(d);" + } + } + Transition tr3: reply -> reply { + triggers { + <pingFloat32: PingPongPort> + } + action { + "PingPongPort.pongFloat32(d);" + } + } + Transition tr4: reply -> reply { + triggers { + <pingFloat64: PingPongPort> + } + action { + "PingPongPort.pongFloat64(d);" + } + } + Transition tr7: reply -> cp cp0 { + triggers { + <pingInt32Ref: PingPongPort guard { + "d!=0" + }> + } + } + Transition tr8: cp cp0 -> reply { + action { + "PingPongPort.pongInt32(d+10);" + } + } + Transition tr6: cp cp0 -> reply { + cond { + "d!=5" + } + action { + "PingPongPort.pongInt32(d);" + } + } + Transition tr9: reply -> reply { + triggers { + <pingComplex: PingPongPort> + } + action { + "PingPongPort.pongComplex(d);" + } + } + Transition tr11: reply -> reply { + triggers { + <pingComplexRef: PingPongPort> + } + action { + "PingPongPort.pongComplex(d);" + } + } + Transition tr5: reply -> reply { + triggers { + <pingInt64: PingPongPort> + } + action { + "PingPongPort.pongInt64(d);" + } + } + Transition tr10: reply -> reply { + triggers { + <pingInt16Ref: PingPongPort> + } + action { + "PingPongPort.pongInt16(d);" + } + } + Transition tr12: reply -> cp cp1 { + triggers { + <pingComplexRef: PingPongPort guard { + "d.i8Val == 5" + }> + } + action { + "PingPongPort.pongComplex(d);" + } + } + Transition tr13: cp cp1 -> reply { + action { + "PingPongPort.pongComplex(d);" + } + } + Transition tr14: cp cp1 -> reply { + cond { + "d.i8Val==7" + } + action { + "PingPongPort.pongComplex(d);" + } + } + Transition tr15: reply -> reply { + triggers { + <pingComplexDerived: PingPongPort> + } + action { + "PingPongPort.pongComplexDerived(d);" + } + } + ChoicePoint cp0 + ChoicePoint cp1 + State reply + } + } + } + + ActorClass MrPing { + Interface { + conjugated Port PingPongPort: PingPongProtocol + } + Structure { + external Port PingPongPort + Attribute i8Val: int8="5" + Attribute i16Val:int16="19" + Attribute i32Val: int32 = "4711" + Attribute i64Val: int64 = "11470815" + Attribute i32Array [ 10 ]: int32="{0,1,2,3,4,5,6,7,8,9}" + Attribute f32Val: float32="3.14" + Attribute f64Val: float64="7.987654321" + Attribute data: PingPongData + Attribute dataD: PingPongDataDerived + Attribute counter:int32 + Attribute caseId: int32 + Attribute lang: languageIndicator + Attribute resultlist [ 18 ]: int16 = "{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23}" + } + Behavior { + StateMachine { + Transition init: initial -> tp0 of state0 { + action { + "caseId = etUnit_openAll(\".\", \"SendingDataTest\", \"org.eclipse.etrice.generator.common.tests.SendingDataTest\", \"SendingDataTest_case\");" + "EXPECT_ORDER_START(caseId,resultlist,23);" + "EXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 1);" + "// send the default values" + "" + "PingPongPort.pingInt8(i8Val);" + "PingPongPort.pingInt16(i16Val);" + "PingPongPort.pingInt32(i32Val);" + "PingPongPort.pingInt64(i64Val);" + "PingPongPort.pingFloat32(f32Val);" + "PingPongPort.pingFloat64(f64Val);" + "PingPongPort.pingInt16Ref(i16Val);" + "PingPongPort.pingInt32Ref(i32Val);" + "i8Val++;" + "i16Val++;" + "i32Val++;" + "i64Val++;" + "f32Val+=10.1;" + "f64Val+=20.2;" + "PingPongPort.pingInt8(i8Val);" + "PingPongPort.pingInt16(i16Val);" + "PingPongPort.pingInt32(i32Val);" + "PingPongPort.pingInt64(i64Val);" + "PingPongPort.pingFloat32(f32Val);" + "PingPongPort.pingFloat64(f64Val);" + "PingPongPort.pingInt16Ref(i16Val);" + "PingPongPort.pingInt32Ref(i32Val);" + } + } + Transition tr0: tp1 of state0 -> tp0 of state1 + Transition tr1: tp1 of state1 -> test_finished + State state0 { + subgraph { + Transition tr0: my tp0 -> receiveFirst7 { + action { + "counter=0;" + } + } + Transition tr1: receiveFirst7 -> receiveFirst7 { + triggers { + <pongInt8: PingPongPort> + } + action { + "counter++;" + "if (d==5){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 2);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + Transition tr2: receiveFirst7 -> receiveFirst7 { + triggers { + <pongInt16: PingPongPort> + } + action { + "counter++;" + "if (d==19){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 3);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + Transition tr3: receiveFirst7 -> receiveFirst7 { + triggers { + <pongInt32: PingPongPort> + } + action { + "counter++;" + "if (d==4711){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 4);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + Transition tr4: receiveFirst7 -> receiveSecond7 { + triggers { + <pongInt32: PingPongPort guard { + "counter==7" + }> + } + action { + "counter=0;" + "if (lang == 1){" + "// Java cannot send references of primitive types" + "\tif (d==4711){\t" + "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 9);" + "\t}else{" + "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "\t}" + "} " + "if (lang == 2){" + "// C" + "\tif (d==4712){\t" + "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 9);" + "\t}else{" + "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "\t}" + "}" + } + } + Transition tr6: receiveFirst7 -> receiveFirst7 { + triggers { + <pongInt64: PingPongPort> + } + action { + "counter++;" + "if (d==11470815){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 5);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + Transition tr5: receiveFirst7 -> receiveFirst7 { + triggers { + <pongFloat32: PingPongPort> + } + action { + "counter++;" + "if ((d>3)&&(d<4)){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 6);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + Transition tr7: receiveFirst7 -> receiveFirst7 { + triggers { + <pongFloat64: PingPongPort> + } + action { + "counter++;" + "if ((d>7)&&(d<8)){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 7);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + Transition tr8: receiveSecond7 -> receiveSecond7 { + triggers { + <pongInt8: PingPongPort> + } + action { + "counter++;" + "if (d==6){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 10);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + Transition tr9: receiveSecond7 -> receiveSecond7 { + triggers { + <pongInt16: PingPongPort> + } + action { + "counter++;" + "if (d==20){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 11);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + Transition tr10: receiveSecond7 -> receiveSecond7 { + triggers { + <pongInt32: PingPongPort> + } + action { + "counter++;" + "if (d==4712){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 12);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + Transition tr11: receiveSecond7 -> receiveSecond7 { + triggers { + <pongInt64: PingPongPort> + } + action { + "counter++;" + "if (d==11470816){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 13);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + Transition tr12: receiveSecond7 -> receiveSecond7 { + triggers { + <pongFloat32: PingPongPort> + } + action { + "counter++;" + "if ((d>13)&&(d<14)){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 14);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + Transition tr13: receiveSecond7 -> receiveSecond7 { + triggers { + <pongFloat64: PingPongPort> + } + action { + "counter++;" + "if ((d>28)&&(d<29)){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 15);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + Transition tr14: receiveSecond7 -> my tp1 { + triggers { + <pongInt32: PingPongPort guard { + "counter==7" + }> + } + action { + "if (d==4712){\t" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 17);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + Transition tr15: receiveFirst7 -> receiveFirst7 { + triggers { + <pongInt16: PingPongPort guard { + "counter==6" + }> + } + action { + "counter++;" + "if (lang == 1){" + "// Java cannot send references of primitive types" + "\tif (d==19){\t" + "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 8);" + "\t}else{" + "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "\t}" + "} " + "if (lang == 2){" + "// C" + "\tif (d==20){\t" + "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 8);" + "\t}else{" + "\t\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "\t}" + "}" + } + } + Transition tr16: receiveSecond7 -> receiveSecond7 { + triggers { + <pongInt16: PingPongPort guard { + "counter==6" + }> + } + action { + "counter++;" + "if (d==20){\t" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 16);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + EntryPoint tp0 + ExitPoint tp1 + State receiveFirst7 + State receiveSecond7 + } + } + State test_finished { + entry { + "EXPECT_ORDER_END(caseId,\"<|MODEL_LOCATION|>\", 23);" + "etUnit_closeAll(caseId);" + "etUnit_testFinished(caseId);" + } + } + State state1 { + subgraph { + Transition tr0: my tp0 -> state0 { + action { + "counter=0;" + "// send default values" + "PingPongPort.pingComplex(data);" + "PingPongPort.pingComplexRef(data);" + } + } + Transition tr1: state0 -> state1 { + triggers { + <pongComplex: PingPongPort guard { + "counter==1" + }> + } + action { + "counter=0;" + "if (d.i8Val==10){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 19);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + "" + "if (d.complexVal.i32Val2==80){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 20);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + "" + "dataD.i8Val=11;" + "PingPongPort.pingComplexDerived(dataD);" + } + } + Transition tr2: state0 -> state0 { + triggers { + <pongComplex: PingPongPort> + } + action { + "counter++;" + "if (d.i8Val==10){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 18);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + Transition tr3: state1 -> my tp1 { + triggers { + <pongComplexDerived: PingPongPort> + } + action { + "if (d.i8Val==11){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 21);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + "" + "if (d.i32Val3==150){" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 22);" + "}else{" + "\tEXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", 0xFF);" + "}" + } + } + EntryPoint tp0 + ExitPoint tp1 + State state0 + State state1 + } + } + } + } + } + + ProtocolClass PingPongProtocol { + incoming { + Message pingInt8(d: int8) + Message pingInt16(d: int16) + Message pingInt32(d: int32) + Message pingInt64(d: int64) + Message pingFloat32(d: float32) + Message pingFloat64(d: float64) + Message pingInt16Ref(d: int16 ref) + Message pingInt32Ref(d: int32 ref) + Message pingComplex(d: PingPongData) + Message pingComplexRef(d: PingPongData ref) + Message pingComplexDerived(d:PingPongDataDerived) + } + outgoing { + Message pongInt8(d: int8) + Message pongInt16(d: int16) + Message pongInt32(d: int32) + Message pongInt64(d:int64) + Message pongFloat32(d: float32) + Message pongFloat64(d: float64) + Message pongComplex(d: PingPongData) + Message pongComplexDerived(d: PingPongDataDerived) + } + } + + DataClass PingPongData { + Attribute i8Val: int8 = "10" + Attribute i8ValRef: int8 ref + Attribute i32Array [ 3 ]: int32 = "{200,300,400}" + Attribute i8ArrayRef [ 2 ]: int8 ref + Attribute complexVal: PingPongDataDeep + } + + DataClass PingPongDataDeep { + Attribute i32Val1: int32 + Attribute i32Val2: int32 = "80" + } + + DataClass PingPongDataDerived extends PingPongData { + Attribute i32Val3: int32 = "150" + } +} diff --git a/tests/org.eclipse.etrice.generator.java.tests/models/StaticConfigTest.config b/tests/org.eclipse.etrice.generator.java.tests/models/StaticConfigTest.config new file mode 100644 index 000000000..426adc5e6 --- /dev/null +++ b/tests/org.eclipse.etrice.generator.java.tests/models/StaticConfigTest.config @@ -0,0 +1,141 @@ +ConfigModel StaticTestConfig { + + import StaticConfigTest.* from "StaticConfigTest.room" + + ActorClassConfig Tester_ac { + // nothing + } + + ActorClassConfig Testee_1_ac { + Attr data_1 { + Attr bool_c = false + Attr bool_i = false + Attr int8_c = 24 + Attr int8_i = 24 + Attr int16_c = 48 + Attr int16_i = 48 + Attr int32_c = 96 + Attr int32_i = 96 + Attr int64_c = 192 + Attr int64_i = 192 + Attr float32_c = 9.6 + Attr float32_i = 9.6 + Attr float64_c = 19.2 + Attr float64_i = 19.2 + Attr char_c = "C" + Attr char_i = "C" + Attr string_c = ":)" + Attr string_i = ":)" + + Attr bool_array_c = true, false + Attr bool_array_i = true, false + Attr int8_array_c = 24, 48 + Attr int8_array_i = 24, 48 + Attr int16_array_c = 48, 96 + Attr int16_array_i = 48, 96 + Attr int32_array_c = 96, 192 + Attr int32_array_i = 96, 192 + Attr int64_array_c = 192, 384 + Attr int64_array_i = 192, 384 + Attr float32_array_c = 9.6 + Attr float32_array_i = 9.6 + Attr float64_array_c = 19.2 + Attr float64_array_i = 19.2 + Attr char_array_c = "Claz" + Attr char_array_i = "Claz" + + Attr data_2 { + Attr int32_c = 42 + Attr int32_i = 42 + } + } + Attr enumval1 = Enum_1.two + Attr enumval2 = Enum_2.three + } + + ActorClassConfig Testee_Super2_ac { + Attr float64_super_c = 2.2 + Attr float64_super_i = 2.2 + } + + ActorClassConfig Testee_2_ac { + Attr int32_own_c = 12 + Attr int32_own_i = 12 + } + + ProtocolClassConfig TestProtocolAttributes { + regular Port{ + Attr float_c = 3.0 + Attr float_i = 3.0 + } + conjugate Port { + Attr array2_c = 16, 32 + Attr array2_i = 16, 32 + } + } + + ProtocolClassConfig TestProtocolWithDataClass { + conjugate Port { + Attr sap_data_2{ + Attr int32_c = 2 + Attr int32_i = 2 + } + } + } + + ActorInstanceConfig System_StaticConfigTest/main/top/tester { + // nothing + } + + ActorInstanceConfig System_StaticConfigTest/main/top/testee_1 { + Attr data_1 { + Attr bool_i = true + Attr int8_i = 2 + Attr int16_i = 4 + Attr int32_i = 8 + Attr int64_i = 16 + Attr float32_i = 1.6 + Attr float64_i = 3.2 + Attr char_i = "I" + Attr string_i = ":]" + + Attr bool_array_i = true, true + Attr int8_array_i = 2, 6 + Attr int16_array_i = 4, 12 + Attr int32_array_i = 8, 24 + Attr int64_array_i = 16, 48 + Attr float32_array_i = 1.6 + Attr float64_array_i = 3.2 + Attr char_array_i = "Inst" + + Attr data_2 { + Attr int32_i = 43 + } + } + InterfaceItem conj_port { + Attr array2_i = 1, 2 + } + } + + + ActorInstanceConfig System_StaticConfigTest/main/top/tester/testee_super2{ + Attr float64_super_i = 3.3 + InterfaceItem reg_port { + Attr float_i = 25.0 + } + } + + ActorInstanceConfig System_StaticConfigTest/main/top/testee_1/testee_2 { + Attr float64_super_i = 4.4 + Attr int32_own_i = 13 + InterfaceItem reg_port { + Attr float_i = 50.0 + } + InterfaceItem sap { + Attr sap_data_2 { + Attr int32_i = 3 + } + } + } + +}
\ No newline at end of file diff --git a/tests/org.eclipse.etrice.generator.java.tests/models/StaticConfigTest.etmap b/tests/org.eclipse.etrice.generator.java.tests/models/StaticConfigTest.etmap new file mode 100644 index 000000000..c0f26f88d --- /dev/null +++ b/tests/org.eclipse.etrice.generator.java.tests/models/StaticConfigTest.etmap @@ -0,0 +1,10 @@ +MappingModel StaticConfigTest { + + import StaticConfigTest.* from "StaticConfigTest.room" + import room.generic.physical.* from "../../org.eclipse.etrice.generator.common.tests/models/GenericPhysical.etphys" + + Mapping System_StaticConfigTest -> GenericPhysicalSystem { + SubSystemMapping main -> node {} + } + +}
\ No newline at end of file diff --git a/tests/org.eclipse.etrice.generator.java.tests/models/StaticConfigTest.room b/tests/org.eclipse.etrice.generator.java.tests/models/StaticConfigTest.room new file mode 100644 index 000000000..3d3ba6b49 --- /dev/null +++ b/tests/org.eclipse.etrice.generator.java.tests/models/StaticConfigTest.room @@ -0,0 +1,393 @@ +RoomModel StaticConfigTest { + + import room.basic.types.* from "../../../runtime/org.eclipse.etrice.modellib.java/model/Types.room" + import room.basic.service.timing.* from "../../../runtime/org.eclipse.etrice.modellib.java/model/TimingService.room" + + LogicalSystem System_StaticConfigTest { + SubSystemRef main : SubSystem_StaticConfigTest + } + + SubSystemClass SubSystem_StaticConfigTest { + LayerConnection ref top satisfied_by timer.timer + ActorRef top: Top_ac + ActorRef timer : ATimingService + } + + ActorClass Top_ac { + Structure { + LayerConnection ref testee_1 satisfied_by tester.spp + ActorRef testee_1: Testee_1_ac + ActorRef tester: Tester_ac + SAP timer : PTimer + } + Behavior { + ctor { + "etUnit_open(\".\", \"StaticConfigTest\");" + "etUnit_openTestSuite(\"org.eclipse.etrice.generator.common.tests.StaticConfigTest\");" + } + dtor { + "etUnit_closeTestSuite();" + "etUnit_close();" + } + StateMachine { + Transition init: initial -> state0 { + action { + "timer.startTimeout(1000);" + } + } + Transition tr0: state0 -> state0 { + triggers { + <timeout: timer> + } + action { + "etUnit_testFinished(-1);" + } + } + State state0 + } + } + } + + ActorClass Tester_ac { + Interface { + SPP spp: TestProtocolWithDataClass + } + Structure { + ServiceImplementation of spp + ActorRef testee_super2: Testee_Super2_ac + Attribute caseId: int32 + + // none config test + Attribute data_3: Data_3_dc + } + Behavior { + StateMachine { + Transition init: initial -> s1 + State s1 { + entry { + "caseId = etUnit_openTestCase(\"AttrConfigTest_case_Tester_ac\");" + "data_3.varCheck3(caseId);" + "SubSystemClassBase subSystem = (SubSystemClassBase) RTServices.getInstance().getSubSystem();" + "Testee_Super2_ac testee_super2 = (Testee_Super2_ac) subSystem.getInstance(\"/System_StaticConfigTest/main/top/tester/testee_super2\");" + "int caseId_2 = etUnit_openTestCase(\"AttrConfigTest_case_Testee_Super2_ac\");" + "testee_super2.getReg_port().varCheck(caseId_2);" + "EXPECT_TRUE(caseId_2, \"Tester_ac:1\", testee_super2.getFloat64_super_r() == 1.1);" + "EXPECT_TRUE(caseId_2, \"Tester_ac:2\", testee_super2.getFloat64_super_c() == 2.2);" + "EXPECT_TRUE(caseId_2, \"Tester_ac:3\", testee_super2.getFloat64_super_i() == 3.3);" + "EXPECT_EQUAL_FLOAT32(caseId,\"Tester_ac:4\", 25.f, testee_super2.getReg_port().getFloat_i(), 0.1f);" + "etUnit_closeTestCase(caseId);" + "etUnit_closeTestCase(caseId_2);" + } + } + } + } + } + + ActorClass Testee_1_ac { + Interface { + conjugated Port conj_port: TestProtocolAttributes + } + Structure { + ActorRef testee_2: Testee_2_ac + Attribute caseId: int32 + Attribute data_1: Data_1_dc + Attribute enumval1: Enum_1 = "one" + Attribute enumval2: Enum_2 = "four" + external Port conj_port + } + Behavior { + StateMachine { + Transition init: initial -> s1 + State s1 { + entry { + "caseId = etUnit_openTestCase(\"AttrConfigTest_case_Testee_1_ac\");" + "conj_port.varCheck();" + "data_1.varCheck1(caseId);" + "EXPECT_FALSE(caseId,\"testee_1:data_1:1\", getData_1().getBool_c());" + "EXPECT_TRUE(caseId,\"testee_1:data_1:2\", getData_1().getInt8_c() == 24);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:3\", getData_1().getInt16_c() == 48);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:4\", getData_1().getInt32_c() == 96);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:5\", getData_1().getInt64_c() == 192);" + "EXPECT_EQUAL_FLOAT32(caseId,\"testee_1:data_1:6\", 9.6f, getData_1().getFloat32_c(), 0.1f);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:7\", getData_1().getFloat64_c() == 19.2);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:8\", getData_1().getChar_c() == \'C\');" + "EXPECT_TRUE(caseId,\"testee_1:data_1:9\", getData_1().getString_c().equals(\":)\"));" + "EXPECT_TRUE(caseId,\"testee_1:data_1:10\", getData_1().getBool_i());" + "EXPECT_TRUE(caseId,\"testee_1:data_1:11\", getData_1().getInt8_i() == 2);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:12\", getData_1().getInt16_i() == 4);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:13\", getData_1().getInt32_i() == 8);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:14\", getData_1().getInt64_i() == 16);" + "EXPECT_EQUAL_FLOAT32(caseId,\"testee_1:data_1:15\", 1.6f, getData_1().getFloat32_i(), 0.1f);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:16\", getData_1().getFloat64_i() == 3.2);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:17\", getData_1().getChar_i() == \'I\');" + "EXPECT_TRUE(caseId,\"testee_1:data_1:18\", getData_1().getString_i().equals(\":]\"));" + + // Array + "EXPECT_TRUE(caseId,\"testee_1:data_1:19\", getData_1().getBool_array_c()[0] == true && getData_1().getBool_array_c()[1] == false);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:20\", getData_1().getInt8_array_c()[0] == 24 && getData_1().getInt8_array_c()[1] == 48);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:21\", getData_1().getInt16_array_c()[0] == 48 && getData_1().getInt16_array_c()[1] == 96);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:22\", getData_1().getInt32_array_c()[0] == 96 && getData_1().getInt32_array_c()[1] == 192);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:23\", getData_1().getInt64_array_c()[0] == 192 && getData_1().getInt64_array_c()[1] == 384);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:24\", getData_1().getFloat32_array_c()[0] == 9.6f && getData_1().getFloat32_array_c()[1] == 9.6f);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:25\", getData_1().getFloat64_array_c()[0] == 19.2 && getData_1().getFloat64_array_c()[1] == 19.2);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:26\", String.valueOf(getData_1().getChar_array_c()).equals(\"Claz\"));" + "EXPECT_TRUE(caseId,\"testee_1:data_1:27\", getData_1().getBool_array_i()[0] == true && getData_1().getBool_array_i()[1] == true);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:28\", getData_1().getInt8_array_i()[0] == 2 && getData_1().getInt8_array_i()[1] == 6);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:29\", getData_1().getInt16_array_i()[0] == 4 && getData_1().getInt16_array_i()[1] == 12);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:30\", getData_1().getInt32_array_i()[0] == 8 && getData_1().getInt32_array_i()[1] == 24);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:31\", getData_1().getInt64_array_i()[0] == 16 && getData_1().getInt64_array_i()[1] == 48);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:32\", getData_1().getFloat32_array_i()[0] == 1.6f && getData_1().getFloat32_array_i()[1] == 1.6f);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:33\", getData_1().getFloat64_array_i()[0] == 3.2 && getData_1().getFloat64_array_i()[1] == 3.2);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:34\", String.valueOf(getData_1().getChar_array_i()).equals(\"Inst\"));" + "EXPECT_TRUE(caseId,\"testee_1:data_1:35\", getData_1().getData_2().getInt32_c() == 42);" + "EXPECT_TRUE(caseId,\"testee_1:data_1:36\", getData_1().getData_2().getInt32_i() == 43);" + + // enums + "EXPECT_TRUE(caseId,\"testee_1:enumval1\", getEnumval1() == Enum_1.two);" + "EXPECT_TRUE(caseId,\"testee_1:enumval2\", getEnumval2() == Enum_2.three);" + "etUnit_closeTestCase(caseId);" + } + } + } + } + } + + ActorClass Testee_Super2_ac { + Interface { + Port reg_port: TestProtocolAttributes + } + Structure { + Attribute caseId: int32 + + // test + Attribute data_2: Data_2_dc + Attribute float64_super_r: float64 = "1.1" + Attribute float64_super_c: float64 = "1.1" + Attribute float64_super_i: float64 = "1.1" + external Port reg_port + } + } + + ActorClass Testee_2_ac extends Testee_Super2_ac { + Structure { + Attribute int32_own_r: int32 = "11" + Attribute int32_own_c: int32 = "11" + Attribute int32_own_i: int32 = "11" + SAP sap: TestProtocolWithDataClass + } + Behavior { + StateMachine { + Transition init: initial -> s1 + State s1 { + entry { + "caseId = etUnit_openTestCase(\"AttrConfigTest_case_Testee_2_ac\");" + "sap.varCheck(caseId);" + "reg_port.varCheck(caseId);" + "EXPECT_TRUE(caseId, \"Testee_2_ac:1\", float64_super_c == 2.2);" + "EXPECT_TRUE(caseId, \"Testee_2_ac:2\", float64_super_i == 4.4);" + "EXPECT_TRUE(caseId, \"Testee_2_ac:3\", int32_own_r == 11);" + "EXPECT_TRUE(caseId, \"Testee_2_ac:4\", int32_own_c == 12);" + "EXPECT_TRUE(caseId, \"Testee_2_ac:5\", int32_own_i == 13);" + "EXPECT_EQUAL_FLOAT32(caseId,\"Testee_2_ac:reg_port:6\", 50.f, reg_port.getFloat_i(), 0.1f);" + "etUnit_closeTestCase(caseId);" + } + } + } + } + } + + ProtocolClass TestProtocolAttributes { + incoming { + Message dummy() + } + regular PortClass + { + Operation varCheck(caseId: int32) { + "EXPECT_EQUAL_FLOAT32(caseId,\"TestProtocolAttributes:1\", 4.f, float_r, 0.1f);" + "EXPECT_EQUAL_FLOAT32(caseId,\"TestProtocolAttributes:2\", 3.f, float_c, 0.1f);" + } + Attribute float_r: float32 = "4" + Attribute float_c: float32 = "16" + Attribute float_i: float32 = "256" + } + conjugated PortClass + { + Operation varCheck() { + "int caseId = etUnit_openTestCase(\"ConfigTest_case_PortProtocol_conjugated\");" + "EXPECT_TRUE(caseId,\"array2_r[0]: <|MODEL_LOCATION|>\", array2_r[0] == 11);" + "EXPECT_TRUE(caseId,\"array2_r[1]: <|MODEL_LOCATION|>\", array2_r[1] == 22);" + "EXPECT_TRUE(caseId,\"array2_c[0]: <|MODEL_LOCATION|>\", array2_c[0] == 16);" + "EXPECT_TRUE(caseId,\"array2_c[1]: <|MODEL_LOCATION|>\", array2_c[1] == 32);" + "EXPECT_TRUE(caseId,\"array2_i[0]: <|MODEL_LOCATION|>\", array2_i[0] == 1);" + "EXPECT_TRUE(caseId,\"array2_i[1]: <|MODEL_LOCATION|>\", array2_i[1] == 2);" + "etUnit_closeTestCase(caseId);" + } + Attribute array2_r [ 2 ]: int64 = "{11,22}" + Attribute array2_c [ 2 ]: int64 = "{0,0}" + Attribute array2_i [ 2 ]: int64 = "{0,0}" + } + } + + ProtocolClass TestProtocolWithDataClass { + incoming { + Message dummy() + } + + //SAP + conjugated PortClass + { + Operation varCheck(caseId: int32) { + "sap_data_2.varCheck2(caseId);" + "sap_data_3.varCheck3(caseId);" + "EXPECT_TRUE(caseId, \"TestProtocolWithDataClass:1\", getSap_data_2().getInt32_c() == 2);" + "EXPECT_TRUE(caseId, \"TestProtocolWithDataClass:1\", getSap_data_2().getInt32_i() == 3);" + } + Attribute sap_data_2: Data_2_dc + + // none config test + Attribute sap_data_3: Data_3_dc + } + } + + DataClass Data_Super1_dc { + + // PrimitiveType + Attribute bool_r: boolean = "false" + Attribute bool_c: boolean = "false" + Attribute bool_i: boolean = "false" + Attribute int8_r: int8 = "8" + Attribute int8_c: int8 = "8" + Attribute int8_i: int8 = "8" + + // Array + Attribute bool_array_r [ 2 ]: boolean = "{ FALSE, false }" + Attribute bool_array_c [ 2 ]: boolean = "{ false, false }" + Attribute bool_array_i [ 2 ]: boolean = "{ false, false }" + Attribute int8_array_r [ 2 ]: int8 = "{ 8, 16 }" + Attribute int8_array_c [ 2 ]: int8 = "{ 8, 16 }" + Attribute int8_array_i [ 2 ]: int8 = "{ 8, 16 }" + } + + DataClass Data_1_dc extends Data_Super1_dc { + Operation varCheck1(caseId: int32) { + "data_2.varCheck2(caseId);" + + // PrimitiveType + "EXPECT_TRUE(caseId,\"Data_1_dc:varCheck:1\", bool_r == false);" + "EXPECT_TRUE(caseId,\"Data_1_dc:varCheck:2\", int8_r == 8);" + "EXPECT_TRUE(caseId,\"Data_1_dc:varCheck:3\", int16_r == 16);" + "EXPECT_TRUE(caseId,\"Data_1_dc:varCheck:4\", int32_r == 32);" + "EXPECT_TRUE(caseId,\"Data_1_dc:varCheck:5\", int64_r == 64);" + "EXPECT_EQUAL_FLOAT32(caseId,\"Data_1_dc:varCheck:6\", 3.2f, float32_r, 0.1f);" + "EXPECT_TRUE(caseId,\"Data_1_dc:varCheck:7\", float64_r == 6.4);" + "EXPECT_TRUE(caseId,\"Data_1_dc:varCheck:8\", char_r == \'R\');" + "EXPECT_TRUE(caseId,\"Data_1_dc:varCheck:9\", string_r.equals(\":/\"));" + + // Array + "EXPECT_TRUE(caseId,\"Data_1_dc:varCheck:10\", bool_array_r[0] == false && bool_array_r[1] == false);" + "EXPECT_TRUE(caseId,\"Data_1_dc:varCheck:11\", int8_array_r[0] == 8 && int8_array_r[1] == 16);" + "EXPECT_TRUE(caseId,\"Data_1_dc:varCheck:12\", int16_array_r[0] == 16 && int16_array_r[1] == 32);" + "EXPECT_TRUE(caseId,\"Data_1_dc:varCheck:13\", int32_array_r[0] == 32 && int32_array_r[1] == 64);" + "EXPECT_TRUE(caseId,\"Data_1_dc:varCheck:24\", int64_array_r[0] == 64 && int64_array_r[1] == 128);" + "EXPECT_TRUE(caseId,\"Data_1_dc:varCheck:25\", float32_array_r[0] == 3.2f && float32_array_r[1] == 6.4f);" + "EXPECT_TRUE(caseId,\"Data_1_dc:varCheck:26\", float64_array_r[0] == 6.4 && float64_array_r[1] == 12.8);" + "EXPECT_TRUE(caseId,\"Data_1_dc:varCheck:27\", String.valueOf(char_array_r).equals(\"ROOM\"));" + } + Attribute int16_r: int16 = "16" + Attribute int16_c: int16 = "16" + Attribute int16_i: int16 = "16" + Attribute int32_r: int32 = "32" + Attribute int32_c: int32 = "32" + Attribute int32_i: int32 = "32" + Attribute int64_r: int64 = "64" + Attribute int64_c: int64 = "64" + Attribute int64_i: int64 = "64" + Attribute float32_r: float32 = "3.2" + Attribute float32_c: float32 = "3.2" + Attribute float32_i: float32 = "3.2" + Attribute float64_r: float64 = "6.4" + Attribute float64_c: float64 = "6.4" + Attribute float64_i: float64 = "6.4" + Attribute char_r: char = "R" + Attribute char_c: char = 'R' + Attribute char_i: char = "R" + Attribute string_r: string = ":/" + Attribute string_c: string = ":/" + Attribute string_i: string = ":/" + + // Array + Attribute int16_array_r [ 2 ]: int16 = "{ 16, 32 }" + Attribute int16_array_c [ 2 ]: int16 = "{ 16, 32 }" + Attribute int16_array_i [ 2 ]: int16 = "{ 16, 32 }" + Attribute int32_array_r [ 2 ]: int32 = "{ 32, 64 }" + Attribute int32_array_c [ 2 ]: int32 = "{ 32, 64 }" + Attribute int32_array_i [ 2 ]: int32 = "{ 32, 64 }" + Attribute int64_array_r [ 2 ]: int64 = "{ 64, 128 }" + Attribute int64_array_c [ 2 ]: int64 = "{ 64, 128 }" + Attribute int64_array_i [ 2 ]: int64 = "{ 64, 128 }" + Attribute float32_array_r [ 2 ]: float32 = "{ 3.2, 6.4 }" + Attribute float32_array_c [ 2 ]: float32 = "{ 3.2, 6.4 }" + Attribute float32_array_i [ 2 ]: float32 = "{ 3.2, 6.4 }" + Attribute float64_array_r [ 2 ]: float64 = "{ 6.4, 12.8 }" + Attribute float64_array_c [ 2 ]: float64 = "{ 6.4, 12.8 }" + Attribute float64_array_i [ 2 ]: float64 = "{ 6.4, 12.8 }" + Attribute char_array_r [ 5 ]: char = "ROOM" + Attribute char_array_c [ 5 ]: char = "ROOM" + Attribute char_array_i [ 5 ]: char = "ROOM" + + // ComplexType + Attribute data_2: Data_2_dc + } + + DataClass Data_2_dc { + Operation varCheck2(caseId: int32) { + "EXPECT_TRUE(caseId, \"Data_2_dc:1\", int32_r == 1);" + } + Attribute int32_r: int32 = "1" + Attribute int32_c: int32 = "1" + Attribute int32_i: int32 = "1" + } + + DataClass Data_3_dc { + Operation varCheck3(caseId: int32) { + "EXPECT_TRUE(caseId, \"Data_3_dc:1\", dataClass_ref == null);" + "EXPECT_TRUE(caseId, \"Data_3_dc:2\", dataClass_array[0].getInt32_r() == 1);" + "EXPECT_TRUE(caseId, \"Data_3_dc:3\", dataClass_array[1].getInt32_c() == 1);" + "EXPECT_TRUE(caseId, \"Data_3_dc:4\", dataClass_ref_array[0] == null && dataClass_ref_array[1] == null);" + "EXPECT_TRUE(caseId, \"Data_3_dc:5\", ext_type instanceof External_Type_Test);" + "EXPECT_TRUE(caseId, \"Data_3_dc:6\", ext_type_array[0] instanceof External_Type_Test && ext_type_array[1] instanceof External_Type_Test);" + "EXPECT_TRUE(caseId, \"Data_3_dc:7\", ext_type_ref == null);" + "EXPECT_TRUE(caseId, \"Data_3_dc:8\", ext_type_ref_array[0] == null && ext_type_ref_array[1] == null);" + "EXPECT_TRUE(caseId, \"Data_3_dc:9\", primitive_array_ref instanceof byte[]);" + "EXPECT_TRUE(caseId, \"Data_3_dc:10\", string_ref == null);" + } +// none config test + Attribute dataClass_array [ 2 ]: Data_2_dc + Attribute dataClass_ref: Data_2_dc ref + Attribute dataClass_ref_array [ 2 ]: Data_2_dc ref + Attribute ext_type: extType + Attribute ext_type_array [ 2 ]: extType + Attribute ext_type_ref: extType ref + Attribute ext_type_ref_array [ 2 ]: extType ref + Attribute primitive_array_ref [ 2 ]: int8 ref + Attribute string_ref: string ref + + // no check at all + Attribute primitive1_ref: int8 ref + Attribute primitive3_ref: char ref + } + + ExternalType extType -> "External_Type_Test" + + Enumeration Enum_1 { + zero, + one, + two + } + + Enumeration Enum_2 of int16 { + three=3, + four + } + +}
\ No newline at end of file |