1 #
   2 # Copyright (c) 1995, 2011, 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 jdk tests
  27 #
  28 
  29 # Get OS/ARCH specifics
  30 OSNAME = $(shell uname -s)
  31 ifeq ($(OSNAME), SunOS)
  32   PLATFORM = solaris
  33   SLASH_JAVA = /java
  34   ARCH = $(shell uname -p)
  35   ifeq ($(ARCH), i386)
  36     ARCH=i586
  37   endif
  38 endif
  39 ifeq ($(OSNAME), Linux)
  40   PLATFORM = linux
  41   SLASH_JAVA = /java
  42   ARCH = $(shell uname -m)
  43   ifeq ($(ARCH), i386)
  44     ARCH = i586
  45   endif
  46 endif
  47 ifeq ($(OSNAME), Darwin)
  48   PLATFORM = bsd
  49   SLASH_JAVA = /java
  50   ARCH = $(shell uname -m)
  51   ifeq ($(ARCH), i386)
  52     ARCH = i586
  53   endif
  54 endif
  55 ifeq ($(findstring BSD,$(OSNAME)), BSD)
  56   PLATFORM = bsd
  57   SLASH_JAVA = /java
  58   ARCH = $(shell uname -m)
  59   ifeq ($(ARCH), i386)
  60     ARCH = i586
  61   endif
  62 endif
  63 ifeq ($(OSNAME), Windows_NT)
  64   PLATFORM = windows
  65   SLASH_JAVA = J:
  66   ifeq ($(word 1, $(PROCESSOR_IDENTIFIER)),ia64)
  67     ARCH = ia64
  68   else
  69     ifeq ($(word 1, $(PROCESSOR_IDENTIFIER)),AMD64)
  70       ARCH = x64
  71     else
  72       ifeq ($(word 1, $(PROCESSOR_IDENTIFIER)),EM64T)
  73         ARCH = x64
  74       else
  75         ARCH = i586
  76       endif
  77     endif
  78   endif
  79   EXESUFFIX = .exe
  80 endif
  81 
  82 ifdef ALT_SLASH_JAVA
  83   SLASH_JAVA = $(ALT_SLASH_JAVA)
  84 endif
  85 
  86 # Utilities used
  87 CD    = cd
  88 CP    = cp
  89 ECHO  = echo
  90 MKDIR = mkdir
  91 ZIP   = zip
  92 
  93 # Root of this test area (important to use full paths in some places)
  94 TEST_ROOT := $(shell pwd)
  95 
  96 # Root of all test results
  97 ifdef ALT_OUTPUTDIR
  98   ABS_BUILD_ROOT = $(ALT_OUTPUTDIR)/$(PLATFORM)-$(ARCH)
  99 else
 100   ABS_BUILD_ROOT = $(TEST_ROOT)/../build/$(PLATFORM)-$(ARCH)
 101 endif
 102 ABS_TEST_OUTPUT_DIR = $(ABS_BUILD_ROOT)/testoutput
 103 
 104 # Expect JPRT to set PRODUCT_HOME (the product or jdk in this case to test)
 105 ifndef PRODUCT_HOME
 106   # Try to use j2sdk-image if it exists
 107   ABS_JDK_IMAGE = $(ABS_BUILD_ROOT)/j2sdk-image
 108   PRODUCT_HOME :=                       \
 109     $(shell                             \
 110       if [ -d $(ABS_JDK_IMAGE) ] ; then \
 111          $(ECHO) "$(ABS_JDK_IMAGE)";    \
 112        else                             \
 113          $(ECHO) "$(ABS_BUILD_ROOT)" ;  \
 114        fi)
 115 endif
 116 
 117 # Expect JPRT to set JAVA_ARGS (e.g. -server etc.)
 118 JAVA_OPTIONS = 
 119 ifdef JAVA_ARGS
 120   JAVA_OPTIONS = $(JAVA_ARGS)
 121 endif
 122 
 123 # Expect JPRT to set JPRT_ARCHIVE_BUNDLE (path to zip bundle for results)
 124 ARCHIVE_BUNDLE = $(ABS_TEST_OUTPUT_DIR)/ARCHIVE_BUNDLE.zip
 125 ifdef JPRT_ARCHIVE_BUNDLE
 126   ARCHIVE_BUNDLE = $(JPRT_ARCHIVE_BUNDLE)
 127 endif
 128 
 129 # How to create the test bundle (pass or fail, we want to create this)
 130 BUNDLE_UP = ( $(MKDIR) -p `dirname $(ARCHIVE_BUNDLE)`     \
 131               && $(CD) $(ABS_TEST_OUTPUT_DIR)             \
 132               && $(ZIP) -q -r $(ARCHIVE_BUNDLE) . )
 133 BUNDLE_UP_FAILED = ( exitCode=$$? && $(BUNDLE_UP) && exit $${exitCode} )
 134 
 135 ################################################################
 136 
 137 # Default make rule (runs jtreg_tests)
 138 all: jtreg_tests
 139         @$(ECHO) "Testing completed successfully"
 140 
 141 # Prep for output
 142 prep: clean
 143         @$(MKDIR) -p $(ABS_TEST_OUTPUT_DIR)
 144         @$(MKDIR) -p `dirname $(ARCHIVE_BUNDLE)`
 145 
 146 # Cleanup
 147 clean:
 148         $(RM) -r $(ABS_TEST_OUTPUT_DIR)
 149         $(RM) $(ARCHIVE_BUNDLE)
 150 
 151 ################################################################
 152 
 153 # jtreg tests
 154 
 155 # Expect JT_HOME to be set for jtreg tests. (home for jtreg)
 156 JT_HOME = $(SLASH_JAVA)/re/jtreg/4.0/promoted/latest/binaries/jtreg
 157 ifdef JPRT_JTREG_HOME
 158   JT_HOME = $(JPRT_JTREG_HOME)
 159 endif
 160 
 161 # Expect JPRT to set TESTDIRS to the jtreg test dirs
 162 JTREG_TESTDIRS = demo/jvmti/gctest demo/jvmti/hprof
 163 ifdef TESTDIRS
 164   JTREG_TESTDIRS = $(TESTDIRS)
 165 endif
 166 
 167 # Default JTREG to run (win32 script works for everybody)
 168 JTREG = $(JT_HOME)/win32/bin/jtreg
 169 
 170 # Option to tell jtreg to not run tests marked with "ignore"
 171 ifeq ($(PLATFORM), windows)
 172   JTREG_KEY_OPTION = -k:!ignore
 173 else
 174   JTREG_KEY_OPTION = -k:\!ignore
 175 endif
 176 
 177 #EXTRA_JTREG_OPTIONS =
 178 
 179 jtreg_tests: prep $(JT_HOME) $(PRODUCT_HOME) $(JTREG)
 180         $(JTREG) -a -v:fail,error               \
 181           $(JTREG_KEY_OPTION)                   \
 182           $(EXTRA_JTREG_OPTIONS)                \
 183           -r:$(ABS_TEST_OUTPUT_DIR)/JTreport    \
 184           -w:$(ABS_TEST_OUTPUT_DIR)/JTwork      \
 185           -jdk:$(PRODUCT_HOME)                  \
 186           $(JAVA_OPTIONS:%=-vmoption:%)         \
 187           $(JTREG_TESTDIRS)                     \
 188           || $(BUNDLE_UP_FAILED)
 189         $(BUNDLE_UP)
 190 
 191 PHONY_LIST += jtreg_tests
 192 
 193 ################################################################
 194 
 195 # clienttest (make sure various basic java client options work)
 196 
 197 clienttest: prep $(PRODUCT_HOME)
 198         $(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -version
 199         $(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -help
 200         $(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -X
 201         $(RM) $(PRODUCT_HOME)/jre/lib/*/client/classes.jsa
 202         $(RM) $(PRODUCT_HOME)/jre/lib/*/client/classes_g.jsa
 203         $(RM) $(PRODUCT_HOME)/jre/bin/client/classes.jsa
 204         $(RM) $(PRODUCT_HOME)/jre/bin/client/classes_g.jsa
 205         $(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -Xshare:dump
 206 
 207 PHONY_LIST += clienttest
 208 
 209 ################################################################
 210 
 211 # servertest (make sure various basic java server options work)
 212 
 213 servertest: prep $(PRODUCT_HOME)
 214         $(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -version
 215         $(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -help
 216         $(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -X
 217 
 218 PHONY_LIST += servertest
 219 
 220 ################################################################
 221 
 222 # internalvmtests (run internal unit tests inside the VM)
 223 
 224 internalvmtests: prep $(PRODUCT_HOME)
 225         $(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -XX:+ExecuteInternalVMTests -version
 226 
 227 PHONY_LIST += internalvmtests
 228 
 229 ################################################################
 230 
 231 # packtest
 232 
 233 # Expect JPRT to set JPRT_PACKTEST_HOME.
 234 PACKTEST_HOME = /net/jprt-web.sfbay.sun.com/jprt/allproducts/packtest
 235 ifdef JPRT_PACKTEST_HOME
 236   PACKTEST_HOME = $(JPRT_PACKTEST_HOME)
 237 endif
 238 
 239 #EXTRA_PACKTEST_OPTIONS =
 240 
 241 packtest: prep $(PACKTEST_HOME)/ptest $(PRODUCT_HOME)
 242         ( $(CD) $(PACKTEST_HOME) &&            \
 243             $(PACKTEST_HOME)/ptest             \
 244                  -t "$(PRODUCT_HOME)"          \
 245                  $(PACKTEST_STRESS_OPTION)     \
 246                  $(EXTRA_PACKTEST_OPTIONS)     \
 247                  -W $(ABS_TEST_OUTPUT_DIR)     \
 248                  $(JAVA_OPTIONS:%=-J %)        \
 249          ) || $(BUNDLE_UP_FAILED)
 250         $(BUNDLE_UP)
 251 
 252 packtest_stress: PACKTEST_STRESS_OPTION=-s
 253 packtest_stress: packtest
 254 
 255 PHONY_LIST += packtest packtest_stress
 256 
 257 ################################################################
 258 
 259 # Phony targets (e.g. these are not filenames)
 260 .PHONY: all clean prep $(PHONY_LIST)
 261 
 262 ################################################################
 263