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