Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 92141b100ac38efb23930fd83c2228f18015bc73 (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
RoomModel DataDrivenTest {
	
	import room.basic.types.* from "../../../runtime/${etModellib}/model/Types.room"
	import room.basic.test.* from "../../../runtime/${etModellib}/model/Tests.room"
	import room.basic.service.timing.* from "../../../runtime/${etModellib}/model/TimingService.room"
	
	SubSystemClass SubSystem_DataDrivenTest {
		@TestInstance
		ActorRef appl: Appl
		ActorRef timing: ATimingService
		LayerConnection ref appl satisfied_by timing.timer
		
		// all unmapped instances are mapped to the default *physical* thread
		//LogicalThread dflt_thread
		//ActorInstanceMapping appl -> dflt_thread
		//ActorInstanceMapping timing -> dflt_thread
	}

	ActorClass Appl {
		Structure {
			ActorRef srv: Tester
			ActorRef cli: Testee
			Binding srv.p0 and cli.p0
		}
		Behavior { }
	}	
	async ActorClass Tester {
		Interface {
			conjugated Port p0: PC
		}
		Structure {
			external Port p0
			SAP timer: PTimer
			
			Attribute counter: int32
		}
		Behavior {
			StateMachine {
				Transition init: initial -> Idle {
					action {
						"timer.startTimer(300);"
						"counter = 0;"
					}
				}
				Transition tr0: Idle -> Idle {
					triggers {
						<timeout: timer>
					}
				}
				State Idle {
					entry {
						"p0.in1(counter++);"
					}
				}
			}
		}
	}
	async ActorClass Testee {
		Interface {
			Port p0: PC
		}
		Structure {
			external Port p0
			
			Attribute caseId: int32
			Attribute counter: int32
			Attribute resultlist[10]: int16 = "{1,2,3,4,5,6,7,8,9,10}"
		}
		Behavior {
			ctor {
				"caseId = etUnit_openAll(\"log\", \"DataDrivenTest\", \"org.eclipse.etrice.generator.common.tests.DataDrivenTest\", \"DataDrivenTest_case\");"
			}
			dtor {
				"etUnit_closeAll(caseId);"
			}
			StateMachine {
				Transition init: initial -> Idle {
					action {
						"counter = 0;"
					}
				}
				Transition tr0: Idle -> Idle {
					guard {
						"p0.in1==counter"
					}
					action {
						"if (p0.in1==1)"
						"	EXPECT_ORDER_START(caseId, resultlist, 10);"
						"if (p0.in1<10)"
						"	EXPECT_ORDER(caseId,\"<|MODEL_LOCATION|>\", p0.in1);"
						"else if (counter==10) {"
						"	EXPECT_ORDER_END(caseId,\"<|MODEL_LOCATION|>\", 10);"
						"	etUnit_testFinished(caseId);"
						"}"
						"++counter;"
					}
				}
				State Idle
			}
		}
	}
	
	datadriven ProtocolClass PC {
		incoming {
			Message in1(data: int32)
			Message in2(data: int8)
			Message in3(data: DC)
		}
	}
	
	DataClass DC {
		Attribute x: float32
		Attribute i: int32
	}
}

Back to the top