1 #
   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.
   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 NATIVE_TEST_PATH := hotspot/jtreg/native
  28 
  29 TREAT_EXIT_CODE_1_AS_0 := true
  30 
  31 CLEAN_BEFORE_PREP := true
  32 
  33 USE_JTREG_VERSION := 4.1
  34 
  35 USE_JTREG_ASSERT := false
  36 
  37 LIMIT_JTREG_VM_MEMORY := false
  38 
  39 IGNORE_MARKED_TESTS := true
  40 
  41 # Get OS name from uname (Cygwin inexplicably adds _NT-5.1)
  42 UNAME_S := $(shell uname -s | cut -f1 -d_)
  43 
  44 ifeq ($(UNAME_S), SunOS)
  45   NUM_CORES := $(shell LC_MESSAGES=C /usr/sbin/psrinfo -v | grep -c on-line)
  46 endif
  47 ifeq ($(UNAME_S), Linux)
  48   NUM_CORES := $(shell cat /proc/cpuinfo  | grep -c processor)
  49 endif
  50 ifeq ($(UNAME_S), Darwin)
  51   NUM_CORES := $(shell /usr/sbin/sysctl -n hw.ncpu)
  52 endif
  53 ifeq ($(findstring CYGWIN,$(UNAME_S)), CYGWIN)
  54   ifneq ($(NUMBER_OF_PROCESSORS), )
  55     NUM_CORES := $(NUMBER_OF_PROCESSORS)
  56   else
  57     ifneq ($(HOTSPOT_BUILD_JOBS), )
  58       NUM_CORES := $(HOTSPOT_BUILD_JOBS)
  59     else
  60       NUM_CORES := 1 # fallback
  61     endif
  62   endif
  63 endif
  64 
  65 # Concurrency based on min(cores / 2, 12)
  66 CONCURRENCY := $(shell expr $(NUM_CORES) / 2)
  67 ifeq ($(CONCURRENCY), 0)
  68   CONCURRENCY := 1
  69 else ifeq ($(shell expr $(CONCURRENCY) \> 12), 1)
  70   CONCURRENCY := 12
  71 endif
  72 
  73 # Make sure MaxRAMFraction is high enough to not cause OOM or swapping since we may end up with a lot of JVM's
  74 JTREG_BASIC_OPTIONS += -vmoption:-XX:MaxRAMFraction=$(shell expr $(CONCURRENCY) \* 4)
  75 
  76 # Include the common base file with most of the logic
  77 include ../../test/TestCommon.gmk
  78 
  79 ################################################################
  80 # Default make rule (runs jtreg_tests)
  81 all: hotspot_all
  82         @$(ECHO) "Testing completed successfully"
  83 
  84 # Support "hotspot_" prefixed test make targets (too)
  85 # The hotspot_% targets are used by the top level Makefile
  86 # Unless explicitly defined below, hotspot_<x> is interpreted as a jtreg test group name
  87 hotspot_%:
  88         $(ECHO) "Running tests: $@"
  89         $(MAKE) -j 1 TEST_SELECTION=":$@" UNIQUE_DIR=$@ jtreg_tests;
  90 
  91 hotspot_internal:
  92         $(ALT_OUTPUTDIR)/jdk/bin/java -XX:+ExecuteInternalVMTests -XX:+ShowMessageBoxOnError -version
  93 
  94 ################################################################
  95 ALT_MAKE ?= closed
  96 -include $(ALT_MAKE)/Makefile
  97 
  98 # Make sure jtreg exists
  99 $(JTREG): $(JT_HOME)
 100 
 101 jtreg_tests: prep $(PRODUCT_HOME) $(JTREG)
 102         (                                                                    \
 103           ( JT_HOME=$(shell $(GETMIXEDPATH) "$(JT_HOME)");                   \
 104             export JT_HOME;                                                  \
 105             $(shell $(GETMIXEDPATH) "$(JTREG)")                              \
 106               $(JTREG_BASIC_OPTIONS)                                         \
 107               -r:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTreport")  \
 108               -w:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTwork")    \
 109               -jdk:$(shell $(GETMIXEDPATH) "$(PRODUCT_HOME)")                \
 110               $(JTREG_NATIVE_PATH)                                           \
 111               $(JTREG_FAILURE_HANDLER_OPTIONS)                               \
 112               $(JTREG_EXCLUSIONS)                                            \
 113               $(JTREG_TEST_OPTIONS)                                          \
 114               $(TEST_SELECTION)                                              \
 115           ) ;                                                                \
 116           $(BUNDLE_UP_AND_EXIT)                                              \
 117         ) 2>&1 | $(TEE) $(ABS_TEST_OUTPUT_DIR)/output.txt ; $(TESTEXIT)
 118 
 119 PHONY_LIST += jtreg_tests
 120 
 121 # flags used to execute java in test targets
 122 TEST_FLAGS += -version -Xinternalversion -X -help
 123 
 124 sanitytest: prep $(PRODUCT_HOME)
 125         @for flag in $(TEST_FLAGS);                                             \
 126         do                                                                      \
 127             echo Executing java $(JAVA_OPTIONS) $$flag;                         \
 128             $(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) $$flag;                    \
 129             res=$$?;                                                            \
 130             if [ $$res -ne 0 ]; then                                            \
 131                 exit $$res;                                                     \
 132             fi;                                                                 \
 133         done
 134 
 135 PHONY_LIST += sanitytest
 136 
 137 ################################################################
 138 
 139 # basicvmtest (make sure various basic java options work)
 140 
 141 # Set up the directory in which the jvm directories live (client/, server/, etc.)
 142 ifeq ($(PLATFORM),windows)
 143 JVMS_DIR := $(PRODUCT_HOME)/bin
 144 else
 145 JVMS_DIR := $(PRODUCT_HOME)/lib
 146 endif
 147 
 148 # Use the existance of a directory as a sign that jvm variant is available
 149 CANDIDATE_JVM_VARIANTS := client minimal server
 150 JVM_VARIANTS := $(strip $(foreach x,$(CANDIDATE_JVM_VARIANTS),$(if $(wildcard $(JVMS_DIR)/$(x)),$(x))))
 151 
 152 hotspot_basicvmtest:
 153         for variant in $(JVM_VARIANTS);                                           \
 154         do                                                                        \
 155             $(MAKE) JAVA_ARGS="$(JAVA_ARGS) -$$variant" hotspot_$${variant}test;  \
 156             res=$$?;                                                              \
 157             if [ $$res -ne 0 ]; then                                              \
 158                 exit $$res;                                                       \
 159             fi;                                                                   \
 160         done
 161 
 162 PHONY_LIST += hotspot_basicvmtest
 163 
 164 ################################################################
 165 
 166 # clienttest (make sure various basic java client options work)
 167 
 168 hotspot_clienttest clienttest: sanitytest
 169         $(RM) $(PRODUCT_HOME)/jre/lib/*/client/classes.jsa
 170         $(RM) $(PRODUCT_HOME)/jre/bin/client/classes.jsa
 171         $(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -Xshare:dump
 172 
 173 PHONY_LIST += hotspot_clienttest clienttest
 174 
 175 ################################################################
 176 
 177 # minimaltest (make sure various basic java minimal options work)
 178 
 179 hotspot_minimaltest minimaltest: sanitytest
 180 
 181 PHONY_LIST += hotspot_minimaltest minimaltest
 182 
 183 ################################################################
 184 
 185 # servertest (make sure various basic java server options work)
 186 
 187 hotspot_servertest servertest: sanitytest
 188 
 189 PHONY_LIST += hotspot_servertest servertest
 190 
 191 ################################################################
 192 
 193 # Run the native gtest tests from the test image
 194 
 195 define NEWLINE
 196 
 197 
 198 endef
 199 
 200 
 201 hotspot_gtest:
 202         $(foreach v, $(JVM_VARIANTS), \
 203           $(MAKE) hotspot_gtest$v $(NEWLINE) )
 204 
 205 hotspot_gtestserver hotspot_gtestclient hotspot_gtestminimal: hotspot_gtest%:
 206         $(TESTNATIVE_DIR)/hotspot/gtest/$*/gtestLauncher \
 207             -jdk $(shell $(GETMIXEDPATH) "$(PRODUCT_HOME)")
 208 
 209 PHONY_LIST += hotspot_gtest hotspot_gtestserver hotspot_gtestclient \
 210     hotspot_gtestminimal