Makefile revision 1735:a0d37d08c989
1# 2# Copyright (c) 1995, 2015, 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# 27# Makefile to run various nashorn tests 28# 29 30.DEFAULT : all 31 32# Empty these to get rid of some default rules 33.SUFFIXES: 34.SUFFIXES: .java 35CO= 36GET= 37 38# Utilities used 39AWK = awk 40CAT = cat 41CD = cd 42CHMOD = chmod 43CP = cp 44CUT = cut 45DIRNAME = dirname 46ECHO = echo 47EGREP = egrep 48EXPAND = expand 49FIND = find 50MKDIR = mkdir 51PWD = pwd 52SED = sed 53SORT = sort 54TEE = tee 55UNAME = uname 56UNIQ = uniq 57WC = wc 58ZIP = zip 59 60# Get OS name from uname (Cygwin inexplicably adds _NT-5.1) 61UNAME_S := $(shell $(UNAME) -s | $(CUT) -f1 -d_) 62 63# Commands to run on paths to make mixed paths for java on windows 64ifeq ($(UNAME_S), CYGWIN) 65 # Location of developer shared files 66 SLASH_JAVA = J: 67 GETMIXEDPATH = cygpath -m 68else 69 # Location of developer shared files 70 SLASH_JAVA = /java 71 72 GETMIXEDPATH=$(ECHO) 73endif 74 75# Root of this test area (important to use full paths in some places) 76TEST_ROOT := $(shell $(PWD)) 77 78# Root of all test results 79ifdef TEST_OUTPUT_DIR 80 $(shell $(MKDIR) -p $(TEST_OUTPUT_DIR)/jtreg) 81 ABS_TEST_OUTPUT_DIR := \ 82 $(shell $(CD) $(TEST_OUTPUT_DIR)/jtreg && $(PWD)) 83else 84 ifdef ALT_OUTPUTDIR 85 ABS_OUTPUTDIR = $(shell $(CD) $(ALT_OUTPUTDIR) && $(PWD)) 86 else 87 ABS_OUTPUTDIR = $(shell $(CD) $(TEST_ROOT)/.. && $(PWD)) 88 endif 89 90 ABS_PLATFORM_BUILD_ROOT = $(ABS_OUTPUTDIR) 91 ABS_TEST_OUTPUT_DIR := $(ABS_PLATFORM_BUILD_ROOT)/testoutput/$(UNIQUE_DIR) 92endif 93 94# Expect JPRT to set PRODUCT_HOME (the product or jdk in this case to test) 95ifndef PRODUCT_HOME 96 # Try to use images/jdk if it exists 97 ABS_JDK_IMAGE = $(ABS_PLATFORM_BUILD_ROOT)/images/jdk 98 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 failure handler config 122ifeq ($(FAILURE_HANDLER_DIR), ) 123 ifneq ($(TESTNATIVE_DIR), ) 124 FAILURE_HANDLER_DIR := $(TESTNATIVE_DIR)/failure_handler 125 endif 126endif 127ifneq ($(FAILURE_HANDLER_DIR), ) 128 FAILURE_HANDLER_DIR_MIXED := $(shell $(GETMIXEDPATH) "$(FAILURE_HANDLER_DIR)") 129 JTREG_FAILURE_HANDLER_OPTIONS := \ 130 -timeoutHandlerDir:$(FAILURE_HANDLER_DIR_MIXED)/jtregFailureHandler.jar \ 131 -observerDir:$(FAILURE_HANDLER_DIR_MIXED)/jtregFailureHandler.jar \ 132 -timeoutHandler:jdk.test.failurehandler.jtreg.GatherProcessInfoTimeoutHandler \ 133 -observer:jdk.test.failurehandler.jtreg.GatherDiagnosticInfoObserver 134 ifeq ($(UNAME_S), CYGWIN) 135 JTREG_FAILURE_HANDLER_OPTIONS += -J-Djava.library.path="$(FAILURE_HANDLER_DIR_MIXED)" 136 endif 137endif 138 139# Expect JPRT to set JPRT_ARCHIVE_BUNDLE (path to zip bundle for results) 140ifdef JPRT_ARCHIVE_BUNDLE 141 ARCHIVE_BUNDLE = $(JPRT_ARCHIVE_BUNDLE) 142else 143 ARCHIVE_BUNDLE = $(ABS_TEST_OUTPUT_DIR)/ARCHIVE_BUNDLE.zip 144endif 145 146# How to create the test bundle (pass or fail, we want to create this) 147# Follow command with ";$(BUNDLE_UP_AND_EXIT)", so it always gets executed. 148ZIP_UP_RESULTS = ( $(MKDIR) -p `$(DIRNAME) $(ARCHIVE_BUNDLE)` \ 149 && $(CD) $(ABS_TEST_OUTPUT_DIR) \ 150 && $(CHMOD) -R a+r . \ 151 && $(ZIP) -q -r $(ARCHIVE_BUNDLE) . ) 152 153# important results files 154SUMMARY_TXT = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTreport/text/summary.txt") 155STATS_TXT_NAME = Stats.txt 156STATS_TXT = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/$(STATS_TXT_NAME)") 157RUNLIST = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/runlist.txt") 158PASSLIST = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/passlist.txt") 159FAILLIST = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/faillist.txt") 160EXITCODE = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/exitcode.txt") 161 162TESTEXIT = \ 163 if [ ! -s $(EXITCODE) ] ; then \ 164 $(ECHO) "ERROR: EXITCODE file not filled in."; \ 165 $(ECHO) "1" > $(EXITCODE); \ 166 fi ; \ 167 testExitCode=`$(CAT) $(EXITCODE)`; \ 168 $(ECHO) "EXIT CODE: $${testExitCode}"; \ 169 exit $${testExitCode} 170 171BUNDLE_UP_AND_EXIT = \ 172( \ 173 jtregExitCode=$$? && \ 174 _summary="$(SUMMARY_TXT)"; \ 175 $(RM) -f $(STATS_TXT) $(RUNLIST) $(PASSLIST) $(FAILLIST) $(EXITCODE); \ 176 $(ECHO) "$${jtregExitCode}" > $(EXITCODE); \ 177 if [ -r "$${_summary}" ] ; then \ 178 $(ECHO) "Summary: $(UNIQUE_DIR)" > $(STATS_TXT); \ 179 $(EXPAND) $${_summary} | $(EGREP) -v ' Not run\.' > $(RUNLIST); \ 180 $(EGREP) ' Passed\.' $(RUNLIST) \ 181 | $(EGREP) -v ' Error\.' \ 182 | $(EGREP) -v ' Failed\.' > $(PASSLIST); \ 183 ( $(EGREP) ' Failed\.' $(RUNLIST); \ 184 $(EGREP) ' Error\.' $(RUNLIST); \ 185 $(EGREP) -v ' Passed\.' $(RUNLIST) ) \ 186 | $(SORT) | $(UNIQ) > $(FAILLIST); \ 187 if [ $${jtregExitCode} != 0 -o -s $(FAILLIST) ] ; then \ 188 $(EXPAND) $(FAILLIST) \ 189 | $(CUT) -d' ' -f1 \ 190 | $(SED) -e 's@^@FAILED: @' >> $(STATS_TXT); \ 191 if [ $${jtregExitCode} = 0 ] ; then \ 192 jtregExitCode=1; \ 193 fi; \ 194 fi; \ 195 runc="`$(CAT) $(RUNLIST) | $(WC) -l | $(AWK) '{print $$1;}'`"; \ 196 passc="`$(CAT) $(PASSLIST) | $(WC) -l | $(AWK) '{print $$1;}'`"; \ 197 failc="`$(CAT) $(FAILLIST) | $(WC) -l | $(AWK) '{print $$1;}'`"; \ 198 exclc="FIXME CODETOOLS-7900176"; \ 199 $(ECHO) "TEST STATS: name=$(UNIQUE_DIR) run=$${runc} pass=$${passc} fail=$${failc}" \ 200 >> $(STATS_TXT); \ 201 else \ 202 $(ECHO) "Missing file: $${_summary}" >> $(STATS_TXT); \ 203 fi; \ 204 if [ -f $(STATS_TXT) ] ; then \ 205 $(CAT) $(STATS_TXT); \ 206 fi; \ 207 $(ZIP_UP_RESULTS) ; \ 208 $(TESTEXIT) \ 209) 210 211################################################################ 212 213# Default make rule (runs default nashorn tests) 214all: nashorn_default 215 @$(ECHO) "Testing completed successfully" 216 217# Prep for output 218# Change execute permissions on shared library files. 219# Files in repositories should never have execute permissions, but 220# there are some tests that have pre-built shared libraries, and these 221# windows dll files must have execute permission. Adding execute 222# permission may happen automatically on windows when using certain 223# versions of mercurial but it cannot be guaranteed. And blindly 224# adding execute permission might be seen as a mercurial 'change', so 225# we avoid adding execute permission to repository files. But testing 226# from a plain source tree needs the chmod a+rx. Applying the chmod to 227# all shared libraries not just dll files. And with CYGWIN and sshd 228# service, you may need CYGWIN=ntsec for this to work. 229prep: 230 @$(MKDIR) -p $(ABS_TEST_OUTPUT_DIR) 231 @$(MKDIR) -p `$(DIRNAME) $(ARCHIVE_BUNDLE)` 232 @if [ ! -d $(TEST_ROOT)/../.hg ] ; then \ 233 $(FIND) $(TEST_ROOT) \( -name \*.dll -o -name \*.DLL -o -name \*.so \) \ 234 -exec $(CHMOD) a+rx {} \; ; \ 235 fi 236 237# Cleanup 238clean: 239 @$(RM) -r $(ABS_TEST_OUTPUT_DIR) 240 @$(RM) $(ARCHIVE_BUNDLE) 241 242################################################################ 243 244# jtreg tests 245 246# Expect JT_HOME to be set for jtreg tests. (home for jtreg) 247ifndef JT_HOME 248 JT_HOME = $(SLASH_JAVA)/re/jtreg/4.2/promoted/latest/binaries/jtreg 249 ifdef JPRT_JTREG_HOME 250 JT_HOME = $(JPRT_JTREG_HOME) 251 endif 252endif 253 254# Problematic tests to be excluded 255PROBLEM_LISTS=$(call MixedDirs,$(wildcard ProblemList.txt closed/ProblemList.txt)) 256 257# Create exclude list for this platform and arch 258ifdef NO_EXCLUDES 259 JTREG_EXCLUSIONS = 260else 261 JTREG_EXCLUSIONS = $(PROBLEM_LISTS:%=-exclude:%) 262endif 263 264# convert list of directories to dos paths 265define MixedDirs 266$(foreach i,$1,$(shell $(GETMIXEDPATH) "${i}")) 267endef 268 269define SummaryInfo 270$(ECHO) "########################################################" 271$(CAT) $(?:%=$(ABS_TEST_OUTPUT_DIR)/%/$(STATS_TXT_NAME)) 272$(ECHO) "########################################################" 273endef 274 275# ------------------------------------------------------------------ 276 277nashorn_%: 278 $(ECHO) "Running tests: $@" 279 for each in $@; do \ 280 $(MAKE) -j 1 TEST_SELECTION=":$$each" UNIQUE_DIR=$$each jtreg_tests; \ 281 done 282 283# ------------------------------------------------------------------ 284 285# When called from JPRT the TESTDIRS variable is set to the jtreg tests to run 286ifdef TESTDIRS 287 TEST_SELECTION = $(TESTDIRS) 288endif 289 290ifdef CONCURRENCY 291 JTREG_BASIC_OPTIONS += -concurrency:$(CONCURRENCY) 292endif 293ifdef EXTRA_JTREG_OPTIONS 294 JTREG_BASIC_OPTIONS += $(EXTRA_JTREG_OPTIONS) 295endif 296 297# Default JTREG to run 298JTREG = $(JT_HOME)/bin/jtreg 299# run in agentvm mode 300JTREG_BASIC_OPTIONS += -agentvm 301# Only run automatic tests 302JTREG_BASIC_OPTIONS += -a 303# Always turn on assertions 304JTREG_ASSERT_OPTION = -ea -esa 305JTREG_BASIC_OPTIONS += $(JTREG_ASSERT_OPTION) 306# Report details on all failed or error tests, times too 307JTREG_BASIC_OPTIONS += -v:fail,error,time 308# Retain all files for failing tests 309JTREG_BASIC_OPTIONS += -retain:fail,error 310# Ignore tests are not run and completely silent about it 311JTREG_IGNORE_OPTION = -ignore:quiet 312JTREG_BASIC_OPTIONS += $(JTREG_IGNORE_OPTION) 313# Multiple by 4 the timeout numbers 314JTREG_TIMEOUT_OPTION = -timeoutFactor:4 315JTREG_BASIC_OPTIONS += $(JTREG_TIMEOUT_OPTION) 316# Set the max memory for jtreg control vm 317JTREG_MEMORY_OPTION = -J-Xmx512m 318JTREG_BASIC_OPTIONS += $(JTREG_MEMORY_OPTION) 319# Give tests access to JT_JAVA, see JDK-8141609 320JTREG_BASIC_OPTIONS += -e:JDK8_HOME=${JT_JAVA} 321# Set other vm and test options 322JTREG_TEST_OPTIONS = $(JAVA_ARGS:%=-javaoptions:%) $(JAVA_VM_ARGS:%=-vmoption:%) 323# Set the GC options for test vms 324#JTREG_GC_OPTION = -vmoption:-XX:+UseSerialGC 325#JTREG_TEST_OPTIONS += $(JTREG_GC_OPTION) 326# Set the max memory for jtreg target test vms 327JTREG_TESTVM_MEMORY_OPTION = -vmoption:-Xmx512m 328JTREG_TEST_OPTIONS += $(JTREG_TESTVM_MEMORY_OPTION) 329 330# Make sure jtreg exists 331$(JTREG): $(JT_HOME) 332 333# Run jtreg 334jtreg_tests: prep $(PRODUCT_HOME) $(JTREG) 335 ( \ 336 ( JT_HOME=$(shell $(GETMIXEDPATH) "$(JT_HOME)"); \ 337 export JT_HOME; \ 338 $(shell $(GETMIXEDPATH) "$(JTREG)") \ 339 $(JTREG_BASIC_OPTIONS) \ 340 -r:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTreport") \ 341 -w:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTwork") \ 342 -jdk:$(shell $(GETMIXEDPATH) "$(PRODUCT_HOME)") \ 343 $(JTREG_NATIVE_PATH) \ 344 $(JTREG_FAILURE_HANDLER_OPTIONS) \ 345 $(JTREG_EXCLUSIONS) \ 346 $(JTREG_TEST_OPTIONS) \ 347 $(TEST_SELECTION) \ 348 ) ; \ 349 $(BUNDLE_UP_AND_EXIT) \ 350 ) 2>&1 | $(TEE) $(ABS_TEST_OUTPUT_DIR)/output.txt ; $(TESTEXIT) 351 352PHONY_LIST += jtreg_tests 353 354################################################################ 355 356# Phony targets (e.g. these are not filenames) 357.PHONY: all clean prep $(PHONY_LIST) 358 359################################################################ 360