1 # 2 # Copyright (c) 2016, 2018, 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 default: all 27 28 include $(SPEC) 29 include MakeBase.gmk 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, \ 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 64 ifeq ($(OPENJDK_TARGET_OS), windows) 65 ifndef _NT_SYMBOL_PATH 66 # Can't use PathList here as it adds quotes around the value. 67 _NT_SYMBOL_PATH := \ 68 $(subst $(SPACE),;,$(strip \ 69 $(foreach p, $(sort $(dir $(wildcard \ 70 $(addprefix $(SYMBOLS_IMAGE_DIR)/bin/, *.pdb */*.pdb)))), \ 71 $(call FixPath, $p) \ 72 ) \ 73 )) 74 export _NT_SYMBOL_PATH 75 $(info _NT_SYMBOL_PATH=$(_NT_SYMBOL_PATH)) 76 endif 77 endif 78 79 ################################################################################ 80 # Hook to include the corresponding custom file, if present. 81 $(eval $(call IncludeCustomExtension, RunTests.gmk)) 82 ################################################################################ 83 84 TEST_RESULTS_DIR := $(OUTPUTDIR)/test-results 85 TEST_SUPPORT_DIR := $(OUTPUTDIR)/test-support 86 TEST_SUMMARY := $(TEST_RESULTS_DIR)/test-summary.txt 87 TEST_LAST_IDS := $(TEST_SUPPORT_DIR)/test-last-ids.txt 88 89 ifeq ($(CUSTOM_ROOT), ) 90 JTREG_TOPDIR := $(TOPDIR) 91 else 92 JTREG_TOPDIR := $(CUSTOM_ROOT) 93 endif 94 95 JTREG_FAILURE_HANDLER_DIR := $(TEST_IMAGE_DIR)/failure_handler 96 JTREG_FAILURE_HANDLER := $(JTREG_FAILURE_HANDLER_DIR)/jtregFailureHandler.jar 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:0 105 endif 106 107 GTEST_LAUNCHER_DIRS := $(patsubst %/gtestLauncher, %, $(wildcard $(TEST_IMAGE_DIR)/hotspot/gtest/*/gtestLauncher)) 108 GTEST_VARIANTS := $(strip $(patsubst $(TEST_IMAGE_DIR)/hotspot/gtest/%, %, $(GTEST_LAUNCHER_DIRS))) 109 110 ################################################################################ 111 # Setup global test running parameters 112 ################################################################################ 113 114 # Each factor variable comes in 3 variants. The first one is reserved for users 115 # to use on command line. The other two are for predifined configurations in JDL 116 # and for machine specific configurations respectively. 117 TEST_JOBS_FACTOR ?= 1 118 TEST_JOBS_FACTOR_JDL ?= 1 119 TEST_JOBS_FACTOR_MACHINE ?= 1 120 121 ifeq ($(TEST_JOBS), 0) 122 # Concurrency based on min(cores / 2, 12) * TEST_JOBS_FACTOR 123 TEST_JOBS := $(shell $(AWK) \ 124 'BEGIN { \ 125 c = $(NUM_CORES) / 2; \ 126 if (c > 12) c = 12; \ 127 c = c * $(TEST_JOBS_FACTOR); \ 128 c = c * $(TEST_JOBS_FACTOR_JDL); \ 129 c = c * $(TEST_JOBS_FACTOR_MACHINE); \ 130 if (c < 1) c = 1; \ 131 printf "%.0f", c; \ 132 }') 133 endif 134 135 ################################################################################ 136 # Parse control variables 137 ################################################################################ 138 139 ifneq ($(TEST_OPTS), ) 140 # Inform the user 141 $(info Running tests using TEST_OPTS control variable '$(TEST_OPTS)') 142 endif 143 144 $(eval $(call SetTestOpt,VM_OPTIONS,JTREG)) 145 $(eval $(call SetTestOpt,JAVA_OPTIONS,JTREG)) 146 $(eval $(call SetTestOpt,VM_OPTIONS,GTEST)) 147 $(eval $(call SetTestOpt,JAVA_OPTIONS,GTEST)) 148 149 $(eval $(call SetTestOpt,JOBS,JTREG)) 150 $(eval $(call SetTestOpt,TIMEOUT_FACTOR,JTREG)) 151 152 $(eval $(call ParseKeywordVariable, JTREG, \ 153 SINGLE_KEYWORDS := JOBS TIMEOUT_FACTOR TEST_MODE ASSERT VERBOSE RETAIN MAX_MEM \ 154 EXTRA_PROBLEM_LISTS KEYWORDS, \ 155 STRING_KEYWORDS := OPTIONS JAVA_OPTIONS VM_OPTIONS, \ 156 )) 157 158 ifneq ($(JTREG), ) 159 # Inform the user 160 $(info Running tests using JTREG control variable '$(JTREG)') 161 endif 162 163 $(eval $(call ParseKeywordVariable, GTEST, \ 164 SINGLE_KEYWORDS := REPEAT, \ 165 STRING_KEYWORDS := OPTIONS VM_OPTIONS JAVA_OPTIONS, \ 166 )) 167 168 ifneq ($(GTEST), ) 169 # Inform the user 170 $(info Running tests using GTEST control variable '$(GTEST)') 171 endif 172 173 174 ################################################################################ 175 # Component-specific Jtreg settings 176 ################################################################################ 177 178 hotspot_JTREG_MAX_MEM := 0 179 hotspot_JTREG_ASSERT := false 180 hotspot_JTREG_NATIVEPATH := $(TEST_IMAGE_DIR)/hotspot/jtreg/native 181 jdk_JTREG_NATIVEPATH := $(TEST_IMAGE_DIR)/jdk/jtreg/native 182 183 jdk_JTREG_PROBLEM_LIST += $(TOPDIR)/test/jdk/ProblemList.txt 184 jaxp_JTREG_PROBLEM_LIST += $(TOPDIR)/test/jaxp/ProblemList.txt 185 langtools_JTREG_PROBLEM_LIST += $(TOPDIR)/test/langtools/ProblemList.txt 186 nashorn_JTREG_PROBLEM_LIST += $(TOPDIR)/test/nashorn/ProblemList.txt 187 hotspot_JTREG_PROBLEM_LIST += $(TOPDIR)/test/hotspot/jtreg/ProblemList.txt 188 189 langtools_JTREG_MAX_MEM := 768m 190 191 ################################################################################ 192 # Parse test selection 193 # 194 # The user has given a test selection in the TEST variable. We must parse it 195 # and determine what that means in terms of actual calls to the test framework. 196 # 197 # The parse functions take as argument a test specification as given by the 198 # user, and returns a fully qualified test descriptor if it was a match, or 199 # nothing if not. A single test specification can result in multiple test 200 # descriptors being returned. A valid test descriptor must always be accepted 201 # and returned identically. 202 ################################################################################ 203 204 # Helper function to determine if a test specification is a Gtest test 205 # 206 # It is a Gtest test if it is either "gtest", or "gtest:" followed by an optional 207 # test filter string, and an optional "/<variant>" to select a specific JVM 208 # variant. If no variant is specified, all found variants are tested. 209 define ParseGtestTestSelection 210 $(if $(filter gtest%, $1), \ 211 $(if $(filter gtest, $1), \ 212 $(addprefix gtest:all/, $(GTEST_VARIANTS)) \ 213 , \ 214 $(if $(strip $(or $(filter gtest/%, $1) $(filter gtest:/%, $1))), \ 215 $(patsubst gtest:/%, gtest:all/%, $(patsubst gtest/%, gtest:/%, $1)) \ 216 , \ 217 $(if $(filter gtest:%, $1), \ 218 $(if $(findstring /, $1), \ 219 $1 \ 220 , \ 221 $(addprefix $1/, $(GTEST_VARIANTS)) \ 222 ) \ 223 ) \ 224 ) \ 225 ) \ 226 ) 227 endef 228 229 # Helper function that removes the TOPDIR part 230 CleanupJtregPath = \ 231 $(strip $(patsubst %/, %, $(subst $(JTREG_TOPDIR)/,, $1))) 232 233 # Take a partial Jtreg root path and return a full, absolute path to that Jtreg 234 # root. Also support having "hotspot" as an alias for "hotspot/jtreg". 235 ExpandJtregRoot = \ 236 $(call CleanupJtregPath, $(wildcard \ 237 $(if $(filter /%, $1), \ 238 $(if $(wildcard $(strip $1)/TEST.ROOT), \ 239 $1 \ 240 ) \ 241 , \ 242 $(filter $(addprefix %, $1), $(JTREG_TESTROOTS) $(addsuffix /, $(JTREG_TESTROOTS))) \ 243 $(filter $(addprefix %, $(strip $1)/jtreg), $(JTREG_TESTROOTS) $(addsuffix /, $(JTREG_TESTROOTS))) \ 244 ) \ 245 )) 246 247 # Take a partial Jtreg test path and return a full, absolute path to that Jtreg 248 # test. Also support having "hotspot" as an alias for "hotspot/jtreg". 249 ExpandJtregPath = \ 250 $(if $(call ExpandJtregRoot, $1), \ 251 $(call ExpandJtregRoot, $1) \ 252 , \ 253 $(call CleanupJtregPath, $(wildcard \ 254 $(if $(filter /%, $1), \ 255 $1 \ 256 , \ 257 $(addsuffix /$(strip $1), $(JTREG_TESTROOTS) $(TEST_BASEDIRS)) \ 258 $(addsuffix $(strip $(patsubst hotspot/%, /hotspot/jtreg/%, $1)), $(JTREG_TESTROOTS) $(TEST_BASEDIRS)) \ 259 ) \ 260 )) \ 261 ) 262 263 # Helper function to determine if a test specification is a Jtreg test 264 # 265 # It is a Jtreg test if it optionally begins with jtreg:, and then is either 266 # an unspecified group name (possibly prefixed by :), or a group in a 267 # specified test root, or a path to a test or test directory, 268 # either absolute or relative to any of the TEST_BASEDIRS or test roots. 269 define ParseJtregTestSelection 270 $(eval TEST_NAME := $(strip $(patsubst jtreg:%, %, $1))) \ 271 $(if $(or $(findstring :, $(TEST_NAME)), $(findstring /, $(TEST_NAME))), , \ 272 $(eval TEST_NAME := :$(TEST_NAME)) \ 273 ) \ 274 $(if $(findstring :, $(TEST_NAME)), \ 275 $(if $(filter :%, $(TEST_NAME)), \ 276 $(eval TEST_GROUP := $(patsubst :%, %, $(TEST_NAME))) \ 277 $(eval TEST_ROOTS := $(foreach test_root, $(JTREG_TESTROOTS), \ 278 $(call CleanupJtregPath, $(test_root)))) \ 279 , \ 280 $(eval TEST_PATH := $(word 1, $(subst :, $(SPACE), $(TEST_NAME)))) \ 281 $(eval TEST_GROUP := $(word 2, $(subst :, $(SPACE), $(TEST_NAME)))) \ 282 $(eval TEST_ROOTS := $(call ExpandJtregRoot, $(TEST_PATH))) \ 283 ) \ 284 $(foreach test_root, $(TEST_ROOTS), \ 285 $(if $(filter /%, $(test_root)), \ 286 jtreg:$(test_root):$(TEST_GROUP) \ 287 , \ 288 $(if $(filter $(TEST_GROUP), $($(JTREG_TOPDIR)/$(test_root)_JTREG_TEST_GROUPS)), \ 289 jtreg:$(test_root):$(TEST_GROUP) \ 290 ) \ 291 ) \ 292 ) \ 293 , \ 294 $(eval TEST_PATHS := $(call ExpandJtregPath, $(TEST_NAME))) \ 295 $(foreach test_path, $(TEST_PATHS), \ 296 jtreg:$(test_path) \ 297 ) \ 298 ) 299 endef 300 301 # Helper function to determine if a test specification is a special test 302 # 303 # It is a special test if it is "special:" followed by a test name, 304 # if it is "make:" or "make-" followed by a make test, or any of the special test names 305 # as a single word. 306 define ParseSpecialTestSelection 307 $(if $(filter special:%, $1), \ 308 $1 \ 309 ) \ 310 $(if $(filter make%, $1), \ 311 $(if $(filter make:%, $1), \ 312 special:$(strip $1) \ 313 ) \ 314 $(if $(filter make-%, $1), \ 315 special:$(patsubst make-%,make:%, $1) \ 316 ) \ 317 $(if $(filter make, $1), \ 318 special:make:all \ 319 ) 320 ) \ 321 $(if $(filter hotspot-internal failure-handler, $1), \ 322 special:$(strip $1) \ 323 ) 324 endef 325 326 ifeq ($(TEST), ) 327 $(info No test selection given in TEST!) 328 $(info Please use e.g. 'make test TEST=tier1' or 'make test-tier1') 329 $(info See doc/testing.[md|html] for help) 330 $(error Cannot continue) 331 endif 332 333 # Now intelligently convert the test selection given by the user in TEST 334 # into a list of fully qualified test descriptors of the tests to run. 335 TESTS_TO_RUN := 336 $(foreach test, $(TEST), \ 337 $(eval PARSED_TESTS := $(call ParseCustomTestSelection, $(test))) \ 338 $(if $(strip $(PARSED_TESTS)), , \ 339 $(eval PARSED_TESTS += $(call ParseGtestTestSelection, $(test))) \ 340 ) \ 341 $(if $(strip $(PARSED_TESTS)), , \ 342 $(eval PARSED_TESTS += $(call ParseJtregTestSelection, $(test))) \ 343 ) \ 344 $(if $(strip $(PARSED_TESTS)), , \ 345 $(eval PARSED_TESTS += $(call ParseSpecialTestSelection, $(test))) \ 346 ) \ 347 $(if $(strip $(PARSED_TESTS)), , \ 348 $(eval UNKNOWN_TEST := $(test)) \ 349 ) \ 350 $(eval TESTS_TO_RUN += $(PARSED_TESTS)) \ 351 ) 352 353 ifneq ($(UNKNOWN_TEST), ) 354 $(info Unknown test selection: '$(UNKNOWN_TEST)') 355 $(info See doc/testing.[md|html] for help) 356 $(error Cannot continue) 357 endif 358 359 TESTS_TO_RUN := $(strip $(TESTS_TO_RUN)) 360 361 362 # Present the result of our parsing to the user 363 $(info Test selection '$(TEST)', will run:) 364 $(foreach test, $(TESTS_TO_RUN), $(info * $(test))) 365 366 367 ################################################################################ 368 # Functions for setting up rules for running the selected tests 369 # 370 # The SetupRun*Test functions all have the same interface: 371 # 372 # Parameter 1 is the name of the rule. This is the test id, based on the test 373 # descriptor, and this is also used as variable prefix, and the targets 374 # generated are listed in a variable by that name. 375 # 376 # Remaining parameters are named arguments. Currently this is only: 377 # TEST -- The properly formatted fully qualified test descriptor 378 # 379 # After the rule named by the test id has been executed, the following 380 # variables will be available: 381 # testid_TOTAL - the total number of tests run 382 # testid_PASSED - the number of successful tests 383 # testid_FAILED - the number of failed tests 384 # testid_ERROR - the number of tests was neither successful or failed 385 # 386 ################################################################################ 387 388 ### Rules for Gtest 389 390 SetupRunGtestTest = $(NamedParamsMacroTemplate) 391 define SetupRunGtestTestBody 392 $1_TEST_RESULTS_DIR := $$(TEST_RESULTS_DIR)/$1 393 $1_TEST_SUPPORT_DIR := $$(TEST_SUPPORT_DIR)/$1 394 $1_EXITCODE := $$($1_TEST_RESULTS_DIR)/exitcode.txt 395 396 $1_VARIANT := $$(lastword $$(subst /, , $$($1_TEST))) 397 ifeq ($$(filter $$($1_VARIANT), $$(GTEST_VARIANTS)), ) 398 $$(error Invalid gtest variant '$$($1_VARIANT)'. Valid variants: $$(GTEST_VARIANTS)) 399 endif 400 $1_TEST_NAME := $$(strip $$(patsubst %/$$($1_VARIANT), %, \ 401 $$(patsubst gtest:%, %, $$($1_TEST)))) 402 ifneq ($$($1_TEST_NAME), all) 403 $1_GTEST_FILTER := --gtest_filter=$$($1_TEST_NAME)* 404 endif 405 406 ifneq ($$(GTEST_REPEAT), ) 407 $1_GTEST_REPEAT :=--gtest_repeat=$$(GTEST_REPEAT) 408 endif 409 410 run-test-$1: $(TEST_PREREQS) 411 $$(call LogWarn) 412 $$(call LogWarn, Running test '$$($1_TEST)') 413 $$(call MakeDir, $$($1_TEST_RESULTS_DIR) $$($1_TEST_SUPPORT_DIR)) 414 $$(call ExecuteWithLog, $$($1_TEST_SUPPORT_DIR)/gtest, \ 415 $$(FIXPATH) $$(TEST_IMAGE_DIR)/hotspot/gtest/$$($1_VARIANT)/gtestLauncher \ 416 -jdk $(JDK_IMAGE_DIR) $$($1_GTEST_FILTER) \ 417 --gtest_output=xml:$$($1_TEST_RESULTS_DIR)/gtest.xml \ 418 $$($1_GTEST_REPEAT) $$(GTEST_OPTIONS) $$(GTEST_VM_OPTIONS) \ 419 $$($1_GTEST_JAVA_OPTIONS) \ 420 > >($(TEE) $$($1_TEST_RESULTS_DIR)/gtest.txt) \ 421 && $$(ECHO) $$$$? > $$($1_EXITCODE) \ 422 || $$(ECHO) $$$$? > $$($1_EXITCODE) \ 423 ) 424 425 $1_RESULT_FILE := $$($1_TEST_RESULTS_DIR)/gtest.txt 426 427 parse-test-$1: run-test-$1 428 $$(call LogWarn, Finished running test '$$($1_TEST)') 429 $$(call LogWarn, Test report is stored in $$(strip \ 430 $$(subst $$(TOPDIR)/, , $$($1_TEST_RESULTS_DIR)))) 431 $$(if $$(wildcard $$($1_RESULT_FILE)), \ 432 $$(eval $1_TOTAL := $$(shell $$(AWK) '/==========.* tests? from .* \ 433 test cases? ran/ { print $$$$2 }' $$($1_RESULT_FILE))) \ 434 $$(if $$($1_TOTAL), , $$(eval $1_TOTAL := 0)) \ 435 $$(eval $1_PASSED := $$(shell $$(AWK) '/\[ PASSED \] .* tests?./ \ 436 { print $$$$4 }' $$($1_RESULT_FILE))) \ 437 $$(if $$($1_PASSED), , $$(eval $1_PASSED := 0)) \ 438 $$(eval $1_FAILED := $$(shell $$(AWK) '/\[ FAILED \] .* tests?, \ 439 listed below/ { print $$$$4 }' $$($1_RESULT_FILE))) \ 440 $$(if $$($1_FAILED), , $$(eval $1_FAILED := 0)) \ 441 $$(eval $1_ERROR := $$(shell \ 442 $$(EXPR) $$($1_TOTAL) - $$($1_PASSED) - $$($1_FAILED))) \ 443 , \ 444 $$(eval $1_PASSED := 0) \ 445 $$(eval $1_FAILED := 0) \ 446 $$(eval $1_ERROR := 1) \ 447 $$(eval $1_TOTAL := 1) \ 448 ) 449 450 $1: run-test-$1 parse-test-$1 451 452 TARGETS += $1 453 endef 454 455 ################################################################################ 456 457 ### Rules for Jtreg 458 459 # Helper function for SetupRunJtregTest. Set a JTREG_* variable from, in order: 460 # 1) Specified by user on command line 461 # 2) Component-specific default 462 # 3) Generic default 463 # 464 # Note: No spaces are allowed around the arguments. 465 # Arg $1 The test ID (i.e. $1 in SetupRunJtregTest) 466 # Arg $2 Base variable, e.g. JTREG_JOBS 467 # Arg $3 The default value (optional) 468 define SetJtregValue 469 ifneq ($$($2), ) 470 $1_$2 := $$($2) 471 else 472 ifneq ($$($$($1_COMPONENT)_$2), ) 473 $1_$2 := $$($$($1_COMPONENT)_$2) 474 else 475 ifneq ($3, ) 476 $1_$2 := $3 477 endif 478 endif 479 endif 480 endef 481 482 SetupRunJtregTest = $(NamedParamsMacroTemplate) 483 define SetupRunJtregTestBody 484 $1_TEST_RESULTS_DIR := $$(TEST_RESULTS_DIR)/$1 485 $1_TEST_SUPPORT_DIR := $$(TEST_SUPPORT_DIR)/$1 486 $1_EXITCODE := $$($1_TEST_RESULTS_DIR)/exitcode.txt 487 488 $1_TEST_NAME := $$(strip $$(patsubst jtreg:%, %, $$($1_TEST))) 489 490 $1_TEST_ROOT := \ 491 $$(strip $$(foreach root, $$(JTREG_TESTROOTS), \ 492 $$(if $$(filter $$(root)%, $$(JTREG_TOPDIR)/$$($1_TEST_NAME)), $$(root)) \ 493 )) 494 $1_COMPONENT := $$(lastword $$(subst /, $$(SPACE), $$($1_TEST_ROOT))) 495 # This will work only as long as just hotspot has the additional "jtreg" directory 496 ifeq ($$($1_COMPONENT), jtreg) 497 $1_COMPONENT := hotspot 498 endif 499 500 ifeq ($$(JT_HOME), ) 501 $$(info Error: jtreg framework is not found.) 502 $$(info Please run configure using --with-jtreg.) 503 $$(error Cannot continue) 504 endif 505 506 # Unfortunately, we need different defaults for some JTREG values, 507 # depending on what component we're running. 508 509 # Convert JTREG_foo into $1_JTREG_foo with a suitable value. 510 $$(eval $$(call SetJtregValue,$1,JTREG_TEST_MODE,agentvm)) 511 $$(eval $$(call SetJtregValue,$1,JTREG_ASSERT,true)) 512 $$(eval $$(call SetJtregValue,$1,JTREG_MAX_MEM,512m)) 513 $$(eval $$(call SetJtregValue,$1,JTREG_NATIVEPATH)) 514 $$(eval $$(call SetJtregValue,$1,JTREG_BASIC_OPTIONS)) 515 $$(eval $$(call SetJtregValue,$1,JTREG_PROBLEM_LIST)) 516 517 # Only the problem list for the current test root should be used. 518 $1_JTREG_PROBLEM_LIST := $$(filter $$($1_TEST_ROOT)%, $$($1_JTREG_PROBLEM_LIST)) 519 520 ifneq ($(TEST_JOBS), 0) 521 $$(eval $$(call SetJtregValue,$1,JTREG_JOBS,$$(TEST_JOBS))) 522 else 523 $$(eval $$(call SetJtregValue,$1,JTREG_JOBS,$$(JOBS))) 524 endif 525 526 # Make sure MaxRAMPercentage is high enough to not cause OOM or swapping since 527 # we may end up with a lot of JVM's 528 $1_JTREG_MAX_RAM_PERCENTAGE := $$(shell $$(EXPR) 25 / $$($1_JTREG_JOBS)) 529 530 JTREG_TIMEOUT_FACTOR ?= 4 531 JTREG_VERBOSE ?= fail,error,summary 532 JTREG_RETAIN ?= fail,error 533 534 ifneq ($$($1_JTREG_MAX_MEM), 0) 535 $1_JTREG_BASIC_OPTIONS += -vmoption:-Xmx$$($1_JTREG_MAX_MEM) 536 $1_JTREG_LAUNCHER_OPTIONS += -Xmx$$($1_JTREG_MAX_MEM) 537 endif 538 539 $1_JTREG_BASIC_OPTIONS += -$$($1_JTREG_TEST_MODE) \ 540 -verbose:$$(JTREG_VERBOSE) -retain:$$(JTREG_RETAIN) \ 541 -concurrency:$$($1_JTREG_JOBS) -timeoutFactor:$$(JTREG_TIMEOUT_FACTOR) \ 542 -vmoption:-XX:MaxRAMPercentage=$$($1_JTREG_MAX_RAM_PERCENTAGE) 543 544 $1_JTREG_BASIC_OPTIONS += -automatic -ignore:quiet 545 546 # Make it possible to specify the JIB_DATA_DIR for tests using the 547 # JIB Artifact resolver 548 $1_JTREG_BASIC_OPTIONS += -e:JIB_DATA_DIR 549 # Some tests needs to find a boot JDK using the JDK8_HOME variable. 550 $1_JTREG_BASIC_OPTIONS += -e:JDK8_HOME=$$(BOOT_JDK) 551 # If running on Windows, propagate the _NT_SYMBOL_PATH to enable 552 # symbol lookup in hserr files 553 ifeq ($$(OPENJDK_TARGET_OS), windows) 554 $1_JTREG_BASIC_OPTIONS += -e:_NT_SYMBOL_PATH 555 endif 556 557 $1_JTREG_BASIC_OPTIONS += \ 558 $$(addprefix -javaoption:, $$(JTREG_JAVA_OPTIONS)) \ 559 $$(addprefix -vmoption:, $$(JTREG_VM_OPTIONS)) \ 560 # 561 562 ifeq ($$($1_JTREG_ASSERT), true) 563 $1_JTREG_BASIC_OPTIONS += -ea -esa 564 endif 565 566 ifneq ($$($1_JTREG_NATIVEPATH), ) 567 $1_JTREG_BASIC_OPTIONS += -nativepath:$$($1_JTREG_NATIVEPATH) 568 endif 569 570 ifneq ($$($1_JTREG_PROBLEM_LIST), ) 571 $1_JTREG_BASIC_OPTIONS += $$(addprefix -exclude:, $$($1_JTREG_PROBLEM_LIST)) 572 endif 573 574 ifneq ($$(JTREG_EXTRA_PROBLEM_LISTS), ) 575 # Accept both absolute paths as well as relative to the current test root. 576 $1_JTREG_BASIC_OPTIONS += $$(addprefix -exclude:, $$(wildcard \ 577 $$(JTREG_EXTRA_PROBLEM_LISTS) \ 578 $$(addprefix $$($1_TEST_ROOT)/, $$(JTREG_EXTRA_PROBLEM_LISTS)) \ 579 )) 580 endif 581 582 ifneq ($$(JIB_HOME), ) 583 $1_JTREG_BASIC_OPTIONS += -e:JIB_HOME=$$(JIB_HOME) 584 endif 585 586 $1_JTREG_BASIC_OPTIONS += -e:TEST_IMAGE_GRAAL_DIR=${TEST_IMAGE_DIR}/hotspot/jtreg/graal 587 588 ifneq ($$(JTREG_FAILURE_HANDLER_OPTIONS), ) 589 $1_JTREG_LAUNCHER_OPTIONS += -Djava.library.path="$(JTREG_FAILURE_HANDLER_DIR)" 590 endif 591 592 ifneq ($$(JTREG_KEYWORDS), ) 593 # The keywords string may contain problematic characters and may be quoted 594 # already when it arrives here. Remove any existing quotes and replace them 595 # with one set of single quotes. 596 $1_JTREG_KEYWORDS := \ 597 $$(strip $$(subst $$(SQUOTE),,$$(subst $$(DQUOTE),,$$(JTREG_KEYWORDS)))) 598 ifneq ($$($1_JTREG_KEYWORDS), ) 599 $1_JTREG_BASIC_OPTIONS += -k:'$$($1_JTREG_KEYWORDS)' 600 endif 601 endif 602 603 clean-workdir-$1: 604 $$(RM) -r $$($1_TEST_SUPPORT_DIR) 605 606 run-test-$1: clean-workdir-$1 $(TEST_PREREQS) 607 $$(call LogWarn) 608 $$(call LogWarn, Running test '$$($1_TEST)') 609 $$(call MakeDir, $$($1_TEST_RESULTS_DIR) $$($1_TEST_SUPPORT_DIR)) 610 $$(call ExecuteWithLog, $$($1_TEST_SUPPORT_DIR)/jtreg, \ 611 $$(JAVA) $$($1_JTREG_LAUNCHER_OPTIONS) \ 612 -Dprogram=jtreg -jar $$(JT_HOME)/lib/jtreg.jar \ 613 $$($1_JTREG_BASIC_OPTIONS) \ 614 -testjdk:$$(JDK_IMAGE_DIR) \ 615 -dir:$$(JTREG_TOPDIR) \ 616 -reportDir:$$($1_TEST_RESULTS_DIR) \ 617 -workDir:$$($1_TEST_SUPPORT_DIR) \ 618 $$(JTREG_OPTIONS) \ 619 $$(JTREG_FAILURE_HANDLER_OPTIONS) \ 620 $$($1_TEST_NAME) \ 621 && $$(ECHO) $$$$? > $$($1_EXITCODE) \ 622 || $$(ECHO) $$$$? > $$($1_EXITCODE) \ 623 ) 624 625 $1_RESULT_FILE := $$($1_TEST_RESULTS_DIR)/text/stats.txt 626 627 parse-test-$1: run-test-$1 628 $$(call LogWarn, Finished running test '$$($1_TEST)') 629 $$(call LogWarn, Test report is stored in $$(strip \ 630 $$(subst $$(TOPDIR)/, , $$($1_TEST_RESULTS_DIR)))) 631 $$(if $$(wildcard $$($1_RESULT_FILE)), \ 632 $$(eval $1_PASSED := $$(shell $$(AWK) '{ gsub(/[,;]/, ""); \ 633 for (i=1; i<=NF; i++) { if ($$$$i == "passed:") \ 634 print $$$$(i+1) } }' $$($1_RESULT_FILE))) \ 635 $$(if $$($1_PASSED), , $$(eval $1_PASSED := 0)) \ 636 $$(eval $1_FAILED := $$(shell $$(AWK) '{gsub(/[,;]/, ""); \ 637 for (i=1; i<=NF; i++) { if ($$$$i == "failed:") \ 638 print $$$$(i+1) } }' $$($1_RESULT_FILE))) \ 639 $$(if $$($1_FAILED), , $$(eval $1_FAILED := 0)) \ 640 $$(eval $1_ERROR := $$(shell $$(AWK) '{gsub(/[,;]/, ""); \ 641 for (i=1; i<=NF; i++) { if ($$$$i == "error:") \ 642 print $$$$(i+1) } }' $$($1_RESULT_FILE))) \ 643 $$(if $$($1_ERROR), , $$(eval $1_ERROR := 0)) \ 644 $$(eval $1_TOTAL := $$(shell \ 645 $$(EXPR) $$($1_PASSED) + $$($1_FAILED) + $$($1_ERROR))) \ 646 , \ 647 $$(eval $1_PASSED := 0) \ 648 $$(eval $1_FAILED := 0) \ 649 $$(eval $1_ERROR := 1) \ 650 $$(eval $1_TOTAL := 1) \ 651 ) 652 653 $1: run-test-$1 parse-test-$1 654 655 TARGETS += $1 656 endef 657 658 ################################################################################ 659 660 ### Rules for special tests 661 662 SetupRunSpecialTest = $(NamedParamsMacroTemplate) 663 define SetupRunSpecialTestBody 664 $1_TEST_RESULTS_DIR := $$(TEST_RESULTS_DIR)/$1 665 $1_TEST_SUPPORT_DIR := $$(TEST_SUPPORT_DIR)/$1 666 $1_EXITCODE := $$($1_TEST_RESULTS_DIR)/exitcode.txt 667 668 $1_FULL_TEST_NAME := $$(strip $$(patsubst special:%, %, $$($1_TEST))) 669 ifneq ($$(findstring :, $$($1_FULL_TEST_NAME)), ) 670 $1_TEST_NAME := $$(firstword $$(subst :, ,$$($1_FULL_TEST_NAME))) 671 $1_TEST_ARGS := $$(strip $$(patsubst special:$$($1_TEST_NAME):%, %, $$($1_TEST))) 672 else 673 $1_TEST_NAME := $$($1_FULL_TEST_NAME) 674 $1_TEST_ARGS := 675 endif 676 677 ifeq ($$($1_TEST_NAME), hotspot-internal) 678 $1_TEST_COMMAND_LINE := \ 679 $$(JDK_IMAGE_DIR)/bin/java -XX:+ExecuteInternalVMTests \ 680 -XX:+ShowMessageBoxOnError -version 681 else ifeq ($$($1_TEST_NAME), failure-handler) 682 ifeq ($(BUILD_FAILURE_HANDLER), true) 683 $1_TEST_COMMAND_LINE := \ 684 ($(CD) $(TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f \ 685 BuildFailureHandler.gmk test) 686 else 687 $$(error Cannot test failure handler if it is not built) 688 endif 689 else ifeq ($$($1_TEST_NAME), make) 690 $1_TEST_COMMAND_LINE := \ 691 ($(CD) $(TOPDIR)/test/make && $(MAKE) $(MAKE_ARGS) -f \ 692 TestMake.gmk $$($1_TEST_ARGS)) 693 else 694 $$(error Invalid special test specification: $$($1_TEST_NAME)) 695 endif 696 697 run-test-$1: $(TEST_PREREQS) 698 $$(call LogWarn) 699 $$(call LogWarn, Running test '$$($1_TEST)') 700 $$(call MakeDir, $$($1_TEST_RESULTS_DIR) $$($1_TEST_SUPPORT_DIR)) 701 $$(call ExecuteWithLog, $$($1_TEST_SUPPORT_DIR)/test-execution, \ 702 $$($1_TEST_COMMAND_LINE) \ 703 > >($(TEE) $$($1_TEST_RESULTS_DIR)/test-output.txt) \ 704 && $$(ECHO) $$$$? > $$($1_EXITCODE) \ 705 || $$(ECHO) $$$$? > $$($1_EXITCODE) \ 706 ) 707 708 $1_RESULT_FILE := $$($1_TEST_RESULTS_DIR)/gtest.txt 709 710 # We can not parse the various "special" tests. 711 parse-test-$1: run-test-$1 712 $$(call LogWarn, Finished running test '$$($1_TEST)') 713 $$(call LogWarn, Test report is stored in $$(strip \ 714 $$(subst $$(TOPDIR)/, , $$($1_TEST_RESULTS_DIR)))) 715 $$(call LogWarn, Warning: Special test results are not properly parsed!) 716 $$(eval $1_PASSED := 0) 717 $$(eval $1_FAILED := 0) 718 $$(eval $1_ERROR := 0) 719 $$(eval $1_TOTAL := 0) 720 721 $1: run-test-$1 parse-test-$1 722 723 TARGETS += $1 724 endef 725 726 ################################################################################ 727 # Setup and execute make rules for all selected tests 728 ################################################################################ 729 730 # Helper function to determine which handler to use for the given test 731 UseGtestTestHandler = \ 732 $(if $(filter gtest:%, $1), true) 733 734 UseJtregTestHandler = \ 735 $(if $(filter jtreg:%, $1), true) 736 737 UseSpecialTestHandler = \ 738 $(if $(filter special:%, $1), true) 739 740 # Now process each test to run and setup a proper make rule 741 $(foreach test, $(TESTS_TO_RUN), \ 742 $(eval TEST_ID := $(shell $(ECHO) $(strip $(test)) | \ 743 $(TR) -cs '[a-z][A-Z][0-9]\n' '[_*1000]')) \ 744 $(eval ALL_TEST_IDS += $(TEST_ID)) \ 745 $(if $(call UseCustomTestHandler, $(test)), \ 746 $(eval $(call SetupRunCustomTest, $(TEST_ID), \ 747 TEST := $(test), \ 748 )) \ 749 ) \ 750 $(if $(call UseGtestTestHandler, $(test)), \ 751 $(eval $(call SetupRunGtestTest, $(TEST_ID), \ 752 TEST := $(test), \ 753 )) \ 754 ) \ 755 $(if $(call UseJtregTestHandler, $(test)), \ 756 $(eval $(call SetupRunJtregTest, $(TEST_ID), \ 757 TEST := $(test), \ 758 )) \ 759 ) \ 760 $(if $(call UseSpecialTestHandler, $(test)), \ 761 $(eval $(call SetupRunSpecialTest, $(TEST_ID), \ 762 TEST := $(test), \ 763 )) \ 764 ) \ 765 ) 766 767 # Sort also removes duplicates, so if there is any we'll get fewer words. 768 ifneq ($(words $(ALL_TEST_IDS)), $(words $(sort $(ALL_TEST_IDS)))) 769 $(error Duplicate test specification) 770 endif 771 772 773 ################################################################################ 774 # The main target for RunTests.gmk 775 ################################################################################ 776 777 # The SetupRun*Test functions have populated TARGETS. 778 779 TEST_FAILURE := false 780 781 run-test: $(TARGETS) 782 # Create and print a table of the result of all tests run 783 $(RM) $(TEST_SUMMARY).old 2> /dev/null 784 $(MV) $(TEST_SUMMARY) $(TEST_SUMMARY).old 2> /dev/null || true 785 $(RM) $(TEST_LAST_IDS).old 2> /dev/null 786 $(MV) $(TEST_LAST_IDS) $(TEST_LAST_IDS).old 2> /dev/null || true 787 $(ECHO) >> $(TEST_SUMMARY) ============================== 788 $(ECHO) >> $(TEST_SUMMARY) Test summary 789 $(ECHO) >> $(TEST_SUMMARY) ============================== 790 $(PRINTF) >> $(TEST_SUMMARY) "%2s %-49s %5s %5s %5s %5s %2s\n" " " \ 791 TEST TOTAL PASS FAIL ERROR " " 792 $(foreach test, $(TESTS_TO_RUN), \ 793 $(eval TEST_ID := $(shell $(ECHO) $(strip $(test)) | \ 794 $(TR) -cs '[a-z][A-Z][0-9]\n' '[_*1000]')) \ 795 $(ECHO) >> $(TEST_LAST_IDS) $(TEST_ID) $(NEWLINE) \ 796 $(eval NAME_PATTERN := $(shell $(ECHO) $(test) | $(TR) -c '\n' '[_*1000]')) \ 797 $(if $(filter __________________________________________________%, $(NAME_PATTERN)), \ 798 $(eval TEST_NAME := ) \ 799 $(PRINTF) >> $(TEST_SUMMARY) "%2s %-49s\n" " " "$(test)" $(NEWLINE) \ 800 , \ 801 $(eval TEST_NAME := $(test)) \ 802 ) \ 803 $(if $(filter $($(TEST_ID)_PASSED), $($(TEST_ID)_TOTAL)), \ 804 $(PRINTF) >> $(TEST_SUMMARY) "%2s %-49s %5d %5d %5d %5d %2s\n" \ 805 " " "$(TEST_NAME)" $($(TEST_ID)_TOTAL) $($(TEST_ID)_PASSED) \ 806 $($(TEST_ID)_FAILED) $($(TEST_ID)_ERROR) " " $(NEWLINE) \ 807 , \ 808 $(PRINTF) >> $(TEST_SUMMARY) "%2s %-49s %5d %5d %5d %5d %2s\n" \ 809 ">>" "$(TEST_NAME)" $($(TEST_ID)_TOTAL) $($(TEST_ID)_PASSED) \ 810 $($(TEST_ID)_FAILED) $($(TEST_ID)_ERROR) "<<" $(NEWLINE) \ 811 $(eval TEST_FAILURE := true) \ 812 ) \ 813 ) 814 $(ECHO) >> $(TEST_SUMMARY) ============================== 815 $(if $(filter true, $(TEST_FAILURE)), \ 816 $(ECHO) >> $(TEST_SUMMARY) TEST FAILURE $(NEWLINE) \ 817 $(MKDIR) -p $(MAKESUPPORT_OUTPUTDIR) $(NEWLINE) \ 818 $(TOUCH) $(MAKESUPPORT_OUTPUTDIR)/exit-with-error \ 819 , \ 820 $(ECHO) >> $(TEST_SUMMARY) TEST SUCCESS \ 821 ) 822 $(ECHO) 823 $(CAT) $(TEST_SUMMARY) 824 $(ECHO) 825 826 ################################################################################ 827 828 all: run-test 829 830 .PHONY: default all run-test $(TARGETS)