1 #
2 # Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved.
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 #
5 # This code is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License version 2 only, as
7 # published by the Free Software Foundation. Oracle designates this
8 # particular file as subject to the "Classpath" exception as provided
9 # by Oracle in the LICENSE file that accompanied this code.
10 #
11 # This code is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 # version 2 for more details (a copy is included in the LICENSE file that
15 # accompanied this code).
16 #
17 # You should have received a copy of the GNU General Public License version
18 # 2 along with this work; if not, write to the Free Software Foundation,
19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 #
21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 # or visit www.oracle.com if you need additional information or have any
23 # questions.
24 #
25
26 include MakeFileStart.gmk
27
28 ################################################################################
29
30 include FindTests.gmk
31
32 # We will always run multiple tests serially
33 .NOTPARALLEL:
34
35 ################################################################################
36 # Parse global control variables
37 ################################################################################
38
39 ifneq ($(TEST_VM_OPTS), )
40 ifneq ($(TEST_OPTS), )
41 TEST_OPTS := $(TEST_OPTS);VM_OPTIONS=$(TEST_VM_OPTS)
42 else
43 TEST_OPTS := VM_OPTIONS=$(TEST_VM_OPTS)
44 endif
45 endif
46
47 $(eval $(call ParseKeywordVariable, TEST_OPTS, \
48 SINGLE_KEYWORDS := JOBS TIMEOUT_FACTOR JCOV JCOV_DIFF_CHANGESET AOT_JDK, \
49 STRING_KEYWORDS := VM_OPTIONS JAVA_OPTIONS, \
50 ))
51
52 # Helper function to propagate TEST_OPTS values.
53 #
54 # Note: No spaces are allowed around the arguments.
55 # Arg $1 The variable in TEST_OPTS to propagate
56 # Arg $2 The control variable to propagate it to
57 define SetTestOpt
58 ifneq ($$(TEST_OPTS_$1), )
59 $2_$1 := $$(TEST_OPTS_$1)
60 endif
61 endef
62
63 # Setup _NT_SYMBOL_PATH on Windows, which points to our pdb files.
64 ifeq ($(call isTargetOs, windows), true)
65 ifndef _NT_SYMBOL_PATH
66 SYMBOL_PATH := $(call PathList, $(sort $(patsubst %/, %, $(dir $(wildcard \
67 $(addprefix $(SYMBOLS_IMAGE_DIR)/bin/, *.pdb */*.pdb))))))
68 export _NT_SYMBOL_PATH := $(subst \\,\, $(call FixPath, \
69 $(subst $(DQUOTE),, $(SYMBOL_PATH))))
70 $(call LogDebug, Setting _NT_SYMBOL_PATH to $(_NT_SYMBOL_PATH))
71 endif
72 endif
73
74 ################################################################################
75
76 # This is the JDK that we will test
77 JDK_UNDER_TEST := $(JDK_IMAGE_DIR)
78
79 TEST_RESULTS_DIR := $(OUTPUTDIR)/test-results
80 TEST_SUPPORT_DIR := $(OUTPUTDIR)/test-support
81 TEST_SUMMARY := $(TEST_RESULTS_DIR)/test-summary.txt
82 TEST_LAST_IDS := $(TEST_SUPPORT_DIR)/test-last-ids.txt
83
84 ifeq ($(CUSTOM_ROOT), )
85 JTREG_TOPDIR := $(TOPDIR)
86 else
87 JTREG_TOPDIR := $(CUSTOM_ROOT)
88 endif
89
90 JTREG_FAILURE_HANDLER_DIR := $(TEST_IMAGE_DIR)/failure_handler
91 JTREG_FAILURE_HANDLER := $(JTREG_FAILURE_HANDLER_DIR)/jtregFailureHandler.jar
92
93 JTREG_TEST_THREAD_FACTORY_DIR := $(TEST_IMAGE_DIR)/jtreg_test_thread_factory
94 JTREG_TEST_THREAD_FACTORY_JAR := $(JTREG_TEST_THREAD_FACTORY_DIR)/jtregTestThreadFactory.jar
95
96 JTREG_VALUE_CLASS_PLUGIN_DIR := $(TEST_IMAGE_DIR)/jtreg_value_class_plugin
97 JTREG_VALUE_CLASS_PLUGIN_JAR := $(JTREG_VALUE_CLASS_PLUGIN_DIR)/valueClassPlugin.jar
98
99 JTREG_FAILURE_HANDLER_TIMEOUT ?= 0
100
101 ifneq ($(wildcard $(JTREG_FAILURE_HANDLER)), )
102 JTREG_FAILURE_HANDLER_OPTIONS := \
103 -timeoutHandlerDir:$(JTREG_FAILURE_HANDLER) \
104 -observerDir:$(JTREG_FAILURE_HANDLER) \
105 -timeoutHandler:jdk.test.failurehandler.jtreg.GatherProcessInfoTimeoutHandler \
106 -observer:jdk.test.failurehandler.jtreg.GatherDiagnosticInfoObserver \
107 -timeoutHandlerTimeout:$(JTREG_FAILURE_HANDLER_TIMEOUT) \
108 #
109 endif
110
111 GTEST_LAUNCHER_DIRS := $(patsubst %/gtestLauncher$(EXECUTABLE_SUFFIX), %, \
112 $(wildcard $(TEST_IMAGE_DIR)/hotspot/gtest/*/gtestLauncher$(EXECUTABLE_SUFFIX)))
113 GTEST_VARIANTS := $(strip $(patsubst $(TEST_IMAGE_DIR)/hotspot/gtest/%, %, \
114 $(GTEST_LAUNCHER_DIRS)))
115
116 COV_ENVIRONMENT :=
117 JTREG_COV_OPTIONS :=
118
119 ifeq ($(TEST_OPTS_JCOV), true)
120 JCOV_OUTPUT_DIR := $(TEST_RESULTS_DIR)/jcov-output
121 JCOV_SUPPORT_DIR := $(TEST_SUPPORT_DIR)/jcov-support
122 JCOV_GRABBER_LOG := $(JCOV_OUTPUT_DIR)/grabber.log
123 JCOV_RESULT_FILE := $(JCOV_OUTPUT_DIR)/result.xml
124 JCOV_REPORT := $(JCOV_OUTPUT_DIR)/report
125 JCOV_MEM_OPTIONS := -Xms64m -Xmx4g
126
127 # Replace our normal test JDK with the JCov image.
128 JDK_UNDER_TEST := $(JCOV_IMAGE_DIR)
129
130 COV_ENVIRONMENT += JAVA_TOOL_OPTIONS="$(JCOV_MEM_OPTIONS)" \
131 _JAVA_OPTIONS="$(JCOV_MEM_OPTIONS)"
132 JTREG_COV_OPTIONS += -e:JAVA_TOOL_OPTIONS='$(JCOV_MEM_OPTIONS)' \
133 -e:_JAVA_OPTIONS='$(JCOV_MEM_OPTIONS)'
134 endif
135
136 ifeq ($(GCOV_ENABLED), true)
137 GCOV_OUTPUT_DIR := $(TEST_RESULTS_DIR)/gcov-output
138 COV_ENVIRONMENT += GCOV_PREFIX="$(GCOV_OUTPUT_DIR)"
139 JTREG_COV_OPTIONS += -e:GCOV_PREFIX="$(GCOV_OUTPUT_DIR)"
140 endif
141
142 ################################################################################
143 # Setup global test running parameters
144 ################################################################################
145
146 # Each factor variable comes in 3 variants. The first one is reserved for users
147 # to use on command line. The other two are for predefined configurations in JDL
148 # and for machine specific configurations respectively.
149 TEST_JOBS_FACTOR ?= 1
150 TEST_JOBS_FACTOR_JDL ?= 1
151 TEST_JOBS_FACTOR_MACHINE ?= 1
152
153 ifeq ($(TEST_JOBS), 0)
154 CORES_DIVIDER := 2
155 # For some big multi-core machines with low ulimit -u setting we hit the max
156 # threads/process limit. In such a setup the memory/cores-only-guided
157 # TEST_JOBS config is insufficient. From experience a concurrency setting of
158 # 14 works reasonably well for low ulimit values (<= 4096). Thus, use
159 # divider 4096/14. For high ulimit -u values this shouldn't make a difference.
160 ULIMIT_DIVIDER := (4096/14)
161 PROC_ULIMIT := -1
162 ifneq ($(OPENJDK_TARGET_OS), windows)
163 PROC_ULIMIT := $(shell $(ULIMIT) -u)
164 ifeq ($(PROC_ULIMIT), unlimited)
165 PROC_ULIMIT := -1
166 endif
167 endif
168 MEMORY_DIVIDER := 2048
169 TEST_JOBS := $(shell $(AWK) \
170 'BEGIN { \
171 c = $(NUM_CORES) / $(CORES_DIVIDER); \
172 m = $(MEMORY_SIZE) / $(MEMORY_DIVIDER); \
173 u = $(PROC_ULIMIT); \
174 if (u > -1) { \
175 u = u / $(ULIMIT_DIVIDER); \
176 if (u < c) c = u; \
177 } \
178 if (c > m) c = m; \
179 c = c * $(TEST_JOBS_FACTOR); \
180 c = c * $(TEST_JOBS_FACTOR_JDL); \
181 c = c * $(TEST_JOBS_FACTOR_MACHINE); \
182 if (c < 1) c = 1; \
183 c = c + 0.5; \
184 printf "%d", c; \
185 }')
186 endif
187
188 ################################################################################
189 # Parse control variables
190 ################################################################################
191
192 ifneq ($(TEST_OPTS), )
193 # Inform the user
194 $(info Running tests using TEST_OPTS control variable '$(TEST_OPTS)')
195 endif
196
197 ### Jtreg
198
199 $(eval $(call SetTestOpt,VM_OPTIONS,JTREG))
200 $(eval $(call SetTestOpt,JAVA_OPTIONS,JTREG))
201
202 $(eval $(call SetTestOpt,JOBS,JTREG))
203 $(eval $(call SetTestOpt,TIMEOUT_FACTOR,JTREG))
204 $(eval $(call SetTestOpt,FAILURE_HANDLER_TIMEOUT,JTREG))
205 $(eval $(call SetTestOpt,REPORT,JTREG))
206 $(eval $(call SetTestOpt,AOT_JDK,JTREG))
207
208 $(eval $(call ParseKeywordVariable, JTREG, \
209 SINGLE_KEYWORDS := JOBS TIMEOUT_FACTOR FAILURE_HANDLER_TIMEOUT \
210 TEST_MODE ASSERT VERBOSE RETAIN TEST_THREAD_FACTORY JVMTI_STRESS_AGENT \
211 MAX_MEM RUN_PROBLEM_LISTS RETRY_COUNT REPEAT_COUNT MAX_OUTPUT REPORT \
212 AOT_JDK MANUAL VALUE_CLASS_PLUGIN $(CUSTOM_JTREG_SINGLE_KEYWORDS), \
213 STRING_KEYWORDS := OPTIONS JAVA_OPTIONS VM_OPTIONS KEYWORDS \
214 EXTRA_PROBLEM_LISTS LAUNCHER_OPTIONS \
215 $(CUSTOM_JTREG_STRING_KEYWORDS), \
216 ))
217
218 ifneq ($(JTREG), )
219 # Inform the user
220 $(info Running tests using JTREG control variable '$(JTREG)')
221 endif
222
223 ### Gtest
224
225 $(eval $(call SetTestOpt,VM_OPTIONS,GTEST))
226 $(eval $(call SetTestOpt,JAVA_OPTIONS,GTEST))
227
228 $(eval $(call ParseKeywordVariable, GTEST, \
229 SINGLE_KEYWORDS := REPEAT, \
230 STRING_KEYWORDS := OPTIONS VM_OPTIONS JAVA_OPTIONS, \
231 ))
232
233 ifneq ($(GTEST), )
234 # Inform the user
235 $(info Running tests using GTEST control variable '$(GTEST)')
236 endif
237
238 ### Microbenchmarks
239
240 $(eval $(call SetTestOpt,VM_OPTIONS,MICRO))
241 $(eval $(call SetTestOpt,JAVA_OPTIONS,MICRO))
242
243 $(eval $(call ParseKeywordVariable, MICRO, \
244 SINGLE_KEYWORDS := ITER FORK TIME WARMUP_ITER WARMUP_TIME, \
245 STRING_KEYWORDS := OPTIONS JAVA_OPTIONS VM_OPTIONS RESULTS_FORMAT TEST_JDK \
246 BENCHMARKS_JAR, \
247 ))
248
249 ifneq ($(MICRO), )
250 # Inform the user
251 $(info Running tests using MICRO control variable '$(MICRO)')
252 endif
253
254
255 ################################################################################
256 # Component-specific Jtreg settings
257 ################################################################################
258
259 hotspot_JTREG_MAX_MEM := 0
260 hotspot_JTREG_ASSERT := false
261 hotspot_JTREG_NATIVEPATH := $(TEST_IMAGE_DIR)/hotspot/jtreg/native
262 jdk_JTREG_NATIVEPATH := $(TEST_IMAGE_DIR)/jdk/jtreg/native
263 lib-test_JTREG_NATIVEPATH := $(TEST_IMAGE_DIR)/lib-test/jtreg/native
264
265 jdk_JTREG_PROBLEM_LIST += $(TOPDIR)/test/jdk/ProblemList.txt
266 jaxp_JTREG_PROBLEM_LIST += $(TOPDIR)/test/jaxp/ProblemList.txt
267 langtools_JTREG_PROBLEM_LIST += $(TOPDIR)/test/langtools/ProblemList.txt
268 hotspot_JTREG_PROBLEM_LIST += $(TOPDIR)/test/hotspot/jtreg/ProblemList.txt
269 lib-test_JTREG_PROBLEM_LIST += $(TOPDIR)/test/lib-test/ProblemList.txt
270 docs_JTREG_PROBLEM_LIST += $(TOPDIR)/test/docs/ProblemList.txt
271
272 ################################################################################
273 # Parse test selection
274 #
275 # The user has given a test selection in the TEST variable. We must parse it
276 # and determine what that means in terms of actual calls to the test framework.
277 #
278 # The parse functions take as argument a test specification as given by the
279 # user, and returns a fully qualified test descriptor if it was a match, or
280 # nothing if not. A single test specification can result in multiple test
281 # descriptors being returned. A valid test descriptor must always be accepted
282 # and returned identically.
283 ################################################################################
284
285 # Helper function to determine if a test specification is a Gtest test
286 #
287 # It is a Gtest test if it is either "gtest", or "gtest:" followed by an optional
288 # test filter string, and an optional "/<variant>" to select a specific JVM
289 # variant. If no variant is specified, all found variants are tested.
290 define ParseGtestTestSelection
291 $(if $(filter gtest%, $1), \
292 $(if $(filter gtest, $1), \
293 $(addprefix gtest:all/, $(GTEST_VARIANTS)) \
294 , \
295 $(if $(strip $(or $(filter gtest/%, $1) $(filter gtest:/%, $1))), \
296 $(patsubst gtest:/%, gtest:all/%, $(patsubst gtest/%, gtest:/%, $1)) \
297 , \
298 $(if $(filter gtest:%, $1), \
299 $(if $(findstring /, $1), \
300 $1 \
301 , \
302 $(addprefix $1/, $(GTEST_VARIANTS)) \
303 ) \
304 ) \
305 ) \
306 ) \
307 )
308 endef
309
310 # Helper function to determine if a test specification is a microbenchmark test
311 #
312 # It is a microbenchmark test if it is either "micro", or "micro:" followed by
313 # an optional test filter string.
314 define ParseMicroTestSelection
315 $(if $(filter micro%, $1), \
316 $(if $(filter micro, $1), \
317 micro:all \
318 , \
319 $(if $(filter micro:, $1), \
320 micro:all \
321 , \
322 $1 \
323 ) \
324 ) \
325 )
326 endef
327
328 # Helper function that removes the TOPDIR part
329 CleanupJtregPath = \
330 $(strip $(patsubst %/, %, $(subst $(JTREG_TOPDIR)/,, $1)))
331
332 # Take a partial Jtreg root path and return a full, absolute path to that Jtreg
333 # root. Also support having "hotspot" as an alias for "hotspot/jtreg".
334 ExpandJtregRoot = \
335 $(call CleanupJtregPath, $(wildcard \
336 $(if $(filter /%, $1), \
337 $(if $(wildcard $(strip $1)/TEST.ROOT), \
338 $1 \
339 ) \
340 , \
341 $(filter $(addprefix %, $1), $(JTREG_TESTROOTS) $(addsuffix /, $(JTREG_TESTROOTS))) \
342 $(filter $(addprefix %, $(strip $1)/jtreg), $(JTREG_TESTROOTS) $(addsuffix /, $(JTREG_TESTROOTS))) \
343 ) \
344 ))
345
346 # Take a partial Jtreg test path and return a full, absolute path to that Jtreg
347 # test. Also support having "hotspot" as an alias for "hotspot/jtreg".
348 ExpandJtregPath = \
349 $(if $(call ExpandJtregRoot, $1), \
350 $(call ExpandJtregRoot, $1) \
351 , \
352 $(call CleanupJtregPath, $(wildcard \
353 $(if $(filter /%, $1), \
354 $1 \
355 , \
356 $(addsuffix /$(strip $1), $(JTREG_TESTROOTS) $(TEST_BASEDIRS)) \
357 $(addsuffix $(strip $(patsubst hotspot/%, /hotspot/jtreg/%, $1)), $(JTREG_TESTROOTS) $(TEST_BASEDIRS)) \
358 ) \
359 )) \
360 )
361
362 # with test id: dir/Test.java#selection -> Test.java#selection -> .java#selection -> #selection
363 # without: dir/Test.java -> Test.java -> .java -> <<empty string>>
364 TestID = \
365 $(subst .jasm,,$(subst .sh,,$(subst .html,,$(subst .java,,$(suffix $(notdir $1))))))
366
367 # The test id starting with a hash (#testid) will be stripped by all
368 # evals in ParseJtregTestSelectionInner and will be reinserted by calling
369 # TestID (if it is present).
370 ParseJtregTestSelection = \
371 $(call IfAppend, $(call ParseJtregTestSelectionInner, $1), $(call TestID, $1))
372
373 # Helper function to determine if a test specification is a Jtreg test
374 #
375 # It is a Jtreg test if it optionally begins with jtreg:, and then is either
376 # an unspecified group name (possibly prefixed by :), or a group in a
377 # specified test root, or a path to a test or test directory,
378 # either absolute or relative to any of the TEST_BASEDIRS or test roots.
379 define ParseJtregTestSelectionInner
380 $(eval TEST_NAME := $(strip $(patsubst jtreg:%, %, $1))) \
381 $(if $(or $(findstring :, $(TEST_NAME)), $(findstring /, $(TEST_NAME))), , \
382 $(eval TEST_NAME := :$(TEST_NAME)) \
383 ) \
384 $(if $(findstring :, $(TEST_NAME)), \
385 $(if $(filter :%, $(TEST_NAME)), \
386 $(eval TEST_GROUP := $(patsubst :%, %, $(TEST_NAME))) \
387 $(eval TEST_ROOTS := $(foreach test_root, $(JTREG_TESTROOTS), \
388 $(call CleanupJtregPath, $(test_root)))) \
389 , \
390 $(eval TEST_PATH := $(word 1, $(subst :, $(SPACE), $(TEST_NAME)))) \
391 $(eval TEST_GROUP := $(word 2, $(subst :, $(SPACE), $(TEST_NAME)))) \
392 $(eval TEST_ROOTS := $(call ExpandJtregRoot, $(TEST_PATH))) \
393 ) \
394 $(foreach test_root, $(TEST_ROOTS), \
395 $(if $(filter /%, $(test_root)), \
396 jtreg:$(test_root):$(TEST_GROUP) \
397 , \
398 $(if $(filter $(TEST_GROUP), $($(JTREG_TOPDIR)/$(test_root)_JTREG_TEST_GROUPS)), \
399 jtreg:$(test_root):$(TEST_GROUP) \
400 ) \
401 ) \
402 ) \
403 , \
404 $(eval TEST_PATHS := $(call ExpandJtregPath, $(TEST_NAME))) \
405 $(foreach test_path, $(TEST_PATHS), \
406 jtreg:$(test_path) \
407 ) \
408 )
409 endef
410
411 # Helper function to determine if a test specification is a special test
412 #
413 # It is a special test if it is "special:" followed by a test name,
414 # if it is "make:" or "make-" followed by a make test, or any of the special
415 # test names as a single word.
416 define ParseSpecialTestSelection
417 $(if $(filter special:%, $1), \
418 $1 \
419 ) \
420 $(if $(filter make%, $1), \
421 $(if $(filter make:%, $1), \
422 special:$(strip $1) \
423 ) \
424 $(if $(filter make-%, $1), \
425 special:$(patsubst make-%,make:%, $1) \
426 ) \
427 $(if $(filter make, $1), \
428 special:make:all \
429 )
430 ) \
431 $(if $(filter failure-handler, $1), \
432 special:$(strip $1) \
433 )
434 endef
435
436 ifeq ($(TEST), )
437 $(info No test selection given in TEST!)
438 $(info Please use e.g. 'make test TEST=tier1' or 'make test-tier1')
439 $(info See doc/testing.[md|html] for help)
440 $(error Cannot continue)
441 endif
442
443 ParseTestSelection = \
444 $(strip $(or \
445 $(call ParseCustomTestSelection, $1) \
446 $(call ParseGtestTestSelection, $1) \
447 $(call ParseMicroTestSelection, $1) \
448 $(call ParseJtregTestSelection, $1) \
449 $(call ParseSpecialTestSelection, $1) \
450 ))
451
452 # Now intelligently convert the test selection given by the user in TEST
453 # into a list of fully qualified test descriptors of the tests to run.
454 TESTS_TO_RUN := $(strip $(foreach test, $(TEST), $(call ParseTestSelection, $(test))))
455 UNKNOWN_TEST := $(strip $(foreach test, $(TEST), $(if $(call ParseTestSelection, $(test)), , $(test))))
456
457 ifneq ($(UNKNOWN_TEST), )
458 $(info Unknown test selection: '$(UNKNOWN_TEST)')
459 $(info See doc/testing.[md|html] for help)
460 $(error Cannot continue)
461 endif
462
463 # Present the result of our parsing to the user
464 $(info Test selection '$(TEST)', will run:)
465 $(foreach test, $(TESTS_TO_RUN), $(info * $(test)))
466
467
468 ################################################################################
469 # Functions for setting up rules for running the selected tests
470 #
471 # The SetupRun*Test functions all have the same interface:
472 #
473 # Parameter 1 is the name of the rule. This is the test id, based on the test
474 # descriptor, and this is also used as variable prefix, and the targets
475 # generated are listed in a variable by that name.
476 #
477 # Remaining parameters are named arguments. Currently this is only:
478 # TEST -- The properly formatted fully qualified test descriptor
479 #
480 # After the rule named by the test id has been executed, the following
481 # variables will be available:
482 # testid_TOTAL - the total number of tests run
483 # testid_PASSED - the number of successful tests
484 # testid_FAILED - the number of failed tests
485 # testid_ERROR - the number of tests was neither successful or failed
486 #
487 ################################################################################
488
489 ### Rules for Gtest
490
491 SetupRunGtestTest = $(NamedParamsMacroTemplate)
492 define SetupRunGtestTestBody
493 $1_TEST_RESULTS_DIR := $$(TEST_RESULTS_DIR)/$1
494 $1_TEST_SUPPORT_DIR := $$(TEST_SUPPORT_DIR)/$1
495 $1_EXITCODE := $$($1_TEST_RESULTS_DIR)/exitcode.txt
496
497 $1_VARIANT := $$(lastword $$(subst /, , $$($1_TEST)))
498 ifeq ($$(filter $$($1_VARIANT), $$(GTEST_VARIANTS)), )
499 $$(error Invalid gtest variant '$$($1_VARIANT)'. Valid variants: $$(GTEST_VARIANTS))
500 endif
501 $1_TEST_NAME := $$(strip $$(patsubst %/$$($1_VARIANT), %, \
502 $$(patsubst gtest:%, %, $$($1_TEST))))
503 ifneq ($$($1_TEST_NAME), all)
504 $1_GTEST_FILTER := --gtest_filter=$$($1_TEST_NAME)*
505 endif
506
507 ifneq ($$(GTEST_REPEAT), )
508 $1_GTEST_REPEAT := --gtest_repeat=$$(GTEST_REPEAT)
509 endif
510
511 run-test-$1: pre-run-test
512 $$(call LogWarn)
513 $$(call LogWarn, Running test '$$($1_TEST)')
514 $$(call MakeDir, $$($1_TEST_RESULTS_DIR) $$($1_TEST_SUPPORT_DIR))
515 $$(call ExecuteWithLog, $$($1_TEST_SUPPORT_DIR)/gtest, \
516 $$(CD) $$($1_TEST_SUPPORT_DIR) && \
517 $$(FIXPATH) $$(TEST_IMAGE_DIR)/hotspot/gtest/$$($1_VARIANT)/gtestLauncher \
518 -jdk $(JDK_UNDER_TEST) $$($1_GTEST_FILTER) \
519 --gtest_output=xml:$$($1_TEST_RESULTS_DIR)/gtest.xml \
520 --gtest_catch_exceptions=0 \
521 $$($1_GTEST_REPEAT) $$(GTEST_OPTIONS) $$(GTEST_VM_OPTIONS) \
522 $$(GTEST_JAVA_OPTIONS) \
523 > >($(TEE) $$($1_TEST_RESULTS_DIR)/gtest.txt) \
524 && $$(ECHO) $$$$? > $$($1_EXITCODE) \
525 || $$(ECHO) $$$$? > $$($1_EXITCODE) \
526 )
527
528 $1_RESULT_FILE := $$($1_TEST_RESULTS_DIR)/gtest.txt
529
530 parse-test-$1: run-test-$1
531 $$(call LogWarn, Finished running test '$$($1_TEST)')
532 $$(call LogWarn, Test report is stored in $$(strip \
533 $$(subst $$(TOPDIR)/, , $$($1_TEST_RESULTS_DIR))))
534 $$(if $$(wildcard $$($1_RESULT_FILE)), \
535 $$(eval $1_RUN := $$(shell $$(AWK) \
536 '/==========.* tests? from .* test (cases?|suites?) ran/ { print $$$$2 }' \
537 $$($1_RESULT_FILE))) \
538 $$(if $$($1_RUN), , $$(eval $1_RUN := 0)) \
539 $$(eval $1_PASSED := $$(shell $$(AWK) '/\[ PASSED \] .* tests?./ \
540 { print $$$$4 }' $$($1_RESULT_FILE))) \
541 $$(if $$($1_PASSED), , $$(eval $1_PASSED := 0)) \
542 $$(eval $1_GTEST_DISABLED := $$(shell $$(AWK) '/YOU HAVE .* DISABLED TEST/ \
543 { print $$$$3 }' $$($1_RESULT_FILE))) \
544 $$(if $$($1_GTEST_DISABLED), , $$(eval $1_GTEST_DISABLED := 0)) \
545 $$(eval $1_GTEST_SKIPPED := $$(shell $$(AWK) '/\[ SKIPPED \] .* tests?.*/ \
546 { print $$$$4 }' $$($1_RESULT_FILE))) \
547 $$(if $$($1_GTEST_SKIPPED), , $$(eval $1_GTEST_SKIPPED := 0)) \
548 $$(eval $1_SKIPPED := $$(shell \
549 $$(EXPR) $$($1_GTEST_DISABLED) + $$($1_GTEST_SKIPPED))) \
550 $$(eval $1_FAILED := $$(shell $$(AWK) '/\[ FAILED \] .* tests?, \
551 listed below/ { print $$$$4 }' $$($1_RESULT_FILE))) \
552 $$(if $$($1_FAILED), , $$(eval $1_FAILED := 0)) \
553 $$(eval $1_ERROR := $$(shell \
554 $$(EXPR) $$($1_RUN) - $$($1_PASSED) - $$($1_FAILED) - $$($1_GTEST_SKIPPED))) \
555 $$(eval $1_TOTAL := $$(shell \
556 $$(EXPR) $$($1_RUN) + $$($1_GTEST_DISABLED))) \
557 , \
558 $$(eval $1_PASSED := 0) \
559 $$(eval $1_FAILED := 0) \
560 $$(eval $1_ERROR := 1) \
561 $$(eval $1_SKIPPED := 0) \
562 $$(eval $1_TOTAL := 1) \
563 )
564
565 $1: run-test-$1 parse-test-$1
566
567 TARGETS += $1 run-test-$1 parse-test-$1
568 TEST_TARGETS += parse-test-$1
569
570 endef
571
572 ################################################################################
573
574 ### Rules for Microbenchmarks
575
576 # Helper function for SetupRunMicroTest. Set a MICRO_* variable from, in order:
577 # 1) Specified by user on command line
578 # 2) Generic default
579 #
580 # Note: No spaces are allowed around the arguments.
581 # Arg $1 The test ID (i.e. $1 in SetupRunMicroTest)
582 # Arg $2 Base variable, e.g. MICRO_TEST_JDK
583 # Arg $3 The default value (optional)
584 define SetMicroValue
585 ifneq ($$($2), )
586 $1_$2 := $$($2)
587 else
588 ifneq ($3, )
589 $1_$2 := $3
590 else
591 $1_$2 :=
592 endif
593 endif
594 endef
595
596 SetupRunMicroTest = $(NamedParamsMacroTemplate)
597 define SetupRunMicroTestBody
598 $1_TEST_RESULTS_DIR := $$(TEST_RESULTS_DIR)/$1
599 $1_TEST_SUPPORT_DIR := $$(TEST_SUPPORT_DIR)/$1
600 $1_EXITCODE := $$($1_TEST_RESULTS_DIR)/exitcode.txt
601
602 $1_TEST_NAME := $$(strip $$(patsubst micro:%, %, $$($1_TEST)))
603
604 $$(eval $$(call SetMicroValue,$1,MICRO_BENCHMARKS_JAR,$$(TEST_IMAGE_DIR)/micro/benchmarks.jar))
605 $$(eval $$(call SetMicroValue,$1,MICRO_TEST_JDK,$$(JDK_UNDER_TEST)))
606 $$(eval $$(call SetMicroValue,$1,MICRO_JAVA_OPTIONS))
607
608 # Current tests needs to open java.io
609 $1_MICRO_JAVA_OPTIONS += --add-opens=java.base/java.io=ALL-UNNAMED
610
611 # Save output as JSON or CSV file
612 ifneq ($$(MICRO_RESULTS_FORMAT), )
613 $1_MICRO_BASIC_OPTIONS += -rf $$(MICRO_RESULTS_FORMAT)
614 $1_MICRO_BASIC_OPTIONS += -rff $$($1_TEST_RESULTS_DIR)/jmh-result.$(MICRO_RESULTS_FORMAT)
615 endif
616
617 # Set library path for native dependencies
618 $1_JMH_JVM_ARGS := -Djava.library.path=$$(TEST_IMAGE_DIR)/micro/native
619
620 ifneq ($$(MICRO_VM_OPTIONS)$$(MICRO_JAVA_OPTIONS), )
621 $1_JMH_JVM_ARGS += $$(MICRO_VM_OPTIONS) $$(MICRO_JAVA_OPTIONS)
622 endif
623
624 $1_MICRO_VM_OPTIONS := -jvmArgsPrepend $(call ShellQuote,$$($1_JMH_JVM_ARGS))
625
626 ifneq ($$(MICRO_ITER), )
627 $1_MICRO_ITER := -i $$(MICRO_ITER)
628 endif
629 ifneq ($$(MICRO_FORK), )
630 $1_MICRO_FORK := -f $$(MICRO_FORK)
631 endif
632 ifneq ($$(MICRO_TIME), )
633 $1_MICRO_TIME := -r $$(MICRO_TIME)
634 endif
635 ifneq ($$(MICRO_WARMUP_ITER), )
636 $1_MICRO_WARMUP_ITER := -wi $$(MICRO_WARMUP_ITER)
637 endif
638 ifneq ($$(MICRO_WARMUP_TIME), )
639 $1_MICRO_WARMUP_TIME := -w $$(MICRO_WARMUP_TIME)
640 endif
641
642 # Microbenchmarks are executed from the root of the test image directory.
643 # This enables JMH tests to add dependencies using relative paths such as
644 # -Djava.library.path=micro/native
645
646 run-test-$1: pre-run-test
647 $$(call LogWarn)
648 $$(call LogWarn, Running test '$$($1_TEST)')
649 $$(call MakeDir, $$($1_TEST_RESULTS_DIR) $$($1_TEST_SUPPORT_DIR))
650 $$(call ExecuteWithLog, $$($1_TEST_SUPPORT_DIR)/micro, \
651 $$(CD) $$(TEST_IMAGE_DIR) && \
652 $$(FIXPATH) $$($1_MICRO_TEST_JDK)/bin/java $$($1_MICRO_JAVA_OPTIONS) \
653 -jar $$($1_MICRO_BENCHMARKS_JAR) \
654 $$($1_MICRO_ITER) $$($1_MICRO_FORK) $$($1_MICRO_TIME) \
655 $$($1_MICRO_WARMUP_ITER) $$($1_MICRO_WARMUP_TIME) \
656 $$($1_MICRO_VM_OPTIONS) $$($1_MICRO_BASIC_OPTIONS) $$(MICRO_OPTIONS) \
657 $$($1_TEST_NAME) \
658 > >($(TEE) $$($1_TEST_RESULTS_DIR)/micro.txt) \
659 && $$(ECHO) $$$$? > $$($1_EXITCODE) \
660 || $$(ECHO) $$$$? > $$($1_EXITCODE) \
661 )
662
663 $1_RESULT_FILE := $$($1_TEST_RESULTS_DIR)/micro.txt
664
665 parse-test-$1: run-test-$1
666 $$(call LogWarn, Finished running test '$$($1_TEST)')
667 $$(call LogWarn, Test report is stored in $$(strip \
668 $$(subst $$(TOPDIR)/, , $$($1_TEST_RESULTS_DIR))))
669 $$(if $$(wildcard $$($1_EXITCODE)), \
670 $$(eval $1_EXIT_CODE := $$(shell $$(CAT) $$($1_EXITCODE))) \
671 $$(if $$(filter 0, $$($1_EXIT_CODE)), \
672 $$(eval $1_PASSED := 1) \
673 $$(eval $1_ERROR := 0) \
674 , \
675 $$(eval $1_PASSED := 0) \
676 $$(eval $1_ERROR := 1) \
677 ) \
678 $$(eval $1_FAILED := 0) \
679 $$(eval $1_TOTAL := $$(shell \
680 $$(EXPR) $$($1_PASSED) + $$($1_ERROR))) \
681 , \
682 $$(eval $1_PASSED := 0) \
683 $$(eval $1_FAILED := 0) \
684 $$(eval $1_ERROR := 1) \
685 $$(eval $1_TOTAL := 1) \
686 )
687 $$(eval $1_SKIPPED := 0)
688
689 $1: run-test-$1 parse-test-$1
690
691 TARGETS += $1 run-test-$1 parse-test-$1
692 TEST_TARGETS += parse-test-$1
693
694 endef
695
696 ################################################################################
697
698 ### Rules for Jtreg
699
700 # Helper function for SetupRunJtregTest. Set a JTREG_* variable from, in order:
701 # 1) Specified by user on command line
702 # 2) Component-specific default
703 # 3) Generic default
704 #
705 # Note: No spaces are allowed around the arguments.
706 # Arg $1 The test ID (i.e. $1 in SetupRunJtregTest)
707 # Arg $2 Base variable, e.g. JTREG_JOBS
708 # Arg $3 The default value (optional)
709 define SetJtregValue
710 ifneq ($$($2), )
711 $1_$2 := $$($2)
712 else
713 ifneq ($$($$($1_COMPONENT)_$2), )
714 $1_$2 := $$($$($1_COMPONENT)_$2)
715 else
716 ifneq ($3, )
717 $1_$2 := $3
718 else
719 $1_$2 :=
720 endif
721 endif
722 endif
723 endef
724
725 ################################################################################
726 # Helper function for creating a customized AOT cache for running tests
727 ################################################################################
728
729 # Parameter 1 is the name of the rule.
730 #
731 # Remaining parameters are named arguments.
732 # TRAINING The AOT training mode: onestep or twostep
733 # VM_OPTIONS List of JVM arguments to use when creating AOT cache
734 #
735 # After calling this, the following variables are defined
736 # $1_AOT_TARGETS List of all targets that the test rule will need to depend on
737 # $1_AOT_JDK_CACHE The AOT cache file to be used to run the test with
738 #
739 SetupAOT = $(NamedParamsMacroTemplate)
740 define SetupAOTBody
741 $1_AOT_JDK_OUTPUT_DIR := $$($1_TEST_SUPPORT_DIR)/aot
742 $1_AOT_JDK_CONF := $$($1_AOT_JDK_OUTPUT_DIR)/jdk.aotconf
743 $1_AOT_JDK_CACHE := $$($1_AOT_JDK_OUTPUT_DIR)/jdk.aotcache
744 $1_AOT_JDK_LOG := $$($1_AOT_JDK_OUTPUT_DIR)/TestSetupAOT.log
745
746 # We execute the training run with the TestSetupAOT class from $(TEST_IMAGE_DIR)/setup_aot/TestSetupAOT.jar
747 # to touch a fair number of classes inside the JDK. Note that we can't specify a classpath,
748 # or else the AOT cache cannot be used with jtreg test cases that use a different value
749 # for their classpaths. Instead, we cd in the $$($1_AOT_JDK_OUTPUT_DIR) directory,
750 # extract the TestSetupAOT.jar there, and run in that directory without specifying a classpath.
751 # The "java" launcher will have an implicit classpath of ".", so it can pick up the TestSetupAOT
752 # class from the JVM's current directory.
753 #
754 # The TestSetupAOT class (or any other classes that are loaded from ".") will be excluded
755 # from the the AOT cache as "." is an unsupported location. As a result, the AOT cache will contain
756 # only classes from the JDK.
757
758 $$($1_AOT_JDK_CACHE): $$(JDK_IMAGE_DIR)/release
759 $$(call MakeDir, $$($1_AOT_JDK_OUTPUT_DIR))
760
761 ifeq ($$($1_TRAINING), onestep)
762
763 $$(call LogWarn, AOT: Create AOT cache $$($1_AOT_JDK_CACHE) in one step with flags: $$($1_VM_OPTIONS)) \
764 $$(call ExecuteWithLog, $$($1_AOT_JDK_OUTPUT_DIR), \
765 cd $$($1_AOT_JDK_OUTPUT_DIR); \
766 $(JAR) --extract --file $(TEST_IMAGE_DIR)/setup_aot/TestSetupAOT.jar; \
767 $$(FIXPATH) $(JDK_UNDER_TEST)/bin/java $$($1_VM_OPTIONS) \
768 -Xlog:class+load$$(COMMA)aot$$(COMMA)aot+class=debug:file=$$($1_AOT_JDK_CACHE).log -Xlog:cds*=error -Xlog:aot*=error \
769 -XX:AOTMode=record -XX:AOTCacheOutput=$$($1_AOT_JDK_CACHE) \
770 TestSetupAOT $$($1_AOT_JDK_OUTPUT_DIR) > $$($1_AOT_JDK_LOG) \
771 )
772
773 else
774
775 $$(call LogWarn, AOT: Create cache configuration) \
776 $$(call ExecuteWithLog, $$($1_AOT_JDK_OUTPUT_DIR), \
777 cd $$($1_AOT_JDK_OUTPUT_DIR); \
778 $(JAR) --extract --file $(TEST_IMAGE_DIR)/setup_aot/TestSetupAOT.jar; \
779 $$(FIXPATH) $(JDK_UNDER_TEST)/bin/java $$($1_VM_OPTIONS) \
780 -Xlog:class+load$$(COMMA)aot$$(COMMA)aot+class=debug:file=$$($1_AOT_JDK_CONF).log -Xlog:cds*=error -Xlog:aot*=error \
781 -XX:AOTMode=record -XX:AOTConfiguration=$$($1_AOT_JDK_CONF) \
782 TestSetupAOT $$($1_AOT_JDK_OUTPUT_DIR) > $$($1_AOT_JDK_LOG) \
783 )
784
785 $$(call LogWarn, AOT: Generate AOT cache $$($1_AOT_JDK_CACHE) with flags: $$($1_VM_OPTIONS))
786 $$(call ExecuteWithLog, $$($1_AOT_JDK_OUTPUT_DIR), \
787 $$(FIXPATH) $(JDK_UNDER_TEST)/bin/java \
788 $$($1_VM_OPTIONS) -Xlog:aot$$(COMMA)aot+class=debug:file=$$($1_AOT_JDK_CACHE).log -Xlog:cds*=error -Xlog:aot*=error \
789 -XX:ExtraSharedClassListFile=$(JDK_UNDER_TEST)/lib/classlist \
790 -XX:AOTMode=create -XX:AOTConfiguration=$$($1_AOT_JDK_CONF) -XX:AOTCache=$$($1_AOT_JDK_CACHE) \
791 )
792
793 endif
794
795 $1_AOT_TARGETS += $$($1_AOT_JDK_CACHE)
796
797 endef
798
799 SetupRunJtregTest = $(NamedParamsMacroTemplate)
800 define SetupRunJtregTestBody
801 $1_TEST_RESULTS_DIR := $$(TEST_RESULTS_DIR)/$1
802 $1_TEST_SUPPORT_DIR := $$(TEST_SUPPORT_DIR)/$1
803 $1_EXITCODE := $$($1_TEST_RESULTS_DIR)/exitcode.txt
804
805 $1_TEST_NAME := $$(strip $$(patsubst jtreg:%, %, $$($1_TEST)))
806
807 $1_TEST_ROOT := \
808 $$(strip $$(foreach root, $$(JTREG_TESTROOTS), \
809 $$(if $$(filter $$(root)%, $$(JTREG_TOPDIR)/$$($1_TEST_NAME)), $$(root)) \
810 ))
811 $1_COMPONENT := $$(lastword $$(subst /, $$(SPACE), $$($1_TEST_ROOT)))
812 # This will work only as long as just hotspot has the additional "jtreg" directory
813 ifeq ($$($1_COMPONENT), jtreg)
814 $1_COMPONENT := hotspot
815 endif
816
817 ifeq ($$(JT_HOME), )
818 $$(info Error: jtreg framework is not found.)
819 $$(info Please run configure using --with-jtreg.)
820 $$(error Cannot continue)
821 endif
822
823 # Unfortunately, we need different defaults for some JTREG values,
824 # depending on what component we're running.
825
826 # Convert JTREG_foo into $1_JTREG_foo with a suitable value.
827 $$(eval $$(call SetJtregValue,$1,JTREG_TEST_MODE,agentvm))
828 $$(eval $$(call SetJtregValue,$1,JTREG_ASSERT,true))
829 $$(eval $$(call SetJtregValue,$1,JTREG_MAX_MEM,768m))
830 $$(eval $$(call SetJtregValue,$1,JTREG_NATIVEPATH))
831 $$(eval $$(call SetJtregValue,$1,JTREG_BASIC_OPTIONS))
832 $$(eval $$(call SetJtregValue,$1,JTREG_PROBLEM_LIST))
833
834 # Only the problem list for the current test root should be used.
835 $1_JTREG_PROBLEM_LIST := $$(filter $$($1_TEST_ROOT)%, $$($1_JTREG_PROBLEM_LIST))
836
837 # Pass along the path to the tidy html checker
838 ifneq ($$(TIDY), )
839 $1_JTREG_BASIC_OPTIONS += -Dtidy=$$(TIDY)
840 endif
841
842 ifneq ($(TEST_JOBS), 0)
843 $$(eval $$(call SetJtregValue,$1,JTREG_JOBS,$$(TEST_JOBS)))
844 else
845 $$(eval $$(call SetJtregValue,$1,JTREG_JOBS,$$(JOBS)))
846 endif
847
848 # Make sure MaxRAMPercentage is high enough to not cause OOM or swapping since
849 # we may end up with a lot of JVM's
850 $1_JTREG_MAX_RAM_PERCENTAGE := $$(shell $(AWK) 'BEGIN { print 25 / $$($1_JTREG_JOBS); }')
851
852 JTREG_VERBOSE ?= fail,error,summary
853 JTREG_RETAIN ?= fail,error
854 JTREG_TEST_THREAD_FACTORY ?=
855 JTREG_RUN_PROBLEM_LISTS ?= false
856 JTREG_RETRY_COUNT ?= 0
857 JTREG_REPEAT_COUNT ?= 0
858 JTREG_REPORT ?= files
859 JTREG_AOT_JDK ?= none
860
861 ifneq ($$(JTREG_RETRY_COUNT), 0)
862 ifneq ($$(JTREG_REPEAT_COUNT), 0)
863 $$(info Error: Cannot use both JTREG_RETRY_COUNT and JTREG_REPEAT_COUNT together.)
864 $$(info Please choose one or the other.)
865 $$(error Cannot continue)
866 endif
867 endif
868
869 ifeq ($$(JTREG_RUN_PROBLEM_LISTS), true)
870 JTREG_PROBLEM_LIST_PREFIX := -match:
871 else
872 JTREG_PROBLEM_LIST_PREFIX := -exclude:
873 endif
874
875 ifneq ($$(JTREG_TEST_THREAD_FACTORY), )
876 $1_JTREG_BASIC_OPTIONS += -testThreadFactoryPath:$$(JTREG_TEST_THREAD_FACTORY_JAR)
877 $1_JTREG_BASIC_OPTIONS += -testThreadFactory:$$(JTREG_TEST_THREAD_FACTORY)
878 $1_JTREG_BASIC_OPTIONS += $$(addprefix $$(JTREG_PROBLEM_LIST_PREFIX), $$(wildcard \
879 $$(addprefix $$($1_TEST_ROOT)/, ProblemList-$$(JTREG_TEST_THREAD_FACTORY).txt) \
880 ))
881 endif
882
883 ifneq ($$(JTREG_VALUE_CLASS_PLUGIN), )
884 ifneq ($$(wildcard $$(JTREG_VALUE_CLASS_PLUGIN_JAR)), )
885 $1_JTREG_BASIC_OPTIONS += -cpa:$$(JTREG_VALUE_CLASS_PLUGIN_JAR)
886 endif
887 $1_JTREG_BASIC_OPTIONS += -vmoption:--enable-preview
888 $1_JTREG_BASIC_OPTIONS += -javacoption:-XDaccessInternalAPI
889 $1_JTREG_BASIC_OPTIONS += -javacoption:--source -javacoption:$(VERSION_FEATURE)
890 $1_JTREG_BASIC_OPTIONS += -javacoption:--enable-preview
891 $1_JTREG_BASIC_OPTIONS += -javacoption:-Xplugin:ValueClassPlugin
892 $1_JTREG_BASIC_OPTIONS += $$(addprefix $$(JTREG_PROBLEM_LIST_PREFIX), $$(wildcard \
893 $$(addprefix $$($1_TEST_ROOT)/, ProblemList-ValueClass.txt) \
894 ))
895 endif
896
897 ifneq ($$(JTREG_JVMTI_STRESS_AGENT), )
898 AGENT := $$(LIBRARY_PREFIX)JvmtiStressAgent$$(SHARED_LIBRARY_SUFFIX)=$$(JTREG_JVMTI_STRESS_AGENT)
899 $1_JTREG_BASIC_OPTIONS += -javaoption:'-agentpath:$(TEST_IMAGE_DIR)/hotspot/jtreg/native/$$(AGENT)'
900 $1_JTREG_BASIC_OPTIONS += $$(addprefix $$(JTREG_PROBLEM_LIST_PREFIX), $$(wildcard \
901 $$(addprefix $$($1_TEST_ROOT)/, ProblemList-jvmti-stress-agent.txt) \
902 ))
903 endif
904
905
906 ifneq ($$(JTREG_LAUNCHER_OPTIONS), )
907 $1_JTREG_LAUNCHER_OPTIONS += $$(JTREG_LAUNCHER_OPTIONS)
908 endif
909
910 ifneq ($$(JTREG_MAX_OUTPUT), )
911 $1_JTREG_LAUNCHER_OPTIONS += -Djavatest.maxOutputSize=$$(JTREG_MAX_OUTPUT)
912 endif
913
914 ifneq ($$($1_JTREG_MAX_MEM), 0)
915 $1_JTREG_BASIC_OPTIONS += -vmoption:-Xmx$$($1_JTREG_MAX_MEM)
916 $1_JTREG_LAUNCHER_OPTIONS += -Xmx$$($1_JTREG_MAX_MEM)
917 endif
918
919 # Make sure the tmp dir is normalized as some tests will react badly otherwise
920 $1_TEST_TMP_DIR := $$(abspath $$($1_TEST_SUPPORT_DIR)/tmp)
921
922 # test.boot.jdk is used by some test cases that want to execute a previous
923 # version of the JDK.
924 $1_JTREG_BASIC_OPTIONS += -$$($1_JTREG_TEST_MODE) \
925 -verbose:$$(JTREG_VERBOSE) -retain:$$(JTREG_RETAIN) \
926 -concurrency:$$($1_JTREG_JOBS) \
927 -vmoption:-XX:MaxRAMPercentage=$$($1_JTREG_MAX_RAM_PERCENTAGE) \
928 -vmoption:-Dtest.boot.jdk="$$(BOOT_JDK)" \
929 -vmoption:-Djava.io.tmpdir="$$($1_TEST_TMP_DIR)"
930
931 $1_JTREG_BASIC_OPTIONS += -ignore:quiet
932
933 ifeq ($$(JTREG_MANUAL), true)
934 $1_JTREG_BASIC_OPTIONS += -manual
935 else
936 $1_JTREG_BASIC_OPTIONS += -automatic
937 endif
938
939 # Make it possible to specify the JIB_DATA_DIR for tests using the
940 # JIB Artifact resolver
941 $1_JTREG_BASIC_OPTIONS += -e:JIB_DATA_DIR
942 # If running on Windows, propagate the _NT_SYMBOL_PATH to enable
943 # symbol lookup in hserr files
944 # The minidumps are disabled by default on client Windows, so enable them
945 ifeq ($$(call isTargetOs, windows), true)
946 $1_JTREG_BASIC_OPTIONS += -e:_NT_SYMBOL_PATH
947 $1_JTREG_BASIC_OPTIONS += -vmoption:-XX:+CreateCoredumpOnCrash
948 else ifeq ($$(call isTargetOs, linux), true)
949 $1_JTREG_BASIC_OPTIONS += -e:_JVM_DWARF_PATH=$$(SYMBOLS_IMAGE_DIR)
950 endif
951
952 $1_JTREG_BASIC_OPTIONS += \
953 $$(addprefix -javaoption:, $$(JTREG_JAVA_OPTIONS)) \
954 $$(addprefix -vmoption:, $$(JTREG_VM_OPTIONS)) \
955 #
956
957 ifeq ($$($1_JTREG_ASSERT), true)
958 $1_JTREG_BASIC_OPTIONS += -ea -esa
959 endif
960
961 ifneq ($$($1_JTREG_NATIVEPATH), )
962 $1_JTREG_BASIC_OPTIONS += -nativepath:$$($1_JTREG_NATIVEPATH)
963 endif
964
965 ifneq ($$($1_JTREG_PROBLEM_LIST), )
966 $1_JTREG_BASIC_OPTIONS += $$(addprefix $$(JTREG_PROBLEM_LIST_PREFIX), $$($1_JTREG_PROBLEM_LIST))
967 endif
968
969 JTREG_ALL_OPTIONS := $$(JTREG_JAVA_OPTIONS) $$(JTREG_VM_OPTIONS)
970
971 JTREG_AUTO_PROBLEM_LISTS :=
972 # Please reach consensus before changing this.
973 JTREG_AUTO_TIMEOUT_FACTOR := 4
974
975 ifneq ($$(findstring -Xcomp, $$(JTREG_ALL_OPTIONS)), )
976 JTREG_AUTO_PROBLEM_LISTS += ProblemList-Xcomp.txt
977 JTREG_AUTO_TIMEOUT_FACTOR := 10
978 endif
979
980 ifneq ($$(findstring -XX:+UseZGC, $$(JTREG_ALL_OPTIONS)), )
981 JTREG_AUTO_PROBLEM_LISTS += ProblemList-zgc.txt
982 endif
983
984 ifneq ($$(findstring -XX:+UseShenandoahGC, $$(JTREG_ALL_OPTIONS)), )
985 JTREG_AUTO_PROBLEM_LISTS += ProblemList-shenandoah.txt
986 endif
987
988 ifneq ($$(findstring --enable-preview, $$(JTREG_ALL_OPTIONS)), )
989 JTREG_AUTO_PROBLEM_LISTS += ProblemList-enable-preview.txt
990 endif
991
992 ifneq ($$(findstring -XX:+UseCompactObjectHeaders, $$(JTREG_ALL_OPTIONS)), )
993 JTREG_AUTO_PROBLEM_LISTS += ProblemList-coh.txt
994 endif
995
996
997 ifneq ($$(JTREG_EXTRA_PROBLEM_LISTS), )
998 # Accept both absolute paths as well as relative to the current test root.
999 $1_JTREG_BASIC_OPTIONS += $$(addprefix $$(JTREG_PROBLEM_LIST_PREFIX), $$(wildcard \
1000 $$(JTREG_EXTRA_PROBLEM_LISTS) \
1001 $$(addprefix $$($1_TEST_ROOT)/, $$(JTREG_EXTRA_PROBLEM_LISTS)) \
1002 ))
1003 endif
1004
1005 ifneq ($$(JIB_HOME), )
1006 $1_JTREG_BASIC_OPTIONS += -e:JIB_HOME=$$(JIB_HOME)
1007 endif
1008
1009 ifneq ($$(JDK_FOR_COMPILE), )
1010 # Allow overriding the JDK used for compilation from the command line
1011 $1_JTREG_BASIC_OPTIONS += -compilejdk:$$(JDK_FOR_COMPILE)
1012 endif
1013
1014 $1_JTREG_BASIC_OPTIONS += -e:TEST_IMAGE_DIR=$(TEST_IMAGE_DIR)
1015
1016 $1_JTREG_BASIC_OPTIONS += -e:DOCS_JDK_IMAGE_DIR=$$(DOCS_JDK_IMAGE_DIR)
1017
1018 ifneq ($$(JTREG_FAILURE_HANDLER_OPTIONS), )
1019 $1_JTREG_LAUNCHER_OPTIONS += -Djava.library.path="$(JTREG_FAILURE_HANDLER_DIR)"
1020 endif
1021
1022 ifneq ($$(JTREG_KEYWORDS), )
1023 # The keywords string may contain problematic characters and may be quoted
1024 # already when it arrives here. Remove any existing quotes and replace them
1025 # with one set of single quotes.
1026 $1_JTREG_KEYWORDS := \
1027 $$(strip $$(subst $$(SQUOTE),,$$(subst $$(DQUOTE),,$$(JTREG_KEYWORDS))))
1028 ifneq ($$($1_JTREG_KEYWORDS), )
1029 $1_JTREG_BASIC_OPTIONS += -k:'$$($1_JTREG_KEYWORDS)'
1030 endif
1031 endif
1032
1033 ifneq ($$(filter $$(JTREG_AOT_JDK), onestep twostep), )
1034 $$(call LogWarn, Add AOT target for $1)
1035 $$(eval $$(call SetupAOT, $1, \
1036 TRAINING := $$(JTREG_AOT_JDK), \
1037 VM_OPTIONS := $$(JTREG_ALL_OPTIONS) ))
1038 $$(call LogWarn, AOT_JDK_CACHE=$$($1_AOT_JDK_CACHE))
1039 $1_JTREG_BASIC_OPTIONS += -vmoption:-XX:AOTCache="$$($1_AOT_JDK_CACHE)"
1040 endif
1041
1042
1043 $$(eval $$(call SetupRunJtregTestCustom, $1))
1044
1045 # SetupRunJtregTestCustom might also adjust JTREG_AUTO_ variables
1046 # so set the final results after setting values from custom setup
1047 ifneq ($$(JTREG_AUTO_PROBLEM_LISTS), )
1048 # Accept both absolute paths as well as relative to the current test root.
1049 $1_JTREG_BASIC_OPTIONS += $$(addprefix $$(JTREG_PROBLEM_LIST_PREFIX), $$(wildcard \
1050 $$(JTREG_AUTO_PROBLEM_LISTS) \
1051 $$(addprefix $$($1_TEST_ROOT)/, $$(JTREG_AUTO_PROBLEM_LISTS)) \
1052 ))
1053 endif
1054
1055 JTREG_TIMEOUT_FACTOR ?= $$(JTREG_AUTO_TIMEOUT_FACTOR)
1056 $1_JTREG_BASIC_OPTIONS += -timeoutFactor:$$(JTREG_TIMEOUT_FACTOR)
1057
1058 clean-outputdirs-$1:
1059 $$(call LogWarn, Clean up dirs for $1)
1060 $$(RM) -r $$($1_TEST_SUPPORT_DIR)
1061 $$(RM) -r $$($1_TEST_RESULTS_DIR)
1062
1063 $1_COMMAND_LINE := \
1064 $$(JTREG_JAVA) $$($1_JTREG_LAUNCHER_OPTIONS) \
1065 -Dprogram=jtreg -jar $$(JT_HOME)/lib/jtreg.jar \
1066 $$($1_JTREG_BASIC_OPTIONS) \
1067 -testjdk:$$(JDK_UNDER_TEST) \
1068 -dir:$$(JTREG_TOPDIR) \
1069 -reportDir:$$($1_TEST_RESULTS_DIR) \
1070 -workDir:$$($1_TEST_SUPPORT_DIR) \
1071 -report:$${JTREG_REPORT} \
1072 $$$${JTREG_STATUS} \
1073 $$(JTREG_OPTIONS) \
1074 $$(JTREG_FAILURE_HANDLER_OPTIONS) \
1075 $$(JTREG_COV_OPTIONS) \
1076 $$($1_TEST_NAME) \
1077 && $$(ECHO) $$$$? > $$($1_EXITCODE) \
1078 || $$(ECHO) $$$$? > $$($1_EXITCODE)
1079
1080
1081 ifneq ($$(JTREG_RETRY_COUNT), 0)
1082 $1_COMMAND_LINE := \
1083 for i in {0..$$(JTREG_RETRY_COUNT)}; do \
1084 if [ "$$$$i" != 0 ]; then \
1085 $$(ECHO) ""; \
1086 $$(ECHO) "Retrying Jtreg run. Attempt: $$$$i"; \
1087 fi; \
1088 $$($1_COMMAND_LINE); \
1089 if [ "`$$(CAT) $$($1_EXITCODE)`" = "0" ]; then \
1090 break; \
1091 fi; \
1092 export JTREG_STATUS="-status:error,fail"; \
1093 done
1094 endif
1095
1096 ifneq ($$(JTREG_REPEAT_COUNT), 0)
1097 $1_COMMAND_LINE := \
1098 for i in {1..$$(JTREG_REPEAT_COUNT)}; do \
1099 $$(ECHO) ""; \
1100 $$(ECHO) "Repeating Jtreg run: $$$$i out of $$(JTREG_REPEAT_COUNT)"; \
1101 $$($1_COMMAND_LINE); \
1102 if [ "`$$(CAT) $$($1_EXITCODE)`" != "0" ]; then \
1103 $$(ECHO) ""; \
1104 $$(ECHO) "Failures detected, no more repeats."; \
1105 break; \
1106 fi; \
1107 done
1108 endif
1109
1110 run-test-$1: clean-outputdirs-$1 pre-run-test $$($1_AOT_TARGETS)
1111 $$(call LogWarn)
1112 $$(call LogWarn, Running test '$$($1_TEST)')
1113 $$(call MakeDir, $$($1_TEST_RESULTS_DIR) $$($1_TEST_SUPPORT_DIR) \
1114 $$($1_TEST_TMP_DIR))
1115 $$(call ExecuteWithLog, $$($1_TEST_SUPPORT_DIR)/jtreg, \
1116 $$(COV_ENVIRONMENT) $$($1_COMMAND_LINE) \
1117 )
1118
1119 $1_RESULT_FILE := $$($1_TEST_RESULTS_DIR)/text/stats.txt
1120
1121 parse-test-$1: run-test-$1
1122 $$(call LogWarn, Finished running test '$$($1_TEST)')
1123 $$(call LogWarn, Test report is stored in $$(strip \
1124 $$(subst $$(TOPDIR)/, , $$($1_TEST_RESULTS_DIR))))
1125
1126 # Read jtreg documentation to learn on the test stats categories:
1127 # https://github.com/openjdk/jtreg/blob/master/src/share/doc/javatest/regtest/faq.md#what-do-all-those-numbers-in-the-test-results-line-mean
1128 # In jtreg, "skipped:" category accounts for tests that threw jtreg.SkippedException at runtime.
1129 # At the same time these tests contribute to "passed:" tests.
1130 # In here we don't want that and so we substract number of "skipped:" from "passed:".
1131
1132 $$(if $$(wildcard $$($1_RESULT_FILE)), \
1133 $$(eval $1_PASSED_AND_RUNTIME_SKIPPED := $$(shell $$(AWK) '{ gsub(/[,;]/, ""); \
1134 for (i=1; i<=NF; i++) { if ($$$$i == "passed:") \
1135 print $$$$(i+1) } }' $$($1_RESULT_FILE))) \
1136 $$(if $$($1_PASSED_AND_RUNTIME_SKIPPED), , $$(eval $1_PASSED_AND_RUNTIME_SKIPPED := 0)) \
1137 $$(eval $1_FAILED := $$(shell $$(AWK) '{gsub(/[,;]/, ""); \
1138 for (i=1; i<=NF; i++) { if ($$$$i == "failed:") \
1139 print $$$$(i+1) } }' $$($1_RESULT_FILE))) \
1140 $$(if $$($1_FAILED), , $$(eval $1_FAILED := 0)) \
1141 $$(eval $1_RUNTIME_SKIPPED := $$(shell $$(AWK) '{gsub(/[,;]/, ""); \
1142 for (i=1; i<=NF; i++) { if ($$$$i == "skipped:") \
1143 print $$$$(i+1) } }' $$($1_RESULT_FILE))) \
1144 $$(if $$($1_RUNTIME_SKIPPED), , $$(eval $1_RUNTIME_SKIPPED := 0)) \
1145 $$(eval $1_SKIPPED := $$(shell \
1146 $$(AWK) \
1147 'BEGIN { \
1148 overall_skipped = 0; \
1149 patterns[1] = "skipped"; \
1150 patterns[2] = "excluded"; \
1151 patterns[3] = "not in match-list"; \
1152 patterns[4] = "did not match keywords"; \
1153 patterns[5] = "did not meet module requirements"; \
1154 patterns[6] = "did not meet platform requirements"; \
1155 patterns[7] = "did not match prior status"; \
1156 patterns[8] = "did not meet time-limit requirements"; \
1157 } { \
1158 split($$$$0, arr, ";"); \
1159 for (item in arr) { \
1160 for (p in patterns) { \
1161 if (match(arr[item], patterns[p] ": [0-9]+")) { \
1162 overall_skipped += substr(arr[item], RSTART + length(patterns[p]) + 2, RLENGTH); \
1163 } \
1164 } \
1165 } \
1166 print overall_skipped; \
1167 }' \
1168 $$($1_RESULT_FILE) \
1169 )) \
1170 $$(eval $1_ERROR := $$(shell $$(AWK) '{gsub(/[,;]/, ""); \
1171 for (i=1; i<=NF; i++) { if ($$$$i == "error:") \
1172 print $$$$(i+1) } }' $$($1_RESULT_FILE))) \
1173 $$(if $$($1_ERROR), , $$(eval $1_ERROR := 0)) \
1174 \
1175 $$(eval $1_PASSED := $$(shell \
1176 $$(EXPR) $$($1_PASSED_AND_RUNTIME_SKIPPED) - $$($1_RUNTIME_SKIPPED))) \
1177 $$(eval $1_TOTAL := $$(shell \
1178 $$(EXPR) $$($1_PASSED) + $$($1_FAILED) + $$($1_ERROR) + $$($1_SKIPPED))) \
1179 , \
1180 $$(eval $1_PASSED_AND_RUNTIME_SKIPPED := 0) \
1181 $$(eval $1_PASSED := 0) \
1182 $$(eval $1_RUNTIME_SKIPPED := 0) \
1183 $$(eval $1_SKIPPED := 0) \
1184 $$(eval $1_FAILED := 0) \
1185 $$(eval $1_ERROR := 1) \
1186 $$(eval $1_TOTAL := 1) \
1187 )
1188
1189 $1: run-test-$1 parse-test-$1 clean-outputdirs-$1
1190
1191 TARGETS += $1 run-test-$1 parse-test-$1 clean-outputdirs-$1
1192 TEST_TARGETS += parse-test-$1
1193
1194 endef
1195
1196 ################################################################################
1197
1198 ### Rules for special tests
1199
1200 SetupRunSpecialTest = $(NamedParamsMacroTemplate)
1201 define SetupRunSpecialTestBody
1202 $1_TEST_RESULTS_DIR := $$(TEST_RESULTS_DIR)/$1
1203 $1_TEST_SUPPORT_DIR := $$(TEST_SUPPORT_DIR)/$1
1204 $1_EXITCODE := $$($1_TEST_RESULTS_DIR)/exitcode.txt
1205
1206 $1_FULL_TEST_NAME := $$(strip $$(patsubst special:%, %, $$($1_TEST)))
1207 ifneq ($$(findstring :, $$($1_FULL_TEST_NAME)), )
1208 $1_TEST_NAME := $$(firstword $$(subst :, ,$$($1_FULL_TEST_NAME)))
1209 $1_TEST_ARGS := $$(strip $$(patsubst special:$$($1_TEST_NAME):%, %, $$($1_TEST)))
1210 else
1211 $1_TEST_NAME := $$($1_FULL_TEST_NAME)
1212 $1_TEST_ARGS :=
1213 endif
1214
1215 ifeq ($$($1_TEST_NAME), failure-handler)
1216 ifeq ($(BUILD_FAILURE_HANDLER), true)
1217 $1_TEST_COMMAND_LINE := \
1218 ($(CD) $(TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f \
1219 BuildFailureHandler.gmk test)
1220 else
1221 $$(error Cannot test failure handler if it is not built)
1222 endif
1223 else ifeq ($$($1_TEST_NAME), make)
1224 $1_TEST_COMMAND_LINE := \
1225 ($(CD) $(TOPDIR)/test/make && $(MAKE) $(MAKE_ARGS) -f \
1226 TestMake.gmk $$($1_TEST_ARGS) TEST_SUPPORT_DIR="$$($1_TEST_SUPPORT_DIR)")
1227 else
1228 $$(error Invalid special test specification: $$($1_TEST_NAME))
1229 endif
1230
1231 run-test-$1: pre-run-test
1232 $$(call LogWarn)
1233 $$(call LogWarn, Running test '$$($1_TEST)')
1234 $$(call MakeDir, $$($1_TEST_RESULTS_DIR) $$($1_TEST_SUPPORT_DIR))
1235 $$(call ExecuteWithLog, $$($1_TEST_SUPPORT_DIR)/test-execution, \
1236 $$($1_TEST_COMMAND_LINE) \
1237 > >($(TEE) $$($1_TEST_RESULTS_DIR)/test-output.txt) \
1238 && $$(ECHO) $$$$? > $$($1_EXITCODE) \
1239 || $$(ECHO) $$$$? > $$($1_EXITCODE) \
1240 )
1241
1242 # We can not parse the various "special" tests.
1243 parse-test-$1: run-test-$1
1244 $$(call LogWarn, Finished running test '$$($1_TEST)')
1245 $$(call LogWarn, Test report is stored in $$(strip \
1246 $$(subst $$(TOPDIR)/, , $$($1_TEST_RESULTS_DIR))))
1247 $$(call LogWarn, Warning: Special test results are not properly parsed!)
1248 $$(eval $1_PASSED := $$(shell \
1249 if [ `$(CAT) $$($1_EXITCODE)` = "0" ]; then $(ECHO) 1; else $(ECHO) 0; fi \
1250 ))
1251 $$(eval $1_SKIPPED := 0)
1252 $$(eval $1_FAILED := $$(shell \
1253 if [ `$(CAT) $$($1_EXITCODE)` = "0" ]; then $(ECHO) 0; else $(ECHO) 1; fi \
1254 ))
1255 $$(eval $1_ERROR := 0)
1256 $$(eval $1_TOTAL := 1)
1257
1258 $1: run-test-$1 parse-test-$1
1259
1260 TARGETS += $1 run-test-$1 parse-test-$1
1261 TEST_TARGETS += parse-test-$1
1262
1263 endef
1264
1265 ################################################################################
1266 # Setup and execute make rules for all selected tests
1267 ################################################################################
1268
1269 # Helper function to determine which handler to use for the given test
1270 UseGtestTestHandler = \
1271 $(if $(filter gtest:%, $1), true)
1272
1273 UseMicroTestHandler = \
1274 $(if $(filter micro:%, $1), true)
1275
1276 UseJtregTestHandler = \
1277 $(if $(filter jtreg:%, $1), true)
1278
1279 UseSpecialTestHandler = \
1280 $(if $(filter special:%, $1), true)
1281
1282 # Now process each test to run and setup a proper make rule
1283 $(foreach test, $(TESTS_TO_RUN), \
1284 $(eval TEST_ID := $(shell $(ECHO) $(strip $(test)) | \
1285 $(TR) -cs '[a-z][A-Z][0-9]\n' '_')) \
1286 $(eval ALL_TEST_IDS += $(TEST_ID)) \
1287 $(if $(call UseCustomTestHandler, $(test)), \
1288 $(eval $(call SetupRunCustomTest, $(TEST_ID), \
1289 TEST := $(test), \
1290 )) \
1291 ) \
1292 $(if $(call UseGtestTestHandler, $(test)), \
1293 $(eval $(call SetupRunGtestTest, $(TEST_ID), \
1294 TEST := $(test), \
1295 )) \
1296 ) \
1297 $(if $(call UseMicroTestHandler, $(test)), \
1298 $(eval $(call SetupRunMicroTest, $(TEST_ID), \
1299 TEST := $(test), \
1300 )) \
1301 ) \
1302 $(if $(call UseJtregTestHandler, $(test)), \
1303 $(eval $(call SetupRunJtregTest, $(TEST_ID), \
1304 TEST := $(test), \
1305 )) \
1306 ) \
1307 $(if $(call UseSpecialTestHandler, $(test)), \
1308 $(eval $(call SetupRunSpecialTest, $(TEST_ID), \
1309 TEST := $(test), \
1310 )) \
1311 ) \
1312 )
1313
1314 # Sort also removes duplicates, so if there is any we'll get fewer words.
1315 ifneq ($(words $(ALL_TEST_IDS)), $(words $(sort $(ALL_TEST_IDS))))
1316 $(error Duplicate test specification)
1317 endif
1318
1319
1320 ################################################################################
1321 # The main target for RunTests.gmk
1322 ################################################################################
1323
1324 #
1325 # Provide hooks for adding functionality before and after all tests are run.
1326 #
1327
1328 $(call LogInfo, RunTest setup starting)
1329
1330 # This target depends on all actual test having been run (TEST_TARGETS has beeen
1331 # populated by the SetupRun*Test functions). If you need to provide a teardown
1332 # hook, you must let it depend on this target.
1333 run-all-tests: $(TEST_TARGETS)
1334 $(call LogInfo, RunTest teardown starting)
1335
1336 # This is an abstract target that will be run before any actual tests. Add your
1337 # target as a dependency to thisif you need "setup" type functionality executed
1338 # before all tests.
1339 pre-run-test:
1340 $(call LogInfo, RunTest setup done)
1341
1342 # This is an abstract target that will be run after all actual tests, but before
1343 # the test summary. If you need "teardown" type functionality, add your target
1344 # as a dependency on this, and let the teardown target depend on run-all-tests.
1345 post-run-test: run-all-tests
1346 $(call LogInfo, RunTest teardown done)
1347
1348 #
1349 # Create and print a table of the result of all tests run
1350 #
1351 TEST_FAILURE := false
1352
1353 run-test-report: post-run-test
1354 $(RM) $(TEST_SUMMARY).old 2> /dev/null
1355 $(MV) $(TEST_SUMMARY) $(TEST_SUMMARY).old 2> /dev/null || true
1356 $(RM) $(TEST_LAST_IDS).old 2> /dev/null
1357 $(MV) $(TEST_LAST_IDS) $(TEST_LAST_IDS).old 2> /dev/null || true
1358 $(ECHO) >> $(TEST_SUMMARY) ==============================
1359 $(ECHO) >> $(TEST_SUMMARY) Test summary
1360 $(ECHO) >> $(TEST_SUMMARY) ==============================
1361 $(PRINTF) >> $(TEST_SUMMARY) "%2s %-49s %5s %5s %5s %5s %5s %2s\n" " " \
1362 TEST TOTAL PASS FAIL ERROR SKIP " "
1363 $(foreach test, $(TESTS_TO_RUN), \
1364 $(eval TEST_ID := $(shell $(ECHO) $(strip $(test)) | \
1365 $(TR) -cs '[a-z][A-Z][0-9]\n' '_')) \
1366 $(ECHO) >> $(TEST_LAST_IDS) $(TEST_ID) $(NEWLINE) \
1367 $(eval NAME_PATTERN := $(shell $(ECHO) $(test) | $(TR) -c '\n' '_')) \
1368 $(if $(filter __________________________________________________%, $(NAME_PATTERN)), \
1369 $(eval TEST_NAME := ) \
1370 $(PRINTF) >> $(TEST_SUMMARY) "%2s %-49s\n" " " "$(test)" $(NEWLINE) \
1371 , \
1372 $(eval TEST_NAME := $(test)) \
1373 ) \
1374 $(if $(filter-out 0, $($(TEST_ID)_FAILED) $($(TEST_ID)_ERROR)), \
1375 $(PRINTF) >> $(TEST_SUMMARY) "%2s %-49s %5d %5d %5d %5d %5d %2s\n" \
1376 ">>" "$(TEST_NAME)" $($(TEST_ID)_TOTAL) $($(TEST_ID)_PASSED) \
1377 $($(TEST_ID)_FAILED) $($(TEST_ID)_ERROR) $($(TEST_ID)_SKIPPED) "<<" $(NEWLINE) \
1378 $(eval TEST_FAILURE := true) \
1379 , \
1380 $(PRINTF) >> $(TEST_SUMMARY) "%2s %-49s %5d %5d %5d %5d %5d %2s\n" \
1381 " " "$(TEST_NAME)" $($(TEST_ID)_TOTAL) $($(TEST_ID)_PASSED) \
1382 $($(TEST_ID)_FAILED) $($(TEST_ID)_ERROR) $($(TEST_ID)_SKIPPED) " " $(NEWLINE) \
1383 ) \
1384 )
1385 $(ECHO) >> $(TEST_SUMMARY) ==============================
1386 $(if $(filter true, $(TEST_FAILURE)), \
1387 $(ECHO) >> $(TEST_SUMMARY) TEST FAILURE $(NEWLINE) \
1388 $(MKDIR) -p $(MAKESUPPORT_OUTPUTDIR) $(NEWLINE) \
1389 $(TOUCH) $(MAKESUPPORT_OUTPUTDIR)/exit-with-error \
1390 , \
1391 $(ECHO) >> $(TEST_SUMMARY) TEST SUCCESS \
1392 )
1393 $(ECHO)
1394 $(CAT) $(TEST_SUMMARY)
1395 $(ECHO)
1396
1397 # The main run-test target
1398 run-test: run-test-report
1399
1400 TARGETS += run-all-tests pre-run-test post-run-test run-test-report run-test
1401
1402 ################################################################################
1403 # Setup JCov
1404 ################################################################################
1405
1406 ifeq ($(TEST_OPTS_JCOV), true)
1407
1408 JCOV_VM_OPTS := -Xmx4g -Djdk.xml.totalEntitySizeLimit=0 -Djdk.xml.maxGeneralEntitySizeLimit=0
1409
1410 jcov-do-start-grabber:
1411 $(call MakeDir, $(JCOV_OUTPUT_DIR))
1412 if $(JAVA) -jar $(JCOV_HOME)/lib/jcov.jar GrabberManager -status 1>/dev/null 2>&1 ; then \
1413 $(JAVA) -jar $(JCOV_HOME)/lib/jcov.jar GrabberManager -stop -stoptimeout 3600 ; \
1414 fi
1415 $(JAVA) $(JCOV_VM_OPTS) -jar $(JCOV_HOME)/lib/jcov.jar Grabber -v -t \
1416 $(JCOV_IMAGE_DIR)/template.xml -o $(JCOV_RESULT_FILE) \
1417 1>$(JCOV_GRABBER_LOG) 2>&1 &
1418
1419 jcov-start-grabber: jcov-do-start-grabber
1420 $(call LogWarn, Starting JCov Grabber...)
1421 $(JAVA) -jar $(JCOV_HOME)/lib/jcov.jar GrabberManager -t 600 -wait
1422
1423 jcov-stop-grabber:
1424 $(call LogWarn, Stopping JCov Grabber...)
1425 $(JAVA) -jar $(JCOV_HOME)/lib/jcov.jar GrabberManager -stop -stoptimeout 3600
1426
1427 JCOV_REPORT_TITLE := JDK code coverage report<br/>
1428 ifneq ($(JCOV_MODULES), )
1429 JCOV_MODULES_FILTER := $(foreach m, $(JCOV_MODULES), -include_module $m)
1430 JCOV_REPORT_TITLE += Included modules: $(JCOV_MODULES)<br>
1431 endif
1432 ifneq ($(JCOV_FILTERS), )
1433 JCOV_REPORT_TITLE += Code filters: $(JCOV_FILTERS)<br>
1434 endif
1435 JCOV_REPORT_TITLE += Tests: $(TEST)
1436
1437 jcov-gen-report: jcov-stop-grabber
1438 $(call LogWarn, Generating JCov report ...)
1439 $(call ExecuteWithLog, $(JCOV_SUPPORT_DIR)/run-jcov-repgen, \
1440 $(JAVA) $(JCOV_VM_OPTS) -jar $(JCOV_HOME)/lib/jcov.jar RepGen -sourcepath \
1441 `$(ECHO) $(TOPDIR)/src/*/share/classes/ | $(TR) ' ' ':'` -fmt html \
1442 $(JCOV_MODULES_FILTER) $(JCOV_FILTERS) \
1443 -mainReportTitle "$(JCOV_REPORT_TITLE)" \
1444 -o $(JCOV_REPORT) $(JCOV_RESULT_FILE))
1445
1446 TARGETS += jcov-do-start-grabber jcov-start-grabber jcov-stop-grabber \
1447 jcov-gen-report
1448
1449 ifneq ($(TEST_OPTS_JCOV_DIFF_CHANGESET), )
1450
1451 JCOV_SOURCE_DIFF := $(JCOV_OUTPUT_DIR)/source_diff
1452 JCOV_DIFF_COVERAGE_REPORT := $(JCOV_OUTPUT_DIR)/diff_coverage_report
1453
1454 ifneq ($(and $(GIT), $(wildcard $(TOPDIR)/.git)), )
1455 DIFF_COMMAND := $(GIT) -C $(TOPDIR) diff $(TEST_OPTS_JCOV_DIFF_CHANGESET) > $(JCOV_SOURCE_DIFF)
1456 else
1457 $(info Error: Must be a git source tree for diff coverage.)
1458 $(error No git source tree.)
1459 endif
1460
1461 jcov-gen-diffcoverage: jcov-stop-grabber
1462 $(call LogWarn, Generating diff coverage with changeset $(TEST_OPTS_JCOV_DIFF_CHANGESET) ... )
1463 $(DIFF_COMMAND)
1464 $(JAVA) $(JCOV_VM_OPTS) -jar $(JCOV_HOME)/lib/jcov.jar \
1465 DiffCoverage -replaceDiff "src/.*/classes/:" -all \
1466 $(JCOV_RESULT_FILE) $(JCOV_SOURCE_DIFF) > \
1467 $(JCOV_DIFF_COVERAGE_REPORT)
1468
1469 TARGETS += jcov-gen-diffcoverage
1470
1471 endif
1472
1473 # Hook this into the framework at appropriate places
1474 pre-run-test: jcov-start-grabber
1475
1476 post-run-test: jcov-gen-report
1477
1478 ifneq ($(TEST_OPTS_JCOV_DIFF_CHANGESET), )
1479
1480 post-run-test: jcov-gen-diffcoverage
1481
1482 endif
1483
1484 jcov-stop-grabber: run-all-tests
1485
1486 endif
1487
1488 ################################################################################
1489
1490 all: run-test
1491
1492 .PHONY: $(TARGETS)
1493
1494 ################################################################################
1495
1496 include MakeFileEnd.gmk