Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 9817cb769b0fd0e947ba1b51c1df402224eb2283 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
RoomModel ConfigTest {

	import room.basic.types.* from "Types.room"

	/* if this is included the paths start with the LogicalSystem's name and the configuration mappings don't work	
	LogicalSystem System_ConfigTest {
		SubSystemRef SubSystem_ConfigTest: SubSystemConfigTest
	}
	*/

	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"
			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_EQUAL_FLOAT32(caseId,\"float_r: <|MODEL_LOCATION|>\", 4.f, float_r, 0.1f);"
				"EXPECT_EQUAL_FLOAT32(caseId,\"float_c: <|MODEL_LOCATION|>\", 3.f, float_c, 0.1f);"
				"EXPECT_EQUAL_FLOAT32(caseId,\"float_i: <|MODEL_LOCATION|>\", 25.f, float_i, 0.1f);"
				"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_EQUAL_FLOAT32(caseId,\"array1_r[0]: <|MODEL_LOCATION|>\", 1000.f, array1_r[0], 0.1f);"
				"EXPECT_EQUAL_FLOAT32(caseId,\"array1_c[0]: <|MODEL_LOCATION|>\", 1.f, array1_c[0], 0.1f);"
				"EXPECT_EQUAL_FLOAT32(caseId,\"array1_i[0]: <|MODEL_LOCATION|>\", 256.f, array1_i[0], 0.1f);"
				"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_testFinished(caseId);"
				"return etUnit_isSuccess(caseId);"
			}
		}
	}
	
	ProtocolClass TestCommProtocol {
		incoming {
			Message ok()
			
		}
		outgoing {
			Message test()
		}
	}
	

}

Back to the top