annotate test/TestCommon.gmk @ 51029:43b54a307c89

8203937: Not possible to read data from socket after write detects connection reset Reviewed-by: chegar
author alanb
date Wed, 06 Jun 2018 12:17:01 +0100
parents ece10494786c
children 7c51db95ccb6
rev   line source
ihse@42424 1 #
mseledtsov@49411 2 # Copyright (c) 1995, 2018, Oracle and/or its affiliates. All rights reserved.
ihse@42424 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ihse@42424 4 #
ihse@42424 5 # This code is free software; you can redistribute it and/or modify it
ihse@42424 6 # under the terms of the GNU General Public License version 2 only, as
ihse@42424 7 # published by the Free Software Foundation. Oracle designates this
ihse@42424 8 # particular file as subject to the "Classpath" exception as provided
ihse@42424 9 # by Oracle in the LICENSE file that accompanied this code.
ihse@42424 10 #
ihse@42424 11 # This code is distributed in the hope that it will be useful, but WITHOUT
ihse@42424 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ihse@42424 13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ihse@42424 14 # version 2 for more details (a copy is included in the LICENSE file that
ihse@42424 15 # accompanied this code).
ihse@42424 16 #
ihse@42424 17 # You should have received a copy of the GNU General Public License version
ihse@42424 18 # 2 along with this work; if not, write to the Free Software Foundation,
ihse@42424 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ihse@42424 20 #
ihse@42424 21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ihse@42424 22 # or visit www.oracle.com if you need additional information or have any
ihse@42424 23 # questions.
ihse@42424 24 #
ihse@42424 25
ihse@42424 26 #
ihse@42424 27 # Common logic to run various tests for a component, to be included by the
ihse@42424 28 # component specific test makefiles.
ihse@42424 29 #
ihse@42424 30
ihse@42424 31 # Default values for some properties that can be overridden by components.
ihse@42424 32 USE_JTREG_VERSION ?= 4.2
ihse@42424 33 JTREG_VM_TYPE ?= -agentvm
ihse@42424 34 USE_JTREG_ASSERT ?= true
ihse@42424 35 LIMIT_JTREG_VM_MEMORY ?= true
ihse@42424 36
erikj@49578 37 X:=
erikj@49578 38 SPACE:=$(X) $(X)
erikj@49578 39
ihse@42424 40 .DEFAULT : all
ihse@42424 41
ihse@42424 42 # Empty these to get rid of some default rules
ihse@42424 43 .SUFFIXES:
ihse@42424 44 .SUFFIXES: .java
ihse@42424 45 CO=
ihse@42424 46 GET=
ihse@42424 47
ihse@42424 48 # Utilities used
ihse@42424 49 AWK = awk
ihse@42424 50 CAT = cat
ihse@42424 51 CD = cd
ihse@42424 52 CHMOD = chmod
ihse@42424 53 CP = cp
ihse@42424 54 CUT = cut
ihse@42424 55 DIRNAME = dirname
ihse@42424 56 ECHO = echo
ihse@42424 57 EGREP = egrep
ihse@42424 58 EXPAND = expand
ihse@42424 59 FIND = find
ihse@42424 60 MKDIR = mkdir
ihse@42424 61 PWD = pwd
ihse@42424 62 RM = rm -f
ihse@42424 63 SED = sed
ihse@42424 64 SORT = sort
ihse@42424 65 TEE = tee
ihse@42424 66 UNAME = uname
ihse@42424 67 UNIQ = uniq
ihse@42424 68 WC = wc
ihse@42424 69 ZIPEXE = zip
ihse@42424 70
ihse@42424 71 # Get OS name from uname (Cygwin inexplicably adds _NT-5.1)
ihse@42424 72 UNAME_S := $(shell $(UNAME) -s | $(CUT) -f1 -d_)
ihse@42424 73
ihse@42424 74 # Commands to run on paths to make mixed paths for java on windows
ihse@42424 75 ifeq ($(findstring CYGWIN,$(UNAME_S)), CYGWIN)
ihse@42424 76 # Location of developer shared files
ihse@42424 77 SLASH_JAVA = J:
ihse@42424 78 GETMIXEDPATH = cygpath -m
ihse@42424 79 PLATFORM = windows
ihse@42424 80 else
ihse@42424 81 # Location of developer shared files
ihse@42424 82 SLASH_JAVA = /java
ihse@42424 83 GETMIXEDPATH = $(ECHO)
ihse@42424 84 PLATFORM = unix # we only care about windows or bsd.
ihse@42424 85 ifeq ($(UNAME_S), Darwin)
ihse@42424 86 PLATFORM = bsd
ihse@42424 87 endif
ihse@42424 88 ifeq ($(findstring BSD,$(UNAME_S)), BSD)
ihse@42424 89 PLATFORM = bsd
ihse@42424 90 endif
ihse@42424 91 endif
ihse@42424 92
erikj@49578 93 # convert list of directories to dos paths
erikj@49578 94 define MixedDirs
erikj@49578 95 $(foreach i,$1,$(shell $(GETMIXEDPATH) "${i}"))
erikj@49578 96 endef
erikj@49578 97
ihse@42424 98 ifdef ALT_SLASH_JAVA
ihse@42424 99 SLASH_JAVA = $(ALT_SLASH_JAVA)
ihse@42424 100 endif
ihse@42424 101
ihse@42424 102 # Root of this test area (important to use full paths in some places)
ihse@42424 103 TEST_ROOT := $(shell $(PWD))
ihse@42424 104
ihse@42424 105 # Root of all test results
ihse@42424 106 ifdef TEST_OUTPUT_DIR
ihse@42424 107 $(shell $(MKDIR) -p $(TEST_OUTPUT_DIR)/jtreg)
ihse@42424 108 ABS_TEST_OUTPUT_DIR := \
ihse@42424 109 $(shell $(CD) $(TEST_OUTPUT_DIR)/jtreg && $(PWD))
ihse@42424 110 else
ihse@42424 111 ifdef ALT_OUTPUTDIR
ihse@42424 112 ABS_OUTPUTDIR = $(shell $(CD) $(ALT_OUTPUTDIR) && $(PWD))
ihse@42424 113 else
ihse@42424 114 ABS_OUTPUTDIR = $(shell $(CD) $(TEST_ROOT)/.. && $(PWD))
ihse@42424 115 endif
ihse@42424 116
ihse@42424 117 ABS_PLATFORM_BUILD_ROOT = $(ABS_OUTPUTDIR)
ihse@42424 118 ABS_TEST_OUTPUT_DIR := $(ABS_PLATFORM_BUILD_ROOT)/testoutput/$(UNIQUE_DIR)
ihse@42424 119 endif
ihse@42424 120
ihse@42424 121 # Expect JPRT to set PRODUCT_HOME (the product or jdk in this case to test)
ihse@42424 122 ifndef PRODUCT_HOME
ihse@42424 123 # Try to use images/jdk if it exists
ihse@42424 124 ABS_JDK_IMAGE = $(ABS_PLATFORM_BUILD_ROOT)/images/jdk
ihse@42424 125 PRODUCT_HOME := \
ihse@42424 126 $(shell \
ihse@42424 127 if [ -d $(ABS_JDK_IMAGE) ] ; then \
ihse@42424 128 $(ECHO) "$(ABS_JDK_IMAGE)"; \
ihse@42424 129 else \
ihse@42424 130 $(ECHO) "$(ABS_PLATFORM_BUILD_ROOT)"; \
ihse@42424 131 fi)
ihse@42424 132 PRODUCT_HOME := $(PRODUCT_HOME)
ihse@42424 133 endif
ihse@42424 134
erikj@49578 135 # On Windows, setup the _NT_SYMBOL_PATH if possible.
erikj@49578 136 ifeq ($(PLATFORM), windows)
erikj@49578 137 ifndef _NT_SYMBOL_PATH
erikj@49578 138 ifdef PRODUCT_SYMBOLS_HOME
erikj@49578 139 _NT_SYMBOL_PATH := \
erikj@49578 140 $(subst $(SPACE),;,$(strip $(call MixedDirs, $(sort $(dir $(wildcard \
erikj@49578 141 $(addprefix $(PRODUCT_SYMBOLS_HOME)/bin/, *.pdb */*.pdb)))))))
erikj@49578 142 export _NT_SYMBOL_PATH
erikj@49578 143 endif
erikj@49578 144 endif
erikj@49578 145 JTREG_BASIC_OPTIONS += -e:_NT_SYMBOL_PATH='$(_NT_SYMBOL_PATH)'
erikj@49578 146 endif
erikj@49578 147
ihse@42424 148 # Expect JPRT to set JPRT_PRODUCT_ARGS (e.g. -server etc.)
ihse@42424 149 # Should be passed into 'java' only.
ihse@42424 150 # Could include: -d64 -server -client OR any java option
ihse@42424 151 ifdef JPRT_PRODUCT_ARGS
ihse@42424 152 JAVA_ARGS = $(JPRT_PRODUCT_ARGS)
ihse@42424 153 endif
ihse@42424 154
ihse@42424 155 # Expect JPRT to set JPRT_PRODUCT_VM_ARGS (e.g. -Xcomp etc.)
ihse@42424 156 # Should be passed into anything running the vm (java, javac, javadoc, ...).
ihse@42424 157 ifdef JPRT_PRODUCT_VM_ARGS
ihse@42424 158 JAVA_VM_ARGS = $(JPRT_PRODUCT_VM_ARGS)
ihse@42424 159 endif
ihse@42424 160
ihse@42424 161 ifneq ($(NATIVE_TEST_PATH), )
ihse@42424 162 # jtreg -nativepath <dir>
ihse@42424 163 #
ihse@42424 164 # Local make tests will be TEST_IMAGE_DIR and JPRT with jprt.use.reg.test.bundle=true
ihse@42424 165 # should be JPRT_TESTNATIVE_PATH
ihse@42424 166 ifdef TEST_IMAGE_DIR
ihse@42424 167 TESTNATIVE_DIR = $(TEST_IMAGE_DIR)
ihse@42424 168 else ifdef JPRT_TESTNATIVE_PATH
ihse@42424 169 TESTNATIVE_DIR = $(JPRT_TESTNATIVE_PATH)
ihse@42424 170 endif
ihse@42424 171 ifdef TESTNATIVE_DIR
ihse@42424 172 JTREG_NATIVE_PATH = -nativepath:$(shell $(GETMIXEDPATH) "$(TESTNATIVE_DIR)/$(NATIVE_TEST_PATH)")
ihse@42424 173 endif
ihse@42424 174 endif
ihse@42424 175
ihse@42424 176 ifeq ($(USE_FAILURE_HANDLER), true)
ihse@42424 177 # jtreg failure handler config
ihse@42424 178 ifeq ($(FAILURE_HANDLER_DIR), )
ihse@42424 179 ifneq ($(TESTNATIVE_DIR), )
ihse@42424 180 FAILURE_HANDLER_DIR := $(TESTNATIVE_DIR)/failure_handler
ihse@42424 181 endif
ihse@42424 182 endif
ihse@42424 183 ifneq ($(FAILURE_HANDLER_DIR), )
ihse@42424 184 FAILURE_HANDLER_DIR_MIXED := $(shell $(GETMIXEDPATH) "$(FAILURE_HANDLER_DIR)")
ihse@42424 185 JTREG_FAILURE_HANDLER_OPTIONS := \
ihse@42424 186 -timeoutHandlerDir:$(FAILURE_HANDLER_DIR_MIXED)/jtregFailureHandler.jar \
ihse@42424 187 -observerDir:$(FAILURE_HANDLER_DIR_MIXED)/jtregFailureHandler.jar \
ihse@42424 188 -timeoutHandler:jdk.test.failurehandler.jtreg.GatherProcessInfoTimeoutHandler \
ihse@42424 189 -observer:jdk.test.failurehandler.jtreg.GatherDiagnosticInfoObserver \
ihse@42424 190 -timeoutHandlerTimeout:0
ihse@42424 191 ifeq ($(PLATFORM), windows)
ihse@42424 192 JTREG_FAILURE_HANDLER_OPTIONS += -J-Djava.library.path="$(FAILURE_HANDLER_DIR_MIXED)"
ihse@42424 193 endif
ihse@42424 194 endif
ihse@42424 195 endif
ihse@42424 196
mseledtsov@49411 197
mseledtsov@49411 198 # Optionally create a CDS archive before running tests
mseledtsov@49411 199 ifeq ($(GENERATE_CDS_ARCHIVE), true)
mseledtsov@49411 200 CDS_ARCHIVE_FILE := $(ABS_TEST_OUTPUT_DIR)/cds_archive.jsa
mseledtsov@49411 201
mseledtsov@49411 202 $(CDS_ARCHIVE_FILE): $(PRODUCT_HOME)
mseledtsov@49411 203 $(PRODUCT_HOME)/bin/java -XX:+UnlockDiagnosticVMOptions \
mseledtsov@49411 204 -XX:SharedArchiveFile=$(shell $(GETMIXEDPATH) "$(CDS_ARCHIVE_FILE)") -Xshare:dump
mseledtsov@49411 205
mseledtsov@49411 206 CDS_VM_ARGS := -XX:+UnlockDiagnosticVMOptions -XX:SharedArchiveFile=$(shell $(GETMIXEDPATH) "$(CDS_ARCHIVE_FILE)")
mseledtsov@49411 207 JTREG_TEST_OPTIONS += $(addprefix -vmoption:, $(CDS_VM_ARGS))
mseledtsov@49411 208 TEST_PREREQS += $(CDS_ARCHIVE_FILE)
mseledtsov@49411 209 endif
mseledtsov@49411 210
ihse@42424 211 # Expect JPRT to set JPRT_ARCHIVE_BUNDLE (path to zip bundle for results)
ihse@42424 212 ifdef JPRT_ARCHIVE_BUNDLE
ihse@42424 213 ARCHIVE_BUNDLE = $(JPRT_ARCHIVE_BUNDLE)
ihse@42424 214 endif
ihse@42424 215
ihse@42424 216 # How to create the test bundle (pass or fail, we want to create this)
ihse@42424 217 # Follow command with ";$(BUNDLE_UP_AND_EXIT)", so it always gets executed.
erikj@47565 218 ifneq ($(ARCHIVE_BUNDLE), )
erikj@47565 219 ZIP_UP_RESULTS = ( $(MKDIR) -p `$(DIRNAME) $(ARCHIVE_BUNDLE)` \
ihse@42424 220 && $(CD) $(ABS_TEST_OUTPUT_DIR) \
ihse@42424 221 && $(CHMOD) -R a+r . \
erikj@47565 222 && $(ZIPEXE) -q -r $(ARCHIVE_BUNDLE) . ) ;
erikj@47565 223 CLEAN_ARCHIVE_BUNDLE = @$(RM) $(ARCHIVE_BUNDLE)
erikj@47565 224 endif
ihse@42424 225
asmotrak@47625 226 # AddressSanitizer
asmotrak@47625 227 ifeq ($(ASAN_ENABLED), yes)
asmotrak@47625 228 export ASAN_OPTIONS="handle_segv=0 detect_leaks=0"
asmotrak@47625 229 JTREG_BASIC_OPTIONS += -e:ASAN_OPTIONS=$(ASAN_OPTIONS)
asmotrak@47625 230 ifneq ($(DEVKIT_LIB_DIR),)
asmotrak@47625 231 export LD_LIBRARY_PATH:=$(LD_LIBRARY_PATH):$(DEVKIT_LIB_DIR)
asmotrak@47625 232 JTREG_BASIC_OPTIONS += -e:LD_LIBRARY_PATH=$(LD_LIBRARY_PATH)
asmotrak@47625 233 endif
asmotrak@47625 234 endif
asmotrak@47625 235
ihse@42424 236 # important results files
ihse@42424 237 SUMMARY_TXT = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTreport/text/summary.txt")
ihse@42424 238 STATS_TXT_NAME = Stats.txt
ihse@42424 239 STATS_TXT = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/$(STATS_TXT_NAME)")
ihse@42424 240 RUNLIST = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/runlist.txt")
ihse@42424 241 PASSLIST = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/passlist.txt")
ihse@42424 242 FAILLIST = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/faillist.txt")
ihse@42424 243 EXITCODE = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/exitcode.txt")
ihse@42424 244
ihse@42424 245 TESTEXIT = \
ihse@42424 246 if [ ! -s $(EXITCODE) ] ; then \
ihse@42424 247 $(ECHO) "ERROR: EXITCODE file not filled in."; \
ihse@42424 248 $(ECHO) "1" > $(EXITCODE); \
ihse@42424 249 fi ; \
ihse@42424 250 testExitCode=`$(CAT) $(EXITCODE)`; \
ihse@42424 251 $(ECHO) "EXIT CODE: $${testExitCode}"; \
ihse@42424 252 exit $${testExitCode}
ihse@42424 253
ihse@42424 254 ifeq ($(TREAT_EXIT_CODE_1_AS_0), true)
ihse@42424 255 ADJUST_EXIT_CODE := \
ihse@42424 256 if [ $${jtregExitCode} = 1 ] ; then \
ihse@42424 257 jtregExitCode=0; \
ihse@42424 258 fi
ihse@42424 259 else
ihse@42424 260 # colon is the shell no-op
ihse@42424 261 ADJUST_EXIT_CODE := :
ihse@42424 262 endif
ihse@42424 263
ihse@42424 264 BUNDLE_UP_AND_EXIT = \
ihse@42424 265 ( \
ihse@42424 266 jtregExitCode=$$? && \
ihse@42424 267 _summary="$(SUMMARY_TXT)"; \
ihse@42424 268 $(ADJUST_EXIT_CODE) ; \
ihse@42424 269 $(RM) -f $(STATS_TXT) $(RUNLIST) $(PASSLIST) $(FAILLIST) $(EXITCODE); \
ihse@42424 270 $(ECHO) "$${jtregExitCode}" > $(EXITCODE); \
ihse@42424 271 if [ -r "$${_summary}" ] ; then \
ihse@42424 272 $(ECHO) "Summary: $(UNIQUE_DIR)" > $(STATS_TXT); \
ihse@42424 273 $(EXPAND) $${_summary} | $(EGREP) -v ' Not run\.' > $(RUNLIST); \
ihse@42424 274 $(EGREP) ' Passed\.' $(RUNLIST) \
ihse@42424 275 | $(EGREP) -v ' Error\.' \
ihse@42424 276 | $(EGREP) -v ' Failed\.' > $(PASSLIST); \
ihse@42424 277 ( $(EGREP) ' Failed\.' $(RUNLIST); \
ihse@42424 278 $(EGREP) ' Error\.' $(RUNLIST); \
ihse@42424 279 $(EGREP) -v ' Passed\.' $(RUNLIST) ) \
ihse@42424 280 | $(SORT) | $(UNIQ) > $(FAILLIST); \
ihse@42424 281 if [ $${jtregExitCode} != 0 -o -s $(FAILLIST) ] ; then \
ihse@42424 282 $(EXPAND) $(FAILLIST) \
ihse@42424 283 | $(CUT) -d' ' -f1 \
ihse@42424 284 | $(SED) -e 's@^@FAILED: @' >> $(STATS_TXT); \
ihse@42424 285 if [ $${jtregExitCode} = 0 ] ; then \
ihse@42424 286 jtregExitCode=1; \
ihse@42424 287 fi; \
ihse@42424 288 fi; \
ihse@42424 289 runc="`$(CAT) $(RUNLIST) | $(WC) -l | $(AWK) '{print $$1;}'`"; \
ihse@42424 290 passc="`$(CAT) $(PASSLIST) | $(WC) -l | $(AWK) '{print $$1;}'`"; \
ihse@42424 291 failc="`$(CAT) $(FAILLIST) | $(WC) -l | $(AWK) '{print $$1;}'`"; \
ihse@42424 292 exclc="FIXME CODETOOLS-7900176"; \
ihse@42424 293 $(ECHO) "TEST STATS: name=$(UNIQUE_DIR) run=$${runc} pass=$${passc} fail=$${failc}" \
ihse@42424 294 >> $(STATS_TXT); \
ihse@42424 295 else \
ihse@42424 296 $(ECHO) "Missing file: $${_summary}" >> $(STATS_TXT); \
ihse@42424 297 fi; \
ihse@42424 298 if [ -f $(STATS_TXT) ] ; then \
ihse@42424 299 $(CAT) $(STATS_TXT); \
ihse@42424 300 fi; \
erikj@47565 301 $(ZIP_UP_RESULTS) \
ihse@42424 302 $(TESTEXIT) \
ihse@42424 303 )
ihse@42424 304
ihse@42424 305 ################################################################
ihse@42424 306
ihse@42424 307 # Prep for output
ihse@42424 308 # Change execute permissions on shared library files.
ihse@42424 309 # Files in repositories should never have execute permissions, but
ihse@42424 310 # there are some tests that have pre-built shared libraries, and these
ihse@42424 311 # windows dll files must have execute permission. Adding execute
ihse@42424 312 # permission may happen automatically on windows when using certain
ihse@42424 313 # versions of mercurial but it cannot be guaranteed. And blindly
ihse@42424 314 # adding execute permission might be seen as a mercurial 'change', so
ihse@42424 315 # we avoid adding execute permission to repository files. But testing
ihse@42424 316 # from a plain source tree needs the chmod a+rx. Applying the chmod to
ihse@42424 317 # all shared libraries not just dll files. And with CYGWIN and sshd
ihse@42424 318 # service, you may need CYGWIN=ntsec for this to work.
ihse@42424 319 prep:
ihse@42424 320 @$(MKDIR) -p $(ABS_TEST_OUTPUT_DIR)
mcimadamore@47330 321 @if [ ! -d $(TEST_ROOT)/../../.hg ] && [ ! -d $(TEST_ROOT)/../../../.hg ]; then \
ihse@42424 322 $(FIND) $(TEST_ROOT) \( -name \*.dll -o -name \*.DLL -o -name \*.so \) \
ihse@42424 323 -exec $(CHMOD) a+rx {} \; ; \
ihse@42424 324 fi
ihse@42424 325
ihse@42424 326 ifeq ($(CLEAN_BEFORE_PREP), true)
ihse@42424 327 prep: clean
ihse@42424 328
ihse@42424 329 endif
ihse@42424 330
ihse@42424 331 # Cleanup
ihse@42424 332 clean:
ihse@42424 333 @$(RM) -r $(ABS_TEST_OUTPUT_DIR)
erikj@47565 334 $(CLEAN_ARCHIVE_BUNDLE)
ihse@42424 335
ihse@42424 336 ################################################################
ihse@42424 337
ihse@42424 338 # jtreg tests
ihse@42424 339
ihse@42424 340 # Expect JT_HOME to be set for jtreg tests. (home for jtreg)
ihse@42424 341 ifndef JT_HOME
ihse@42424 342 JT_HOME = $(SLASH_JAVA)/re/jtreg/$(USE_JTREG_VERSION)/promoted/latest/binaries/jtreg
ihse@42424 343 ifdef JPRT_JTREG_HOME
ihse@42424 344 JT_HOME = $(JPRT_JTREG_HOME)
ihse@42424 345 endif
ihse@42424 346 endif
ihse@42424 347
ihse@42424 348 # Problematic tests to be excluded
epavlova@49610 349 EXTRA_PROBLEM_LISTS :=
epavlova@49610 350 PROBLEM_LISTS := ProblemList.txt $(EXTRA_PROBLEM_LISTS)
ihse@42424 351
ihse@42424 352 # Create exclude list for this platform and arch
ihse@42424 353 ifdef NO_EXCLUDES
ihse@42424 354 JTREG_EXCLUSIONS =
ihse@42424 355 else
epavlova@49610 356 JTREG_EXCLUSIONS = $(addprefix -exclude:, $(wildcard $(PROBLEM_LISTS)))
ihse@42424 357 endif
ihse@42424 358
ihse@42424 359 # ------------------------------------------------------------------
ihse@42424 360
ihse@42424 361 # When called from JPRT the TESTDIRS variable is set to the jtreg tests to run
ihse@42424 362 ifdef TESTDIRS
ihse@42424 363 TEST_SELECTION = $(TESTDIRS)
ihse@42424 364 endif
ihse@42424 365
ctornqvi@49018 366 ifeq ($(UNAME_S), SunOS)
ctornqvi@49018 367 NUM_CORES := $(shell LC_MESSAGES=C /usr/sbin/psrinfo -v | grep -c on-line)
ihse@42424 368 endif
ctornqvi@49018 369 ifeq ($(UNAME_S), Linux)
ctornqvi@49018 370 NUM_CORES := $(shell cat /proc/cpuinfo | grep -c processor)
ctornqvi@49018 371 endif
ctornqvi@49018 372 ifeq ($(UNAME_S), Darwin)
ctornqvi@49018 373 NUM_CORES := $(shell /usr/sbin/sysctl -n hw.ncpu)
ctornqvi@49018 374 endif
ctornqvi@49018 375 ifeq ($(findstring CYGWIN,$(UNAME_S)), CYGWIN)
ctornqvi@49018 376 ifneq ($(NUMBER_OF_PROCESSORS), )
ctornqvi@49018 377 NUM_CORES := $(NUMBER_OF_PROCESSORS)
ctornqvi@49018 378 else
ctornqvi@49018 379 ifneq ($(HOTSPOT_BUILD_JOBS), )
ctornqvi@49018 380 NUM_CORES := $(HOTSPOT_BUILD_JOBS)
ctornqvi@49018 381 else
ctornqvi@49018 382 NUM_CORES := 1 # fallback
ctornqvi@49018 383 endif
ctornqvi@49018 384 endif
ctornqvi@49018 385 endif
ctornqvi@49018 386
ctornqvi@49018 387 ifndef CONCURRENCY_FACTOR
ctornqvi@49018 388 CONCURRENCY_FACTOR = 1
ctornqvi@49018 389 endif
ctornqvi@49018 390
ctornqvi@49018 391 # Concurrency based on min(cores / 2, 12) * CONCURRENCY_FACTOR
erikj@49034 392 CONCURRENCY := $(shell $(AWK) \
ctornqvi@49018 393 'BEGIN { \
ctornqvi@49018 394 c = $(NUM_CORES) / 2; \
ctornqvi@49018 395 if (c > 12) c = 12; \
ctornqvi@49018 396 c = c * $(CONCURRENCY_FACTOR); \
ctornqvi@49018 397 if (c < 1) c = 1; \
ctornqvi@49018 398 printf "%.0f", c; \
ctornqvi@49018 399 }')
ctornqvi@49018 400 JTREG_BASIC_OPTIONS += -concurrency:$(CONCURRENCY)
ctornqvi@49018 401
erikj@49034 402 # Make sure MaxRAMPercentage is low enough to not cause OOM or swapping since
erikj@49034 403 # we may end up with a lot of JVM's
erikj@49034 404 MAX_RAM_PERCENTAGE := $(shell expr 25 / $(CONCURRENCY))
erikj@49034 405 JTREG_BASIC_OPTIONS += -vmoption:-XX:MaxRAMPercentage=$(MAX_RAM_PERCENTAGE)
ctornqvi@49018 406
ihse@42424 407 ifdef EXTRA_JTREG_OPTIONS
ihse@42424 408 JTREG_BASIC_OPTIONS += $(EXTRA_JTREG_OPTIONS)
ihse@42424 409 endif
ihse@42424 410
ihse@42424 411 # Default JTREG to run
ihse@42424 412 JTREG = $(JT_HOME)/bin/jtreg
ihse@42424 413 # run in agentvm/othervm mode
ihse@42424 414 JTREG_BASIC_OPTIONS += $(JTREG_VM_TYPE)
ihse@42424 415 # Only run automatic tests
ihse@42424 416 JTREG_BASIC_OPTIONS += -a
ihse@42424 417 # Always turn on assertions
ihse@42424 418 ifeq ($(USE_JTREG_ASSERT), true)
ihse@42424 419 JTREG_ASSERT_OPTION = -ea -esa
ihse@42424 420 endif
ihse@42424 421 JTREG_BASIC_OPTIONS += $(JTREG_ASSERT_OPTION)
ihse@42424 422 # jtreg verbosity setting
ihse@42424 423 # Default is to report details on all failed or error tests, times too
ihse@42424 424 JTREG_VERBOSE ?= fail,error,time
ihse@42424 425 JTREG_BASIC_OPTIONS += $(if $(JTREG_VERBOSE),-v:$(JTREG_VERBOSE))
ihse@42424 426 # Retain all files for failing tests
ihse@42424 427 JTREG_BASIC_OPTIONS += -retain:fail,error
ihse@42424 428 # Ignore tests are not run and completely silent about it
ihse@42424 429 JTREG_IGNORE_OPTION = -ignore:quiet
ihse@42424 430 JTREG_BASIC_OPTIONS += $(JTREG_IGNORE_OPTION)
ihse@42424 431 # Multiply by 4 the timeout factor
ihse@42424 432 JTREG_TIMEOUT_OPTION = -timeoutFactor:4
ihse@42424 433 JTREG_BASIC_OPTIONS += $(JTREG_TIMEOUT_OPTION)
ihse@42424 434 ifeq ($(LIMIT_JTREG_VM_MEMORY), true)
ihse@42424 435 # Set the max memory for jtreg control vm
ihse@42424 436 JTREG_MEMORY_OPTION = -J-Xmx512m
ihse@42424 437 JTREG_BASIC_OPTIONS += $(JTREG_MEMORY_OPTION)
ihse@42424 438 # Set the max memory for jtreg target test vms
ihse@42424 439 JTREG_TESTVM_MEMORY_OPTION = -vmoption:-Xmx512m
ihse@42424 440 JTREG_TEST_OPTIONS += $(JTREG_TESTVM_MEMORY_OPTION)
ihse@42424 441 endif
ctornqvi@47418 442 # Make it possible to specify the JIB_DATA_DIR for tests using the
ctornqvi@47418 443 # JIB Artifact resolver
ctornqvi@47418 444 JTREG_BASIC_OPTIONS += -e:JIB_DATA_DIR
ihse@42424 445 # Give tests access to JT_JAVA, see JDK-8141609
ihse@42424 446 JTREG_BASIC_OPTIONS += -e:JDK8_HOME=${JT_JAVA}
bobv@46192 447 # Give aot tests access to Visual Studio installation
bobv@46192 448 ifneq ($(VS120COMNTOOLS), )
mikael@50017 449 JTREG_BASIC_OPTIONS += -e:VS120COMNTOOLS="$(shell $(GETMIXEDPATH) "$(patsubst %\,%,$(VS120COMNTOOLS))")"
bobv@46192 450 endif
ihse@42424 451 # Set other vm and test options
ctornqvi@46248 452 JTREG_TEST_OPTIONS += $(JAVA_ARGS:%=-javaoptions:%) $(JAVA_VM_ARGS:%=-vmoption:%)
ctornqvi@46196 453 ifneq ($(JIB_JAR), )
ctornqvi@46196 454 JTREG_BASIC_OPTIONS += -cpa:$(shell $(GETMIXEDPATH) "$(JIB_JAR)")
ctornqvi@46196 455 endif
ihse@42424 456 ifeq ($(IGNORE_MARKED_TESTS), true)
ihse@42424 457 # Option to tell jtreg to not run tests marked with "ignore"
ihse@42424 458 ifeq ($(PLATFORM), windows)
ihse@42424 459 JTREG_KEY_OPTION = -k:!ignore
ihse@42424 460 else
ihse@42424 461 JTREG_KEY_OPTION = -k:\!ignore
ihse@42424 462 endif
ihse@42424 463 JTREG_BASIC_OPTIONS += $(JTREG_KEY_OPTION)
ihse@42424 464 endif
ihse@42424 465
ihse@42424 466 # Make sure jtreg exists
ihse@42424 467 ifeq ($(USE_WINDOWS_EXISTENCE_CHECK), true)
ihse@42424 468 jtreg_exists:
ihse@42424 469 test -d $(shell $(GETMIXEDPATH) "$(JT_HOME)")
ihse@42424 470 test -f $(shell $(GETMIXEDPATH) "$(JTREG)")
ihse@42424 471
ihse@42424 472 else
ihse@42424 473 jtreg_exists: $(JT_HOME)
ihse@42424 474 endif
ihse@42424 475 PHONY_LIST += jtreg_exists
ihse@42424 476
ihse@42424 477 # Run jtreg
mseledtsov@49411 478 jtreg_tests: prep jtreg_exists $(PRODUCT_HOME) $(TEST_PREREQS)
ihse@42424 479 ( \
ihse@42424 480 ( JT_HOME=$(shell $(GETMIXEDPATH) "$(JT_HOME)"); \
ihse@42424 481 export JT_HOME; \
ihse@42424 482 $(shell $(GETMIXEDPATH) "$(JTREG)") \
ihse@42424 483 $(JTREG_BASIC_OPTIONS) \
ihse@42424 484 -r:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTreport") \
ihse@42424 485 -w:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTwork") \
ihse@42424 486 -jdk:$(shell $(GETMIXEDPATH) "$(PRODUCT_HOME)") \
ihse@42424 487 $(JTREG_NATIVE_PATH) \
ihse@42424 488 $(JTREG_FAILURE_HANDLER_OPTIONS) \
ihse@42424 489 $(JTREG_EXCLUSIONS) \
ihse@42424 490 $(JTREG_TEST_OPTIONS) \
ihse@42424 491 $(TEST_SELECTION) \
ihse@42424 492 ) ; \
ihse@42424 493 $(BUNDLE_UP_AND_EXIT) \
ihse@42424 494 ) 2>&1 | $(TEE) $(ABS_TEST_OUTPUT_DIR)/output.txt ; $(TESTEXIT)
ihse@42424 495
ihse@42424 496 PHONY_LIST += jtreg_tests
ihse@42424 497
erikj@47218 498 # Make it possible to call this with <component>_jtreg_tests
erikj@47218 499 %_jtreg_tests: jtreg_tests
erikj@47218 500 # Must have a fake recipe here to prevent make from matching any other rule
erikj@47218 501
ihse@42424 502 ################################################################
ihse@42424 503
ihse@42424 504 # Phony targets (e.g. these are not filenames)
ihse@42424 505 .PHONY: all clean prep $(PHONY_LIST)
ihse@42424 506
ihse@42424 507 ################################################################