Makefile 11.3 KB
Newer Older
D
duke 已提交
1
#
2
# Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
D
duke 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
19 20 21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
22
#
D
duke 已提交
23 24 25
#

#
26
# Makefile to run various hotspot tests
D
duke 已提交
27 28
#

M
mgerdin 已提交
29 30
GETMIXEDPATH=echo

31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
# Utilities used
AWK       = awk
CAT       = cat
CD        = cd
CHMOD     = chmod
CP        = cp
CUT       = cut
DIRNAME   = dirname
ECHO      = echo
EGREP     = egrep
EXPAND    = expand
FIND      = find
MKDIR     = mkdir
PWD       = pwd
SED       = sed
SORT      = sort
TEE       = tee
UNAME     = uname
UNIQ      = uniq
WC        = wc
ZIP       = zip

# Get OS name from uname (Cygwin inexplicably adds _NT-5.1)
UNAME_S := $(shell $(UNAME) -s | $(CUT) -f1 -d_)
ifeq ($(UNAME_S), SunOS)
D
duke 已提交
56
  PLATFORM = solaris
57
  SLASH_JAVA = /java
D
duke 已提交
58 59 60 61 62
  ARCH = $(shell uname -p)
  ifeq ($(ARCH), i386)
    ARCH=i586
  endif
endif
63
ifeq ($(UNAME_S), Linux)
D
duke 已提交
64
  PLATFORM = linux
65
  SLASH_JAVA = /java
D
duke 已提交
66 67
  ARCH = $(shell uname -m)
  ifeq ($(ARCH), i386)
68
    ARCH = i586
D
duke 已提交
69 70
  endif
endif
71
ifeq ($(UNAME_S), Darwin)
N
never 已提交
72 73 74 75 76 77 78
  PLATFORM = bsd
  SLASH_JAVA = /java
  ARCH = $(shell uname -m)
  ifeq ($(ARCH), i386)
    ARCH = i586
  endif
endif
79
ifeq ($(findstring BSD,$(UNAME_S)), BSD)
N
never 已提交
80 81 82 83 84 85 86
  PLATFORM = bsd
  SLASH_JAVA = /java
  ARCH = $(shell uname -m)
  ifeq ($(ARCH), i386)
    ARCH = i586
  endif
endif
M
mgerdin 已提交
87
ifeq ($(PLATFORM),)
88 89
  # detect whether we're running in MKS or cygwin
  ifeq ($(UNAME_S), Windows_NT) # MKS
M
mgerdin 已提交
90 91
    GETMIXEDPATH=dosname -s
  endif
92 93
  ifeq ($(findstring CYGWIN,$(UNAME_S)), CYGWIN)
    GETMIXEDPATH=cygpath -m
M
mgerdin 已提交
94
  endif
D
duke 已提交
95
  PLATFORM = windows
96
  SLASH_JAVA = J:
D
duke 已提交
97
  ifeq ($(word 1, $(PROCESSOR_IDENTIFIER)),ia64)
98
    ARCH = ia64
D
duke 已提交
99 100
  else
    ifeq ($(word 1, $(PROCESSOR_IDENTIFIER)),AMD64)
101
      ARCH = x64
D
duke 已提交
102 103
    else
      ifeq ($(word 1, $(PROCESSOR_IDENTIFIER)),EM64T)
104
        ARCH = x64
D
duke 已提交
105
      else
106
        ARCH = i586
D
duke 已提交
107 108 109
      endif
    endif
  endif
110
  EXESUFFIX = .exe
D
duke 已提交
111 112
endif

113 114 115 116
ifdef ALT_SLASH_JAVA
  SLASH_JAVA = $(ALT_SLASH_JAVA)
endif

117 118 119 120
# Root of this test area (important to use full paths in some places)
TEST_ROOT := $(shell pwd)

# Root of all test results
121 122 123 124 125
ifdef ALT_OUTPUTDIR
  ABS_BUILD_ROOT = $(ALT_OUTPUTDIR)/$(PLATFORM)-$(ARCH)
else
  ABS_BUILD_ROOT = $(TEST_ROOT)/../build/$(PLATFORM)-$(ARCH)
endif
126 127 128 129 130 131 132 133 134 135 136 137 138
ABS_TEST_OUTPUT_DIR = $(ABS_BUILD_ROOT)/testoutput

# Expect JPRT to set PRODUCT_HOME (the product or jdk in this case to test)
ifndef PRODUCT_HOME
  # Try to use j2sdk-image if it exists
  ABS_JDK_IMAGE = $(ABS_BUILD_ROOT)/j2sdk-image
  PRODUCT_HOME :=                       \
    $(shell                             \
      if [ -d $(ABS_JDK_IMAGE) ] ; then \
         $(ECHO) "$(ABS_JDK_IMAGE)";    \
       else                             \
         $(ECHO) "$(ABS_BUILD_ROOT)" ;  \
       fi)
D
duke 已提交
139 140
endif

141 142 143 144 145
# Expect JPRT to set JAVA_ARGS (e.g. -server etc.)
JAVA_OPTIONS = 
ifdef JAVA_ARGS
  JAVA_OPTIONS = $(JAVA_ARGS)
endif
D
duke 已提交
146

147 148 149 150 151
# Expect JPRT to set JPRT_ARCHIVE_BUNDLE (path to zip bundle for results)
ARCHIVE_BUNDLE = $(ABS_TEST_OUTPUT_DIR)/ARCHIVE_BUNDLE.zip
ifdef JPRT_ARCHIVE_BUNDLE
  ARCHIVE_BUNDLE = $(JPRT_ARCHIVE_BUNDLE)
endif
D
duke 已提交
152

153
# How to create the test bundle (pass or fail, we want to create this)
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
#   Follow command with ";$(BUNDLE_UP_AND_EXIT)", so it always gets executed.
ZIP_UP_RESULTS = ( $(MKDIR) -p `$(DIRNAME) $(ARCHIVE_BUNDLE)`     \
	           && $(CD) $(ABS_TEST_OUTPUT_DIR)             \
	           && $(CHMOD) -R a+r . \
	           && $(ZIP) -q -r $(ARCHIVE_BUNDLE) . )

# important results files
SUMMARY_TXT = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTreport/text/summary.txt")
STATS_TXT_NAME = Stats.txt
STATS_TXT = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/$(STATS_TXT_NAME)")
RUNLIST   = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/runlist.txt")
PASSLIST  = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/passlist.txt")
FAILLIST  = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/faillist.txt")
EXITCODE  = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/exitcode.txt")

TESTEXIT = \
  if [ ! -s $(EXITCODE) ] ; then \
    $(ECHO) "ERROR: EXITCODE file not filled in."; \
    $(ECHO) "1" > $(EXITCODE); \
  fi ; \
  testExitCode=`$(CAT) $(EXITCODE)`; \
  $(ECHO) "EXIT CODE: $${testExitCode}"; \
  exit $${testExitCode}

BUNDLE_UP_AND_EXIT = \
( \
  jtregExitCode=$$? && \
  _summary="$(SUMMARY_TXT)"; \
  $(RM) -f $(STATS_TXT) $(RUNLIST) $(PASSLIST) $(FAILLIST) $(EXITCODE); \
  $(ECHO) "$${jtregExitCode}" > $(EXITCODE); \
  if [ -r "$${_summary}" ] ; then \
    $(ECHO) "Summary: $(UNIQUE_DIR)" > $(STATS_TXT); \
    $(EXPAND) $${_summary} | $(EGREP) -v ' Not run\.' > $(RUNLIST); \
    $(EGREP) ' Passed\.' $(RUNLIST) \
      | $(EGREP) -v ' Error\.' \
      | $(EGREP) -v ' Failed\.' > $(PASSLIST); \
    ( $(EGREP) ' Failed\.' $(RUNLIST); \
      $(EGREP) ' Error\.' $(RUNLIST); \
      $(EGREP) -v ' Passed\.' $(RUNLIST) ) \
      | $(SORT) | $(UNIQ) > $(FAILLIST); \
    if [ $${jtregExitCode} != 0 -o -s $(FAILLIST) ] ; then \
      $(EXPAND) $(FAILLIST) \
        | $(CUT) -d' ' -f1 \
        | $(SED) -e 's@^@FAILED: @' >> $(STATS_TXT); \
      if [ $${jtregExitCode} = 0 ] ; then \
        jtregExitCode=1; \
      fi; \
    fi; \
    runc="`$(CAT) $(RUNLIST)      | $(WC) -l | $(AWK) '{print $$1;}'`"; \
    passc="`$(CAT) $(PASSLIST)    | $(WC) -l | $(AWK) '{print $$1;}'`"; \
    failc="`$(CAT) $(FAILLIST)    | $(WC) -l | $(AWK) '{print $$1;}'`"; \
    exclc="FIXME CODETOOLS-7900176"; \
    $(ECHO) "TEST STATS: name=$(UNIQUE_DIR)  run=$${runc}  pass=$${passc}  fail=$${failc}" \
      >> $(STATS_TXT); \
  else \
    $(ECHO) "Missing file: $${_summary}" >> $(STATS_TXT); \
  fi; \
  if [ -f $(STATS_TXT) ] ; then \
    $(CAT) $(STATS_TXT); \
  fi; \
  $(ZIP_UP_RESULTS) ; \
  $(TESTEXIT) \
)
D
duke 已提交
217

218
################################################################
D
duke 已提交
219

220
# Default make rule (runs jtreg_tests)
221
all: hotspot_all
222
	@$(ECHO) "Testing completed successfully"
D
duke 已提交
223

224 225 226
# Support "hotspot_" prefixed test make targets (too)
# The hotspot_% targets are used by the top level Makefile
# Unless explicitly defined below, hotspot_<x> is interpreted as a jtreg test group name
227
hotspot_%:
228 229
	$(ECHO) "Running tests: $@"
	$(MAKE) -j 1 TEST_SELECTION=":$@" UNIQUE_DIR=$@ jtreg_tests;
230

231 232 233 234
# Prep for output
prep: clean
	@$(MKDIR) -p $(ABS_TEST_OUTPUT_DIR)
	@$(MKDIR) -p `dirname $(ARCHIVE_BUNDLE)`
