2
# Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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.
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).
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.
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
26
################################################################################
27
# Initial bootstrapping, copied and stripped down from Makefile and Init.gmk
28
################################################################################
30
# In Cygwin, the MAKE variable gets prepended with the current directory if the
31
# make executable is called using a Windows mixed path (c:/cygwin/bin/make.exe).
32
ifneq ($(findstring :, $(MAKE)), )
33
export MAKE := $(patsubst $(CURDIR)%, %, $(patsubst $(CURDIR)/%, %, $(MAKE)))
37
ifeq ($(filter /%, $(lastword $(MAKEFILE_LIST))),)
38
makefile_path := $(CURDIR)/$(strip $(lastword $(MAKEFILE_LIST)))
40
makefile_path := $(lastword $(MAKEFILE_LIST))
42
TOPDIR := $(strip $(patsubst %/make/, %, $(dir $(makefile_path))))
44
################################################################################
46
################################################################################
48
# Setup a required or optional variable, and/or check that it is properly
50
# Note: No spaces are allowed around the arguments.
52
# $1: The name of the variable
53
# $2: The default value, if any, or OPTIONAL (do not provide a default but
54
# do not exit if it is missing)
55
# $3: If NO_CHECK, disable checking for target file/directory existence
56
# If MKDIR, create the default directory
60
$$(info Error: Prebuilt variable $1 is missing, needed for run-tests-prebuilt)
61
$$(error Cannot continue.)
62
else ifeq ($2, OPTIONAL)
63
ifneq ($$(findstring $$(LOG), info debug trace), )
64
$$(info Prebuilt variable $1 is not provided)
67
ifneq ($$(findstring $$(LOG), info debug trace), )
68
$$(info Prebuilt variable $1=$2 (default value))
73
ifneq ($$(findstring $$(LOG), info debug trace), )
74
$$(info Prebuilt variable $1=$$($1))
77
# If $1 has a value (is not optional), and $3 is not set (to NO_CHECK),
78
# and if wildcard is empty, then complain that the file is missing.
80
ifneq ($$(findstring $$(LOG), info debug trace), )
81
$$(info Creating directory for $1)
83
$$(shell mkdir -p $$($1))
84
else ifneq ($3, NO_CHECK)
85
ifeq ($$(strip $$(if $$($1), , OPTIONAL) $$(wildcard $$($1))), )
86
$$(info Error: Prebuilt variable $1 points to missing file/directory:)
88
$$(error Cannot continue.)
93
# Create an ephemeral spec file
95
# $1: The output file name
96
# $2..$N: The lines to output to the file
98
$(if $(strip $(33)), \
99
$(error Internal makefile error: \
100
Too many arguments to macro, please update CreateNewSpec in RunTestsPrebuilt.gmk) \
103
$(foreach i, $(call sequence, 2, 32), \
104
$(if $(strip $($i)), \
105
$(call AppendFile, $(strip $($i)), $1) \
110
################################################################################
111
# Check input and setup basic buildsystem support
112
################################################################################
114
# Verify that user has given correct additional input.
116
# These variables are absolutely necessary
117
$(eval $(call SetupVariable,OUTPUTDIR,$(TOPDIR)/build/run-test-prebuilt,MKDIR))
118
$(eval $(call SetupVariable,BOOT_JDK))
119
$(eval $(call SetupVariable,JT_HOME))
121
# These can have default values based on the ones above
122
$(eval $(call SetupVariable,JDK_IMAGE_DIR,$(OUTPUTDIR)/images/jdk))
123
$(eval $(call SetupVariable,TEST_IMAGE_DIR,$(OUTPUTDIR)/images/test))
124
$(eval $(call SetupVariable,SYMBOLS_IMAGE_DIR,$(OUTPUTDIR)/images/symbols,NO_CHECK))
125
$(eval $(call SetupVariable,JTREG_JDK,$(BOOT_JDK)))
127
# Provide default values for tools that we need
128
$(eval $(call SetupVariable,MAKE,make,NO_CHECK))
129
$(eval $(call SetupVariable,BASH,bash,NO_CHECK))
131
# Check optional variables
132
$(eval $(call SetupVariable,JIB_JAR,OPTIONAL))
134
# Now that we have verified that we have the required variables available, we
135
# can include the prebuilt spec file ourselves, without an ephemeral spec
136
# wrapper. This is required so we can include MakeBase which is needed for
139
include $(TOPDIR)/make/InitSupport.gmk
141
$(eval $(call CheckDeprecatedEnvironment))
142
$(eval $(call CheckInvalidMakeFlags))
143
$(eval $(call ParseLogLevel))
145
SPEC := $(TOPDIR)/make/RunTestsPrebuiltSpec.gmk
147
include $(TOPDIR)/make/common/MakeBase.gmk
149
################################################################################
150
# Determine what platform we're running on
151
################################################################################
154
# Get OS name from uname (Cygwin inexplicably adds _NT-x.x)
155
UNAME_OS := $(shell $(UNAME) -s | $(CUT) -f1 -d_)
157
ifeq ($(UNAME_OS), CYGWIN)
158
OPENJDK_TARGET_OS := windows
159
OPENJDK_TARGET_OS_TYPE := windows
160
OPENJDK_TARGET_OS_ENV := windows.cygwin
161
else ifeq ($(UNAME_OS), MINGW64)
162
OPENJDK_TARGET_OS := windows
163
OPENJDK_TARGET_OS_TYPE := windows
164
OPENJDK_TARGET_OS_ENV := windows.msys2
166
OPENJDK_TARGET_OS_TYPE:=unix
167
ifeq ($(UNAME_OS), Linux)
168
OPENJDK_TARGET_OS := linux
169
else ifeq ($(UNAME_OS), Darwin)
170
OPENJDK_TARGET_OS := macosx
172
OPENJDK_TARGET_OS := $(UNAME_OS)
174
OPENJDK_TARGET_OS_ENV := $(OPENJDK_TARGET_OS)
177
# Sanity check env detection
178
$(info Detected target OS, type and env: [$(OPENJDK_TARGET_OS)] [$(OPENJDK_TARGET_OS_TYPE)] [$(OPENJDK_TARGET_OS_ENV)])
180
# Assume little endian unless otherwise specified
181
OPENJDK_TARGET_CPU_ENDIAN := little
183
UNAME_CPU := $(shell $(UNAME) -m)
184
ifeq ($(UNAME_CPU), i686)
185
OPENJDK_TARGET_CPU := x86
186
OPENJDK_TARGET_CPU_BITS := 32
188
# Assume all others are 64-bit. We use the same CPU name as uname for
189
# at least x86_64 and aarch64.
190
OPENJDK_TARGET_CPU := $(UNAME_CPU)
191
OPENJDK_TARGET_CPU_BITS := 64
194
OPENJDK_TARGET_CPU_ARCH := $(OPENJDK_TARGET_CPU)
195
ifeq ($(OPENJDK_TARGET_CPU), x86_64)
196
OPENJDK_TARGET_CPU_ARCH := x86
199
ifeq ($(OPENJDK_TARGET_OS), windows)
200
FIXPATH_BASE := $(BASH) $(TOPDIR)/make/scripts/fixpath.sh
201
FIXPATH := $(FIXPATH_BASE) exec
207
# Check number of cores and memory in MB
208
ifeq ($(OPENJDK_TARGET_OS), linux)
209
NUM_CORES := $(shell $(CAT) /proc/cpuinfo | $(GREP) -c processor)
210
MEMORY_SIZE := $(shell \
211
$(EXPR) `$(CAT) /proc/meminfo | $(GREP) MemTotal | $(AWK) '{print $$2}'` / 1024 \
213
else ifeq ($(OPENJDK_TARGET_OS), macosx)
214
NUM_CORES := $(shell /usr/sbin/sysctl -n hw.ncpu)
215
MEMORY_SIZE := $(shell $(EXPR) `/usr/sbin/sysctl -n hw.memsize` / 1024 / 1024)
216
else ifeq ($(OPENJDK_TARGET_OS), windows)
217
NUM_CORES := $(NUMBER_OF_PROCESSORS)
218
MEMORY_SIZE := $(shell \
219
$(EXPR) `wmic computersystem get totalphysicalmemory -value \
220
| $(GREP) = | $(SED) 's/\\r//g' \
221
| $(CUT) -d "=" -f 2-` / 1024 / 1024 \
225
$(warn Could not find number of CPUs, assuming 1)
228
ifeq ($(MEMORY_SIZE), )
229
$(warn Could not find memory size, assuming 1024 MB)
233
ifneq ($(wildcard $(JDK_IMAGE_DIR)/template.xml), )
234
TEST_OPTS_JCOV := true
235
JCOV_IMAGE_DIR := $(JDK_IMAGE_DIR)
237
TEST_OPTS_JCOV := false
241
################################################################################
242
# Generate the ephemeral spec file
243
################################################################################
245
# Now we can include additional custom support.
246
# This might define CUSTOM_NEW_SPEC_LINE
247
ifneq ($(CUSTOM_MAKE_DIR), )
248
include $(CUSTOM_MAKE_DIR)/RunTestsPrebuilt.gmk
251
NEW_SPEC := $(OUTPUTDIR)/run-test-spec.gmk
253
$(call CreateNewSpec, $(NEW_SPEC), \
254
# Generated file -- do not edit!, \
255
SPEC := $(NEW_SPEC), \
256
TOPDIR := $(TOPDIR), \
257
OUTPUTDIR := $(OUTPUTDIR), \
258
BOOT_JDK := $(BOOT_JDK), \
259
JTREG_JDK := $(JTREG_JDK), \
260
JT_HOME := $(JT_HOME), \
261
JDK_IMAGE_DIR := $(JDK_IMAGE_DIR), \
262
JCOV_IMAGE_DIR := $(JCOV_IMAGE_DIR), \
263
TEST_IMAGE_DIR := $(TEST_IMAGE_DIR), \
264
SYMBOLS_IMAGE_DIR := $(SYMBOLS_IMAGE_DIR), \
267
JIB_JAR := $(JIB_JAR), \
268
FIXPATH_BASE := $(FIXPATH_BASE), \
269
FIXPATH := $(FIXPATH), \
270
OPENJDK_TARGET_OS := $(OPENJDK_TARGET_OS), \
271
OPENJDK_TARGET_OS_TYPE := $(OPENJDK_TARGET_OS_TYPE), \
272
OPENJDK_TARGET_OS_ENV := $(OPENJDK_TARGET_OS_ENV), \
273
OPENJDK_TARGET_CPU := $(OPENJDK_TARGET_CPU), \
274
OPENJDK_TARGET_CPU_ARCH := $(OPENJDK_TARGET_CPU_ARCH), \
275
OPENJDK_TARGET_CPU_BITS := $(OPENJDK_TARGET_CPU_BITS), \
276
OPENJDK_TARGET_CPU_ENDIAN := $(OPENJDK_TARGET_CPU_ENDIAN), \
277
NUM_CORES := $(NUM_CORES), \
278
MEMORY_SIZE := $(MEMORY_SIZE), \
279
include $(TOPDIR)/make/RunTestsPrebuiltSpec.gmk, \
280
TEST_OPTS_JCOV := $(TEST_OPTS_JCOV), \
281
$(CUSTOM_NEW_SPEC_LINE), \
284
################################################################################
285
# The run-test-prebuilt target
286
################################################################################
293
# Need to make sure the failure logs output dir exists since
294
# ExecuteWithLog is called in RunTests.gmk. The PrepareFailureLogs macro
295
# is unfortunately not available at this point.
296
$(call MakeDir, $(MAKESUPPORT_OUTPUTDIR)/failure-logs)
297
@$(RM) -f $(MAKESUPPORT_OUTPUTDIR)/exit-with-error
298
# The lazy initialization of the cache file in FindTests.gmk does not
299
# always work with RunTests.gmk. To guarantee that the jtreg test groups
300
# are always found and parsed, call FindTests.gmk stand alone once
301
# before calling RunTests.gmk.
302
@cd $(TOPDIR) && $(MAKE) $(MAKE_ARGS) -f make/common/FindTests.gmk \
303
SPEC=$(SPEC) FINDTESTS_STAND_ALONE=true
304
@cd $(TOPDIR) && $(MAKE) $(MAKE_ARGS) -f make/RunTests.gmk run-test \
307
test-prebuilt-with-exit-code: test-prebuilt
308
@if test -f $(MAKESUPPORT_OUTPUTDIR)/exit-with-error ; then \
314
.PHONY: default all test-prebuilt