Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 78f0d91e544c2efee05f9182b0824e01055a1a0c (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
<?xml version="1.0"?>
<!--
	Ant makefile for building and running of tests.
	
	Includes common.xml from org.eclipse.etrice.generator.common.tests
-->
<project name="org.eclipse.etrice.generator.java.tests" basedir="." default="all">
	
	<target name="testing" depends="dynamicActorTests,common.testing">
		
		<!-- add test here, testid==testSuiteFileName -->
		<test testid="SendingDataTestJava" 	models="${models.path}/sendingData/SendingDataTestJava.room ${models.path}/GenericPhysical.etphys" />
		<test testid="TCPTest"		 	 	models="${models.path}/TCPTest.room ${models.path}/GenericPhysical.etphys" />
		<test testid="DynamicConfigTest" 	models="${models.path}/DynamicConfigTest.etmap ${models.path}/DynamicConfigTest.config"/>
		<test testid="StaticConfigTest" models="${models.path}/staticConfig/StaticConfigTest.etmap ${models.path}/staticConfig/StaticConfigTest.config" />
		
		<echo>done with ${ant.project.name}</echo>
	</target>
	
	<target name="dynamicActorTests">
		<property name="genOptions" value="-persistable -storeDataObj"/>
		
		<test testid="DynamicActorTest1" genOptions="${genOptions}" models="${models.path}/DynamicActorTest1.etmap" />
		<test testid="DynamicActorTest2" genOptions="${genOptions}" models="${models.path}/DynamicActorTest2.etmap" />
		<test testid="DynamicActorTest3" genOptions="${genOptions}" models="${models.path}/DynamicActorTest3.room ${models.path}/GenericPhysical.etphys" />
		<test testid="DynamicActorTest4" genOptions="${genOptions}" models="${models.path}/DynamicActorTest4.room ${models.path}/GenericPhysical.etphys" />
		<test testid="DynamicActorTest5" genOptions="${genOptions}" models="${models.path}/DynamicActorTest5.room ${models.path}/GenericPhysical.etphys" />
		<test testid="DynamicActorTest6" genOptions="${genOptions}" models="${models.path}/DynamicActorTest6.room ${models.path}/GenericPhysical.etphys" />
		<test testid="DynamicActorTest7" genOptions="${genOptions}" models="${models.path}/DynamicActorTest7.etmap" />
		<test testid="StoreRestore" 	 genOptions="${genOptions}" models="${models.path}/StoreRestore.room ${models.path}/GenericPhysical.etphys" />
	</target>
	
	<target name="copyModels" depends="common.copyModels">
		<copy todir="${models.path}">
			<fileset dir="./targetModels"/>
		</copy>
		<move file="${models.path}/staticConfig/StaticConfigTest_Java.room" toFile="${models.path}/staticConfig//StaticConfigTest.room" />
	</target>
	
	<!-- ################################################################ -->
	
	<import file="../org.eclipse.etrice.generator.common.tests/common.xml" as="common"/>
	
	<property name="modellib.path" value="../../runtime/org.eclipse.etrice.modellib.java" />
	<property name="runtime.path" value="../../runtime/org.eclipse.etrice.runtime.java" />
	
	<target name="all" depends="clean,copyModels,testing"/>
		
	<!-- test := generate 1 executable, build, run, process results -->
	<macrodef name="test">
		<attribute name="testId"/>
		<attribute name="models"/>
		<attribute name="genOptions" default=""/>
		<sequential>
			<standaloneGenerator testId="@{testId}" models="@{models}" genOptions="@{genOptions}"/>
			<build testId="@{testId}"/>
			<run testId="@{testId}"/>
			<convert testId="@{testId}"/>
			<copyResult testId="@{testId}" targetId="Java_"/>
		</sequential>
	</macrodef>
	
	<macrodef name="standaloneGenerator">
		<attribute name="testId"/>
		<attribute name="models"/>
		<attribute name="genOptions" default=""/>
		<sequential>
			<mkdir dir="${output}"/>
			<java output="${output}/generate.txt" error="${output}/generate_err.txt" classname="org.eclipse.etrice.generator.java.Main" fork="true" failonerror="true">
				<arg line="@{models}"/>
				<arg value="-genDir"/><arg value="src-gen/@{testId}"/>
				<arg value="-msc_instr" />
				<arg line="@{genOptions}" />
				<classpath refid="etrice.clspath" />
			</java>
		</sequential>
	</macrodef>
	
		<!--
			compile: compiles the generated Java sources
		-->
		<macrodef name="build">
			<attribute name="testId"/>
			<sequential>
				<mkdir dir="${bin.path}/@{testId}" />
				<!-- ./src/xxx is optional, create it anyway to avoid error -->
				<mkdir dir="./src/@{testId}" />
				<record name="${basedir}/output/compile.txt" action="start"/>
				<javac destdir="${bin.path}/@{testId}" source="1.6" classpath="${runtime.path}/target/classes" debug="off" verbose="off">
					<src>
						<pathelement location="src-gen/@{testId}" />
						<pathelement location="src/@{testId}" />
					</src>
				</javac>
				<record name="${basedir}/output/compile.txt" action="stop"/>
			</sequential>
		</macrodef>

		<!--
			run: runs all executables
		-->
		<macrodef name="run">
			<attribute name="testId"/>
			<sequential>
				<mkdir dir="${testlog.path}" />
				<!-- get runner class -->
				<local name="runner.class"/>
			 	<fileset id="runnerFileSet" dir="./src-gen/@{testId}">
					<include name="**/*Runner.java"/>
				</fileset>
				<pathconvert property="runner.class">
					<string>${toString:runnerFileSet}</string>
					<chainedmapper>
						<globmapper from="*.java" to="*"/>
						<packagemapper from="*" to="*"/>
					</chainedmapper>
				</pathconvert>
				<!--<echo>path of runner.java: ${toString:runnerFileSet}</echo>
				<echo>runner path converted to class: ${runner.class}</echo>-->
				
				<echo>run @{testId}</echo>
				<java output="${output}/run@{testId}.txt" classname="${runner.class}" fork="true" failonerror="true" timeout="${run.msTimout}">
					<arg value="-run_as_test" />
					<classpath path="./bin/@{testId};${runtime.path}/target/classes;" />
				</java>
			</sequential>
		</macrodef>

</project>

Back to the top