D
duke 已提交
235 236 237

# Cleanup
clean:
238 239 240 241 242 243 244 245
	$(RM) -r $(ABS_TEST_OUTPUT_DIR)
	$(RM) $(ARCHIVE_BUNDLE)

################################################################

# jtreg tests

# Expect JT_HOME to be set for jtreg tests. (home for jtreg)
246
ifndef JT_HOME
247 248 249 250
  JT_HOME = $(SLASH_JAVA)/re/jtreg/4.1/promoted/latest/binaries/jtreg
  ifdef JPRT_JTREG_HOME
    JT_HOME = $(JPRT_JTREG_HOME)
  endif
251 252
endif

253
# When called from JPRT the TESTDIRS variable is set to the jtreg tests to run
254
ifdef TESTDIRS
255 256 257 258 259
  TEST_SELECTION = $(TESTDIRS)
endif

ifdef CONCURRENCY
  EXTRA_JTREG_OPTIONS += -concurrency:$(CONCURRENCY)
260 261
endif

262 263
# Default JTREG to run
JTREG = $(JT_HOME)/bin/jtreg
264

265 266 267 268 269 270 271 272 273 274 275 276 277 278
# Only run automatic tests
JTREG_BASIC_OPTIONS += -a
# Report details on all failed or error tests, times too
JTREG_BASIC_OPTIONS += -v:fail,error,time
# Retain all files for failing tests
JTREG_BASIC_OPTIONS += -retain:fail,error
# Ignore tests are not run and completely silent about it
JTREG_IGNORE_OPTION = -ignore:quiet
JTREG_BASIC_OPTIONS += $(JTREG_IGNORE_OPTION)
# Add any extra options
JTREG_BASIC_OPTIONS += $(EXTRA_JTREG_OPTIONS)
# Set other vm and test options
JTREG_TEST_OPTIONS = $(JAVA_ARGS:%=-javaoptions:%) $(JAVA_OPTIONS:%=-vmoption:%) $(JAVA_VM_ARGS:%=-vmoption:%)

279 280 281 282 283 284
# Option to tell jtreg to not run tests marked with "ignore"
ifeq ($(PLATFORM), windows)
  JTREG_KEY_OPTION = -k:!ignore
else
  JTREG_KEY_OPTION = -k:\!ignore
endif
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304
JTREG_BASIC_OPTIONS += $(JTREG_KEY_OPTION)
 
# Make sure jtreg exists
$(JTREG): $(JT_HOME)

jtreg_tests: prep $(PRODUCT_HOME) $(JTREG)
	(                                                                    \
	  ( JT_HOME=$(shell $(GETMIXEDPATH) "$(JT_HOME)");                   \
            export JT_HOME;                                                  \
            $(shell $(GETMIXEDPATH) "$(JTREG)")                              \
              $(JTREG_BASIC_OPTIONS)                                         \
              -r:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTreport")  \
              -w:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTwork")    \
              -jdk:$(shell $(GETMIXEDPATH) "$(PRODUCT_HOME)")                \
              $(JTREG_EXCLUSIONS)                                            \
              $(JTREG_TEST_OPTIONS)                                          \
              $(TEST_SELECTION)                                              \
	  ) ;                                                                \
	  $(BUNDLE_UP_AND_EXIT)                                              \
	) 2>&1 | $(TEE) $(ABS_TEST_OUTPUT_DIR)/output.txt ; $(TESTEXIT)
305 306 307 308 309

PHONY_LIST += jtreg_tests

################################################################

310 311
# clienttest (make sure various basic java client options work)

312
hotspot_clienttest clienttest: prep $(PRODUCT_HOME)
313 314 315 316 317 318 319
	$(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -version
	$(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -help
	$(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -X
	$(RM) $(PRODUCT_HOME)/jre/lib/*/client/classes.jsa
	$(RM) $(PRODUCT_HOME)/jre/bin/client/classes.jsa
	$(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -Xshare:dump

320
PHONY_LIST += hotspot_clienttest clienttest
321 322 323

################################################################

324 325 326 327 328 329 330 331 332 333 334
# minimaltest (make sure various basic java minimal options work)

hotspot_minimaltest minimaltest: prep $(PRODUCT_HOME)
	$(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -version
	$(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -help
	$(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -X

PHONY_LIST += hotspot_minimaltest minimaltest

################################################################

335 336
# servertest (make sure various basic java server options work)

337
hotspot_servertest servertest: prep $(PRODUCT_HOME)
338 339 340 341
	$(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -version
	$(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -help
	$(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -X

342
PHONY_LIST += hotspot_servertest servertest
343 344 345

################################################################

346 347
# internalvmtests (run internal unit tests inside the VM)

348
hotspot_internalvmtests internalvmtests: prep $(PRODUCT_HOME)
349 350
	$(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -XX:+ExecuteInternalVMTests -version

351
PHONY_LIST += hotspot_internalvmtests internalvmtests
352 353 354 355 356

################################################################

# Phony targets (e.g. these are not filenames)
.PHONY: all clean prep $(PHONY_LIST)
D
duke 已提交
357

358
################################################################