Makefile 13.9 KB
Newer Older
D
duke 已提交
1
#
J
jjg 已提交
2
# Makefile to run jtreg and other tests
D
duke 已提交
3 4
#

J
jjg 已提交
5 6 7 8 9
# Product builds and langtools builds
#
# A full product build (or "control" build) creates a complete JDK image.
# To test a product build, set TESTJAVA to the path for the image.
#
10
# A langtools build just builds the langtools components of a JDK.
J
jjg 已提交
11 12 13 14 15 16 17 18
# To test a langtools build, set TESTJAVA to the path for a recent JDK
# build, and set TESTBOOTCLASSPATH to the compiled langtools classes --
# for example build/classes or dist/lib/classes.jar.

# JPRT
# JPRT may invoke this Makefile directly, as part of a langtools build,
# or indirectly, via FOREST/test/Makefile, as part of a control build.

D
duke 已提交
19 20 21
# Get OS/ARCH specifics
OSNAME = $(shell uname -s)
ifeq ($(OSNAME), SunOS)
22
  SLASH_JAVA = /java
D
duke 已提交
23 24 25 26 27 28 29
  PLATFORM = solaris
  ARCH = $(shell uname -p)
  ifeq ($(ARCH), i386)
    ARCH=i586
  endif
endif
ifeq ($(OSNAME), Linux)
30
  SLASH_JAVA = /java
D
duke 已提交
31 32 33 34 35 36
  PLATFORM = linux
  ARCH = $(shell uname -m)
  ifeq ($(ARCH), i386)
    ARCH=i586
  endif
endif
37 38 39 40 41 42 43
ifeq ($(OSNAME), Darwin)
  PLATFORM = bsd
  ARCH = $(shell uname -m)
  ifeq ($(ARCH), i386)
    ARCH=i586
  endif
endif
D
duke 已提交
44
ifeq ($(OSNAME), Windows_NT)
45 46 47 48
  # MKS
  PLATFORM=windows
endif
ifeq ($(PLATFORM),)
D
duke 已提交
49
  PLATFORM = windows
50 51 52 53 54
  CYGPATH = | cygpath -m -s -f -
endif

ifeq ($(PLATFORM), windows)
  SLASH_JAVA = J:
D
duke 已提交
55 56 57 58 59 60 61 62 63 64 65 66 67
  ifeq ($(word 1, $(PROCESSOR_IDENTIFIER)),ia64)
    ARCH=ia64
  else
    ifeq ($(word 1, $(PROCESSOR_IDENTIFIER)),AMD64)
      ARCH=x64
    else
      ifeq ($(word 1, $(PROCESSOR_IDENTIFIER)),EM64T)
        ARCH=x64
      else
        ARCH=i586
      endif
    endif
  endif
68
  EXE_SUFFIX=.exe
D
duke 已提交
69 70 71
endif

# Root of this test area (important to use full paths in some places)
72
TEST_ROOT := $(shell pwd $(CYGPATH) )
D
duke 已提交
73

J
jjg 已提交
74 75 76 77 78
# Default bundle of all test results (passed or not) (JPRT only)
ifdef JPRT_JOB_ID
  JPRT_CLEAN = clean
  JPRT_ARCHIVE_BUNDLE = $(TEST_ROOT)/JPRT_ARCHIVE_BUNDLE.zip
endif
D
duke 已提交
79 80 81 82 83 84 85 86

ifeq ($(PLATFORM), windows)
  SLASH_JAVA = J:
else
  SLASH_JAVA = /java
endif

# Default JTREG to run
87 88 89
ifdef JPRT_JTREG_HOME
  JTREG_HOME = $(JPRT_JTREG_HOME)
else
90
  JTREG_HOME = $(SLASH_JAVA)/re/jtreg/4.1/promoted/latest/binaries/jtreg
91
endif
92 93
JTREG = $(JTREG_HOME)/bin/jtreg
JTDIFF = $(JTREG_HOME)/bin/jtdiff
D
duke 已提交
94

J
jjg 已提交
95 96 97 98
# Default JCK to run
ifdef JPRT_JCK_HOME
  JCK_HOME = $(JPRT_JCK_HOME)
else
99
  JCK_HOME = $(SLASH_JAVA)/re/jck/8/promoted/latest/binaries
J
jjg 已提交
100 101 102 103 104 105 106 107
endif

# Default JDK for JTREG and JCK
#
# JT_JAVA is the version of java used to run jtreg/JCK. Since it is now
# standard to execute tests in sameVM mode, it should normally be set the
# same as TESTJAVA (although not necessarily so.)
#
D
duke 已提交
108 109 110
ifdef JPRT_JAVA_HOME
  JT_JAVA = $(JPRT_JAVA_HOME)
else
111
  JT_JAVA = $(SLASH_JAVA)/re/jdk/1.7.0/archive/fcs/binaries/$(PLATFORM)-$(ARCH)
D
duke 已提交
112 113 114
endif

# Default JDK to test
115 116 117 118 119 120
ifdef JPRT_IMPORT_PRODUCT_HOME
  TESTJAVA = $(JPRT_IMPORT_PRODUCT_HOME)
else
  TESTJAVA = $(SLASH_JAVA)/re/jdk/1.7.0/promoted/latest/binaries/$(PLATFORM)-$(ARCH)
endif

121
# PRODUCT_HOME is a JPRT variable pointing to a directory containing the output from
J
jjg 已提交
122 123
# make/Makefile
# For langtools, this is a directory containing build and dist
124
# For a control build, this is build/$(PRODUCT)-$(ARCH)/XYZ-image
125
#	(i.e, j2sdk-image or jdk-module-image)
J
jjg 已提交
126 127 128 129
ifdef PRODUCT_HOME
  ifeq ($(shell [ -r $(PRODUCT_HOME)/dist/lib/classes.jar ]; echo $$?),0)
    TESTBOOTCLASSPATH = $(PRODUCT_HOME)/dist/lib/classes.jar
  endif
130
  ifeq ($(shell [ -r $(PRODUCT_HOME)/bin/javac$(EXE_SUFFIX) ]; echo $$?),0)
J
jjg 已提交
131 132 133 134 135 136 137
    TESTJAVA = $(PRODUCT_HOME)
  endif
endif

ifdef TESTBOOTCLASSPATH
  JTREG_OPTIONS += -Xbootclasspath/p:$(TESTBOOTCLASSPATH)
### In the following, -refvmoptions is an undocumented option
138
### The following does not work JCK 7 b30 2/6/2010. Awaiting b31.
J
jjg 已提交
139 140 141 142 143
  JCK_OPTIONS += \
	-vmoptions:-Xbootclasspath/p:$(TESTBOOTCLASSPATH) \
	-refvmoptions:-Xbootclasspath/p:$(TESTBOOTCLASSPATH)
endif

144
# Concurrency is the number of tests that can execute at once.
J
jjg 已提交
145 146 147
# On an otherwise empty machine, suggest setting to (#cpus + 2)
# If unset, the default is (#cpus)
### RFE: determine and use #cpus
148 149 150 151 152 153
ifdef CONCURRENCY
  JTREG_OPTIONS += -agentvm -concurrency:$(CONCURRENCY)
else
  JTREG_OPTIONS += -samevm
endif

J
jjg 已提交
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
ifdef JCK_CONCURRENCY
  JCK_OPTIONS += -concurrency:$(JCK_CONCURRENCY)
endif

# JCK is executed using "Multi-JVM Group Mode", which is a hybrid
# of otherVM and sameVM modes. New JVMs are created and reused for
# a number of tests, then eventually discarded and a new one started.
# This amortizes the JVM startup time.  The "group size" defines
# how many tests are run in a JVM before it is replaced.
# If unset, the default is 100.
JCK_GROUP_SIZE = 1000
ifdef JCK_GROUP_SIZE
  JCK_COMPILER_OPTIONS += \
    -jtoptions:-Ejck.env.compiler.testCompile.groupMode.groupSize=$(JCK_GROUP_SIZE) \
    -jtoptions:-Ejck.env.compiler.compRefExecute.groupMode.groupSize=$(JCK_GROUP_SIZE)
