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