1 #
   2 # Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
   3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4 #
   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
   7 # published by the Free Software Foundation.  Oracle designates this
   8 # particular file as subject to the "Classpath" exception as provided
   9 # by Oracle in the LICENSE file that accompanied this code.
  10 #
  11 # This code is distributed in the hope that it will be useful, but WITHOUT
  12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14 # version 2 for more details (a copy is included in the LICENSE file that
  15 # accompanied this code).
  16 #
  17 # You should have received a copy of the GNU General Public License version
  18 # 2 along with this work; if not, write to the Free Software Foundation,
  19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20 #
  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
  23 # questions.
  24 #
  25 
  26 #
  27 # Makefile to run tests from multiple sibling directories
  28 #
  29 
  30 # Macro to run a test target in a subdir
  31 define SUBDIR_TEST # subdirectory target
  32 if [ -d $1 ] ; then \
  33   if [ -r $1/Makefile ] ; then \
  34     $(MAKE) --no-print-directory -k -C $1 $2 ; \
  35   else \
  36     echo "ERROR: File does not exist: $1/Makefile"; \
  37     exit 1; \
  38   fi; \
  39 else \
  40   echo "WARNING: No testing done, directory does not exist: $1"; \
  41 fi
  42 endef
  43 
  44 # Default test target (core)
  45 default: jdk_core langtools_jtreg jaxp_all
  46 
  47 # All testing
  48 all: jdk_all langtools_all jaxp_all
  49 
  50 ifeq ($(TEST_JOBS), 0)
  51   ifeq ($(shell $(EXPR) $(JOBS) \> 50), 1)
  52     # JTReg cannot handle more than 50 in concurrency
  53     JDK_TEST_JOBS=50
  54   else
  55     JDK_TEST_JOBS=$(JOBS)
  56   endif
  57 else
  58   JDK_TEST_JOBS=$(TEST_JOBS)
  59 endif
  60 # Test targets
  61 langtools_% :
  62         @$(NO_STOPPING)$(call SUBDIR_TEST, langtools, \
  63             $(if $(JDK_TEST_JOBS), CONCURRENCY=$(JDK_TEST_JOBS)) \
  64             JT_JAVA=$(PRODUCT_HOME) JTREG_HOME=$(JT_HOME) \
  65             TEST="$(subst langtools_,,$@)" $(subst langtools_,,$@))
  66 
  67 jdk_% core_%s svc_%:
  68         @$(NO_STOPPING)$(call SUBDIR_TEST, jdk, \
  69             $(if $(JDK_TEST_JOBS), CONCURRENCY=$(JDK_TEST_JOBS)) TEST="$@" $@)
  70 
  71 jaxp_%:
  72         @$(NO_STOPPING)$(call SUBDIR_TEST, jaxp, \
  73             $(if $(JDK_TEST_JOBS), CONCURRENCY=$(JDK_TEST_JOBS)) TEST="$@" $@)
  74 
  75 nashorn_%:
  76         @$(NO_STOPPING)$(call SUBDIR_TEST, nashorn, \
  77             $(if $(JDK_TEST_JOBS), CONCURRENCY=$(JDK_TEST_JOBS)) TEST="$@" $@)
  78 
  79 SUB_MAKE_ARGS :=
  80 ifneq ($(TEST_JOBS), 0)
  81   ifneq ($(TEST_JOBS), )
  82     SUB_MAKE_ARGS += CONCURRENCY=$(TEST_JOBS)
  83   endif
  84 endif
  85 hotspot_%:
  86         @$(NO_STOPPING)$(call SUBDIR_TEST, hotspot/jtreg, $(SUB_MAKE_ARGS) TEST="$@" $@)
  87 
  88 #
  89 # jtreg_tests
  90 #
  91 # Invocation:
  92 #
  93 # make jtreg_tests TESTDIRS=<test-dirs> TEST_SELECTION=<path to test or jtreg group> TEST_OUTPUT_DIR=<path>
  94 #
  95 # where <test-dirs> is something like '../<component>/test/runtime',
  96 # <component> in turn being one of the top level directories (for
  97 # example 'hotspot').
  98 #
  99 # The below will strip the path prefix and delegate to the
 100 # corresponding ../<component>/test/Makefile.
 101 
 102 ifneq ($(TESTDIRS),)
 103   # Extract the component from ../test/<component>/...
 104   TESTDIRS_NORM := $(patsubst test/%, %, $(patsubst ../%, %, $(TESTDIRS)))
 105   COMPONENT := $(word 1,$(subst /, ,$(TESTDIRS_NORM)))
 106 
 107   # Strip off the ../<component>/test prefix and pass the rest as TESTDIRS
 108   # to the delegate Makefile
 109   # The hotspot tests are in a subdir "java". Accept paths both including
 110   # and excluding this extra subdir
 111   TESTDIRS_TESTS := $(patsubst $(COMPONENT)/%,%,$(patsubst hotspot/jtreg/%,%, \
 112       $(patsubst ../%, %, $(TESTDIRS_NORM))))
 113 endif
 114 
 115 jtreg_tests:
 116         $(MAKE) --no-print-directory TESTDIRS=$(TESTDIRS_TESTS) \
 117             $(COMPONENT)_jtreg_tests
 118 
 119 ################################################################
 120 
 121 # Phony targets (e.g. these are not filenames)
 122 .PHONY: all clean
 123 
 124 ################################################################