### The following is not supported. Awaiting RFE 6924287
### 6924287: Jck4Jdk: Allow to configure test group size for group mode via simple command line option
###  JCK_RUNTIME_OPTIONS += \
###    -jtoptions:-Ejck.env.runtime.testCompile.groupMode.groupSize=$(JCK_GROUP_SIZE)
endif

175 176 177 178 179 180 181 182 183 184
# Timeouts -- by default, increase test timeouts when running on JPRT
ifdef JPRT_JOB_ID
  ifndef JTREG_TIMEOUT_FACTOR
    JTREG_TIMEOUT_FACTOR = 3
  endif
endif
ifdef JTREG_TIMEOUT_FACTOR
  JTREG_OPTIONS += -timeoutFactor:$(JTREG_TIMEOUT_FACTOR)
endif

185 186 187 188 189 190
# Default verbosity setting for jtreg
JTREG_VERBOSE = fail,error,nopass

# Default verbosity setting for jck
JCK_VERBOSE = non-pass

J
jjg 已提交
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
# Assertions: some tests show failures when assertions are enabled.
# Since javac is typically loaded via the bootclassloader (either via TESTJAVA
# or TESTBOOTCLASSPATH), you may need -esa to enable assertions in javac.
JTREG_OPTIONS += $(ASSERTION_OPTIONS)
JCK_OPTIONS += $(ASSERTION_OPTIONS:%=-vmoptions:%)

# Include shared options
JCK_COMPILER_OPTIONS += $(JCK_OPTIONS)
JCK_RUNTIME_OPTIONS += $(JCK_OPTIONS)

# Exit codes:
# jtreg, jck:   0: OK, 1: tests failed, 2: tests error; 3+: SERIOUS
FATAL_JTREG_EXIT = 3
FATAL_JCK_EXIT = 3
# jtdiff: 0: OK, 1: differences found; 2+: SERIOUS
FATAL_JTDIFF_EXIT = 2
#
# Exit -- used for final "normal" exit from "make". Redefine to "true" to avoid
# having make exit with non-zero return code.
EXIT = exit
211
# Function to exit shell if exit code of preceding command is greater than or equal
J
jjg 已提交
212 213
# to a given level. Redefine function or preceding FATAL_*_EXIT codes as needed.
EXIT_IF_FATAL = status=$$?; if [ $$status -ge $(1) ]; then exit $$status ; fi
D
duke 已提交
214 215 216 217 218 219

# The test directories to run
DEFAULT_TESTDIRS = .
TESTDIRS = $(DEFAULT_TESTDIRS)

# Root of all test results
J
jjg 已提交
220 221
TEST_OUTPUT_DIR = $(TEST_ROOT)/../build/$(PLATFORM)-$(ARCH)/test/langtools
ABS_TEST_OUTPUT_DIR := \
222 223
	$(shell mkdir -p $(TEST_OUTPUT_DIR); \
		cd  $(TEST_OUTPUT_DIR); \
224
		pwd $(CYGPATH))
J
jjg 已提交
225 226 227 228
# Subdirectories for different test runs
JTREG_OUTPUT_DIR = $(ABS_TEST_OUTPUT_DIR)/jtreg
JCK_COMPILER_OUTPUT_DIR = $(ABS_TEST_OUTPUT_DIR)/jck-compiler
JCK_RUNTIME_OUTPUT_DIR = $(ABS_TEST_OUTPUT_DIR)/jck-runtime-Xcompile
D
duke 已提交
229

J
jjg 已提交
230 231
# Default make rule -- warning, may take a while
all: $(JPRT_CLEAN) jtreg-tests jck-compiler-tests jck-runtime-tests $(JPRT_ARCHIVE_BUNDLE) all-summary
D
duke 已提交
232 233
	@echo "Testing completed successfully"

234
jtreg apt javac javadoc javah javap jdeps: $(JPRT_CLEAN) jtreg-tests $(JPRT_ARCHIVE_BUNDLE) jtreg-summary
J
jjg 已提交
235
	@echo "Testing completed successfully"
