Mon, 25 Apr 2011 15:56:09 -0700
7038363: cast from object to primitive should be for source >= 1.7
Reviewed-by: mcimadamore
1 #
2 # Makefile to run jtreg and other tests
3 #
5 # Product builds and langtools builds
6 #
7 # A full product build (or "control" build) creates a complete JDK image.
8 # To test a product build, set TESTJAVA to the path for the image.
9 #
10 # A langtools build just builds the langtools components of a JDK.
11 # To test a langtools build, set TESTJAVA to the path for a recent JDK
12 # build, and set TESTBOOTCLASSPATH to the compiled langtools classes --
13 # for example build/classes or dist/lib/classes.jar.
15 # JPRT
16 # JPRT may invoke this Makefile directly, as part of a langtools build,
17 # or indirectly, via FOREST/test/Makefile, as part of a control build.
19 # Get OS/ARCH specifics
20 OSNAME = $(shell uname -s)
21 ifeq ($(OSNAME), SunOS)
22 PLATFORM = solaris
23 JT_PLATFORM = solaris
24 ARCH = $(shell uname -p)
25 ifeq ($(ARCH), i386)
26 ARCH=i586
27 endif
28 endif
29 ifeq ($(OSNAME), Linux)
30 PLATFORM = linux
31 JT_PLATFORM = linux
32 ARCH = $(shell uname -m)
33 ifeq ($(ARCH), i386)
34 ARCH=i586
35 endif
36 endif
37 ifeq ($(OSNAME), Windows_NT)
38 PLATFORM = windows
39 JT_PLATFORM = win32
40 ifeq ($(word 1, $(PROCESSOR_IDENTIFIER)),ia64)
41 ARCH=ia64
42 else
43 ifeq ($(word 1, $(PROCESSOR_IDENTIFIER)),AMD64)
44 ARCH=x64
45 else
46 ifeq ($(word 1, $(PROCESSOR_IDENTIFIER)),EM64T)
47 ARCH=x64
48 else
49 ARCH=i586
50 endif
51 endif
52 endif
53 EXE_SUFFIX=.exe
54 endif
56 # Root of this test area (important to use full paths in some places)
57 TEST_ROOT := $(shell pwd)
59 # Default bundle of all test results (passed or not) (JPRT only)
60 ifdef JPRT_JOB_ID
61 JPRT_CLEAN = clean
62 JPRT_ARCHIVE_BUNDLE = $(TEST_ROOT)/JPRT_ARCHIVE_BUNDLE.zip
63 endif
65 ifeq ($(PLATFORM), windows)
66 SLASH_JAVA = J:
67 else
68 SLASH_JAVA = /java
69 endif
71 # Default JTREG to run
72 ifdef JPRT_JTREG_HOME
73 JTREG_HOME = $(JPRT_JTREG_HOME)
74 else
75 JTREG_HOME = $(SLASH_JAVA)/re/jtreg/4.0/promoted/latest/binaries/jtreg
76 endif
77 JTREG = $(JTREG_HOME)/$(JT_PLATFORM)/bin/jtreg
78 JTDIFF = $(JTREG_HOME)/$(JT_PLATFORM)/bin/jtdiff
80 # Default JCK to run
81 ifdef JPRT_JCK_HOME
82 JCK_HOME = $(JPRT_JCK_HOME)
83 else
84 JCK_HOME = $(SLASH_JAVA)/re/jck/7/promoted/latest/binaries
85 endif
87 # Default JDK for JTREG and JCK
88 #
89 # JT_JAVA is the version of java used to run jtreg/JCK. Since it is now
90 # standard to execute tests in sameVM mode, it should normally be set the
91 # same as TESTJAVA (although not necessarily so.)
92 #
93 ifdef JPRT_JAVA_HOME
94 JT_JAVA = $(JPRT_JAVA_HOME)
95 else
96 JT_JAVA = $(SLASH_JAVA)/re/jdk/1.6.0/archive/fcs/binaries/$(PLATFORM)-$(ARCH)
97 endif
99 # Default JDK to test
100 ifdef JPRT_IMPORT_PRODUCT_HOME
101 TESTJAVA = $(JPRT_IMPORT_PRODUCT_HOME)
102 else
103 TESTJAVA = $(SLASH_JAVA)/re/jdk/1.7.0/promoted/latest/binaries/$(PLATFORM)-$(ARCH)
104 endif
106 # PRODUCT_HOME is a JPRT variable pointing to a directory containing the output from
107 # make/Makefile
108 # For langtools, this is a directory containing build and dist
109 # For a control build, this is build/$(PRODUCT)-$(ARCH)/XYZ-image
110 # (i.e, j2sdk-image or jdk-module-image)
111 ifdef PRODUCT_HOME
112 ifeq ($(shell [ -r $(PRODUCT_HOME)/dist/lib/classes.jar ]; echo $$?),0)
113 TESTBOOTCLASSPATH = $(PRODUCT_HOME)/dist/lib/classes.jar
114 endif
115 ifeq ($(shell [ -r $(PRODUCT_HOME)/bin/javac$(EXE_SUFFIX) ]; echo $$?),0)
116 TESTJAVA = $(PRODUCT_HOME)
117 endif
118 endif
120 ifdef TESTBOOTCLASSPATH
121 JTREG_OPTIONS += -Xbootclasspath/p:$(TESTBOOTCLASSPATH)
122 ### In the following, -refvmoptions is an undocumented option
123 ### The following does not work JCK 7 b30 2/6/2010. Awaiting b31.
124 JCK_OPTIONS += \
125 -vmoptions:-Xbootclasspath/p:$(TESTBOOTCLASSPATH) \
126 -refvmoptions:-Xbootclasspath/p:$(TESTBOOTCLASSPATH)
127 endif
129 # Concurrency is the number of tests that can execute at once.
130 # Supported for JCK, not supported for jtreg.
131 # On an otherwise empty machine, suggest setting to (#cpus + 2)
132 # If unset, the default is (#cpus)
133 ### RFE: determine and use #cpus
134 ifdef JCK_CONCURRENCY
135 JCK_OPTIONS += -concurrency:$(JCK_CONCURRENCY)
136 endif
138 # JCK is executed using "Multi-JVM Group Mode", which is a hybrid
139 # of otherVM and sameVM modes. New JVMs are created and reused for
140 # a number of tests, then eventually discarded and a new one started.
141 # This amortizes the JVM startup time. The "group size" defines
142 # how many tests are run in a JVM before it is replaced.
143 # If unset, the default is 100.
144 JCK_GROUP_SIZE = 1000
145 ifdef JCK_GROUP_SIZE
146 JCK_COMPILER_OPTIONS += \
147 -jtoptions:-Ejck.env.compiler.testCompile.groupMode.groupSize=$(JCK_GROUP_SIZE) \
148 -jtoptions:-Ejck.env.compiler.compRefExecute.groupMode.groupSize=$(JCK_GROUP_SIZE)
149 ### The following is not supported. Awaiting RFE 6924287
150 ### 6924287: Jck4Jdk: Allow to configure test group size for group mode via simple command line option
151 ### JCK_RUNTIME_OPTIONS += \
152 ### -jtoptions:-Ejck.env.runtime.testCompile.groupMode.groupSize=$(JCK_GROUP_SIZE)
153 endif
155 # Timeouts -- by default, increase test timeouts when running on JPRT
156 ifdef JPRT_JOB_ID
157 ifndef JTREG_TIMEOUT_FACTOR
158 JTREG_TIMEOUT_FACTOR = 3
159 endif
160 endif
161 ifdef JTREG_TIMEOUT_FACTOR
162 JTREG_OPTIONS += -timeoutFactor:$(JTREG_TIMEOUT_FACTOR)
163 endif
165 # Assertions: some tests show failures when assertions are enabled.
166 # Since javac is typically loaded via the bootclassloader (either via TESTJAVA
167 # or TESTBOOTCLASSPATH), you may need -esa to enable assertions in javac.
168 JTREG_OPTIONS += $(ASSERTION_OPTIONS)
169 JCK_OPTIONS += $(ASSERTION_OPTIONS:%=-vmoptions:%)
171 # Include shared options
172 JCK_COMPILER_OPTIONS += $(JCK_OPTIONS)
173 JCK_RUNTIME_OPTIONS += $(JCK_OPTIONS)
175 # Exit codes:
176 # jtreg, jck: 0: OK, 1: tests failed, 2: tests error; 3+: SERIOUS
177 FATAL_JTREG_EXIT = 3
178 FATAL_JCK_EXIT = 3
179 # jtdiff: 0: OK, 1: differences found; 2+: SERIOUS
180 FATAL_JTDIFF_EXIT = 2
181 #
182 # Exit -- used for final "normal" exit from "make". Redefine to "true" to avoid
183 # having make exit with non-zero return code.
184 EXIT = exit
185 # Function to exit shell if exit code of preceding command is greater than or equal
186 # to a given level. Redefine function or preceding FATAL_*_EXIT codes as needed.
187 EXIT_IF_FATAL = status=$$?; if [ $$status -ge $(1) ]; then exit $$status ; fi
189 # The test directories to run
190 DEFAULT_TESTDIRS = .
191 TESTDIRS = $(DEFAULT_TESTDIRS)
193 # Root of all test results
194 TEST_OUTPUT_DIR = $(TEST_ROOT)/../build/$(PLATFORM)-$(ARCH)/test/langtools
195 ABS_TEST_OUTPUT_DIR := \
196 $(shell mkdir -p $(TEST_ROOT)/../build/$(PLATFORM)-$(ARCH)/test/langtools; \
197 cd $(TEST_ROOT)/../build/$(PLATFORM)-$(ARCH)/test/langtools; \
198 pwd )
199 # Subdirectories for different test runs
200 JTREG_OUTPUT_DIR = $(ABS_TEST_OUTPUT_DIR)/jtreg
201 JCK_COMPILER_OUTPUT_DIR = $(ABS_TEST_OUTPUT_DIR)/jck-compiler
202 JCK_RUNTIME_OUTPUT_DIR = $(ABS_TEST_OUTPUT_DIR)/jck-runtime-Xcompile
204 # Default make rule -- warning, may take a while
205 all: $(JPRT_CLEAN) jtreg-tests jck-compiler-tests jck-runtime-tests $(JPRT_ARCHIVE_BUNDLE) all-summary
206 @echo "Testing completed successfully"
208 jtreg apt javac javadoc javah javap: $(JPRT_CLEAN) jtreg-tests $(JPRT_ARCHIVE_BUNDLE) jtreg-summary
209 @echo "Testing completed successfully"
211 jck-compiler: $(JPRT_CLEAN) jck-compiler-tests $(JPRT_ARCHIVE_BUNDLE) jck-compiler-summary
212 @echo "Testing completed successfully"
214 jck-runtime: $(JPRT_CLEAN) jck-runtime-tests $(JPRT_ARCHIVE_BUNDLE) jck-runtime-summary
215 @echo "Testing completed successfully"
217 # for use with JPRT -testrule
218 all: JTREG_TESTDIRS = .
219 jtreg: JTREG_TESTDIRS = .
220 apt: JTREG_TESTDIRS = tools/apt
221 javac: JTREG_TESTDIRS = tools/javac
222 javadoc: JTREG_TESTDIRS = tools/javadoc com/sun/javadoc
223 javah: JTREG_TESTDIRS = tools/javah
224 javap: JTREG_TESTDIRS = tools/javap
226 # Run jtreg tests
227 #
228 # JTREG_HOME
229 # Installed location of jtreg
230 # JT_JAVA
231 # Version of java used to run jtreg. Should normally be the same as TESTJAVA
232 # TESTJAVA
233 # Version of java to be tested.
234 # JTREG_OPTIONS
235 # Additional options for jtreg
236 # JTREG_TESTDIRS
237 # Directories of tests to be run
238 # JTREG_OUTPUT_DIR
239 # Where to write the results
240 # JTREG_REFERENCE
241 # (Optional) reference results (e.g. work, report or summary.txt)
242 #
243 jtreg-tests: check-jtreg FRC
244 @rm -f -r $(JTREG_OUTPUT_DIR)/JTwork $(JTREG_OUTPUT_DIR)/JTreport \
245 $(JTREG_OUTPUT_DIR)/diff.html $(JTREG_OUTPUT_DIR)/status.txt
246 @mkdir -p $(JTREG_OUTPUT_DIR)
247 JT_JAVA=$(JT_JAVA) $(JTREG) \
248 -J-Xmx512m \
249 -a -samevm -ignore:quiet -v:fail,error,nopass \
250 -r:$(JTREG_OUTPUT_DIR)/JTreport \
251 -w:$(JTREG_OUTPUT_DIR)/JTwork \
252 -jdk:$(TESTJAVA) \
253 $(JAVA_ARGS:%=-vmoption:%) \
254 $(JTREG_OPTIONS) \
255 $(JTREG_TESTDIRS) \
256 || ( $(call EXIT_IF_FATAL,$(FATAL_JTREG_EXIT)) ; \
257 echo $$status > $(JTREG_OUTPUT_DIR)/status.txt \
258 )
259 ifdef JTREG_REFERENCE
260 JT_JAVA=$(JT_JAVA) $(JTDIFF) -o $(JTREG_OUTPUT_DIR)/diff.html \
261 $(JTREG_REFERENCE) $(JTREG_OUTPUT_DIR)/JTreport \
262 || ( $(call EXIT_IF_FATAL,$(FATAL_JTDIFF_EXIT)) )
263 endif
265 jtreg-summary: FRC
266 if [ -r $(JTREG_OUTPUT_DIR)/status.txt ]; then \
267 echo ; echo "Summary of jtreg test failures" ; \
268 cat $(JTREG_OUTPUT_DIR)/JTreport/text/summary.txt | \
269 grep -v 'Not run' | grep -v 'Passed' ; \
270 echo ; \
271 $(EXIT) `cat $(JTREG_OUTPUT_DIR)/status.txt` ; \
272 fi
274 # Check to make sure these directories exist
275 check-jtreg: $(JT_HOME) $(PRODUCT_HOME) $(JTREG)
278 # Run JCK-compiler tests
279 #
280 # JCK_HOME
281 # Installed location of JCK: should include JCK-compiler, and JCK-extras
282 # JT_JAVA
283 # Version of java used to run JCK. Should normally be the same as TESTJAVA
284 # TESTJAVA
285 # Version of java to be tested.
286 # JCK_COMPILER_OPTIONS
287 # Additional options for JCK-compiler
288 # JCK_COMPILER_TESTDIRS
289 # Directories of tests to be run
290 # JCK_COMPILER_OUTPUT_DIR
291 # Where to write the results
292 # JCK_COMPILER_REFERENCE
293 # (Optional) reference results (e.g. work, report or summary.txt)
294 #
295 jck-compiler-tests: check-jck FRC
296 @rm -f -r $(JCK_COMPILER_OUTPUT_DIR)/work $(JCK_COMPILER_OUTPUT_DIR)/report \
297 $(JCK_COMPILER_OUTPUT_DIR)/diff.html $(JCK_COMPILER_OUTPUT_DIR)/status.txt
298 @mkdir -p $(JCK_COMPILER_OUTPUT_DIR)
299 $(JT_JAVA)/bin/java -XX:MaxPermSize=256m -Xmx512m \
300 -jar $(JCK_HOME)/JCK-compiler-7/lib/jtjck.jar \
301 -v:non-pass \
302 -r:$(JCK_COMPILER_OUTPUT_DIR)/report \
303 -w:$(JCK_COMPILER_OUTPUT_DIR)/work \
304 -jdk:$(TESTJAVA) \
305 $(JCK_COMPILER_OPTIONS) \
306 $(JCK_COMPILER_TESTDIRS) \
307 || ( $(call EXIT_IF_FATAL,$(FATAL_JCK_EXIT)) ; \
308 echo $$status > $(JCK_COMPILER_OUTPUT_DIR)/status.txt \
309 )
310 ifdef JCK_COMPILER_REFERENCE
311 JT_JAVA=$(JT_JAVA) $(JTDIFF) -o $(JCK_COMPILER_OUTPUT_DIR)/diff.html \
312 $(JCK_COMPILER_REFERENCE) $(JCK_COMPILER_OUTPUT_DIR)/report \
313 || ( $(call EXIT_IF_FATAL,$(FATAL_JTDIFF_EXIT)) )
314 endif
316 jck-compiler-summary: FRC
317 if [ -r $(JCK_COMPILER_OUTPUT_DIR)/status.txt ]; then \
318 echo ; echo "Summary of JCK-compiler test failures" ; \
319 cat $(JCK_COMPILER_OUTPUT_DIR)/report/text/summary.txt | \
320 grep -v 'Not run' | grep -v 'Passed' ; \
321 echo ; \
322 $(EXIT) `cat $(JCK_COMPILER_OUTPUT_DIR)/status.txt` ; \
323 fi
325 # Run JCK-runtime tests in -Xcompile mode
326 # This is a special mode to test javac by compiling the tests in the JCK-runtime test suite
327 # Normal JCK-runtime invocation belongs in the jdk/ repository.
328 #
329 # JCK_HOME
330 # Installed location of JCK: should include JCK-compiler, JCK-runtime and JCK-extras
331 # JT_JAVA
332 # Version of java used to run JCK. Should normally be the same as TESTJAVA
333 # TESTJAVA
334 # Version of java to be tested.
335 # JCK_RUNTIME_OPTIONS
336 # Additional options for JCK-runtime
337 # JCK_RUNTIME_TESTDIRS
338 # Directories of tests to be run
339 # JCK_RUNTIME_OUTPUT_DIR
340 # Where to write the results
341 # JCK_RUNTIME_REFERENCE
342 # (Optional) reference results (e.g. work, report or summary.txt)
343 #
344 jck-runtime-tests: check-jck FRC
345 @rm -f -r $(JCK_RUNTIME_OUTPUT_DIR)/work $(JCK_RUNTIME_OUTPUT_DIR)/report \
346 $(JCK_RUNTIME_OUTPUT_DIR)/diff.html $(JCK_RUNTIME_OUTPUT_DIR)/status.txt
347 @mkdir -p $(JCK_RUNTIME_OUTPUT_DIR)
348 $(JT_JAVA)/bin/java -XX:MaxPermSize=256m -Xmx512m \
349 -jar $(JCK_HOME)/JCK-runtime-7/lib/jtjck.jar \
350 -v:non-pass \
351 -r:$(JCK_RUNTIME_OUTPUT_DIR)/report \
352 -w:$(JCK_RUNTIME_OUTPUT_DIR)/work \
353 -jdk:$(TESTJAVA) \
354 -Xcompile \
355 $(JCK_RUNTIME_OPTIONS) \
356 $(JCK_RUNTIME_TESTDIRS) \
357 || ( $(call EXIT_IF_FATAL,$(FATAL_JCK_EXIT)) ; \
358 echo $$status > $(JCK_RUNTIME_OUTPUT_DIR)/status.txt \
359 )
360 ifdef JCK_RUNTIME_REFERENCE
361 JT_JAVA=$(JT_JAVA) $(JTDIFF) -o $(JCK_RUNTIME_OUTPUT_DIR)/diff.html \
362 $(JCK_RUNTIME_REFERENCE) $(JCK_RUNTIME_OUTPUT_DIR)/report \
363 || ( $(call EXIT_IF_FATAL,$(FATAL_JTDIFF_EXIT)) )
364 endif
366 jck-runtime-summary: FRC
367 if [ -r $(JCK_RUNTIME_OUTPUT_DIR)/status.txt ]; then \
368 echo ; echo "Summary of JCK-runtime test failures" ; \
369 cat $(JCK_RUNTIME_OUTPUT_DIR)/report/text/summary.txt | \
370 grep -v 'Not run' | grep -v 'Passed' ; \
371 echo ; \
372 $(EXIT) `cat $(JCK_RUNTIME_OUTPUT_DIR)/status.txt` ; \
373 fi
375 # Check to make sure these directories exist
376 check-jck: $(JT_HOME) $(JCK_HOME) $(PRODUCT_HOME)
378 all-summary: FRC
379 if [ -n "`find $(TEST_OUTPUT_DIR) -name status.txt`" ]; then
380 echo ; echo "Summary of test failures" ; \
381 cat `find $(TEST_OUTPUT_DIR) -name summary.txt` | \
382 grep -v 'Not run' | grep -v 'Passed' ; \
383 echo ; \
384 $(EXIT) 1
385 fi
387 # Bundle up the results
388 $(JPRT_ARCHIVE_BUNDLE): FRC
389 @rm -f $@
390 @mkdir -p $(@D)
391 ( cd $(TEST_OUTPUT_DIR) && zip -q -r $@ . )
393 # Cleanup
394 clean:
395 rm -f $(JPRT_ARCHIVE_BUNDLE)
397 # Used to force a target rules to run
398 FRC:
400 # Phony targets (e.g. these are not filenames)
401 .PHONY: all clean \
402 jtreg javac javadoc javah javap jtreg-tests jtreg-summary check-jtreg \
403 jck-compiler jck-compiler-tests jck-compiler-summary \
404 jck-runtime jck-runtime-tests jck-runtime-summary check-jck
406 # No use of suffix rules
407 .SUFFIXES: