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, CONCURRENCY=$(JDK_TEST_JOBS) \
  63             JT_JAVA=$(PRODUCT_HOME) JTREG_HOME=$(JT_HOME) \
  64             TEST="$(subst langtools_,,$@)" $(subst langtools_,,$@))
  65 
  66 jdk_% core_%s svc_%:
  67         @$(NO_STOPPING)$(call SUBDIR_TEST, jdk, CONCURRENCY=$(JDK_TEST_JOBS) TEST="$@" $@)
  68 
  69 jaxp_%:
  70         @$(NO_STOPPING)$(call SUBDIR_TEST, jaxp, CONCURRENCY=$(JDK_TEST_JOBS) TEST="$@" $@)
  71 
  72 nashorn_%:
  73         @$(NO_STOPPING)$(call SUBDIR_TEST, nashorn, CONCURRENCY=$(JDK_TEST_JOBS) TEST="$@" $@)
  74 
  75 SUB_MAKE_ARGS :=
  76 ifneq ($(TEST_JOBS), 0)
  77   ifneq ($(TEST_JOBS), )
  78     SUB_MAKE_ARGS += CONCURRENCY=$(TEST_JOBS)
  79   endif
  80 endif
  81 hotspot_%:
  82         @$(NO_STOPPING)$(call SUBDIR_TEST, hotspot/jtreg, $(SUB_MAKE_ARGS) TEST="$@" $@)
  83 
  84 #
  85 # jtreg_tests
  86 #
  87 # Invocation:
  88 #
  89 # make jtreg_tests TESTDIRS=<test-dirs> TEST_SELECTION=<path to test or jtreg group> TEST_OUTPUT_DIR=<path>
  90 #
  91 # where <test-dirs> is something like '../<component>/test/runtime',
  92 # <component> in turn being one of the top level directories (for
  93 # example 'hotspot').
  94 #
  95 # The below will strip the path prefix and delegate to the
  96 # corresponding ../<component>/test/Makefile.
  97 
  98 ifneq ($(TESTDIRS),)
  99   # Extract the component from ../test/<component>/...
 100   TESTDIRS_NORM := $(patsubst test/%, %, $(patsubst ../%, %, $(TESTDIRS)))
 101   COMPONENT := $(word 1,$(subst /, ,$(TESTDIRS_NORM)))
 102 
 103   # Strip off the ../<component>/test prefix and pass the rest as TESTDIRS
 104   # to the delegate Makefile
 105   # The hotspot tests are in a subdir "java". Accept paths both including
 106   # and excluding this extra subdir
 107   TESTDIRS_TESTS := $(patsubst $(COMPONENT)/%,%,$(patsubst hotspot/jtreg/%,%, \
 108       $(patsubst ../%, %, $(TESTDIRS_NORM))))
 109 endif
 110 
 111 jtreg_tests:
 112         $(MAKE) --no-print-directory TESTDIRS=$(TESTDIRS_TESTS) \
 113             $(COMPONENT)_jtreg_tests
 114 
 115 ################################################################
 116 
 117 # Phony targets (e.g. these are not filenames)
 118 .PHONY: all clean
 119 
 120 ################################################################