Makefile revision 1700:80a95fbd3e68
174432Sjedgar# 274432Sjedgar# Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved. 374432Sjedgar# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 474432Sjedgar# 574432Sjedgar# This code is free software; you can redistribute it and/or modify it 674432Sjedgar# under the terms of the GNU General Public License version 2 only, as 774432Sjedgar# published by the Free Software Foundation. Oracle designates this 874432Sjedgar# particular file as subject to the "Classpath" exception as provided 974432Sjedgar# by Oracle in the LICENSE file that accompanied this code. 1074432Sjedgar# 1174432Sjedgar# This code is distributed in the hope that it will be useful, but WITHOUT 1274432Sjedgar# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1374432Sjedgar# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1474432Sjedgar# version 2 for more details (a copy is included in the LICENSE file that 1574432Sjedgar# accompanied this code). 1674432Sjedgar# 17184607Simp# You should have received a copy of the GNU General Public License version 18184607Simp# 2 along with this work; if not, write to the Free Software Foundation, 19184607Simp# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20184607Simp# 21184607Simp# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22184607Simp# or visit www.oracle.com if you need additional information or have any 23184607Simp# questions. 24184607Simp# 2574432Sjedgar 2674432Sjedgar# 2774432Sjedgar# Makefile to run various nashorn tests 2874432Sjedgar# 2974432Sjedgar 3074432Sjedgar.DEFAULT : all 3174432Sjedgar 3274432Sjedgar# Empty these to get rid of some default rules 3374451Sru.SUFFIXES: 3474432Sjedgar.SUFFIXES: .java 3575222SruCO= 3674432SjedgarGET= 3784306Sru 3884306Sru# Utilities used 3974432SjedgarAWK = awk 4074432SjedgarCAT = cat 4174432SjedgarCD = cd 42108037SruCHMOD = chmod 4374432SjedgarCP = cp 44108037SruCUT = cut 4574432SjedgarDIRNAME = dirname 4674451SruECHO = echo 4774451SruEGREP = egrep 4874451SruEXPAND = expand 4974451SruFIND = find 5074432SjedgarMKDIR = mkdir 5174432SjedgarPWD = pwd 5274451SruSED = sed 5374451SruSORT = sort 5474451SruTEE = tee 5574432SjedgarUNAME = uname 5674432SjedgarUNIQ = uniq 5774451SruWC = wc 5874432SjedgarZIP = zip 5974432Sjedgar 6074451Sru# Get OS name from uname (Cygwin inexplicably adds _NT-5.1) 6174451SruUNAME_S := $(shell $(UNAME) -s | $(CUT) -f1 -d_) 6274451Sru 6374451Sru# Commands to run on paths to make mixed paths for java on windows 6474451Sruifeq ($(UNAME_S), CYGWIN) 6574451Sru # Location of developer shared files 6674451Sru SLASH_JAVA = J: 6774432Sjedgar GETMIXEDPATH = cygpath -m 6874432Sjedgarelse 6974451Sru # Location of developer shared files 7074432Sjedgar SLASH_JAVA = /java 7174451Sru 7274432Sjedgar GETMIXEDPATH=$(ECHO) 7374451Sruendif 7474432Sjedgar 7574432Sjedgar# Root of this test area (important to use full paths in some places) 7674432SjedgarTEST_ROOT := $(shell $(PWD)) 7774451Sru 7874432Sjedgar# Root of all test results 7974432Sjedgarifdef TEST_OUTPUT_DIR 8074432Sjedgar $(shell $(MKDIR) -p $(TEST_OUTPUT_DIR)/jtreg) 8174432Sjedgar ABS_TEST_OUTPUT_DIR := \ 8274432Sjedgar $(shell $(CD) $(TEST_OUTPUT_DIR)/jtreg && $(PWD)) 8374432Sjedgarelse 8474432Sjedgar ifdef ALT_OUTPUTDIR 8574432Sjedgar ABS_OUTPUTDIR = $(shell $(CD) $(ALT_OUTPUTDIR) && $(PWD)) 8674432Sjedgar else 8774432Sjedgar ABS_OUTPUTDIR = $(shell $(CD) $(TEST_ROOT)/.. && $(PWD)) 8874432Sjedgar endif 8974432Sjedgar 9074432Sjedgar ABS_PLATFORM_BUILD_ROOT = $(ABS_OUTPUTDIR) 9174432Sjedgar ABS_TEST_OUTPUT_DIR := $(ABS_PLATFORM_BUILD_ROOT)/testoutput/$(UNIQUE_DIR) 9274432Sjedgarendif 9374432Sjedgar 9474432Sjedgar# Expect JPRT to set PRODUCT_HOME (the product or jdk in this case to test) 9574432Sjedgarifndef PRODUCT_HOME 9674432Sjedgar # Try to use images/jdk if it exists 9774432Sjedgar ABS_JDK_IMAGE = $(ABS_PLATFORM_BUILD_ROOT)/images/jdk 9874432Sjedgar PRODUCT_HOME := \ 99 $(shell \ 100 if [ -d $(ABS_JDK_IMAGE) ] ; then \ 101 $(ECHO) "$(ABS_JDK_IMAGE)"; \ 102 else \ 103 $(ECHO) "$(ABS_PLATFORM_BUILD_ROOT)"; \ 104 fi) 105 PRODUCT_HOME := $(PRODUCT_HOME) 106endif 107 108# Expect JPRT to set JPRT_PRODUCT_ARGS (e.g. -server etc.) 109# Should be passed into 'java' only. 110# Could include: -d64 -server -client OR any java option 111ifdef JPRT_PRODUCT_ARGS 112 JAVA_ARGS = $(JPRT_PRODUCT_ARGS) 113endif 114 115# Expect JPRT to set JPRT_PRODUCT_VM_ARGS (e.g. -Xcomp etc.) 116# Should be passed into anything running the vm (java, javac, javadoc, ...). 117ifdef JPRT_PRODUCT_VM_ARGS 118 JAVA_VM_ARGS = $(JPRT_PRODUCT_VM_ARGS) 119endif 120 121# jtreg -nativepath <dir> 122# 123# Local make tests will be TEST_IMAGE_DIR and JPRT with jprt.use.reg.test.bundle=true 124# should be JPRT_TESTNATIVE_PATH 125ifdef TEST_IMAGE_DIR 126 TESTNATIVE_DIR = $(TEST_IMAGE_DIR) 127else ifdef JPRT_TESTNATIVE_PATH 128 TESTNATIVE_DIR = $(JPRT_TESTNATIVE_PATH) 129endif 130ifdef TESTNATIVE_DIR 131 JTREG_NATIVE_PATH = -nativepath:$(shell $(GETMIXEDPATH) "$(TESTNATIVE_DIR)/nashorn/jtreg/native") 132endif 133 134# jtreg failure handler config 135ifeq ($(FAILURE_HANDLER_DIR), ) 136 ifneq ($(TESTNATIVE_DIR), ) 137 FAILURE_HANDLER_DIR := $(TESTNATIVE_DIR)/failure_handler 138 endif 139endif 140ifneq ($(FAILURE_HANDLER_DIR), ) 141 FAILURE_HANDLER_DIR_MIXED := $(shell $(GETMIXEDPATH) "$(FAILURE_HANDLER_DIR)") 142 JTREG_FAILURE_HANDLER_OPTIONS := \ 143 -timeoutHandlerDir:$(FAILURE_HANDLER_DIR_MIXED)/jtregFailureHandler.jar \ 144 -observerDir:$(FAILURE_HANDLER_DIR_MIXED)/jtregFailureHandler.jar \ 145 -timeoutHandler:jdk.test.failurehandler.jtreg.GatherProcessInfoTimeoutHandler \ 146 -observer:jdk.test.failurehandler.jtreg.GatherDiagnosticInfoObserver 147 ifeq ($(UNAME_S), CYGWIN) 148 JTREG_FAILURE_HANDLER_OPTIONS += -J-Djava.library.path="$(FAILURE_HANDLER_DIR_MIXED)" 149 endif 150endif 151 152# Expect JPRT to set JPRT_ARCHIVE_BUNDLE (path to zip bundle for results) 153ifdef JPRT_ARCHIVE_BUNDLE 154 ARCHIVE_BUNDLE = $(JPRT_ARCHIVE_BUNDLE) 155else 156 ARCHIVE_BUNDLE = $(ABS_TEST_OUTPUT_DIR)/ARCHIVE_BUNDLE.zip 157endif 158 159# How to create the test bundle (pass or fail, we want to create this) 160# Follow command with ";$(BUNDLE_UP_AND_EXIT)", so it always gets executed. 161ZIP_UP_RESULTS = ( $(MKDIR) -p `$(DIRNAME) $(ARCHIVE_BUNDLE)` \ 162 && $(CD) $(ABS_TEST_OUTPUT_DIR) \ 163 && $(CHMOD) -R a+r . \ 164 && $(ZIP) -q -r $(ARCHIVE_BUNDLE) . ) 165 166# important results files 167SUMMARY_TXT = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTreport/text/summary.txt") 168STATS_TXT_NAME = Stats.txt 169STATS_TXT = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/$(STATS_TXT_NAME)") 170RUNLIST = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/runlist.txt") 171PASSLIST = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/passlist.txt") 172FAILLIST = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/faillist.txt") 173EXITCODE = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/exitcode.txt") 174 175TESTEXIT = \ 176 if [ ! -s $(EXITCODE) ] ; then \ 177 $(ECHO) "ERROR: EXITCODE file not filled in."; \ 178 $(ECHO) "1" > $(EXITCODE); \ 179 fi ; \ 180 testExitCode=`$(CAT) $(EXITCODE)`; \ 181 $(ECHO) "EXIT CODE: $${testExitCode}"; \ 182 exit $${testExitCode} 183 184BUNDLE_UP_AND_EXIT = \ 185( \ 186 jtregExitCode=$$? && \ 187 _summary="$(SUMMARY_TXT)"; \ 188 $(RM) -f $(STATS_TXT) $(RUNLIST) $(PASSLIST) $(FAILLIST) $(EXITCODE); \ 189 $(ECHO) "$${jtregExitCode}" > $(EXITCODE); \ 190 if [ -r "$${_summary}" ] ; then \ 191 $(ECHO) "Summary: $(UNIQUE_DIR)" > $(STATS_TXT); \ 192 $(EXPAND) $${_summary} | $(EGREP) -v ' Not run\.' > $(RUNLIST); \ 193 $(EGREP) ' Passed\.' $(RUNLIST) \ 194 | $(EGREP) -v ' Error\.' \ 195 | $(EGREP) -v ' Failed\.' > $(PASSLIST); \ 196 ( $(EGREP) ' Failed\.' $(RUNLIST); \ 197 $(EGREP) ' Error\.' $(RUNLIST); \ 198 $(EGREP) -v ' Passed\.' $(RUNLIST) ) \ 199 | $(SORT) | $(UNIQ) > $(FAILLIST); \ 200 if [ $${jtregExitCode} != 0 -o -s $(FAILLIST) ] ; then \ 201 $(EXPAND) $(FAILLIST) \ 202 | $(CUT) -d' ' -f1 \ 203 | $(SED) -e 's@^@FAILED: @' >> $(STATS_TXT); \ 204 if [ $${jtregExitCode} = 0 ] ; then \ 205 jtregExitCode=1; \ 206 fi; \ 207 fi; \ 208 runc="`$(CAT) $(RUNLIST) | $(WC) -l | $(AWK) '{print $$1;}'`"; \ 209 passc="`$(CAT) $(PASSLIST) | $(WC) -l | $(AWK) '{print $$1;}'`"; \ 210 failc="`$(CAT) $(FAILLIST) | $(WC) -l | $(AWK) '{print $$1;}'`"; \ 211 exclc="FIXME CODETOOLS-7900176"; \ 212 $(ECHO) "TEST STATS: name=$(UNIQUE_DIR) run=$${runc} pass=$${passc} fail=$${failc}" \ 213 >> $(STATS_TXT); \ 214 else \ 215 $(ECHO) "Missing file: $${_summary}" >> $(STATS_TXT); \ 216 fi; \ 217 if [ -f $(STATS_TXT) ] ; then \ 218 $(CAT) $(STATS_TXT); \ 219 fi; \ 220 $(ZIP_UP_RESULTS) ; \ 221 $(TESTEXIT) \ 222) 223 224################################################################ 225 226# Default make rule (runs default nashorn tests) 227all: nashorn_default 228 @$(ECHO) "Testing completed successfully" 229 230# Prep for output 231# Change execute permissions on shared library files. 232# Files in repositories should never have execute permissions, but 233# there are some tests that have pre-built shared libraries, and these 234# windows dll files must have execute permission. Adding execute 235# permission may happen automatically on windows when using certain 236# versions of mercurial but it cannot be guaranteed. And blindly 237# adding execute permission might be seen as a mercurial 'change', so 238# we avoid adding execute permission to repository files. But testing 239# from a plain source tree needs the chmod a+rx. Applying the chmod to 240# all shared libraries not just dll files. And with CYGWIN and sshd 241# service, you may need CYGWIN=ntsec for this to work. 242prep: 243 @$(MKDIR) -p $(ABS_TEST_OUTPUT_DIR) 244 @$(MKDIR) -p `$(DIRNAME) $(ARCHIVE_BUNDLE)` 245 @if [ ! -d $(TEST_ROOT)/../.hg ] ; then \ 246 $(FIND) $(TEST_ROOT) \( -name \*.dll -o -name \*.DLL -o -name \*.so \) \ 247 -exec $(CHMOD) a+rx {} \; ; \ 248 fi 249 250# Cleanup 251clean: 252 @$(RM) -r $(ABS_TEST_OUTPUT_DIR) 253 @$(RM) $(ARCHIVE_BUNDLE) 254 255################################################################ 256 257# jtreg tests 258 259# Expect JT_HOME to be set for jtreg tests. (home for jtreg) 260ifndef JT_HOME 261 JT_HOME = $(SLASH_JAVA)/re/jtreg/4.2/promoted/latest/binaries/jtreg 262 ifdef JPRT_JTREG_HOME 263 JT_HOME = $(JPRT_JTREG_HOME) 264 endif 265endif 266 267# Problematic tests to be excluded 268PROBLEM_LISTS=$(call MixedDirs,$(wildcard ProblemList.txt closed/ProblemList.txt)) 269 270# Create exclude list for this platform and arch 271ifdef NO_EXCLUDES 272 JTREG_EXCLUSIONS = 273else 274 JTREG_EXCLUSIONS = $(PROBLEM_LISTS:%=-exclude:%) 275endif 276 277# convert list of directories to dos paths 278define MixedDirs 279$(foreach i,$1,$(shell $(GETMIXEDPATH) "${i}")) 280endef 281 282define SummaryInfo 283$(ECHO) "########################################################" 284$(CAT) $(?:%=$(ABS_TEST_OUTPUT_DIR)/%/$(STATS_TXT_NAME)) 285$(ECHO) "########################################################" 286endef 287 288# ------------------------------------------------------------------ 289 290nashorn_%: 291 $(ECHO) "Running tests: $@" 292 for each in $@; do \ 293 $(MAKE) -j 1 TEST_SELECTION=":$$each" UNIQUE_DIR=$$each jtreg_tests; \ 294 done 295 296# ------------------------------------------------------------------ 297 298# When called from JPRT the TESTDIRS variable is set to the jtreg tests to run 299ifdef TESTDIRS 300 TEST_SELECTION = $(TESTDIRS) 301endif 302 303ifdef CONCURRENCY 304 JTREG_BASIC_OPTIONS += -concurrency:$(CONCURRENCY) 305endif 306ifdef EXTRA_JTREG_OPTIONS 307 JTREG_BASIC_OPTIONS += $(EXTRA_JTREG_OPTIONS) 308endif 309 310# Default JTREG to run 311JTREG = $(JT_HOME)/bin/jtreg 312# run in agentvm mode 313JTREG_BASIC_OPTIONS += -agentvm 314# Only run automatic tests 315JTREG_BASIC_OPTIONS += -a 316# Always turn on assertions 317JTREG_ASSERT_OPTION = -ea -esa 318JTREG_BASIC_OPTIONS += $(JTREG_ASSERT_OPTION) 319# Report details on all failed or error tests, times too 320JTREG_BASIC_OPTIONS += -v:fail,error,time 321# Retain all files for failing tests 322JTREG_BASIC_OPTIONS += -retain:fail,error 323# Ignore tests are not run and completely silent about it 324JTREG_IGNORE_OPTION = -ignore:quiet 325JTREG_BASIC_OPTIONS += $(JTREG_IGNORE_OPTION) 326# Multiple by 4 the timeout numbers 327JTREG_TIMEOUT_OPTION = -timeoutFactor:4 328JTREG_BASIC_OPTIONS += $(JTREG_TIMEOUT_OPTION) 329# Set the max memory for jtreg control vm 330JTREG_MEMORY_OPTION = -J-Xmx512m 331JTREG_BASIC_OPTIONS += $(JTREG_MEMORY_OPTION) 332# Give tests access to JT_JAVA, see JDK-8141609 333JTREG_BASIC_OPTIONS += -e:JDK8_HOME=${JT_JAVA} 334# Set other vm and test options 335JTREG_TEST_OPTIONS = $(JAVA_ARGS:%=-javaoptions:%) $(JAVA_VM_ARGS:%=-vmoption:%) 336# Set the GC options for test vms 337#JTREG_GC_OPTION = -vmoption:-XX:+UseSerialGC 338#JTREG_TEST_OPTIONS += $(JTREG_GC_OPTION) 339# Set the max memory for jtreg target test vms 340JTREG_TESTVM_MEMORY_OPTION = -vmoption:-Xmx512m 341JTREG_TEST_OPTIONS += $(JTREG_TESTVM_MEMORY_OPTION) 342 343# Make sure jtreg exists 344$(JTREG): $(JT_HOME) 345 346# Run jtreg 347jtreg_tests: prep $(PRODUCT_HOME) $(JTREG) 348 ( \ 349 ( JT_HOME=$(shell $(GETMIXEDPATH) "$(JT_HOME)"); \ 350 export JT_HOME; \ 351 $(shell $(GETMIXEDPATH) "$(JTREG)") \ 352 $(JTREG_BASIC_OPTIONS) \ 353 -r:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTreport") \ 354 -w:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTwork") \ 355 -jdk:$(shell $(GETMIXEDPATH) "$(PRODUCT_HOME)") \ 356 $(JTREG_NATIVE_PATH) \ 357 $(JTREG_FAILURE_HANDLER_OPTIONS) \ 358 $(JTREG_EXCLUSIONS) \ 359 $(JTREG_TEST_OPTIONS) \ 360 $(TEST_SELECTION) \ 361 ) ; \ 362 $(BUNDLE_UP_AND_EXIT) \ 363 ) 2>&1 | $(TEE) $(ABS_TEST_OUTPUT_DIR)/output.txt ; $(TESTEXIT) 364 365PHONY_LIST += jtreg_tests 366 367################################################################ 368 369# Phony targets (e.g. these are not filenames) 370.PHONY: all clean prep $(PHONY_LIST) 371 372################################################################ 373