Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2012-10-18 10:45:14 +0000
committerHenrik Rentz-Reichert2012-10-18 10:47:54 +0000
commit8b4c06a7439b656d68c616ae8bfd2b8a0674d872 (patch)
tree89b26712de6dc420371f89d25de021ca28c3855c
parente7fb9972518c6ff3d4c6d7d5da61a86fc70b770b (diff)
downloadorg.eclipse.etrice-8b4c06a7439b656d68c616ae8bfd2b8a0674d872.tar.gz
org.eclipse.etrice-8b4c06a7439b656d68c616ae8bfd2b8a0674d872.tar.xz
org.eclipse.etrice-8b4c06a7439b656d68c616ae8bfd2b8a0674d872.zip
[generator.common.tests, generator.java.tests] added config test
-rw-r--r--tests/org.eclipse.etrice.generator.common.tests/models/ConfigTest.config107
-rw-r--r--tests/org.eclipse.etrice.generator.common.tests/models/ConfigTest.room256
-rw-r--r--tests/org.eclipse.etrice.generator.common.tests/models/subSystemConfigTest.rt-config13
-rw-r--r--tests/org.eclipse.etrice.generator.java.tests/make.xml15
4 files changed, 391 insertions, 0 deletions
diff --git a/tests/org.eclipse.etrice.generator.common.tests/models/ConfigTest.config b/tests/org.eclipse.etrice.generator.common.tests/models/ConfigTest.config
new file mode 100644
index 000000000..0acd8e297
--- /dev/null
+++ b/tests/org.eclipse.etrice.generator.common.tests/models/ConfigTest.config
@@ -0,0 +1,107 @@
+import ConfigTest.* from "ConfigTest.room"
+
+SubSystemConfig SubSystemConfigTest {
+ dynamic configuration {
+ file path "models/subSystemConfigTest.rt-config"
+ //user import "import org.eclipse.etrice.runtime.java.config.ConfigSourceFile"
+ //user constructor "new ConfigSourceFile(\"test\")"
+ polling timer [ms] 4000
+ }
+}
+
+/*
+ * Class Config
+ */
+
+// Actors
+ActorClassConfig Testee_ac {
+ Attr bool_c = false
+ Attr int_c = 210
+ Attr float_c = 16777215
+ Attr char_c = "A"
+ Attr charArray_c = "ROOM-Coon"
+ Attr string_c = ":-)"
+ Attr string_i = ":-]"
+ Attr bool_i = false
+ Attr int_i = 310
+ Attr float_i = 0.0
+ Attr char_i = "B"
+ Attr charArray_i = "ROOM Gloom"
+ Attr array1_c = 99
+ Attr array1_i = 99
+ Attr array2_c = false, false
+ Attr array2_i = false, false
+}
+
+// Protocols
+ProtocolClassConfig PortProtocol {
+ regular Port {
+ Attr float_c = 3
+ Attr float_i = 9
+ }
+ conjugate Port {
+ Attr array1_c = 1
+ Attr array1_i = 2
+ Attr array2_c = 16, 32
+ Attr array2_i = 16, 32
+ }
+}
+
+/*
+ * Instance Config
+ */
+
+ ActorInstanceConfig SubSystemConfigTest / top / testee {
+ Attr bool_i = true
+ Attr int_i = 301
+ Attr float_i = 1.0E-5
+ Attr char_i = "C"
+ Attr charArray_i = "ROOM 2 Moon"
+ Attr string_i = ":^]"
+ Attr array1_i = 4
+ Attr array2_i = false, true
+ InterfaceItem Reg_port {
+ Attr float_i = 25
+ }
+}
+
+ActorInstanceConfig SubSystemConfigTest / top / testee / AR1 {
+ InterfaceItem Conj_port {
+ Attr array1_i = 256
+ Attr array2_i = 1, 2
+ }
+}
+
+ActorInstanceConfig SubSystemConfigTest / top / testee2 {
+ Attr int_i = 301 {
+ dynamic configuration read
+ }
+ Attr dc_i {
+ dynamic configuration read Attr int_i = 302
+ Attr long_array_i = 303
+ Attr dc_i {
+ Attr char_i = "instance3"
+ Attr double_i = 0.304
+ }
+ }
+ Attr blockMe = 0 {
+ dynamic configuration read
+ }
+ Attr blocker = false {
+ dynamic configuration read
+ }
+ Attr dc_dump{
+ dynamic configuration write
+ Attr dc_i {
+ Attr char_i = "dummy"
+ Attr double_i = 0.0e-100
+ }
+ Attr long_array_i = 1000
+ Attr int_i = 123
+ }
+ Attr int_dump = 3 {
+ dynamic configuration write
+ }
+}
+
+
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()
+ }
+ }
+
+
+}
diff --git a/tests/org.eclipse.etrice.generator.common.tests/models/subSystemConfigTest.rt-config b/tests/org.eclipse.etrice.generator.common.tests/models/subSystemConfigTest.rt-config
new file mode 100644
index 000000000..060e2151e
--- /dev/null
+++ b/tests/org.eclipse.etrice.generator.common.tests/models/subSystemConfigTest.rt-config
@@ -0,0 +1,13 @@
+/SubSystemConfigTest/top/testee2/blockMe=0
+/SubSystemConfigTest/top/testee2/blocker=false
+/SubSystemConfigTest/top/testee2/dc_dump/dc_i/char_i="dummy out"
+/SubSystemConfigTest/top/testee2/dc_dump/dc_i/double_i=0.0
+/SubSystemConfigTest/top/testee2/dc_dump/int_i=123
+/SubSystemConfigTest/top/testee2/dc_dump/long_array_i={ 1000 }
+/SubSystemConfigTest/top/testee2/dc_i/dc_i/char_i="instance4"
+/SubSystemConfigTest/top/testee2/dc_i/dc_i/double_i=0.404
+/SubSystemConfigTest/top/testee2/dc_i/int_i=402
+/SubSystemConfigTest/top/testee2/dc_i/long_array_i={ 403 }
+/SubSystemConfigTest/top/testee2/int_dump=888
+/SubSystemConfigTest/top/testee2/int_i=401
+polling_timer[ms]=4000
diff --git a/tests/org.eclipse.etrice.generator.java.tests/make.xml b/tests/org.eclipse.etrice.generator.java.tests/make.xml
index 52b20f0d5..9bff395da 100644
--- a/tests/org.eclipse.etrice.generator.java.tests/make.xml
+++ b/tests/org.eclipse.etrice.generator.java.tests/make.xml
@@ -61,6 +61,8 @@
<copy todir="models" >
<fileset dir="../org.eclipse.etrice.generator.common.tests/models">
<include name="*.room"/>
+ <include name="*.config"/>
+ <include name="*.rt-config"/>
</fileset>
<fileset dir="../../runtime/org.eclipse.etrice.modellib.java/models">
<include name="TimingService.room"/>
@@ -107,6 +109,8 @@
<arg value="${java.tests.model.path}/PingPongThreadReplPortTest.room"/>
<arg value="${java.tests.model.path}/SendingDataTestJava.room"/>
<arg value="${java.tests.model.path}/TCPTest.room"/>
+ <arg value="${java.tests.model.path}/ConfigTest.room"/>
+ <arg value="${java.tests.model.path}/ConfigTest.config"/>
<!-- copied modellib.java models -->
<arg value="${java.tests.model.path}/TimingService.room"/>
@@ -134,6 +138,10 @@
-->
<target name="run" depends="compile">
<mkdir dir="tmp/log"/>
+ <java output="${output}/runConfigTest.txt" classname="ConfigTest.SubSystemConfigTestRunner" fork="true" failonerror="true">
+ <arg value="-run_as_test"/>
+ <classpath path="${bin.path};${runtime.path}/bin;${modellib.path}/bin"/>
+ </java>
<java output="${output}/runHandlerTest.txt" classname="HandlerTest.SubSystem_HandlerTestRunner" fork="true" failonerror="true">
<arg value="-run_as_test"/>
<classpath path="${bin.path};${runtime.path}/bin;${modellib.path}/bin"/>
@@ -215,6 +223,13 @@
<arg value="./tmp/TCPTest.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"/>
+ <arg value="org.eclipse.etrice.generator.java.tests.ConfigPTest"/>
+ <arg value="./tmp/ConfigTest.etu"/>
+ <classpath refid="clspath"/>
+ </java>
</target>
<!--

Back to the top