author | ihse |
Mon, 27 Nov 2017 12:29:28 +0100 | |
branch | ihse-testmakefiles-branch |
changeset 55882 | 79c94bfb654e |
parent 47932 | 0c22f6b9b5e2 |
child 47937 | c1437939b0d8 |
permissions | -rw-r--r-- |
44027 | 1 |
# |
2 |
# Copyright (c) 2016, 2017, 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 |
default: all |
|
27 |
||
28 |
include $(SPEC) |
|
29 |
include MakeBase.gmk |
|
30 |
include FindTests.gmk |
|
31 |
||
32 |
# We will always run multiple tests serially |
|
33 |
.NOTPARALLEL: |
|
34 |
||
35 |
# Hook to include the corresponding custom file, if present. |
|
47314 | 36 |
$(eval $(call IncludeCustomExtension, RunTests.gmk)) |
44027 | 37 |
|
47253
92fd0e04e0e1
8187544: Replace BUILD_OUTPUT and OUTPUT_ROOT with OUTPUTDIR
ihse
parents:
47218
diff
changeset
|
38 |
TEST_RESULTS_DIR := $(OUTPUTDIR)/test-results |
92fd0e04e0e1
8187544: Replace BUILD_OUTPUT and OUTPUT_ROOT with OUTPUTDIR
ihse
parents:
47218
diff
changeset
|
39 |
TEST_SUPPORT_DIR := $(OUTPUTDIR)/test-support |
44027 | 40 |
|
41 |
||
42 |
################################################################################ |
|
43 |
# Parse control variables |
|
44 |
################################################################################ |
|
45 |
||
46 |
$(eval $(call ParseKeywordVariable, JTREG, \ |
|
47 |
KEYWORDS := JOBS TIMEOUT TEST_MODE ASSERT VERBOSE RETAIN MAX_MEM, \ |
|
48 |
STRING_KEYWORDS := OPTIONS JAVA_OPTIONS VM_OPTIONS, \ |
|
49 |
)) |
|
50 |
||
51 |
ifneq ($(JTREG), ) |
|
52 |
# Inform the user |
|
53 |
$(info Running tests using JTREG control variable '$(JTREG)') |
|
54 |
endif |
|
55 |
||
56 |
$(eval $(call ParseKeywordVariable, GTEST, \ |
|
57 |
KEYWORDS := REPEAT, \ |
|
58 |
STRING_KEYWORDS := OPTIONS, \ |
|
59 |
)) |
|
60 |
||
61 |
ifneq ($(GTEST), ) |
|
62 |
# Inform the user |
|
63 |
$(info Running tests using GTEST control variable '$(GTEST)') |
|
64 |
endif |
|
65 |
||
66 |
||
67 |
################################################################################ |
|
68 |
# Component-specific Jtreg settings |
|
69 |
################################################################################ |
|
70 |
||
71 |
ifeq ($(TEST_JOBS), 0) |
|
72 |
# If TEST_JOBS is not specified, hotspot fallback default is |
|
73 |
# min(num_cores / 2, 12). |
|
74 |
hotspot_JTREG_JOBS := $(shell $(EXPR) $(NUM_CORES) / 2) |
|
75 |
ifeq ($(hotspot_JTREG_JOBS), 0) |
|
76 |
hotspot_JTREG_JOBS := 1 |
|
77 |
else ifeq ($(shell $(EXPR) $(hotspot_JTREG_JOBS) \> 12), 1) |
|
78 |
hotspot_JTREG_JOBS := 12 |
|
79 |
endif |
|
80 |
endif |
|
81 |
||
82 |
hotspot_JTREG_MAX_MEM := 0 |
|
83 |
hotspot_JTREG_ASSERT := false |
|
84 |
hotspot_JTREG_NATIVEPATH := $(TEST_IMAGE_DIR)/hotspot/jtreg/native |
|
85 |
jdk_JTREG_NATIVEPATH := $(TEST_IMAGE_DIR)/jdk/jtreg/native |
|
86 |
||
87 |
||
88 |
################################################################################ |
|
89 |
# Parse test selection |
|
90 |
# |
|
91 |
# The user has given a test selection in the TEST variable. We must parse it |
|
92 |
# and determine what that means in terms of actual calls to the test framework. |
|
93 |
# |
|
94 |
# The parse functions take as argument a test specification as given by the |
|
95 |
# user, and returns a fully qualified test descriptor if it was a match, or |
|
96 |
# nothing if not. A single test specification can result in multiple test |
|
97 |
# descriptors being returned. A valid test descriptor must always be accepted |
|
98 |
# and returned identically. |
|
99 |
################################################################################ |
|
100 |
||
101 |
# Helper function to determine if a test specification is a Gtest test |
|
102 |
# |
|
103 |
# It is a Gtest test if it is either "gtest", or "gtest:" followed by an optional |
|
104 |
# test filter string. |
|
105 |
define ParseGtestTestSelection |
|
106 |
$(if $(filter gtest%, $1), \ |
|
107 |
$(if $(filter gtest, $1), \ |
|
108 |
gtest:all \ |
|
109 |
, \ |
|
110 |
$(if $(filter gtest:, $1), \ |
|
111 |
gtest:all \ |
|
112 |
, \ |
|
113 |
$1 \ |
|
114 |
) \ |
|
115 |
) \ |
|
116 |
) |
|
117 |
endef |
|
118 |
||
47932
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
119 |
# Take a partial Jtreg root path and return a full, absolute path to that Jtreg |
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
120 |
# root. Also support having "hotspot" as an alias for "hotspot/jtreg". |
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
121 |
ExpandJtregRoot = \ |
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
122 |
$(strip $(wildcard $(patsubst %/, %, \ |
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
123 |
$(if $(filter /%, $1), \ |
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
124 |
$1 \ |
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
125 |
, \ |
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
126 |
$(filter $(addprefix %, $1), $(JTREG_TESTROOTS) $(addsuffix /, $(JTREG_TESTROOTS))) \ |
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
127 |
$(filter $(addprefix %, $(strip $1)/jtreg), $(JTREG_TESTROOTS) $(addsuffix /, $(JTREG_TESTROOTS))) \ |
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
128 |
) \ |
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
129 |
))) |
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
130 |
|
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
131 |
# Take a partial Jtreg test path and return a full, absolute path to that Jtreg |
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
132 |
# test. Also support having "hotspot" as an alias for "hotspot/jtreg". |
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
133 |
ExpandJtregPath = \ |
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
134 |
$(if $(call ExpandJtregRoot, $1), \ |
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
135 |
$(call ExpandJtregRoot, $1) \ |
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
136 |
, \ |
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
137 |
$(strip $(wildcard $(patsubst %/, %, \ |
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
138 |
$(if $(filter /%, $1), \ |
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
139 |
$1 \ |
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
140 |
, \ |
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
141 |
$(addsuffix /$(strip $1), $(JTREG_TESTROOTS) $(TEST_BASEDIRS)) \ |
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
142 |
$(addsuffix $(strip $(patsubst hotspot/%, /hotspot/jtreg/%, $1)), $(JTREG_TESTROOTS) $(TEST_BASEDIRS)) \ |
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
143 |
) \ |
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
144 |
))) \ |
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
145 |
) |
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
146 |
|
44027 | 147 |
# Helper function to determine if a test specification is a Jtreg test |
148 |
# |
|
149 |
# It is a Jtreg test if it optionally begins with jtreg:, and then is either |
|
150 |
# an unspecified group name (possibly prefixed by :), or a group in a |
|
47932
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
151 |
# specified test root, or a path to a test or test directory, |
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
152 |
# either absolute or relative to any of the TEST_BASEDIRS or test roots. |
44027 | 153 |
define ParseJtregTestSelection |
154 |
$(eval TEST_NAME := $(strip $(patsubst jtreg:%, %, $1))) \ |
|
155 |
$(if $(or $(findstring :, $(TEST_NAME)), $(findstring /, $(TEST_NAME))), , \ |
|
156 |
$(eval TEST_NAME := :$(TEST_NAME)) \ |
|
157 |
) \ |
|
158 |
$(if $(findstring :, $(TEST_NAME)), \ |
|
159 |
$(if $(filter :%, $(TEST_NAME)), \ |
|
47932
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
160 |
$(eval TEST_GROUP := $(patsubst :%, %, $(TEST_NAME))) \ |
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
161 |
$(eval TEST_ROOTS := $(JTREG_TESTROOTS)) \ |
44027 | 162 |
, \ |
47932
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
163 |
$(eval TEST_PATH := $(word 1, $(subst :, $(SPACE), $(TEST_NAME)))) \ |
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
164 |
$(eval TEST_GROUP := $(word 2, $(subst :, $(SPACE), $(TEST_NAME)))) \ |
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
165 |
$(eval TEST_ROOTS := $(call ExpandJtregRoot, $(TEST_PATH))) \ |
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
166 |
) \ |
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
167 |
$(foreach test_root, $(TEST_ROOTS), \ |
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
168 |
$(if $(filter $(TEST_GROUP), $($(test_root)_JTREG_TEST_GROUPS)), \ |
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
169 |
jtreg:$(test_root):$(TEST_GROUP) \ |
44027 | 170 |
) \ |
171 |
) \ |
|
172 |
, \ |
|
173 |
$(if $(filter /%, $(TEST_NAME)), \ |
|
174 |
$(if $(wildcard $(TEST_NAME)), \ |
|
175 |
jtreg:$(TEST_NAME) \ |
|
176 |
) \ |
|
177 |
, \ |
|
47932
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
178 |
$(eval TEST_PATHS := $(call ExpandJtregPath, $(TEST_NAME))) \ |
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
179 |
$(foreach test_path, $(TEST_PATHS), \ |
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
180 |
jtreg:$(test_path) \ |
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
181 |
) \ |
44027 | 182 |
) \ |
183 |
) |
|
184 |
endef |
|
185 |
||
186 |
ifeq ($(TEST), ) |
|
187 |
$(info No test selection given in TEST!) |
|
188 |
$(info Please use e.g. 'run-test TEST=tier1' or 'run-test-tier1') |
|
47928
fb62d4519338
8191715: Update documentation pointing to "common" directory
ihse
parents:
47329
diff
changeset
|
189 |
$(info See doc/testing.[md|html] for help) |
44027 | 190 |
$(error Cannot continue) |
191 |
endif |
|
192 |
||
193 |
# Now intelligently convert the test selection given by the user in TEST |
|
194 |
# into a list of fully qualified test descriptors of the tests to run. |
|
195 |
TESTS_TO_RUN := |
|
196 |
$(foreach test, $(TEST), \ |
|
197 |
$(eval PARSED_TESTS := $(call ParseCustomTestSelection, $(test))) \ |
|
198 |
$(if $(strip $(PARSED_TESTS)), , \ |
|
199 |
$(eval PARSED_TESTS += $(call ParseGtestTestSelection, $(test))) \ |
|
200 |
) \ |
|
201 |
$(if $(strip $(PARSED_TESTS)), , \ |
|
202 |
$(eval PARSED_TESTS += $(call ParseJtregTestSelection, $(test))) \ |
|
203 |
) \ |
|
204 |
$(if $(strip $(PARSED_TESTS)), , \ |
|
205 |
$(eval UNKNOWN_TEST := $(test)) \ |
|
206 |
) \ |
|
207 |
$(eval TESTS_TO_RUN += $(PARSED_TESTS)) \ |
|
208 |
) |
|
209 |
||
210 |
ifneq ($(UNKNOWN_TEST), ) |
|
211 |
$(info Unknown test selection: '$(UNKNOWN_TEST)') |
|
47928
fb62d4519338
8191715: Update documentation pointing to "common" directory
ihse
parents:
47329
diff
changeset
|
212 |
$(info See doc/testing.[md|html] for help) |
44027 | 213 |
$(error Cannot continue) |
214 |
endif |
|
215 |
||
216 |
TESTS_TO_RUN := $(strip $(TESTS_TO_RUN)) |
|
217 |
||
218 |
||
219 |
# Present the result of our parsing to the user |
|
220 |
$(info Test selection '$(TEST)', will run:) |
|
221 |
$(foreach test, $(TESTS_TO_RUN), $(info * $(test))) |
|
222 |
||
223 |
||
224 |
################################################################################ |
|
225 |
# Functions for setting up rules for running the selected tests |
|
226 |
# |
|
227 |
# The SetupRun*Test functions all have the same interface: |
|
228 |
# |
|
229 |
# Parameter 1 is the name of the rule. This is the test id, based on the test |
|
230 |
# descriptor, and this is also used as variable prefix, and the targets |
|
231 |
# generated are listed in a variable by that name. |
|
232 |
# |
|
233 |
# Remaining parameters are named arguments. Currently this is only: |
|
234 |
# TEST -- The properly formatted fully qualified test descriptor |
|
235 |
# |
|
236 |
# After the rule named by the test id has been executed, the following |
|
237 |
# variables will be available: |
|
238 |
# testid_TOTAL - the total number of tests run |
|
239 |
# testid_PASSED - the number of successful tests |
|
240 |
# testid_FAILED - the number of failed tests |
|
241 |
# testid_ERROR - the number of tests was neither successful or failed |
|
242 |
# |
|
243 |
################################################################################ |
|
244 |
||
245 |
### Rules for Gtest |
|
246 |
||
247 |
SetupRunGtestTest = $(NamedParamsMacroTemplate) |
|
248 |
define SetupRunGtestTestBody |
|
249 |
$1_TEST_RESULTS_DIR := $$(TEST_RESULTS_DIR)/$1 |
|
250 |
$1_TEST_SUPPORT_DIR := $$(TEST_SUPPORT_DIR)/$1 |
|
251 |
||
252 |
$1_TEST_NAME := $$(strip $$(patsubst gtest:%, %, $$($1_TEST))) |
|
253 |
ifneq ($$($1_TEST_NAME), all) |
|
254 |
$1_GTEST_FILTER := --gtest_filter=$$($1_TEST_NAME)* |
|
255 |
endif |
|
256 |
||
257 |
ifneq ($$(GTEST_REPEAT), ) |
|
258 |
$1_GTEST_REPEAT :=--gtest_repeat=$$(GTEST_REPEAT) |
|
259 |
endif |
|
260 |
||
261 |
run-test-$1: |
|
262 |
$$(call LogWarn) |
|
263 |
$$(call LogWarn, Running test '$$($1_TEST)') |
|
264 |
$$(call MakeDir, $$($1_TEST_RESULTS_DIR) $$($1_TEST_SUPPORT_DIR)) |
|
265 |
$$(call ExecuteWithLog, $$($1_TEST_SUPPORT_DIR)/gtest, \ |
|
266 |
$$(FIXPATH) $$(TEST_IMAGE_DIR)/hotspot/gtest/server/gtestLauncher \ |
|
267 |
-jdk $(JDK_IMAGE_DIR) $$($1_GTEST_FILTER) \ |
|
268 |
--gtest_output=xml:$$($1_TEST_RESULTS_DIR)/gtest.xml \ |
|
269 |
$$($1_GTEST_REPEAT) $$(GTEST_OPTIONS) \ |
|
270 |
> >($(TEE) $$($1_TEST_RESULTS_DIR)/gtest.txt) || true ) |
|
271 |
||
272 |
$1_RESULT_FILE := $$($1_TEST_RESULTS_DIR)/gtest.txt |
|
273 |
||
274 |
parse-test-$1: run-test-$1 |
|
275 |
$$(call LogWarn, Finished running test '$$($1_TEST)') |
|
276 |
$$(call LogWarn, Test report is stored in $$(strip \ |
|
277 |
$$(subst $$(TOPDIR)/, , $$($1_TEST_RESULTS_DIR)))) |
|
278 |
$$(eval $1_TOTAL := $$(shell $$(AWK) '/==========.* tests? from .* \ |
|
279 |
test cases? ran/ { print $$$$2 }' $$($1_RESULT_FILE))) |
|
280 |
$$(eval $1_PASSED := $$(shell $$(AWK) '/\[ PASSED \] .* tests?./ \ |
|
281 |
{ print $$$$4 }' $$($1_RESULT_FILE))) |
|
282 |
$$(eval $1_FAILED := $$(shell $$(AWK) '/\[ FAILED \] .* tests?, \ |
|
283 |
listed below/ { print $$$$4 }' $$($1_RESULT_FILE))) |
|
284 |
$$(if $$($1_FAILED), , $$(eval $1_FAILED := 0)) |
|
285 |
$$(eval $1_ERROR := $$(shell \ |
|
286 |
$$(EXPR) $$($1_TOTAL) - $$($1_PASSED) - $$($1_FAILED))) |
|
287 |
||
288 |
$1: run-test-$1 parse-test-$1 |
|
289 |
||
290 |
TARGETS += $1 |
|
291 |
endef |
|
292 |
||
293 |
################################################################################ |
|
294 |
||
295 |
### Rules for Jtreg |
|
296 |
||
297 |
# Helper function for SetupRunJtregTest. Set a JTREG_* variable from, in order: |
|
298 |
# 1) Specified by user on command line |
|
299 |
# 2) Component-specific default |
|
300 |
# 3) Generic default |
|
301 |
# |
|
302 |
# Note: No spaces are allowed around the arguments. |
|
303 |
# Arg $1 The test ID (i.e. $1 in SetupRunJtregTest) |
|
304 |
# Arg $2 Base variable, e.g. JTREG_JOBS |
|
305 |
# Arg $3 The default value (optional) |
|
306 |
define SetJtregValue |
|
307 |
ifneq ($$($2), ) |
|
308 |
$1_$2 := $$($2) |
|
309 |
else |
|
310 |
ifneq ($$($$($1_COMPONENT)_$2), ) |
|
311 |
$1_$2 := $$($$($1_COMPONENT)_$2) |
|
312 |
else |
|
313 |
ifneq ($3, ) |
|
314 |
$1_$2 := $3 |
|
315 |
endif |
|
316 |
endif |
|
317 |
endif |
|
318 |
endef |
|
319 |
||
320 |
SetupRunJtregTest = $(NamedParamsMacroTemplate) |
|
321 |
define SetupRunJtregTestBody |
|
322 |
$1_TEST_RESULTS_DIR := $$(TEST_RESULTS_DIR)/$1 |
|
323 |
$1_TEST_SUPPORT_DIR := $$(TEST_SUPPORT_DIR)/$1 |
|
324 |
||
325 |
$1_TEST_NAME := $$(strip $$(patsubst jtreg:%, %, $$($1_TEST))) |
|
47932
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
326 |
|
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
327 |
$1_COMPONENT := \ |
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
328 |
$$(strip $$(foreach root, $$(JTREG_TESTROOTS), \ |
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
329 |
$$(if $$(filter $$(root)%, $$($1_TEST_NAME)), \ |
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
330 |
$$(lastword $$(subst /, $$(SPACE), $$(root))) \ |
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
331 |
) \ |
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
332 |
)) |
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
333 |
# This will work only as long as just hotspot has the additional "jtreg" directory |
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
334 |
ifeq ($$($1_COMPONENT), jtreg) |
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
335 |
$1_COMPONENT := hotspot |
0c22f6b9b5e2
8191820: Fix run-test jtreg test selection and component calculation
ihse
parents:
47928
diff
changeset
|
336 |
endif |
44027 | 337 |
|
45104 | 338 |
ifeq ($$(JT_HOME), ) |
339 |
$$(info Error: jtreg framework is not found.) |
|
340 |
$$(info Please run configure using --with-jtreg.) |
|
341 |
$$(error Cannot continue) |
|
342 |
endif |
|
343 |
||
44027 | 344 |
# Unfortunately, we need different defaults for some JTREG values, |
345 |
# depending on what component we're running. |
|
346 |
||
347 |
# Convert JTREG_foo into $1_JTREG_foo with a suitable value. |
|
348 |
$$(eval $$(call SetJtregValue,$1,JTREG_TEST_MODE,agentvm)) |
|
349 |
$$(eval $$(call SetJtregValue,$1,JTREG_ASSERT,true)) |
|
350 |
$$(eval $$(call SetJtregValue,$1,JTREG_MAX_MEM,512m)) |
|
351 |
$$(eval $$(call SetJtregValue,$1,JTREG_NATIVEPATH)) |
|
352 |
$$(eval $$(call SetJtregValue,$1,JTREG_BASIC_OPTIONS)) |
|
353 |
||
354 |
ifneq ($(TEST_JOBS), 0) |
|
355 |
# User has specified TEST_JOBS, use that as fallback default |
|
356 |
$$(eval $$(call SetJtregValue,$1,JTREG_JOBS,$$(TEST_JOBS))) |
|
357 |
else |
|
358 |
# Use JOBS as default (except for hotspot) |
|
359 |
$$(eval $$(call SetJtregValue,$1,JTREG_JOBS,$$(JOBS))) |
|
360 |
endif |
|
361 |
||
362 |
ifeq ($$(shell $$(EXPR) $$($1_JTREG_JOBS) \> 50), 1) |
|
363 |
# Until CODETOOLS-7901892 is fixed, JTreg cannot handle more than 50 jobs |
|
364 |
$1_JTREG_JOBS := 50 |
|
365 |
endif |
|
366 |
||
47058
85aaac5701da
8186248: Allow more flexibility in selecting Heap % of available RAM
bobv
parents:
46230
diff
changeset
|
367 |
# Make sure MaxRAMPercentage is high enough to not cause OOM or swapping since |
44027 | 368 |
# we may end up with a lot of JVM's |
47058
85aaac5701da
8186248: Allow more flexibility in selecting Heap % of available RAM
bobv
parents:
46230
diff
changeset
|
369 |
$1_JTREG_MAX_RAM_PERCENTAGE := $$(shell $$(EXPR) 25 / $$($1_JTREG_JOBS)) |
44027 | 370 |
|
371 |
JTREG_TIMEOUT ?= 4 |
|
372 |
JTREG_VERBOSE ?= fail,error,summary |
|
373 |
JTREG_RETAIN ?= fail,error |
|
374 |
||
375 |
ifneq ($$($1_JTREG_MAX_MEM), 0) |
|
376 |
$1_JTREG_BASIC_OPTIONS += -vmoption:-Xmx$$($1_JTREG_MAX_MEM) |
|
377 |
$1_JTREG_LAUNCHER_OPTIONS += -Xmx$$($1_JTREG_MAX_MEM) |
|
378 |
endif |
|
379 |
||
380 |
$1_JTREG_BASIC_OPTIONS += -$$($1_JTREG_TEST_MODE) \ |
|
381 |
-verbose:$$(JTREG_VERBOSE) -retain:$$(JTREG_RETAIN) \ |
|
382 |
-concurrency:$$($1_JTREG_JOBS) -timeoutFactor:$$(JTREG_TIMEOUT) \ |
|
47058
85aaac5701da
8186248: Allow more flexibility in selecting Heap % of available RAM
bobv
parents:
46230
diff
changeset
|
383 |
-vmoption:-XX:MaxRAMPercentage=$$($1_JTREG_MAX_RAM_PERCENTAGE) |
44027 | 384 |
|
385 |
$1_JTREG_BASIC_OPTIONS += -automatic -keywords:\!ignore -ignore:quiet |
|
386 |
||
47329 | 387 |
# Make it possible to specify the JIB_DATA_DIR for tests using the |
388 |
# JIB Artifact resolver |
|
389 |
$1_JTREG_BASIC_OPTIONS += -e:JIB_DATA_DIR |
|
44027 | 390 |
# Some tests needs to find a boot JDK using the JDK8_HOME variable. |
391 |
$1_JTREG_BASIC_OPTIONS += -e:JDK8_HOME=$$(BOOT_JDK) |
|
392 |
||
393 |
$1_JTREG_BASIC_OPTIONS += \ |
|
394 |
$$(addprefix -javaoption:, $$(JTREG_JAVA_OPTIONS)) \ |
|
395 |
$$(addprefix -vmoption:, $$(JTREG_VM_OPTIONS)) \ |
|
396 |
# |
|
397 |
||
398 |
ifeq ($$($1_JTREG_ASSERT), true) |
|
399 |
$1_JTREG_BASIC_OPTIONS += -ea -esa |
|
400 |
endif |
|
401 |
||
402 |
ifneq ($$($1_JTREG_NATIVEPATH), ) |
|
403 |
$1_JTREG_BASIC_OPTIONS += -nativepath:$$($1_JTREG_NATIVEPATH) |
|
404 |
endif |
|
405 |
||
46230
e0ca0417b74d
8180600: make run-test does not work with jib test dependencies
erikj
parents:
45104
diff
changeset
|
406 |
ifneq ($$(JIB_JAR), ) |
e0ca0417b74d
8180600: make run-test does not work with jib test dependencies
erikj
parents:
45104
diff
changeset
|
407 |
$1_JTREG_BASIC_OPTIONS += -cpa:$$(JIB_JAR) |
e0ca0417b74d
8180600: make run-test does not work with jib test dependencies
erikj
parents:
45104
diff
changeset
|
408 |
endif |
e0ca0417b74d
8180600: make run-test does not work with jib test dependencies
erikj
parents:
45104
diff
changeset
|
409 |
|
44027 | 410 |
run-test-$1: |
411 |
$$(call LogWarn) |
|
412 |
$$(call LogWarn, Running test '$$($1_TEST)') |
|
413 |
$$(call MakeDir, $$($1_TEST_RESULTS_DIR) $$($1_TEST_SUPPORT_DIR)) |
|
414 |
$$(call ExecuteWithLog, $$($1_TEST_SUPPORT_DIR)/jtreg, \ |
|
415 |
$$(JAVA) $$($1_JTREG_LAUNCHER_OPTIONS) \ |
|
416 |
-Dprogram=jtreg -jar $$(JT_HOME)/lib/jtreg.jar \ |
|
417 |
$$($1_JTREG_BASIC_OPTIONS) \ |
|
418 |
-testjdk:$$(JDK_IMAGE_DIR) \ |
|
419 |
-dir:$$(TOPDIR) \ |
|
420 |
-reportDir:$$($1_TEST_RESULTS_DIR) \ |
|
421 |
-workDir:$$($1_TEST_SUPPORT_DIR) \ |
|
422 |
$$(JTREG_OPTIONS) \ |
|
423 |
$$($1_TEST_NAME) || true ) |
|
424 |
||
425 |
$1_RESULT_FILE := $$($1_TEST_RESULTS_DIR)/text/stats.txt |
|
426 |
||
427 |
parse-test-$1: run-test-$1 |
|
428 |
$$(call LogWarn, Finished running test '$$($1_TEST)') |
|
429 |
$$(call LogWarn, Test report is stored in $$(strip \ |
|
430 |
$$(subst $$(TOPDIR)/, , $$($1_TEST_RESULTS_DIR)))) |
|
47259
0b347d8efb40
8187672: RunTest displays broken output if jtreg fails completely
ihse
parents:
47253
diff
changeset
|
431 |
$$(if $$(wildcard $$($1_RESULT_FILE)), \ |
0b347d8efb40
8187672: RunTest displays broken output if jtreg fails completely
ihse
parents:
47253
diff
changeset
|
432 |
$$(eval $1_PASSED := $$(shell $$(AWK) '{ gsub(/[,;]/, ""); \ |
0b347d8efb40
8187672: RunTest displays broken output if jtreg fails completely
ihse
parents:
47253
diff
changeset
|
433 |
for (i=1; i<=NF; i++) { if ($$$$i == "passed:") \ |
0b347d8efb40
8187672: RunTest displays broken output if jtreg fails completely
ihse
parents:
47253
diff
changeset
|
434 |
print $$$$(i+1) } }' $$($1_RESULT_FILE))) \ |
0b347d8efb40
8187672: RunTest displays broken output if jtreg fails completely
ihse
parents:
47253
diff
changeset
|
435 |
$$(if $$($1_PASSED), , $$(eval $1_PASSED := 0)) \ |
0b347d8efb40
8187672: RunTest displays broken output if jtreg fails completely
ihse
parents:
47253
diff
changeset
|
436 |
$$(eval $1_FAILED := $$(shell $$(AWK) '{gsub(/[,;]/, ""); \ |
0b347d8efb40
8187672: RunTest displays broken output if jtreg fails completely
ihse
parents:
47253
diff
changeset
|
437 |
for (i=1; i<=NF; i++) { if ($$$$i == "failed:") \ |
0b347d8efb40
8187672: RunTest displays broken output if jtreg fails completely
ihse
parents:
47253
diff
changeset
|
438 |
print $$$$(i+1) } }' $$($1_RESULT_FILE))) \ |
0b347d8efb40
8187672: RunTest displays broken output if jtreg fails completely
ihse
parents:
47253
diff
changeset
|
439 |
$$(if $$($1_FAILED), , $$(eval $1_FAILED := 0)) \ |
0b347d8efb40
8187672: RunTest displays broken output if jtreg fails completely
ihse
parents:
47253
diff
changeset
|
440 |
$$(eval $1_ERROR := $$(shell $$(AWK) '{gsub(/[,;]/, ""); \ |
0b347d8efb40
8187672: RunTest displays broken output if jtreg fails completely
ihse
parents:
47253
diff
changeset
|
441 |
for (i=1; i<=NF; i++) { if ($$$$i == "error:") \ |
0b347d8efb40
8187672: RunTest displays broken output if jtreg fails completely
ihse
parents:
47253
diff
changeset
|
442 |
print $$$$(i+1) } }' $$($1_RESULT_FILE))) \ |
0b347d8efb40
8187672: RunTest displays broken output if jtreg fails completely
ihse
parents:
47253
diff
changeset
|
443 |
$$(if $$($1_ERROR), , $$(eval $1_ERROR := 0)) \ |
0b347d8efb40
8187672: RunTest displays broken output if jtreg fails completely
ihse
parents:
47253
diff
changeset
|
444 |
$$(eval $1_TOTAL := $$(shell \ |
0b347d8efb40
8187672: RunTest displays broken output if jtreg fails completely
ihse
parents:
47253
diff
changeset
|
445 |
$$(EXPR) $$($1_PASSED) + $$($1_FAILED) + $$($1_ERROR))) \ |
0b347d8efb40
8187672: RunTest displays broken output if jtreg fails completely
ihse
parents:
47253
diff
changeset
|
446 |
, \ |
0b347d8efb40
8187672: RunTest displays broken output if jtreg fails completely
ihse
parents:
47253
diff
changeset
|
447 |
$$(eval $1_PASSED := 0) \ |
0b347d8efb40
8187672: RunTest displays broken output if jtreg fails completely
ihse
parents:
47253
diff
changeset
|
448 |
$$(eval $1_FAILED := 0) \ |
0b347d8efb40
8187672: RunTest displays broken output if jtreg fails completely
ihse
parents:
47253
diff
changeset
|
449 |
$$(eval $1_ERROR := 1) \ |
0b347d8efb40
8187672: RunTest displays broken output if jtreg fails completely
ihse
parents:
47253
diff
changeset
|
450 |
$$(eval $1_TOTAL := 1) \ |
0b347d8efb40
8187672: RunTest displays broken output if jtreg fails completely
ihse
parents:
47253
diff
changeset
|
451 |
) |
44027 | 452 |
|
453 |
$1: run-test-$1 parse-test-$1 |
|
454 |
||
455 |
TARGETS += $1 |
|
456 |
endef |
|
457 |
||
458 |
||
459 |
################################################################################ |
|
460 |
# Setup and execute make rules for all selected tests |
|
461 |
################################################################################ |
|
462 |
||
463 |
# Helper function to determine which handler to use for the given test |
|
464 |
UseGtestTestHandler = \ |
|
465 |
$(if $(filter gtest:%, $1), true) |
|
466 |
||
467 |
UseJtregTestHandler = \ |
|
468 |
$(if $(filter jtreg:%, $1), true) |
|
469 |
||
470 |
# Now process each test to run and setup a proper make rule |
|
471 |
$(foreach test, $(TESTS_TO_RUN), \ |
|
472 |
$(eval TEST_ID := $(shell $(ECHO) $(strip $(test)) | \ |
|
473 |
$(TR) -cs '[a-z][A-Z][0-9]\n' '_')) \ |
|
474 |
$(eval ALL_TEST_IDS += $(TEST_ID)) \ |
|
475 |
$(if $(call UseCustomTestHandler, $(test)), \ |
|
476 |
$(eval $(call SetupRunCustomTest, $(TEST_ID), \ |
|
477 |
TEST := $(test), \ |
|
478 |
)) \ |
|
479 |
) \ |
|
480 |
$(if $(call UseGtestTestHandler, $(test)), \ |
|
481 |
$(eval $(call SetupRunGtestTest, $(TEST_ID), \ |
|
482 |
TEST := $(test), \ |
|
483 |
)) \ |
|
484 |
) \ |
|
485 |
$(if $(call UseJtregTestHandler, $(test)), \ |
|
486 |
$(eval $(call SetupRunJtregTest, $(TEST_ID), \ |
|
487 |
TEST := $(test), \ |
|
488 |
)) \ |
|
489 |
) \ |
|
490 |
) |
|
491 |
||
492 |
# Sort also removes duplicates, so if there is any we'll get fewer words. |
|
493 |
ifneq ($(words $(ALL_TEST_IDS)), $(words $(sort $(ALL_TEST_IDS)))) |
|
494 |
$(error Duplicate test specification) |
|
495 |
endif |
|
496 |
||
497 |
||
498 |
################################################################################ |
|
499 |
# The main target for RunTests.gmk |
|
500 |
################################################################################ |
|
501 |
||
502 |
# The SetupRun*Test functions have populated TARGETS. |
|
503 |
||
504 |
TEST_FAILURE := false |
|
505 |
||
506 |
run-test: $(TARGETS) |
|
507 |
# Print a table of the result of all tests run and their result |
|
508 |
$(ECHO) |
|
509 |
$(ECHO) ============================== |
|
510 |
$(ECHO) Test summary |
|
511 |
$(ECHO) ============================== |
|
512 |
$(PRINTF) "%2s %-49s %5s %5s %5s %5s %2s\n" " " TEST \ |
|
513 |
TOTAL PASS FAIL ERROR " " |
|
514 |
$(foreach test, $(TESTS_TO_RUN), \ |
|
515 |
$(eval TEST_ID := $(shell $(ECHO) $(strip $(test)) | \ |
|
516 |
$(TR) -cs '[a-z][A-Z][0-9]\n' '_')) \ |
|
517 |
$(if $(filter $($(TEST_ID)_PASSED), $($(TEST_ID)_TOTAL)), \ |
|
518 |
$(PRINTF) "%2s %-49s %5d %5d %5d %5d %2s\n" " " "$(test)" \ |
|
519 |
$($(TEST_ID)_TOTAL) $($(TEST_ID)_PASSED) $($(TEST_ID)_FAILED) \ |
|
520 |
$($(TEST_ID)_ERROR) " " $(NEWLINE) \ |
|
521 |
, \ |
|
522 |
$(PRINTF) "%2s %-49s %5d %5d %5d %5d %2s\n" ">>" "$(test)" \ |
|
523 |
$($(TEST_ID)_TOTAL) $($(TEST_ID)_PASSED) $($(TEST_ID)_FAILED) \ |
|
524 |
$($(TEST_ID)_ERROR) "<<" $(NEWLINE) \ |
|
525 |
$(eval TEST_FAILURE := true) \ |
|
526 |
) \ |
|
527 |
) |
|
528 |
$(ECHO) ============================== |
|
529 |
$(if $(filter true, $(TEST_FAILURE)), \ |
|
530 |
$(ECHO) TEST FAILURE $(NEWLINE) \ |
|
531 |
$(TOUCH) $(MAKESUPPORT_OUTPUTDIR)/exit-with-error \ |
|
532 |
, \ |
|
533 |
$(ECHO) TEST SUCCESS \ |
|
534 |
) |
|
535 |
$(ECHO) |
|
536 |
||
537 |
################################################################################ |
|
538 |
||
539 |
all: run-test |
|
540 |
||
541 |
.PHONY: default all run-test $(TARGETS) |