1 #
   2 # Copyright (c) 1995, 2014, 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.
   8 #
   9 # This code is distributed in the hope that it will be useful, but WITHOUT
  10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12 # version 2 for more details (a copy is included in the LICENSE file that
  13 # accompanied this code).
  14 #
  15 # You should have received a copy of the GNU General Public License version
  16 # 2 along with this work; if not, write to the Free Software Foundation,
  17 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18 #
  19 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20 # or visit www.oracle.com if you need additional information or have any
  21 # questions.
  22 #
  23 #
  24 
  25 #
  26 # Makefile to run various hotspot tests
  27 #
  28 
  29 ALT_MAKE ?= closed
  30 
  31 -include $(ALT_MAKE)/Makefile
  32 
  33 GETMIXEDPATH=echo
  34 
  35 # Utilities used
  36 AWK       = awk
  37 CAT       = cat
  38 CD        = cd
  39 CHMOD     = chmod
  40 CP        = cp
  41 CUT       = cut
  42 DIRNAME   = dirname
  43 ECHO      = echo
  44 EGREP     = egrep
  45 EXPAND    = expand
  46 FIND      = find
  47 MKDIR     = mkdir
  48 PWD       = pwd
  49 SED       = sed
  50 SORT      = sort
  51 TEE       = tee
  52 UNAME     = uname
  53 UNIQ      = uniq
  54 WC        = wc
  55 ZIP       = zip
  56 
  57 # Get OS name from uname (Cygwin inexplicably adds _NT-5.1)
  58 UNAME_S := $(shell $(UNAME) -s | $(CUT) -f1 -d_)
  59 ifeq ($(UNAME_S), SunOS)
  60   PLATFORM = solaris
  61   SLASH_JAVA = /java
  62   ARCH = $(shell uname -p)
  63   ifeq ($(ARCH), i386)
  64     ARCH=i586
  65   endif
  66 endif
  67 ifeq ($(UNAME_S), Linux)
  68   PLATFORM = linux
  69   SLASH_JAVA = /java
  70   ARCH = $(shell uname -m)
  71   ifeq ($(ARCH), i386)
  72     ARCH = i586
  73   endif
  74 endif
  75 ifeq ($(UNAME_S), Darwin)
  76   PLATFORM = bsd
  77   SLASH_JAVA = /java
  78   ARCH = $(shell uname -m)
  79   ifeq ($(ARCH), i386)
  80     ARCH = i586
  81   endif
  82 endif
  83 ifeq ($(findstring BSD,$(UNAME_S)), BSD)
  84   PLATFORM = bsd
  85   SLASH_JAVA = /java
  86   ARCH = $(shell uname -m)
  87   ifeq ($(ARCH), i386)
  88     ARCH = i586
  89   endif
  90 endif
  91 ifeq ($(PLATFORM),)
  92   # detect whether we're running in MKS or cygwin
  93   ifeq ($(UNAME_S), Windows_NT) # MKS
  94     GETMIXEDPATH=dosname -s
  95   endif
  96   ifeq ($(findstring CYGWIN,$(UNAME_S)), CYGWIN)
  97     GETMIXEDPATH=cygpath -m
  98   endif
  99   PLATFORM = windows
 100   SLASH_JAVA = J:
 101   ifeq ($(word 1, $(PROCESSOR_IDENTIFIER)),ia64)
 102     ARCH = ia64
 103   else
 104     ifeq ($(word 1, $(PROCESSOR_IDENTIFIER)),AMD64)
 105       ARCH = x64
 106     else
 107       ifeq ($(word 1, $(PROCESSOR_IDENTIFIER)),EM64T)
 108         ARCH = x64
 109       else
 110         ARCH = i586
 111       endif
 112     endif
 113   endif
 114   EXESUFFIX = .exe
 115 endif
 116 
 117 ifdef ALT_SLASH_JAVA
 118   SLASH_JAVA = $(ALT_SLASH_JAVA)
 119 endif
 120 
 121 # Root of this test area (important to use full paths in some places)
 122 TEST_ROOT := $(shell pwd)
 123 
 124 # Root of all test results
 125 ifdef ALT_OUTPUTDIR
 126   ABS_BUILD_ROOT = $(ALT_OUTPUTDIR)/$(PLATFORM)-$(ARCH)
 127 else
 128   ABS_BUILD_ROOT = $(TEST_ROOT)/../build/$(PLATFORM)-$(ARCH)
 129 endif
 130 ABS_TEST_OUTPUT_DIR = $(ABS_BUILD_ROOT)/testoutput
 131 
 132 # Expect JPRT to set PRODUCT_HOME (the product or jdk in this case to test)
 133 ifndef PRODUCT_HOME
 134   # Try to use j2sdk-image if it exists
 135   ABS_JDK_IMAGE = $(ABS_BUILD_ROOT)/j2sdk-image
 136   PRODUCT_HOME :=                       \
 137     $(shell                             \
 138       if [ -d $(ABS_JDK_IMAGE) ] ; then \
 139          $(ECHO) "$(ABS_JDK_IMAGE)";    \
 140        else                             \
 141          $(ECHO) "$(ABS_BUILD_ROOT)" ;  \
 142        fi)
 143 endif
 144 
 145 # Expect JPRT to set JAVA_ARGS (e.g. -server etc.)
 146 JAVA_OPTIONS = 
 147 ifdef JAVA_ARGS
 148   JAVA_OPTIONS = $(JAVA_ARGS)
 149 endif
 150 













 151 # Expect JPRT to set JPRT_ARCHIVE_BUNDLE (path to zip bundle for results)
 152 ARCHIVE_BUNDLE = $(ABS_TEST_OUTPUT_DIR)/ARCHIVE_BUNDLE.zip
 153 ifdef JPRT_ARCHIVE_BUNDLE
 154   ARCHIVE_BUNDLE = $(JPRT_ARCHIVE_BUNDLE)
 155 endif
 156 
 157 # How to create the test bundle (pass or fail, we want to create this)
 158 #   Follow command with ";$(BUNDLE_UP_AND_EXIT)", so it always gets executed.
 159 ZIP_UP_RESULTS = ( $(MKDIR) -p `$(DIRNAME) $(ARCHIVE_BUNDLE)`     \
 160                    && $(CD) $(ABS_TEST_OUTPUT_DIR)             \
 161                    && $(CHMOD) -R a+r . \
 162                    && $(ZIP) -q -r $(ARCHIVE_BUNDLE) . )
 163 
 164 # important results files
 165 SUMMARY_TXT = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTreport/text/summary.txt")
 166 STATS_TXT_NAME = Stats.txt
 167 STATS_TXT = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/$(STATS_TXT_NAME)")
 168 RUNLIST   = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/runlist.txt")
 169 PASSLIST  = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/passlist.txt")
 170 FAILLIST  = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/faillist.txt")
 171 EXITCODE  = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/exitcode.txt")
 172 
 173 TESTEXIT = \
 174   if [ ! -s $(EXITCODE) ] ; then \
 175     $(ECHO) "ERROR: EXITCODE file not filled in."; \
 176     $(ECHO) "1" > $(EXITCODE); \
 177   fi ; \
 178   testExitCode=`$(CAT) $(EXITCODE)`; \
 179   $(ECHO) "EXIT CODE: $${testExitCode}"; \
 180   exit $${testExitCode}
 181 
 182 BUNDLE_UP_AND_EXIT = \
 183 ( \
 184   jtregExitCode=$$? && \
 185   _summary="$(SUMMARY_TXT)"; \
 186   $(RM) -f $(STATS_TXT) $(RUNLIST) $(PASSLIST) $(FAILLIST) $(EXITCODE); \
 187   $(ECHO) "$${jtregExitCode}" > $(EXITCODE); \
 188   if [ -r "$${_summary}" ] ; then \
 189     $(ECHO) "Summary: $(UNIQUE_DIR)" > $(STATS_TXT); \
 190     $(EXPAND) $${_summary} | $(EGREP) -v ' Not run\.' > $(RUNLIST); \
 191     $(EGREP) ' Passed\.' $(RUNLIST) \
 192       | $(EGREP) -v ' Error\.' \
 193       | $(EGREP) -v ' Failed\.' > $(PASSLIST); \
 194     ( $(EGREP) ' Failed\.' $(RUNLIST); \
 195       $(EGREP) ' Error\.' $(RUNLIST); \
 196       $(EGREP) -v ' Passed\.' $(RUNLIST) ) \
 197       | $(SORT) | $(UNIQ) > $(FAILLIST); \
 198     if [ $${jtregExitCode} != 0 -o -s $(FAILLIST) ] ; then \
 199       $(EXPAND) $(FAILLIST) \
 200         | $(CUT) -d' ' -f1 \
 201         | $(SED) -e 's@^@FAILED: @' >> $(STATS_TXT); \
 202       if [ $${jtregExitCode} = 0 ] ; then \
 203         jtregExitCode=1; \
 204       fi; \
 205     fi; \
 206     runc="`$(CAT) $(RUNLIST)      | $(WC) -l | $(AWK) '{print $$1;}'`"; \
 207     passc="`$(CAT) $(PASSLIST)    | $(WC) -l | $(AWK) '{print $$1;}'`"; \
 208     failc="`$(CAT) $(FAILLIST)    | $(WC) -l | $(AWK) '{print $$1;}'`"; \
 209     exclc="FIXME CODETOOLS-7900176"; \
 210     $(ECHO) "TEST STATS: name=$(UNIQUE_DIR)  run=$${runc}  pass=$${passc}  fail=$${failc}" \
 211       >> $(STATS_TXT); \
 212   else \
 213     $(ECHO) "Missing file: $${_summary}" >> $(STATS_TXT); \
 214   fi; \
 215   if [ -f $(STATS_TXT) ] ; then \
 216     $(CAT) $(STATS_TXT); \
 217   fi; \
 218   $(ZIP_UP_RESULTS) ; \
 219   $(TESTEXIT) \
 220 )
 221 
 222 ################################################################
 223 
 224 # Default make rule (runs jtreg_tests)
 225 all: hotspot_all
 226         @$(ECHO) "Testing completed successfully"
 227 
 228 # Support "hotspot_" prefixed test make targets (too)
 229 # The hotspot_% targets are used by the top level Makefile
 230 # Unless explicitly defined below, hotspot_<x> is interpreted as a jtreg test group name
 231 hotspot_%:
 232         $(ECHO) "Running tests: $@"
 233         $(MAKE) -j 1 TEST_SELECTION=":$@" UNIQUE_DIR=$@ jtreg_tests;
 234 
 235 # Prep for output
 236 prep: clean
 237         @$(MKDIR) -p $(ABS_TEST_OUTPUT_DIR)
 238         @$(MKDIR) -p `dirname $(ARCHIVE_BUNDLE)`
 239 
 240 # Cleanup
 241 clean:
 242         $(RM) -r $(ABS_TEST_OUTPUT_DIR)
 243         $(RM) $(ARCHIVE_BUNDLE)
 244 
 245 ################################################################
 246 
 247 # jtreg tests
 248 
 249 # Expect JT_HOME to be set for jtreg tests. (home for jtreg)
 250 ifndef JT_HOME
 251   JT_HOME = $(SLASH_JAVA)/re/jtreg/4.1/promoted/latest/binaries/jtreg
 252   ifdef JPRT_JTREG_HOME
 253     JT_HOME = $(JPRT_JTREG_HOME)
 254   endif
 255 endif
 256 
 257 # When called from JPRT the TESTDIRS variable is set to the jtreg tests to run
 258 ifdef TESTDIRS
 259   TEST_SELECTION = $(TESTDIRS)
 260 endif
 261 
 262 ifdef CONCURRENCY
 263   EXTRA_JTREG_OPTIONS += -concurrency:$(CONCURRENCY)
 264 endif
 265 
 266 # Default JTREG to run
 267 JTREG = $(JT_HOME)/bin/jtreg
 268 
 269 # Only run automatic tests
 270 JTREG_BASIC_OPTIONS += -a
 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 # Multiply by 4 the timeout factor
 279 JTREG_TIMEOUT_OPTION =  -timeoutFactor:4
 280 JTREG_BASIC_OPTIONS += $(JTREG_TIMEOUT_OPTION)
 281 # Add any extra options
 282 JTREG_BASIC_OPTIONS += $(EXTRA_JTREG_OPTIONS)
 283 # Set other vm and test options
 284 JTREG_TEST_OPTIONS = $(JAVA_ARGS:%=-javaoptions:%) $(JAVA_OPTIONS:%=-vmoption:%) $(JAVA_VM_ARGS:%=-vmoption:%)
 285 
 286 # Option to tell jtreg to not run tests marked with "ignore"
 287 ifeq ($(PLATFORM), windows)
 288   JTREG_KEY_OPTION = -k:!ignore
 289 else
 290   JTREG_KEY_OPTION = -k:\!ignore
 291 endif
 292 JTREG_BASIC_OPTIONS += $(JTREG_KEY_OPTION)
 293 
 294 # Make sure jtreg exists
 295 $(JTREG): $(JT_HOME)
 296 
 297 jtreg_tests: prep $(PRODUCT_HOME) $(JTREG)
 298         (                                                                    \
 299           ( JT_HOME=$(shell $(GETMIXEDPATH) "$(JT_HOME)");                   \
 300             export JT_HOME;                                                  \
 301             $(shell $(GETMIXEDPATH) "$(JTREG)")                              \
 302               $(JTREG_BASIC_OPTIONS)                                         \
 303               -r:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTreport")  \
 304               -w:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTwork")    \
 305               -jdk:$(shell $(GETMIXEDPATH) "$(PRODUCT_HOME)")                \

 306               $(JTREG_EXCLUSIONS)                                            \
 307               $(JTREG_TEST_OPTIONS)                                          \
 308               $(TEST_SELECTION)                                              \
 309           ) ;                                                                \
 310           $(BUNDLE_UP_AND_EXIT)                                              \
 311         ) 2>&1 | $(TEE) $(ABS_TEST_OUTPUT_DIR)/output.txt ; $(TESTEXIT)
 312 
 313 PHONY_LIST += jtreg_tests
 314 
 315 # flags used to execute java in test targets
 316 TEST_FLAGS += -version -Xinternalversion -X -help 
 317 
 318 sanitytest: prep $(PRODUCT_HOME)
 319         @for flag in $(TEST_FLAGS);                                             \
 320         do                                                                      \
 321             echo Executing java $(JAVA_OPTIONS) $$flag;                         \
 322             $(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) $$flag;                    \
 323             res=$$?;                                                            \
 324             if [ $$res -ne 0 ]; then                                            \
 325                 exit $$res;                                                     \
 326             fi;                                                                 \
 327         done
 328 
 329 PHONY_LIST += sanitytest
 330 
 331 ################################################################
 332 
 333 # clienttest (make sure various basic java client options work)
 334 
 335 hotspot_clienttest clienttest: sanitytest
 336         $(RM) $(PRODUCT_HOME)/jre/lib/*/client/classes.jsa
 337         $(RM) $(PRODUCT_HOME)/jre/bin/client/classes.jsa
 338         $(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -Xshare:dump
 339 
 340 PHONY_LIST += hotspot_clienttest clienttest
 341 
 342 ################################################################
 343 
 344 # minimaltest (make sure various basic java minimal options work)
 345 
 346 hotspot_minimaltest minimaltest: sanitytest
 347 
 348 PHONY_LIST += hotspot_minimaltest minimaltest
 349 
 350 ################################################################
 351 
 352 # servertest (make sure various basic java server options work)
 353 
 354 hotspot_servertest servertest: sanitytest
 355 
 356 PHONY_LIST += hotspot_servertest servertest
 357 
 358 ################################################################
 359 
 360 # internalvmtests (run internal unit tests inside the VM)
 361 
 362 hotspot_internalvmtests internalvmtests: prep $(PRODUCT_HOME)
 363         $(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -XX:+ExecuteInternalVMTests -version
 364 
 365 PHONY_LIST += hotspot_internalvmtests internalvmtests
 366 
 367 ################################################################
 368 
 369 # Phony targets (e.g. these are not filenames)
 370 .PHONY: all clean prep $(PHONY_LIST)
 371 
 372 ################################################################
--- EOF ---