Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'tests/org.eclipse.etrice.generator.common.tests/models/ConfigTest.room')
-rw-r--r--tests/org.eclipse.etrice.generator.common.tests/models/ConfigTest.room256
1 files changed, 256 insertions, 0 deletions
diff --git a/tests/org.eclipse.etrice.generator.common.tests/models/ConfigTest.room b/tests/org.eclipse.etrice.generator.common.tests/models/ConfigTest.room
new file mode 100644
index 000000000..2d3cd1549
--- /dev/null
+++ b/tests/org.eclipse.etrice.generator.common.tests/models/ConfigTest.room
@@ -0,0 +1,256 @@
+RoomModel ConfigTest {
+
+ import room.basic.types.* from "Types.room"
+
+ SubSystemClass SubSystemConfigTest {
+ ActorRef top: ConfigTest_Top_ac
+ }
+
+ ActorClass ConfigTest_Top_ac {
+ Structure {
+ ActorRef testee: Testee_ac
+ ActorRef testee2: DynTestee_ac
+ Binding testee2.Conj_DynConfigPort and testee.Reg_dynConfigPort
+ }
+ Behavior {
+ Operation ConfigTest_Top_ac() {
+ "etUnit_open(\"tmp\", \"ConfigTest\");"
+ "etUnit_openTestSuite(\"org.eclipse.etrice.generator.common.tests.ConfigTest\");"
+ }
+ Operation ~ConfigTest_Top_ac() {
+ "etUnit_closeTestSuite();"
+ "etUnit_close();"
+ }
+ }
+ }
+
+ ActorClass DynTestee_ac {
+ Interface {
+ conjugated Port Conj_DynConfigPort: TestCommProtocol
+ }
+ Structure {
+ external Port Conj_DynConfigPort
+ Attribute caseId: int32
+ Attribute int_i : int32
+ Attribute dc_i : Dyn_DC1
+ // manual test
+ Attribute blockMe : int32
+ Attribute blocker : boolean
+ // not explicit test
+ Attribute dc_dump : Dyn_DC1
+ Attribute int_dump : int32
+ }
+ Behavior {
+ Operation DynTestee_ac() {
+ "caseId = etUnit_openTestCase(\"ConfigTest_case_DynTestee_ac\");"
+ }
+ Operation ~DynTestee_ac() {
+ "etUnit_closeTestCase(caseId);"
+ }
+ StateMachine {
+ Transition init: initial -> First { }
+ Transition tr0: First -> Done {
+ triggers {
+ <test : Conj_DynConfigPort>
+ }
+ action {
+ // write without test
+ "Dyn_DC1 tmp = new Dyn_DC1(123, new long[]{1000}, new Dyn_DC2(0.0e-100, \"dummy out\".toCharArray()));"
+ "setAndWriteDc_dump(tmp);"
+ "setAndWriteInt_dump(888);"
+ // read test
+ "if(blocker)getBlockMeLock().forbidUpdate(); else getBlockMeLock().allowUpdate();"
+ "EXPECT_TRUE(caseId,\"<|MODEL_LOCATION|>\", int_i == 401 && getDc_i().getLong_array_i()[0] == 403);"
+ "EXPECT_TRUE(caseId,\"<|MODEL_LOCATION|>\", getDc_i().getDc_i().getDouble_i() == 0.404);"
+ "EXPECT_TRUE(caseId,\"<|MODEL_LOCATION|>\", String.valueOf(getDc_i().getDc_i().getChar_i()).equals(\"instance4\"));"
+ "System.out.println(\"blockMe: \"+getBlockMe()+\", blocker: \"+getBlocker());"
+ "if(!etUnit_isSuccess(caseId))"
+ "\tetUnit_testFinished(caseId);"
+ "else"
+ "\tConj_DynConfigPort.ok();"
+ }
+ }
+ State First {}
+ State Done{}
+ }
+ }
+ }
+
+ DataClass Dyn_DC1 {
+ Attribute int_i: int32
+ Attribute long_array_i[1]: int64 = "0"
+ Attribute dc_i : Dyn_DC2
+ }
+
+ DataClass Dyn_DC2 {
+ Attribute double_i: float64
+ Attribute char_i[10] : char
+ }
+
+ ActorClass AC1_ac {
+ Interface {
+ conjugated Port Conj_port: PortProtocol
+ }
+ Structure {
+ external Port Conj_port
+ }
+ Behavior {
+ StateMachine {
+ Transition init: initial -> Done { }
+ State Done {
+ entry{
+ "if(Conj_port.varCheck())"
+ "\tConj_port.portTestSucc();"
+ }
+ }
+ }
+ }
+ }
+
+ ActorClass Testee_ac {
+ Interface{
+ Port Reg_dynConfigPort: TestCommProtocol
+ }
+ Structure {
+ usercode1 {
+ "import org.eclipse.etrice.runtime.java.messaging.RTServices;"
+ }
+ external Port Reg_dynConfigPort
+ Port Reg_port: PortProtocol
+ Attribute caseId: int32
+ Attribute bool_r: boolean = "true"
+ Attribute bool_c: boolean = "true"
+ Attribute bool_i: boolean = "true"
+ Attribute int_r: int32 = "100"
+ Attribute int_c: int32 = "200"
+ Attribute int_i: int32 = "300"
+ Attribute float_r: float64 = "11.11"
+ Attribute float_c: float64 = "22.22"
+ Attribute float_i: float64 = "33.33"
+
+ Attribute char_r: char = "'R'"
+ Attribute char_c: char = "'C'"
+ Attribute char_i: char = "'I'"
+
+ Attribute charArray_r[20] : char = "\"ROOM will bloom\".toCharArray()"
+ Attribute charArray_c [ 20 ]: char = "ROOM Zoom"
+ Attribute charArray_i [ 20 ]: char = "ROOM Boom"
+ Attribute string_r : string = "\":/\""
+ Attribute string_c : string = "\":)\""
+ Attribute string_i : string = "\":]\""
+ Attribute array1_r [ 1 ]: int32 = "0"
+ Attribute array1_c [ 1 ]: int32 = "0"
+ Attribute array1_i [ 1 ]: int32 = "0"
+ Attribute array2_r [ 2 ]: boolean = "{true, true}"
+ Attribute array2_c [ 2 ]: boolean = "{true, false}"
+ Attribute array2_i [ 2 ]: boolean = "{true, false}"
+
+ ActorRef AR1: AC1_ac
+ Binding Reg_port and AR1.Conj_port
+ }
+ Behavior {
+ Operation Testee_ac() {
+ "caseId = etUnit_openTestCase(\"ConfigTest_case_Testee_ac\");"
+ }
+ Operation ~Testee_ac() {
+ "etUnit_closeTestCase(caseId);"
+ }
+ StateMachine {
+ Transition init: initial -> Testing1 { }
+ Transition tr1: Testing1 -> Testing2{
+ triggers{
+ <portTestSucc : Reg_port>
+ }
+ }
+ Transition tr2: Testing2 -> Done{
+ triggers{
+ <ok : Reg_dynConfigPort>
+ }
+ }
+
+ State Testing1 {
+ entry {
+ "if(Reg_port.varCheck())"
+ "\tReg_port.conjCheck();"
+ }
+ }
+ State Testing2{
+ entry{
+ "Reg_dynConfigPort.test();"
+ }
+ }
+ State Done {
+ entry {
+ "EXPECT_TRUE(caseId,\"<|MODEL_LOCATION|>\", bool_r == true && bool_c == false && bool_i == true);"
+ "EXPECT_TRUE(caseId,\"<|MODEL_LOCATION|>\", int_r == 100 && int_c == 210 && int_i == 301);"
+ "EXPECT_TRUE(caseId,\"<|MODEL_LOCATION|>\", float_r == 11.11 && float_c ==0xFFFFFF && float_i == 0.00001);"
+ "EXPECT_TRUE(caseId,\"<|MODEL_LOCATION|>\", char_r == \'R\' && char_c == \'A\' && char_i == \'C\');"
+ "// string_r.equals(\"ROOM will bloom\")"
+ "EXPECT_TRUE(caseId,\"<|MODEL_LOCATION|>\", !charArray_r.equals(\"ROOM will bloom\") && !charArray_c.equals(\"ROOM-Coon\") && !charArray_i.equals(\"ROOM 2 Moon\"));"
+ "EXPECT_TRUE(caseId,\"<|MODEL_LOCATION|>\", string_r.equals(\":/\") && string_c.equals(\":-)\") && string_i.equals(\":^]\"));"
+ "EXPECT_TRUE(caseId,\"<|MODEL_LOCATION|>\", array1_r[0] == 0 && array1_c[0] == 99 && array1_i[0] == 4);"
+ "EXPECT_TRUE(caseId,\"<|MODEL_LOCATION|>\", array2_r[0] == true && array2_r[1] == true);"
+ "EXPECT_TRUE(caseId,\"<|MODEL_LOCATION|>\", array2_c[0] == false && array2_c[1] == false);"
+ "EXPECT_TRUE(caseId,\"<|MODEL_LOCATION|>\", array2_i[0] == false && array2_i[1] == true);"
+ "etUnit_testFinished(caseId);"
+ }
+ }
+ }
+ }
+ }
+
+
+ ProtocolClass PortProtocol {
+ usercode1 {
+ "import org.eclipse.etrice.runtime.java.messaging.RTServices;"
+ }
+ incoming {
+ Message portTestSucc()
+ }
+ outgoing {
+ Message conjCheck()
+ }
+ regular PortClass
+ {
+ Attribute float_r: float32 = "4"
+ Attribute float_c: float32 = "16"
+ Attribute float_i: float32 = "256"
+ Operation varCheck():boolean {
+ "int caseId = etUnit_openTestCase(\"ConfigTest_case_PortProtocol_regular\");"
+ "EXPECT_TRUE(caseId,\"<|MODEL_LOCATION|>\", float_r == 4 && float_c == 3 && float_i == 25);"
+ "etUnit_testFinished(caseId);"
+ "return etUnit_isSuccess(caseId);"
+ }
+ }
+ conjugate PortClass
+ {
+ Attribute array1_r [ 1 ]: float32 = "1000"
+ Attribute array1_c [ 1 ]: float32 = "1001"
+ Attribute array1_i [ 1 ]: float32 = "1002"
+ Attribute array2_r [ 2 ]: int64 = "{11,22}"
+ Attribute array2_c [ 2 ]: int64 = "{0,0}"
+ Attribute array2_i [ 2 ]: int64 = "{0,0}"
+ Operation varCheck():boolean {
+ "int caseId = etUnit_openTestCase(\"ConfigTest_case_PortProtocol_conjugated\");"
+ "EXPECT_TRUE(caseId,\"<|MODEL_LOCATION|>\", array1_r[0] == 1000 && array1_c[0] == 1 && array1_i[0] == 256);"
+ "EXPECT_TRUE(caseId,\"<|MODEL_LOCATION|>\", array2_r[0] == 11 && array2_r[1] == 22);"
+ "EXPECT_TRUE(caseId,\"<|MODEL_LOCATION|>\", array2_c[0] == 16 && array2_c[1] == 32);"
+ "EXPECT_TRUE(caseId,\"<|MODEL_LOCATION|>\", array2_i[0] == 1 && array2_i[1] == 2);"
+ "etUnit_testFinished(caseId);"
+ "return etUnit_isSuccess(caseId);"
+ }
+ }
+ }
+
+ ProtocolClass TestCommProtocol {
+ incoming {
+ Message ok()
+
+ }
+ outgoing {
+ Message test()
+ }
+ }
+
+
+}

Back to the top