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