jdk

Форк
0
/
RunTestsPrebuilt.gmk 
314 строк · 11.1 Кб
1
#
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.
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
# Initial bootstrapping, copied and stripped down from Makefile and Init.gmk
28
################################################################################
29

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)))
34
endif
35

36
# Locate this Makefile
37
ifeq ($(filter /%, $(lastword $(MAKEFILE_LIST))),)
38
  makefile_path := $(CURDIR)/$(strip $(lastword $(MAKEFILE_LIST)))
39
else
40
  makefile_path := $(lastword $(MAKEFILE_LIST))
41
endif
42
TOPDIR := $(strip $(patsubst %/make/, %, $(dir $(makefile_path))))
43

44
################################################################################
45
# Functions
46
################################################################################
47

48
# Setup a required or optional variable, and/or check that it is properly
49
# given.
50
# Note: No spaces are allowed around the arguments.
51
#
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
57
define SetupVariable
58
  ifeq ($$($1), )
59
    ifeq ($2, )
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)
65
      endif
66
    else
67
      ifneq ($$(findstring $$(LOG), info debug trace), )
68
        $$(info Prebuilt variable $1=$2 (default value))
69
      endif
70
      $1:=$2
71
    endif
72
  else
73
    ifneq ($$(findstring $$(LOG), info debug trace), )
74
      $$(info Prebuilt variable $1=$$($1))
75
    endif
76
  endif
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.
79
  ifeq ($3, MKDIR)
80
    ifneq ($$(findstring $$(LOG), info debug trace), )
81
      $$(info Creating directory for $1)
82
    endif
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:)
87
      $$(info '$$($1)')
88
      $$(error Cannot continue.)
89
    endif
90
  endif
91
endef
92

93
# Create an ephemeral spec file
94
#
95
# $1: The output file name
96
# $2..$N: The lines to output to the file
97
define CreateNewSpec
98
  $(if $(strip $(33)), \
99
    $(error Internal makefile error: \
100
      Too many arguments to macro, please update CreateNewSpec in RunTestsPrebuilt.gmk) \
101
  ) \
102
  $(shell $(RM) $1) \
103
  $(foreach i, $(call sequence, 2, 32), \
104
    $(if $(strip $($i)), \
105
      $(call AppendFile, $(strip $($i)), $1) \
106
    ) \
107
  )
108
endef
109

110
################################################################################
111
# Check input and setup basic buildsystem support
112
################################################################################
113

114
# Verify that user has given correct additional input.
115

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))
120

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)))
126

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))
130

131
# Check optional variables
132
$(eval $(call SetupVariable,JIB_JAR,OPTIONAL))
133

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
137
# CreateNewSpec.
138
HAS_SPEC :=
139
include $(TOPDIR)/make/InitSupport.gmk
140

141
$(eval $(call CheckDeprecatedEnvironment))
142
$(eval $(call CheckInvalidMakeFlags))
143
$(eval $(call ParseLogLevel))
144

145
SPEC := $(TOPDIR)/make/RunTestsPrebuiltSpec.gmk
146
include $(SPEC)
147
include $(TOPDIR)/make/common/MakeBase.gmk
148

149
################################################################################
150
# Determine what platform we're running on
151
################################################################################
152
UNAME := uname
153

154
# Get OS name from uname (Cygwin inexplicably adds _NT-x.x)
155
UNAME_OS := $(shell $(UNAME) -s | $(CUT) -f1 -d_)
156

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
165
else
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
171
  else
172
    OPENJDK_TARGET_OS := $(UNAME_OS)
173
  endif
174
  OPENJDK_TARGET_OS_ENV := $(OPENJDK_TARGET_OS)
175
endif
176

177
# Sanity check env detection
178
$(info Detected target OS, type and env: [$(OPENJDK_TARGET_OS)] [$(OPENJDK_TARGET_OS_TYPE)] [$(OPENJDK_TARGET_OS_ENV)])
179

180
# Assume little endian unless otherwise specified
181
OPENJDK_TARGET_CPU_ENDIAN := little
182

183
UNAME_CPU := $(shell $(UNAME) -m)
184
ifeq ($(UNAME_CPU), i686)
185
  OPENJDK_TARGET_CPU := x86
186
  OPENJDK_TARGET_CPU_BITS := 32
187
else
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
192
endif
193

194
OPENJDK_TARGET_CPU_ARCH := $(OPENJDK_TARGET_CPU)
195
ifeq ($(OPENJDK_TARGET_CPU), x86_64)
196
  OPENJDK_TARGET_CPU_ARCH := x86
197
endif
198

199
ifeq ($(OPENJDK_TARGET_OS), windows)
200
  FIXPATH_BASE := $(BASH) $(TOPDIR)/make/scripts/fixpath.sh
201
  FIXPATH := $(FIXPATH_BASE) exec
202
else
203
  FIXPATH_BASE :=
204
  FIXPATH :=
205
endif
206

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 \
212
  )
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 \
222
  )
223
endif
224
ifeq ($(NUM_CORES), )
225
  $(warn Could not find number of CPUs, assuming 1)
226
  NUM_CORES := 1
227
endif
228
ifeq ($(MEMORY_SIZE), )
229
  $(warn Could not find memory size, assuming 1024 MB)
230
  MEMORY_SIZE := 1024
231
endif
232

233
ifneq ($(wildcard $(JDK_IMAGE_DIR)/template.xml), )
234
  TEST_OPTS_JCOV := true
235
  JCOV_IMAGE_DIR := $(JDK_IMAGE_DIR)
236
else
237
  TEST_OPTS_JCOV := false
238
  JCOV_IMAGE_DIR :=
239
endif
240

241
################################################################################
242
# Generate the ephemeral spec file
243
################################################################################
244

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
249
endif
250

251
NEW_SPEC := $(OUTPUTDIR)/run-test-spec.gmk
252

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), \
265
    MAKE := $(MAKE), \
266
    BASH := $(BASH), \
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), \
282
)
283

284
################################################################################
285
# The run-test-prebuilt target
286
################################################################################
287

288
SPEC := $(NEW_SPEC)
289

290
default: all
291

292
test-prebuilt:
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 \
305
	    TEST="$(TEST)"
306

307
test-prebuilt-with-exit-code: test-prebuilt
308
	@if test -f $(MAKESUPPORT_OUTPUTDIR)/exit-with-error ; then \
309
	  exit 1 ; \
310
	fi
311

312
all: test-prebuilt
313

314
.PHONY: default all test-prebuilt
315

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.