jaxp/test/Makefile
changeset 42485 26156e756dfa
parent 42248 6d7e82a34c09
equal deleted inserted replaced
42419:5c71ea43933b 42485:26156e756dfa
     1 #
     1 #
     2 # Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
     2 # Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
     3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4 #
     4 #
     5 # This code is free software; you can redistribute it and/or modify it
     5 # This code is free software; you can redistribute it and/or modify it
     6 # under the terms of the GNU General Public License version 2 only, as
     6 # under the terms of the GNU General Public License version 2 only, as
     7 # published by the Free Software Foundation.  Oracle designates this
     7 # published by the Free Software Foundation.  Oracle designates this
    21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    22 # or visit www.oracle.com if you need additional information or have any
    22 # or visit www.oracle.com if you need additional information or have any
    23 # questions.
    23 # questions.
    24 #
    24 #
    25 
    25 
    26 #
    26 default: all
    27 # Makefile to run various JAXP tests
       
    28 #
       
    29 
    27 
    30 .DEFAULT : all
    28 USE_JTREG_VERSION := 4.1
    31 
    29 
    32 # Empty these to get rid of some default rules
    30 include ../../test/TestCommon.gmk
    33 .SUFFIXES:
       
    34 .SUFFIXES: .java
       
    35 CO=
       
    36 GET=
       
    37 
       
    38 # Utilities used
       
    39 AWK       = awk
       
    40 CAT       = cat
       
    41 CD        = cd
       
    42 CHMOD     = chmod
       
    43 CP        = cp
       
    44 CUT       = cut
       
    45 DIRNAME   = dirname
       
    46 ECHO      = echo
       
    47 EGREP     = egrep
       
    48 EXPAND    = expand
       
    49 FIND      = find
       
    50 MKDIR     = mkdir
       
    51 PWD       = pwd
       
    52 SED       = sed
       
    53 SORT      = sort
       
    54 TEE       = tee
       
    55 UNAME     = uname
       
    56 UNIQ      = uniq
       
    57 WC        = wc
       
    58 ZIPEXE    = zip
       
    59 
       
    60 # Get OS name from uname (Cygwin inexplicably adds _NT-5.1)
       
    61 UNAME_S := $(shell $(UNAME) -s | $(CUT) -f1 -d_)
       
    62 
       
    63 # Commands to run on paths to make mixed paths for java on windows
       
    64 ifeq ($(UNAME_S), CYGWIN)
       
    65   # Location of developer shared files
       
    66   SLASH_JAVA = J:
       
    67   GETMIXEDPATH = cygpath -m
       
    68 else
       
    69   # Location of developer shared files
       
    70   SLASH_JAVA = /java
       
    71 
       
    72   GETMIXEDPATH=$(ECHO)
       
    73 endif
       
    74 
       
    75 # Root of this test area (important to use full paths in some places)
       
    76 TEST_ROOT := $(shell $(PWD))
       
    77 
       
    78 # Root of all test results
       
    79 ifdef TEST_OUTPUT_DIR
       
    80   $(shell $(MKDIR) -p $(TEST_OUTPUT_DIR)/jtreg)
       
    81   ABS_TEST_OUTPUT_DIR := \
       
    82     $(shell $(CD) $(TEST_OUTPUT_DIR)/jtreg && $(PWD))
       
    83 else
       
    84   ifdef ALT_OUTPUTDIR
       
    85     ABS_OUTPUTDIR = $(shell $(CD) $(ALT_OUTPUTDIR) && $(PWD))
       
    86   else
       
    87     ABS_OUTPUTDIR = $(shell $(CD) $(TEST_ROOT)/.. && $(PWD))
       
    88   endif
       
    89 
       
    90   ABS_PLATFORM_BUILD_ROOT = $(ABS_OUTPUTDIR)
       
    91   ABS_TEST_OUTPUT_DIR := $(ABS_PLATFORM_BUILD_ROOT)/testoutput/$(UNIQUE_DIR)
       
    92 endif
       
    93 
       
    94 # Expect JPRT to set PRODUCT_HOME (the product or jdk in this case to test)
       
    95 ifndef PRODUCT_HOME
       
    96   # Try to use j2sdk-image if it exists
       
    97   ABS_JDK_IMAGE = $(ABS_PLATFORM_BUILD_ROOT)/images/j2sdk-image
       
    98   PRODUCT_HOME :=                       		\
       
    99     $(shell                             		\
       
   100       if [ -d $(ABS_JDK_IMAGE) ] ; then 		\
       
   101          $(ECHO) "$(ABS_JDK_IMAGE)";    		\
       
   102        else                             		\
       
   103          $(ECHO) "$(ABS_PLATFORM_BUILD_ROOT)";		\
       
   104        fi)
       
   105   PRODUCT_HOME := $(PRODUCT_HOME)
       
   106 endif
       
   107 
       
   108 # Expect JPRT to set JPRT_PRODUCT_ARGS (e.g. -server etc.)
       
   109 #   Should be passed into 'java' only.
       
   110 #   Could include: -d64 -server -client OR any java option
       
   111 ifdef JPRT_PRODUCT_ARGS
       
   112   JAVA_ARGS = $(JPRT_PRODUCT_ARGS)
       
   113 endif
       
   114 
       
   115 # Expect JPRT to set JPRT_PRODUCT_VM_ARGS (e.g. -Xcomp etc.)
       
   116 #   Should be passed into anything running the vm (java, javac, javadoc, ...).
       
   117 ifdef JPRT_PRODUCT_VM_ARGS
       
   118   JAVA_VM_ARGS = $(JPRT_PRODUCT_VM_ARGS)
       
   119 endif
       
   120 
       
   121 # Expect JPRT to set JPRT_ARCHIVE_BUNDLE (path to zip bundle for results)
       
   122 ifdef JPRT_ARCHIVE_BUNDLE
       
   123   ARCHIVE_BUNDLE = $(JPRT_ARCHIVE_BUNDLE)
       
   124 else
       
   125   ARCHIVE_BUNDLE = $(ABS_TEST_OUTPUT_DIR)/ARCHIVE_BUNDLE.zip
       
   126 endif
       
   127 
       
   128 # How to create the test bundle (pass or fail, we want to create this)
       
   129 #   Follow command with ";$(BUNDLE_UP_AND_EXIT)", so it always gets executed.
       
   130 ZIP_UP_RESULTS = ( $(MKDIR) -p `$(DIRNAME) $(ARCHIVE_BUNDLE)`     \
       
   131 	           && $(CD) $(ABS_TEST_OUTPUT_DIR)             \
       
   132 	           && $(CHMOD) -R a+r . \
       
   133 	           && $(ZIPEXE) -q -r $(ARCHIVE_BUNDLE) . )
       
   134 
       
   135 # important results files
       
   136 SUMMARY_TXT = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTreport/text/summary.txt")
       
   137 STATS_TXT_NAME = Stats.txt
       
   138 STATS_TXT = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/$(STATS_TXT_NAME)")
       
   139 RUNLIST   = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/runlist.txt")
       
   140 PASSLIST  = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/passlist.txt")
       
   141 FAILLIST  = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/faillist.txt")
       
   142 EXITCODE  = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/exitcode.txt")
       
   143 
       
   144 TESTEXIT = \
       
   145   if [ ! -s $(EXITCODE) ] ; then \
       
   146     $(ECHO) "ERROR: EXITCODE file not filled in."; \
       
   147     $(ECHO) "1" > $(EXITCODE); \
       
   148   fi ; \
       
   149   testExitCode=`$(CAT) $(EXITCODE)`; \
       
   150   $(ECHO) "EXIT CODE: $${testExitCode}"; \
       
   151   exit $${testExitCode}
       
   152 
       
   153 BUNDLE_UP_AND_EXIT = \
       
   154 ( \
       
   155   jtregExitCode=$$? && \
       
   156   _summary="$(SUMMARY_TXT)"; \
       
   157   $(RM) -f $(STATS_TXT) $(RUNLIST) $(PASSLIST) $(FAILLIST) $(EXITCODE); \
       
   158   $(ECHO) "$${jtregExitCode}" > $(EXITCODE); \
       
   159   if [ -r "$${_summary}" ] ; then \
       
   160     $(ECHO) "Summary: $(UNIQUE_DIR)" > $(STATS_TXT); \
       
   161     $(EXPAND) $${_summary} | $(EGREP) -v ' Not run\.' > $(RUNLIST); \
       
   162     $(EGREP) ' Passed\.' $(RUNLIST) \
       
   163       | $(EGREP) -v ' Error\.' \
       
   164       | $(EGREP) -v ' Failed\.' > $(PASSLIST); \
       
   165     ( $(EGREP) ' Failed\.' $(RUNLIST); \
       
   166       $(EGREP) ' Error\.' $(RUNLIST); \
       
   167       $(EGREP) -v ' Passed\.' $(RUNLIST) ) \
       
   168       | $(SORT) | $(UNIQ) > $(FAILLIST); \
       
   169     if [ $${jtregExitCode} != 0 -o -s $(FAILLIST) ] ; then \
       
   170       $(EXPAND) $(FAILLIST) \
       
   171         | $(CUT) -d' ' -f1 \
       
   172         | $(SED) -e 's@^@FAILED: @' >> $(STATS_TXT); \
       
   173       if [ $${jtregExitCode} = 0 ] ; then \
       
   174         jtregExitCode=1; \
       
   175       fi; \
       
   176     fi; \
       
   177     runc="`$(CAT) $(RUNLIST)      | $(WC) -l | $(AWK) '{print $$1;}'`"; \
       
   178     passc="`$(CAT) $(PASSLIST)    | $(WC) -l | $(AWK) '{print $$1;}'`"; \
       
   179     failc="`$(CAT) $(FAILLIST)    | $(WC) -l | $(AWK) '{print $$1;}'`"; \
       
   180     exclc="FIXME CODETOOLS-7900176"; \
       
   181     $(ECHO) "TEST STATS: name=$(UNIQUE_DIR)  run=$${runc}  pass=$${passc}  fail=$${failc}" \
       
   182       >> $(STATS_TXT); \
       
   183   else \
       
   184     $(ECHO) "Missing file: $${_summary}" >> $(STATS_TXT); \
       
   185   fi; \
       
   186   if [ -f $(STATS_TXT) ] ; then \
       
   187     $(CAT) $(STATS_TXT); \
       
   188   fi; \
       
   189   $(ZIP_UP_RESULTS) ; \
       
   190   $(TESTEXIT) \
       
   191 )
       
   192 
       
   193 ################################################################
       
   194 
    31 
   195 # Default make rule (runs default JAXP tests)
    32 # Default make rule (runs default JAXP tests)
   196 all: jaxp_all
    33 all: jaxp_all
   197 	@$(ECHO) "Testing completed successfully"
    34 	@$(ECHO) "Testing completed successfully"
   198 
       
   199 # Prep for output
       
   200 # Change execute permissions on shared library files.
       
   201 # Files in repositories should never have execute permissions, but
       
   202 # there are some tests that have pre-built shared libraries, and these
       
   203 # windows dll files must have execute permission. Adding execute
       
   204 # permission may happen automatically on windows when using certain
       
   205 # versions of mercurial but it cannot be guaranteed. And blindly
       
   206 # adding execute permission might be seen as a mercurial 'change', so
       
   207 # we avoid adding execute permission to repository files. But testing
       
   208 # from a plain source tree needs the chmod a+rx. Applying the chmod to
       
   209 # all shared libraries not just dll files. And with CYGWIN and sshd
       
   210 # service, you may need CYGWIN=ntsec for this to work.
       
   211 prep:
       
   212 	@$(MKDIR) -p $(ABS_TEST_OUTPUT_DIR)
       
   213 	@$(MKDIR) -p `$(DIRNAME) $(ARCHIVE_BUNDLE)`
       
   214 	@if [ ! -d $(TEST_ROOT)/../.hg ] ; then                          \
       
   215 	  $(FIND) $(TEST_ROOT) \( -name \*.dll -o -name \*.DLL -o -name \*.so \)  \
       
   216 	        -exec $(CHMOD) a+rx {} \; ;                             \
       
   217         fi
       
   218 
       
   219 # Cleanup
       
   220 clean:
       
   221 	@$(RM) -r $(ABS_TEST_OUTPUT_DIR)
       
   222 	@$(RM) $(ARCHIVE_BUNDLE)
       
   223 
       
   224 ################################################################
       
   225 
       
   226 # jtreg tests
       
   227 
       
   228 # Expect JT_HOME to be set for jtreg tests. (home for jtreg)
       
   229 ifndef JT_HOME
       
   230   JT_HOME = $(SLASH_JAVA)/re/jtreg/4.1/promoted/latest/binaries/jtreg
       
   231   ifdef JPRT_JTREG_HOME
       
   232     JT_HOME = $(JPRT_JTREG_HOME)
       
   233   endif
       
   234 endif
       
   235 
       
   236 # Problematic tests to be excluded
       
   237 PROBLEM_LISTS=$(call MixedDirs,$(wildcard ProblemList.txt closed/ProblemList.txt))
       
   238 
       
   239 # Create exclude list for this platform and arch
       
   240 ifdef NO_EXCLUDES
       
   241   JTREG_EXCLUSIONS =
       
   242 else
       
   243   JTREG_EXCLUSIONS = $(PROBLEM_LISTS:%=-exclude:%)
       
   244 endif
       
   245 
       
   246 # convert list of directories to dos paths
       
   247 define MixedDirs
       
   248 $(foreach i,$1,$(shell $(GETMIXEDPATH) "${i}"))
       
   249 endef
       
   250 
       
   251 define SummaryInfo
       
   252 $(ECHO) "########################################################"
       
   253 $(CAT) $(?:%=$(ABS_TEST_OUTPUT_DIR)/%/$(STATS_TXT_NAME))
       
   254 $(ECHO) "########################################################"
       
   255 endef
       
   256 
    35 
   257 # ------------------------------------------------------------------
    36 # ------------------------------------------------------------------
   258 
    37 
   259 jaxp_%:
    38 jaxp_%:
   260 	$(ECHO) "Running tests: $@"
    39 	$(ECHO) "Running tests: $@"
   261 	for each in $@; do \
    40 	for each in $@; do \
   262 	        $(MAKE) -j 1 TEST_SELECTION=":$$each" UNIQUE_DIR=$$each jtreg_tests; \
    41 	        $(MAKE) -j 1 TEST_SELECTION=":$$each" UNIQUE_DIR=$$each jtreg_tests; \
   263 	done
    42 	done
   264 
       
   265 # ------------------------------------------------------------------
       
   266 
       
   267 ifdef CONCURRENCY
       
   268   JTREG_BASIC_OPTIONS += -concurrency:$(CONCURRENCY)
       
   269 endif
       
   270 ifdef EXTRA_JTREG_OPTIONS
       
   271   JTREG_BASIC_OPTIONS += $(EXTRA_JTREG_OPTIONS)
       
   272 endif
       
   273 
       
   274 # Default JTREG to run
       
   275 JTREG = $(JT_HOME)/bin/jtreg
       
   276 # run in agentvm mode
       
   277 JTREG_BASIC_OPTIONS += -agentvm
       
   278 # Only run automatic tests
       
   279 JTREG_BASIC_OPTIONS += -a
       
   280 # Always turn on assertions
       
   281 JTREG_ASSERT_OPTION = -ea -esa
       
   282 JTREG_BASIC_OPTIONS += $(JTREG_ASSERT_OPTION)
       
   283 # Report details on all failed or error tests, times too
       
   284 JTREG_BASIC_OPTIONS += -v:fail,error,time
       
   285 # Retain all files for failing tests
       
   286 JTREG_BASIC_OPTIONS += -retain:fail,error
       
   287 # Ignore tests are not run and completely silent about it
       
   288 JTREG_IGNORE_OPTION = -ignore:quiet
       
   289 JTREG_BASIC_OPTIONS += $(JTREG_IGNORE_OPTION)
       
   290 # Multiple by 4 the timeout numbers
       
   291 JTREG_TIMEOUT_OPTION =  -timeoutFactor:4
       
   292 JTREG_BASIC_OPTIONS += $(JTREG_TIMEOUT_OPTION)
       
   293 # Set the max memory for jtreg control vm
       
   294 JTREG_MEMORY_OPTION = -J-Xmx512m
       
   295 JTREG_BASIC_OPTIONS += $(JTREG_MEMORY_OPTION)
       
   296 # Set other vm and test options
       
   297 JTREG_TEST_OPTIONS = $(JAVA_ARGS:%=-javaoptions:%) $(JAVA_VM_ARGS:%=-vmoption:%)
       
   298 # Set the GC options for test vms
       
   299 #JTREG_GC_OPTION = -vmoption:-XX:+UseSerialGC
       
   300 #JTREG_TEST_OPTIONS += $(JTREG_GC_OPTION)
       
   301 # Set the max memory for jtreg target test vms
       
   302 JTREG_TESTVM_MEMORY_OPTION = -vmoption:-Xmx512m
       
   303 JTREG_TEST_OPTIONS += $(JTREG_TESTVM_MEMORY_OPTION)
       
   304 
       
   305 # Make sure jtreg exists
       
   306 $(JTREG): $(JT_HOME)
       
   307 
       
   308 # Run jtreg
       
   309 jtreg_tests: prep $(PRODUCT_HOME) $(JTREG)
       
   310 	(                                                                    \
       
   311 	  ( JT_HOME=$(shell $(GETMIXEDPATH) "$(JT_HOME)");                   \
       
   312             export JT_HOME;                                                  \
       
   313             $(shell $(GETMIXEDPATH) "$(JTREG)")                              \
       
   314               $(JTREG_BASIC_OPTIONS)                                         \
       
   315               -r:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTreport")  \
       
   316               -w:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTwork")    \
       
   317               -jdk:$(shell $(GETMIXEDPATH) "$(PRODUCT_HOME)")                \
       
   318               $(JTREG_EXCLUSIONS)                                            \
       
   319               $(JTREG_TEST_OPTIONS)                                          \
       
   320               $(TEST_SELECTION)                                                    \
       
   321 	  ) ;                                                                \
       
   322 	  $(BUNDLE_UP_AND_EXIT)                                              \
       
   323 	) 2>&1 | $(TEE) $(ABS_TEST_OUTPUT_DIR)/output.txt ; $(TESTEXIT)
       
   324 
       
   325 PHONY_LIST += jtreg_tests
       
   326 
       
   327 ################################################################
       
   328 
       
   329 # Phony targets (e.g. these are not filenames)
       
   330 .PHONY: all clean prep $(PHONY_LIST)
       
   331 
       
   332 ################################################################