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