D
duke 已提交
236

J
jjg 已提交
237 238 239 240 241
jck-compiler: $(JPRT_CLEAN) jck-compiler-tests $(JPRT_ARCHIVE_BUNDLE) jck-compiler-summary
	@echo "Testing completed successfully"

jck-runtime: $(JPRT_CLEAN) jck-runtime-tests $(JPRT_ARCHIVE_BUNDLE) jck-runtime-summary
	@echo "Testing completed successfully"
D
duke 已提交
242

J
jjg 已提交
243 244 245 246 247 248 249 250
# for use with JPRT -testrule
all:		JTREG_TESTDIRS = .
jtreg:		JTREG_TESTDIRS = .
apt:		JTREG_TESTDIRS = tools/apt
javac: 		JTREG_TESTDIRS = tools/javac
javadoc:	JTREG_TESTDIRS = tools/javadoc com/sun/javadoc
javah:		JTREG_TESTDIRS = tools/javah
javap:		JTREG_TESTDIRS = tools/javap
251
jdeps:		JTREG_TESTDIRS = tools/jdeps
J
jjg 已提交
252 253 254 255 256 257 258 259

# Run jtreg tests
#
# JTREG_HOME
#	Installed location of jtreg
# JT_JAVA
#	Version of java used to run jtreg.  Should normally be the same as TESTJAVA
# TESTJAVA
260
# 	Version of java to be tested.
261 262
# JTREG_VERBOSE
# Verbosity setting for jtreg
J
jjg 已提交
263 264 265 266 267 268 269 270 271
# JTREG_OPTIONS
#	Additional options for jtreg
# JTREG_TESTDIRS
#	Directories of tests to be run
# JTREG_OUTPUT_DIR
#	Where to write the results
# JTREG_REFERENCE
#	(Optional) reference results (e.g. work, report or summary.txt)
#
272
jtreg_tests: jtreg-tests
J
jjg 已提交
273 274 275 276
jtreg-tests: check-jtreg FRC
	@rm -f -r $(JTREG_OUTPUT_DIR)/JTwork $(JTREG_OUTPUT_DIR)/JTreport \
	    $(JTREG_OUTPUT_DIR)/diff.html $(JTREG_OUTPUT_DIR)/status.txt
	@mkdir -p $(JTREG_OUTPUT_DIR)
277
	JT_JAVA=$(JT_JAVA) $(JTREG) \
J
jjg 已提交
278
	  -J-Xmx512m \
279
	  -vmoption:-Xmx768m \
280
	  -a -ignore:quiet $(if $(JTREG_VERBOSE),-v:$(JTREG_VERBOSE)) \
J
jjg 已提交
281 282
          -r:$(JTREG_OUTPUT_DIR)/JTreport \
          -w:$(JTREG_OUTPUT_DIR)/JTwork \
D
duke 已提交
283 284
          -jdk:$(TESTJAVA) \
          $(JAVA_ARGS:%=-vmoption:%) \
J
jjg 已提交
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305
	  $(JTREG_OPTIONS) \
          $(JTREG_TESTDIRS) \
	|| ( $(call EXIT_IF_FATAL,$(FATAL_JTREG_EXIT)) ; \
	    echo $$status > $(JTREG_OUTPUT_DIR)/status.txt \
	)
ifdef JTREG_REFERENCE
	JT_JAVA=$(JT_JAVA) $(JTDIFF) -o $(JTREG_OUTPUT_DIR)/diff.html \
	    $(JTREG_REFERENCE) $(JTREG_OUTPUT_DIR)/JTreport \
	|| ( $(call EXIT_IF_FATAL,$(FATAL_JTDIFF_EXIT)) )
endif

jtreg-summary: FRC
	if [ -r $(JTREG_OUTPUT_DIR)/status.txt ]; then \
	    echo ; echo "Summary of jtreg test failures" ; \
	    cat $(JTREG_OUTPUT_DIR)/JTreport/text/summary.txt | \
		grep -v 'Not run' | grep -v 'Passed' ; \
	    echo ; \
	    $(EXIT) `cat $(JTREG_OUTPUT_DIR)/status.txt` ; \
	fi

