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