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