# Check to make sure these directories exist
306
check-jtreg: $(PRODUCT_HOME) $(JTREG)
J
jjg 已提交
307 308 309 310 311 312


# Run JCK-compiler tests
#
# JCK_HOME
#	Installed location of JCK: should include JCK-compiler, and JCK-extras
313
#       Default is JCK 8.
J
jjg 已提交
314 315
# JT_JAVA
#	Version of java used to run JCK.  Should normally be the same as TESTJAVA
316
#       Default is JDK 7
J
jjg 已提交
317
# TESTJAVA
318
# 	Version of java to be tested.
319 320
# JCK_VERBOSE
#	Verbosity setting for jtjck
J
jjg 已提交
321 322 323 324 325 326 327 328 329 330 331 332 333
# JCK_COMPILER_OPTIONS
#	Additional options for JCK-compiler
# JCK_COMPILER_TESTDIRS
#	Directories of tests to be run
# JCK_COMPILER_OUTPUT_DIR
#	Where to write the results
# JCK_COMPILER_REFERENCE
#	(Optional) reference results (e.g. work, report or summary.txt)
#
jck-compiler-tests: check-jck FRC
	@rm -f -r $(JCK_COMPILER_OUTPUT_DIR)/work $(JCK_COMPILER_OUTPUT_DIR)/report \
	    $(JCK_COMPILER_OUTPUT_DIR)/diff.html $(JCK_COMPILER_OUTPUT_DIR)/status.txt
	@mkdir -p $(JCK_COMPILER_OUTPUT_DIR)
334
	$(JT_JAVA)/bin/java -Xmx512m \
335
	    -jar $(JCK_HOME)/JCK-compiler-8/lib/jtjck.jar \
336
	    $(if $(JCK_VERBOSE),-v:$(JCK_VERBOSE)) \
J
jjg 已提交
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368
            -r:$(JCK_COMPILER_OUTPUT_DIR)/report \
            -w:$(JCK_COMPILER_OUTPUT_DIR)/work \
            -jdk:$(TESTJAVA) \
	    $(JCK_COMPILER_OPTIONS) \
            $(JCK_COMPILER_TESTDIRS) \
	|| ( $(call EXIT_IF_FATAL,$(FATAL_JCK_EXIT)) ; \
	    echo $$status > $(JCK_COMPILER_OUTPUT_DIR)/status.txt \
	)
ifdef JCK_COMPILER_REFERENCE
	JT_JAVA=$(JT_JAVA) $(JTDIFF) -o $(JCK_COMPILER_OUTPUT_DIR)/diff.html \
	    $(JCK_COMPILER_REFERENCE) $(JCK_COMPILER_OUTPUT_DIR)/report \
	|| ( $(call EXIT_IF_FATAL,$(FATAL_JTDIFF_EXIT)) )
endif

jck-compiler-summary: FRC
	if [ -r $(JCK_COMPILER_OUTPUT_DIR)/status.txt ]; then \
	    echo ; echo "Summary of JCK-compiler test failures" ; \
	    cat $(JCK_COMPILER_OUTPUT_DIR)/report/text/summary.txt | \
		grep -v 'Not run' | grep -v 'Passed' ; \
	    echo ; \
	    $(EXIT) `cat $(JCK_COMPILER_OUTPUT_DIR)/status.txt` ; \
	fi

