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 # flags used to execute java in test targets
  99 TEST_FLAGS += -version -Xinternalversion -X -help
 100 
 101 sanitytest: prep $(PRODUCT_HOME)
 102         @for flag in $(TEST_FLAGS);                                             \
 103         do                                                                      \
 104             echo Executing java $(JAVA_OPTIONS) $$flag;                         \
 105             $(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) $$flag;                    \
 106             res=$$?;                                                            \
 107             if [ $$res -ne 0 ]; then                                            \
 108                 exit $$res;                                                     \
 109             fi;                                                                 \
 110         done
 111 
 112 PHONY_LIST += sanitytest
 113 
 114 ################################################################
 115 
 116 # basicvmtest (make sure various basic java options work)
 117 
 118 # Set up the directory in which the jvm directories live (client/, server/, etc.)
 119 ifeq ($(PLATFORM),windows)
 120 JVMS_DIR := $(PRODUCT_HOME)/bin
 121 else
 122 JVMS_DIR := $(PRODUCT_HOME)/lib
 123 endif
 124 
 125 # Use the existance of a directory as a sign that jvm variant is available
 126 CANDIDATE_JVM_VARIANTS := client minimal server
 127 JVM_VARIANTS := $(strip $(foreach x,$(CANDIDATE_JVM_VARIANTS),$(if $(wildcard $(JVMS_DIR)/$(x)),$(x))))
 128 
 129 hotspot_basicvmtest:
 130         for variant in $(JVM_VARIANTS);                                           \
 131         do                                                                        \
 132             $(MAKE) JAVA_ARGS="$(JAVA_ARGS) -$$variant" hotspot_$${variant}test;  \
 133             res=$$?;                                                              \
 134             if [ $$res -ne 0 ]; then                                              \
 135                 exit $$res;                                                       \
 136             fi;                                                                   \
 137         done
 138 
 139 PHONY_LIST += hotspot_basicvmtest
 140 
 141 ################################################################
 142 
 143 # clienttest (make sure various basic java client options work)
 144 
 145 hotspot_clienttest clienttest: sanitytest
 146         $(RM) $(PRODUCT_HOME)/jre/lib/*/client/classes.jsa
 147         $(RM) $(PRODUCT_HOME)/jre/bin/client/classes.jsa
 148         $(PRODUCT_HOME)/bin/java $(JAVA_OPTIONS) -Xshare:dump
 149 
 150 PHONY_LIST += hotspot_clienttest clienttest
 151 
 152 ################################################################
 153 
 154 # minimaltest (make sure various basic java minimal options work)
 155 
 156 hotspot_minimaltest minimaltest: sanitytest
 157 
 158 PHONY_LIST += hotspot_minimaltest minimaltest
 159 
 160 ################################################################
 161 
 162 # servertest (make sure various basic java server options work)
 163 
 164 hotspot_servertest servertest: sanitytest
 165 
 166 PHONY_LIST += hotspot_servertest servertest
 167 
 168 ################################################################
 169 
 170 # Run the native gtest tests from the test image
 171 
 172 define NEWLINE
 173 
 174 
 175 endef
 176 
 177 
 178 hotspot_gtest:
 179         $(foreach v, $(JVM_VARIANTS), \
 180           $(MAKE) hotspot_gtest$v $(NEWLINE) )
 181 
 182 hotspot_gtestserver hotspot_gtestclient hotspot_gtestminimal: hotspot_gtest%:
 183         $(TESTNATIVE_DIR)/hotspot/gtest/$*/gtestLauncher \
 184             -jdk $(shell $(GETMIXEDPATH) "$(PRODUCT_HOME)")
 185 
 186 PHONY_LIST += hotspot_gtest hotspot_gtestserver hotspot_gtestclient \
 187     hotspot_gtestminimal