1# 2# Makefile to run jtreg and other tests 3# 4 5# Product builds and langtools builds 6# 7# A full product build (or "control" build) creates a complete JDK image. 8# To test a product build, set TESTJAVA to the path for the image. 9# 10# A langtools build just builds the langtools components of a JDK. 11# To test a langtools build, set TESTJAVA to the path for a recent JDK 12# build, and set TESTBOOTCLASSPATH to the compiled langtools classes -- 13# for example build/classes or dist/lib/classes.jar. 14 15# Get OS/ARCH specifics 16OSNAME = $(shell uname -s) 17ifeq ($(OSNAME), SunOS) 18 SLASH_JAVA = /java 19 PLATFORM = solaris 20 ARCH = $(shell uname -p) 21 ifeq ($(ARCH), i386) 22 ARCH=i586 23 endif 24endif 25ifeq ($(OSNAME), Linux) 26 SLASH_JAVA = /java 27 PLATFORM = linux 28 ARCH = $(shell uname -m) 29 ifeq ($(ARCH), i386) 30 ARCH=i586 31 endif 32endif 33ifeq ($(OSNAME), Darwin) 34 PLATFORM = bsd 35 ARCH = $(shell uname -m) 36 ifeq ($(ARCH), i386) 37 ARCH=i586 38 endif 39endif 40ifeq ($(OSNAME), DragonFly) 41 PLATFORM = bsd 42 ARCH = $(shell uname -m) 43endif 44ifeq ($(findstring BSD,$(OSNAME)), BSD) 45 PLATFORM = bsd 46 ARCH = $(shell uname -m) 47 ifeq ($(ARCH), i386) 48 ARCH=i586 49 endif 50endif 51ifneq ($(findstring BSD,$(OSNAME)),) 52 PLATFORM = bsd 53 ARCH = $(shell uname -m) 54 ifeq ($(ARCH), i386) 55 ARCH=i586 56 endif 57endif 58ifeq ($(OSNAME), Windows_NT) 59 # MKS 60 PLATFORM=windows 61endif 62ifeq ($(PLATFORM),) 63 PLATFORM = windows 64 CYGPATH = | cygpath -m -s -f - 65endif 66 67ifeq ($(PLATFORM), windows) 68 SLASH_JAVA = J: 69 ifeq ($(word 1, $(PROCESSOR_IDENTIFIER)),ia64) 70 ARCH=ia64 71 else 72 ifeq ($(word 1, $(PROCESSOR_IDENTIFIER)),AMD64) 73 ARCH=x64 74 else 75 ifeq ($(word 1, $(PROCESSOR_IDENTIFIER)),EM64T) 76 ARCH=x64 77 else 78 ARCH=i586 79 endif 80 endif 81 endif 82 EXE_SUFFIX=.exe 83endif 84 85# Root of this test area (important to use full paths in some places) 86TEST_ROOT := $(shell pwd $(CYGPATH) ) 87 88ifeq ($(PLATFORM), windows) 89 SLASH_JAVA = J: 90else 91 SLASH_JAVA = /java 92endif 93 94# Default JTREG to run 95ifndef JTREG_HOME 96 ifdef JT_HOME 97 JTREG_HOME = $(JT_HOME) 98 else 99 JTREG_HOME = $(SLASH_JAVA)/re/jtreg/4.2/promoted/latest/ 100 endif 101endif 102JTREG = $(JTREG_HOME)/bin/jtreg 103JTDIFF = $(JTREG_HOME)/bin/jtdiff 104 105# Problematic tests to be excluded 106PROBLEM_LISTS=ProblemList.txt 107 108# Create exclude list for this platform and arch 109ifdef NO_EXCLUDES 110 JTREG_EXCLUSIONS = 111else 112 JTREG_EXCLUSIONS = $(PROBLEM_LISTS:%=-exclude:%) 113endif 114 115# Default JCK to run 116ifndef JCK_HOME 117 JCK_HOME = $(SLASH_JAVA)/re/jck/8/promoted/latest/binaries 118endif 119 120# Default JDK for JTREG and JCK 121# 122# JT_JAVA is the version of java used to run jtreg/JCK. 123# 124ifndef JT_JAVA 125 JT_JAVA = $(SLASH_JAVA)/re/jdk/1.9.0/archive/fcs/binaries/$(PLATFORM)-$(ARCH) 126endif 127 128# Default JDK to test 129TESTJAVA = $(SLASH_JAVA)/re/jdk/1.9.0/promoted/latest/binaries/$(PLATFORM)-$(ARCH) 130 131# PRODUCT_HOME is a variable pointing to a directory containing the output from 132# make/Makefile 133# For langtools, this is a directory containing build and dist 134# For a control build, this is build/$(PRODUCT)-$(ARCH)/XYZ-image 135# (i.e, j2sdk-image or jdk-module-image) 136ifdef PRODUCT_HOME 137 ifeq ($(shell [ -r $(PRODUCT_HOME)/dist/lib/classes.jar ]; echo $$?),0) 138 TESTBOOTCLASSPATH = $(PRODUCT_HOME)/dist/lib/classes.jar 139 endif 140 ifeq ($(shell [ -r $(PRODUCT_HOME)/bin/javac$(EXE_SUFFIX) ]; echo $$?),0) 141 TESTJAVA = $(PRODUCT_HOME) 142 endif 143endif 144 145ifdef TESTBOOTCLASSPATH 146 JTREG_OPTIONS += -Xbootclasspath/p:$(TESTBOOTCLASSPATH) 147### In the following, -refvmoptions is an undocumented option 148### The following does not work JCK 7 b30 2/6/2010. Awaiting b31. 149 JCK_OPTIONS += \ 150 -vmoptions:-Xbootclasspath/p:$(TESTBOOTCLASSPATH) \ 151 -refvmoptions:-Xbootclasspath/p:$(TESTBOOTCLASSPATH) 152endif 153 154# Set the max memory for jtreg target test JVMs 155JTREG_TESTVM_MEMORY_OPTION = -vmoption:-Xmx768m 156JTREG_OPTIONS += $(JTREG_TESTVM_MEMORY_OPTION) 157 158# Retain all files for failing tests 159JTREG_OPTIONS += -retain:fail,error 160 161ifdef EXTRA_JTREG_OPTIONS 162 JTREG_OPTIONS += $(EXTRA_JTREG_OPTIONS) 163endif 164 165# Concurrency is the number of tests that can execute at once. 166# On an otherwise empty machine, suggest setting to (#cpus + 2) 167# If unset, the default is (#cpus) 168### RFE: determine and use #cpus 169ifdef CONCURRENCY 170 JTREG_OPTIONS += -agentvm -concurrency:$(CONCURRENCY) 171else 172 JTREG_OPTIONS += -agentvm 173endif 174 175ifdef JCK_CONCURRENCY 176 JCK_OPTIONS += -concurrency:$(JCK_CONCURRENCY) 177endif 178 179# JCK is executed using "Multi-JVM Group Mode", which is a hybrid 180# of otherVM and sameVM modes. New JVMs are created and reused for 181# a number of tests, then eventually discarded and a new one started. 182# This amortizes the JVM startup time. The "group size" defines 183# how many tests are run in a JVM before it is replaced. 184# If unset, the default is 100. 185JCK_GROUP_SIZE = 1000 186ifdef JCK_GROUP_SIZE 187 JCK_COMPILER_OPTIONS += \ 188 -jtoptions:-Ejck.env.compiler.testCompile.groupMode.groupSize=$(JCK_GROUP_SIZE) \ 189 -jtoptions:-Ejck.env.compiler.compRefExecute.groupMode.groupSize=$(JCK_GROUP_SIZE) 190### The following is not supported. Awaiting RFE 6924287 191### 6924287: Jck4Jdk: Allow to configure test group size for group mode via simple command line option 192### JCK_RUNTIME_OPTIONS += \ 193### -jtoptions:-Ejck.env.runtime.testCompile.groupMode.groupSize=$(JCK_GROUP_SIZE) 194endif 195 196# Timeouts 197ifdef JTREG_TIMEOUT_FACTOR 198 JTREG_OPTIONS += -timeoutFactor:$(JTREG_TIMEOUT_FACTOR) 199endif 200 201ifdef JCK_TIMEOUT_FACTOR 202 JCK_OPTIONS += -timeout:$(JCK_TIMEOUT_FACTOR) 203endif 204 205# Default verbosity setting for jtreg 206JTREG_VERBOSE ?= fail,error,time 207 208# Default verbosity setting for jck 209JCK_VERBOSE ?= non-pass 210 211# Assertions: some tests show failures when assertions are enabled. 212# Since javac is typically loaded via the bootclassloader (either via TESTJAVA 213# or TESTBOOTCLASSPATH), you may need -esa to enable assertions in javac. 214JTREG_OPTIONS += $(ASSERTION_OPTIONS) 215JCK_OPTIONS += $(ASSERTION_OPTIONS:%=-vmoptions:%) 216 217# Include shared options 218JCK_COMPILER_OPTIONS += $(JCK_OPTIONS) 219JCK_RUNTIME_OPTIONS += $(JCK_OPTIONS) 220 221# Exit codes: 222# jtreg, jck: 0: OK, 1: tests failed, 2: tests error; 3+: SERIOUS 223FATAL_JTREG_EXIT = 3 224FATAL_JCK_EXIT = 3 225# jtdiff: 0: OK, 1: differences found; 2+: SERIOUS 226FATAL_JTDIFF_EXIT = 2 227# 228# Exit -- used for final "normal" exit from "make". Redefine to "true" to avoid 229# having make exit with non-zero return code. 230EXIT = exit 231# Function to exit shell if exit code of preceding command is greater than or equal 232# to a given level. Redefine function or preceding FATAL_*_EXIT codes as needed. 233EXIT_IF_FATAL = status=$$?; if [ $$status -ge $(1) ]; then exit $$status ; fi 234 235# Root of all test results 236TEST_OUTPUT_DIR ?= $(TEST_ROOT)/../build/$(PLATFORM)-$(ARCH)/test/langtools 237ABS_TEST_OUTPUT_DIR := \ 238 $(shell mkdir -p $(TEST_OUTPUT_DIR); \ 239 cd $(TEST_OUTPUT_DIR); \ 240 pwd $(CYGPATH)) 241# Subdirectories for different test runs 242JTREG_OUTPUT_DIR = $(ABS_TEST_OUTPUT_DIR)/jtreg 243JCK_COMPILER_OUTPUT_DIR = $(ABS_TEST_OUTPUT_DIR)/jck-compiler 244JCK_RUNTIME_OUTPUT_DIR = $(ABS_TEST_OUTPUT_DIR)/jck-runtime-Xcompile 245 246# Is the test JVM 32-bit? 247DATA_MODEL := \ 248 $(shell $(TESTJAVA)/bin/java -XshowSettings:properties -version 2>&1 | \ 249 grep 'sun\.arch\.data\.model' | \ 250 awk '{print $$3}') 251ifeq ($(DATA_MODEL), 32) 252 # Set the GC options for test vms having a smaller address space 253 JTREG_GC_OPTION = -vmoption:-XX:+UseSerialGC 254 JTREG_OPTIONS += $(JTREG_GC_OPTION) 255endif 256 257# Default make rule -- warning, may take a while 258all: jtreg-tests jck-compiler-tests jck-runtime-tests all-summary 259 @echo "Testing completed successfully" 260 261jtreg apt javac javadoc javah javap jdeps: jtreg-tests jtreg-summary 262 @echo "Testing completed successfully" 263 264jck-compiler: jck-compiler-tests jck-compiler-summary 265 @echo "Testing completed successfully" 266 267jck-runtime: jck-runtime-tests jck-runtime-summary 268 @echo "Testing completed successfully" 269 270# a way to select tests from outside 271# works for targets 'jtreg', 'jck-compiler', and 'jck-runtime' 272ifdef TEST_SELECTION 273 JTREG_TESTDIRS = $(TEST_SELECTION) 274 JCK_COMPILER_TESTDIRS = $(TEST_SELECTION) 275 JCK_RUNTIME_TESTDIRS = $(TEST_SELECTION) 276endif 277 278# convenience targets 279all: JTREG_TESTDIRS = . 280jtreg: JTREG_TESTDIRS ?= . 281apt: JTREG_TESTDIRS = tools/apt 282javac: JTREG_TESTDIRS = tools/javac 283javadoc: JTREG_TESTDIRS = tools/javadoc com/sun/javadoc 284javah: JTREG_TESTDIRS = tools/javah 285javap: JTREG_TESTDIRS = tools/javap 286jdeps: JTREG_TESTDIRS = tools/jdeps 287 288 289# Run jtreg tests 290# 291# JTREG_HOME 292# Installed location of jtreg 293# JT_JAVA 294# Version of java used to run jtreg. Should normally be the same as TESTJAVA 295# TESTJAVA 296# Version of java to be tested. 297# JTREG_VERBOSE 298# Verbosity setting for jtreg 299# JTREG_OPTIONS 300# Additional options for jtreg 301# JTREG_TESTDIRS 302# Directories of tests to be run 303# JTREG_OUTPUT_DIR 304# Where to write the results 305# JTREG_REFERENCE 306# (Optional) reference results (e.g. work, report or summary.txt) 307# 308jtreg_tests: jtreg-tests 309jtreg-tests: check-jtreg FRC 310 @rm -f -r $(JTREG_OUTPUT_DIR)/JTwork $(JTREG_OUTPUT_DIR)/JTreport \ 311 $(JTREG_OUTPUT_DIR)/diff.html $(JTREG_OUTPUT_DIR)/status.txt 312 @mkdir -p $(JTREG_OUTPUT_DIR) 313 ( JT_JAVA=$(JT_JAVA) $(JTREG) \ 314 -a -ignore:quiet $(if $(JTREG_VERBOSE),-v:$(JTREG_VERBOSE)) \ 315 -r:$(JTREG_OUTPUT_DIR)/JTreport \ 316 -w:$(JTREG_OUTPUT_DIR)/JTwork \ 317 -jdk:$(TESTJAVA) \ 318 $(JAVA_ARGS:%=-vmoption:%) \ 319 $(JTREG_EXCLUSIONS) \ 320 $(JTREG_OPTIONS) \ 321 $(JTREG_TESTDIRS) \ 322 || ( $(call EXIT_IF_FATAL,$(FATAL_JTREG_EXIT)) ; \ 323 echo $$status > $(JTREG_OUTPUT_DIR)/status.txt \ 324 ) \ 325 ) 2>&1 | tee $(JTREG_OUTPUT_DIR)/output.txt 326ifdef JTREG_REFERENCE 327 JT_JAVA=$(JT_JAVA) $(JTDIFF) -o $(JTREG_OUTPUT_DIR)/diff.html \ 328 $(JTREG_REFERENCE) $(JTREG_OUTPUT_DIR)/JTreport \ 329 || ( $(call EXIT_IF_FATAL,$(FATAL_JTDIFF_EXIT)) ) 330endif 331 332jtreg-summary: FRC 333 @if [ -r $(JTREG_OUTPUT_DIR)/status.txt ]; then \ 334 echo ; echo "Summary of jtreg test failures" ; \ 335 cat $(JTREG_OUTPUT_DIR)/JTreport/text/summary.txt | \ 336 grep -v 'Not run' | grep -v 'Passed' ; \ 337 echo ; \ 338 $(EXIT) `cat $(JTREG_OUTPUT_DIR)/status.txt` ; \ 339 fi 340 341# Check to make sure these directories exist 342check-jtreg: $(PRODUCT_HOME) $(JTREG) 343 344 345# Run JCK-compiler tests 346# 347# JCK_HOME 348# Installed location of JCK: should include JCK-compiler, and JCK-extras 349# Default is JCK 8. 350# JT_JAVA 351# Version of java used to run JCK. Should normally be the same as TESTJAVA 352# Default is JDK 7 353# TESTJAVA 354# Version of java to be tested. 355# JCK_VERBOSE 356# Verbosity setting for jtjck 357# JCK_COMPILER_OPTIONS 358# Additional options for JCK-compiler 359# JCK_COMPILER_TESTDIRS 360# Directories of tests to be run 361# JCK_COMPILER_OUTPUT_DIR 362# Where to write the results 363# JCK_COMPILER_REFERENCE 364# (Optional) reference results (e.g. work, report or summary.txt) 365# 366jck-compiler-tests: check-jck FRC 367 @rm -f -r $(JCK_COMPILER_OUTPUT_DIR)/work $(JCK_COMPILER_OUTPUT_DIR)/report \ 368 $(JCK_COMPILER_OUTPUT_DIR)/diff.html $(JCK_COMPILER_OUTPUT_DIR)/status.txt 369 @mkdir -p $(JCK_COMPILER_OUTPUT_DIR) 370 $(JT_JAVA)/bin/java -Xmx1024m \ 371 -jar $(JCK_HOME)/JCK-compiler-9/lib/jtjck.jar \ 372 $(if $(JCK_VERBOSE),$(if $(filter $(JCK_VERBOSE),summary),-v,-v:$(JCK_VERBOSE))) \ 373 -r:$(JCK_COMPILER_OUTPUT_DIR)/report \ 374 -w:$(JCK_COMPILER_OUTPUT_DIR)/work \ 375 -jdk:$(TESTJAVA) \ 376 $(JCK_COMPILER_OPTIONS) \ 377 $(JCK_COMPILER_TESTDIRS) \ 378 || ( $(call EXIT_IF_FATAL,$(FATAL_JCK_EXIT)) ; \ 379 echo $$status > $(JCK_COMPILER_OUTPUT_DIR)/status.txt \ 380 ) 381ifdef JCK_COMPILER_REFERENCE 382 JT_JAVA=$(JT_JAVA) $(JTDIFF) -o $(JCK_COMPILER_OUTPUT_DIR)/diff.html \ 383 $(JCK_COMPILER_REFERENCE) $(JCK_COMPILER_OUTPUT_DIR)/report \ 384 || ( $(call EXIT_IF_FATAL,$(FATAL_JTDIFF_EXIT)) ) 385endif 386 387jck-compiler-summary: FRC 388 @if [ -r $(JCK_COMPILER_OUTPUT_DIR)/status.txt ]; then \ 389 echo ; echo "Summary of JCK-compiler test failures" ; \ 390 cat $(JCK_COMPILER_OUTPUT_DIR)/report/text/summary.txt | \ 391 grep -v 'Not run' | grep -v 'Passed' ; \ 392 echo ; \ 393 $(EXIT) `cat $(JCK_COMPILER_OUTPUT_DIR)/status.txt` ; \ 394 fi 395 396# Run JCK-runtime tests in -Xcompile mode 397# This is a special mode to test javac by compiling the tests in the JCK-runtime test suite 398# Normal JCK-runtime invocation belongs in the jdk/ repository. 399# 400# JCK_HOME 401# Installed location of JCK: should include JCK-compiler, JCK-runtime and JCK-extras 402# JT_JAVA 403# Version of java used to run JCK. Should normally be the same as TESTJAVA 404# TESTJAVA 405# Version of java to be tested. 406# JCK_VERBOSE 407# Verbosity setting for jtjck 408# JCK_RUNTIME_OPTIONS 409# Additional options for JCK-runtime 410# JCK_RUNTIME_TESTDIRS 411# Directories of tests to be run 412# JCK_RUNTIME_OUTPUT_DIR 413# Where to write the results 414# JCK_RUNTIME_REFERENCE 415# (Optional) reference results (e.g. work, report or summary.txt) 416# 417jck-runtime-tests: check-jck FRC 418 @rm -f -r $(JCK_RUNTIME_OUTPUT_DIR)/work $(JCK_RUNTIME_OUTPUT_DIR)/report \ 419 $(JCK_RUNTIME_OUTPUT_DIR)/diff.html $(JCK_RUNTIME_OUTPUT_DIR)/status.txt 420 @mkdir -p $(JCK_RUNTIME_OUTPUT_DIR) 421 $(JT_JAVA)/bin/java -Xmx1024m \ 422 -jar $(JCK_HOME)/JCK-runtime-9/lib/jtjck.jar \ 423 $(if $(JCK_VERBOSE),$(if $(filter $(JCK_VERBOSE),summary),-v,-v:$(JCK_VERBOSE))) \ 424 -r:$(JCK_RUNTIME_OUTPUT_DIR)/report \ 425 -w:$(JCK_RUNTIME_OUTPUT_DIR)/work \ 426 -jdk:$(TESTJAVA) \ 427 -Xcompile \ 428 $(JCK_RUNTIME_OPTIONS) \ 429 $(JCK_RUNTIME_TESTDIRS) \ 430 || ( $(call EXIT_IF_FATAL,$(FATAL_JCK_EXIT)) ; \ 431 echo $$status > $(JCK_RUNTIME_OUTPUT_DIR)/status.txt \ 432 ) 433ifdef JCK_RUNTIME_REFERENCE 434 JT_JAVA=$(JT_JAVA) $(JTDIFF) -o $(JCK_RUNTIME_OUTPUT_DIR)/diff.html \ 435 $(JCK_RUNTIME_REFERENCE) $(JCK_RUNTIME_OUTPUT_DIR)/report \ 436 || ( $(call EXIT_IF_FATAL,$(FATAL_JTDIFF_EXIT)) ) 437endif 438 439jck-runtime-summary: FRC 440 @if [ -r $(JCK_RUNTIME_OUTPUT_DIR)/status.txt ]; then \ 441 echo ; echo "Summary of JCK-runtime test failures" ; \ 442 cat $(JCK_RUNTIME_OUTPUT_DIR)/report/text/summary.txt | \ 443 grep -v 'Not run' | grep -v 'Passed' ; \ 444 echo ; \ 445 $(EXIT) `cat $(JCK_RUNTIME_OUTPUT_DIR)/status.txt` ; \ 446 fi 447 448# Check to make sure these directories exist 449check-jck: 450 @if [ ! -d '$(JCK_HOME)' ]; then \ 451 echo "JCK_HOME $(JCK_HOME) missing" ; \ 452 $(EXIT) 1 ; \ 453 fi 454 @if [ ! -d '$(PRODUCT_HOME)' ]; then \ 455 echo "PRODUCT_HOME $(PRODUCT_HOME) missing" ; \ 456 $(EXIT) 1 ; \ 457 fi 458 459all-summary: FRC 460 @if [ -n "`find $(TEST_OUTPUT_DIR) -name status.txt`" ]; then \ 461 echo ; echo "Summary of test failures" ; \ 462 cat `find $(TEST_OUTPUT_DIR) -name summary.txt` | \ 463 grep -v 'Not run' | grep -v 'Passed' ; \ 464 echo ; \ 465 $(EXIT) 1 ; \ 466 fi 467 468# Cleanup 469clean: 470 471# Used to force a target rules to run 472FRC: 473 474# Phony targets (e.g. these are not filenames) 475.PHONY: all clean \ 476 jtreg javac javadoc javah javap jdeps jtreg-tests jtreg-summary check-jtreg \ 477 jck-compiler jck-compiler-tests jck-compiler-summary \ 478 jck-runtime jck-runtime-tests jck-runtime-summary check-jck 479 480# No use of suffix rules 481.SUFFIXES: 482 483