# Run JCK-runtime tests in -Xcompile mode
# This is a special mode to test javac by compiling the tests in the JCK-runtime test suite
# Normal JCK-runtime invocation belongs in the jdk/ repository.
#
# JCK_HOME
#	Installed location of JCK: should include JCK-compiler, JCK-runtime and JCK-extras
# JT_JAVA
#	Version of java used to run JCK.  Should normally be the same as TESTJAVA
# TESTJAVA
369
# 	Version of java to be tested.
370 371
# JCK_VERBOSE
#	Verbosity setting for jtjck
J
jjg 已提交
372 373 374 375 376 377 378 379 380 381 382 383 384
# JCK_RUNTIME_OPTIONS
#	Additional options for JCK-runtime
# JCK_RUNTIME_TESTDIRS
#	Directories of tests to be run
# JCK_RUNTIME_OUTPUT_DIR
#	Where to write the results
# JCK_RUNTIME_REFERENCE
#	(Optional) reference results (e.g. work, report or summary.txt)
#
jck-runtime-tests: check-jck FRC
	@rm -f -r $(JCK_RUNTIME_OUTPUT_DIR)/work $(JCK_RUNTIME_OUTPUT_DIR)/report \
	    $(JCK_RUNTIME_OUTPUT_DIR)/diff.html $(JCK_RUNTIME_OUTPUT_DIR)/status.txt
	@mkdir -p $(JCK_RUNTIME_OUTPUT_DIR)
385
	$(JT_JAVA)/bin/java -Xmx512m \
386
	    -jar $(JCK_HOME)/JCK-runtime-8/lib/jtjck.jar \
387
	    $(if $(JCK_VERBOSE),-v:$(JCK_VERBOSE)) \
J
jjg 已提交
388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412
            -r:$(JCK_RUNTIME_OUTPUT_DIR)/report \
            -w:$(JCK_RUNTIME_OUTPUT_DIR)/work \
            -jdk:$(TESTJAVA) \
	    -Xcompile \
	    $(JCK_RUNTIME_OPTIONS) \
            $(JCK_RUNTIME_TESTDIRS) \
	|| ( $(call EXIT_IF_FATAL,$(FATAL_JCK_EXIT)) ; \
	    echo $$status > $(JCK_RUNTIME_OUTPUT_DIR)/status.txt \
	)
ifdef JCK_RUNTIME_REFERENCE
	JT_JAVA=$(JT_JAVA) $(JTDIFF) -o $(JCK_RUNTIME_OUTPUT_DIR)/diff.html \
	    $(JCK_RUNTIME_REFERENCE) $(JCK_RUNTIME_OUTPUT_DIR)/report \
	|| ( $(call EXIT_IF_FATAL,$(FATAL_JTDIFF_EXIT)) )
endif

jck-runtime-summary: FRC
	if [ -r $(JCK_RUNTIME_OUTPUT_DIR)/status.txt ]; then \
	    echo ; echo "Summary of JCK-runtime test failures" ; \
	    cat $(JCK_RUNTIME_OUTPUT_DIR)/report/text/summary.txt | \
		grep -v 'Not run' | grep -v 'Passed' ; \
	    echo ; \
	    $(EXIT) `cat $(JCK_RUNTIME_OUTPUT_DIR)/status.txt` ; \
	fi

# Check to make sure these directories exist
413
check-jck: $(JCK_HOME) $(PRODUCT_HOME)
J
jjg 已提交
414 415 416 417 418 419 420 421 422

all-summary: FRC
	if [ -n "`find $(TEST_OUTPUT_DIR) -name status.txt`" ]; then
	    echo ; echo "Summary of test failures" ; \
	    cat `find $(TEST_OUTPUT_DIR) -name summary.txt` | \
		grep -v 'Not run' | grep -v 'Passed' ; \
	    echo ; \
	    $(EXIT) 1
	fi
D
duke 已提交
423 424 425 426 427 428 429 430 431 432 433 434 435 436 437

# Bundle up the results
$(JPRT_ARCHIVE_BUNDLE): FRC
	@rm -f $@
	@mkdir -p $(@D)
	( cd $(TEST_OUTPUT_DIR) && zip -q -r $@ . )

# Cleanup
clean:
	rm -f $(JPRT_ARCHIVE_BUNDLE)

# Used to force a target rules to run
FRC:

# Phony targets (e.g. these are not filenames)
J
jjg 已提交
438
.PHONY: all clean \
439
	jtreg javac javadoc javah javap jdeps jtreg-tests jtreg-summary check-jtreg \
J
jjg 已提交
440 441 442 443 444
	jck-compiler jck-compiler-tests jck-compiler-summary \
	jck-runtime jck-runtime-tests jck-runtime-summary check-jck

# No use of suffix rules
.SUFFIXES:
D
duke 已提交
445