test/Makefile

Fri, 17 Feb 2012 15:24:40 -0800

author
darcy
date
Fri, 17 Feb 2012 15:24:40 -0800
changeset 1199
e127334a64fe
parent 1124
9e2eb4bc49eb
child 1223
f3743b82945e
permissions
-rw-r--r--

7143910: test/tools/apt/Basics/apt.sh fails with 'real' sh
Reviewed-by: darcy
Contributed-by: sonali.goel@oracle.com

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

mercurial