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