20 # or visit www.oracle.com if you need additional information or have any |
22 # or visit www.oracle.com if you need additional information or have any |
21 # questions. |
23 # questions. |
22 # |
24 # |
23 # |
25 # |
24 |
26 |
25 # |
27 NATIVE_TEST_PATH := hotspot/jtreg/native |
26 # Makefile to run various hotspot tests |
|
27 # |
|
28 |
28 |
29 ALT_MAKE ?= closed |
29 TREAT_EXIT_CODE_1_AS_0 := true |
30 |
30 |
31 GETMIXEDPATH=echo |
31 CLEAN_BEFORE_PREP := true |
32 |
32 |
33 # Utilities used |
33 USE_JTREG_VERSION := 4.1 |
34 AWK = awk |
|
35 CAT = cat |
|
36 CD = cd |
|
37 CHMOD = chmod |
|
38 CP = cp |
|
39 CUT = cut |
|
40 DIRNAME = dirname |
|
41 ECHO = echo |
|
42 EGREP = egrep |
|
43 EXPAND = expand |
|
44 FIND = find |
|
45 MKDIR = mkdir |
|
46 PWD = pwd |
|
47 SED = sed |
|
48 SORT = sort |
|
49 TEE = tee |
|
50 UNAME = uname |
|
51 UNIQ = uniq |
|
52 WC = wc |
|
53 ZIPEXE = zip |
|
54 |
34 |
55 define NEWLINE |
35 USE_JTREG_ASSERT := false |
56 |
36 |
|
37 LIMIT_JTREG_VM_MEMORY := false |
57 |
38 |
58 endef |
39 IGNORE_MARKED_TESTS := true |
59 |
40 |
60 # Get OS name from uname (Cygwin inexplicably adds _NT-5.1) |
41 # Get OS name from uname (Cygwin inexplicably adds _NT-5.1) |
61 UNAME_S := $(shell $(UNAME) -s | $(CUT) -f1 -d_) |
42 UNAME_S := $(shell uname -s | cut -f1 -d_) |
|
43 |
62 ifeq ($(UNAME_S), SunOS) |
44 ifeq ($(UNAME_S), SunOS) |
63 PLATFORM = solaris |
|
64 SLASH_JAVA = /java |
|
65 ARCH = $(shell uname -p) |
|
66 ifeq ($(ARCH), i386) |
|
67 ARCH=i586 |
|
68 endif |
|
69 NUM_CORES := $(shell LC_MESSAGES=C /usr/sbin/psrinfo -v | grep -c on-line) |
45 NUM_CORES := $(shell LC_MESSAGES=C /usr/sbin/psrinfo -v | grep -c on-line) |
70 endif |
46 endif |
71 ifeq ($(UNAME_S), Linux) |
47 ifeq ($(UNAME_S), Linux) |
72 PLATFORM = linux |
|
73 SLASH_JAVA = /java |
|
74 ARCH = $(shell uname -m) |
|
75 ifeq ($(ARCH), i386) |
|
76 ARCH = i586 |
|
77 endif |
|
78 NUM_CORES := $(shell cat /proc/cpuinfo | grep -c processor) |
48 NUM_CORES := $(shell cat /proc/cpuinfo | grep -c processor) |
79 endif |
49 endif |
80 ifeq ($(UNAME_S), Darwin) |
50 ifeq ($(UNAME_S), Darwin) |
81 PLATFORM = bsd |
|
82 SLASH_JAVA = /java |
|
83 ARCH = $(shell uname -m) |
|
84 ifeq ($(ARCH), i386) |
|
85 ARCH = i586 |
|
86 endif |
|
87 NUM_CORES := $(shell /usr/sbin/sysctl -n hw.ncpu) |
51 NUM_CORES := $(shell /usr/sbin/sysctl -n hw.ncpu) |
88 endif |
52 endif |
89 ifeq ($(findstring BSD,$(UNAME_S)), BSD) |
53 ifeq ($(findstring CYGWIN,$(UNAME_S)), CYGWIN) |
90 PLATFORM = bsd |
|
91 SLASH_JAVA = /java |
|
92 ARCH = $(shell uname -m) |
|
93 ifeq ($(ARCH), i386) |
|
94 ARCH = i586 |
|
95 endif |
|
96 endif |
|
97 ifeq ($(PLATFORM),) |
|
98 # detect whether we're running in MKS or cygwin |
|
99 ifeq ($(UNAME_S), Windows_NT) # MKS |
|
100 GETMIXEDPATH=dosname -s |
|
101 endif |
|
102 ifeq ($(findstring CYGWIN,$(UNAME_S)), CYGWIN) |
|
103 GETMIXEDPATH=cygpath -m |
|
104 endif |
|
105 PLATFORM = windows |
|
106 SLASH_JAVA = J: |
|
107 ifeq ($(word 1, $(PROCESSOR_IDENTIFIER)),ia64) |
|
108 ARCH = ia64 |
|
109 else |
|
110 ifeq ($(word 1, $(PROCESSOR_IDENTIFIER)),AMD64) |
|
111 ARCH = x64 |
|
112 else |
|
113 ifeq ($(word 1, $(PROCESSOR_IDENTIFIER)),EM64T) |
|
114 ARCH = x64 |
|
115 else |
|
116 ARCH = i586 |
|
117 endif |
|
118 endif |
|
119 endif |
|
120 EXESUFFIX = .exe |
|
121 ifneq ($(NUMBER_OF_PROCESSORS), ) |
54 ifneq ($(NUMBER_OF_PROCESSORS), ) |
122 NUM_CORES := $(NUMBER_OF_PROCESSORS) |
55 NUM_CORES := $(NUMBER_OF_PROCESSORS) |
123 else |
56 else |
124 ifneq ($(HOTSPOT_BUILD_JOBS), ) |
57 ifneq ($(HOTSPOT_BUILD_JOBS), ) |
125 NUM_CORES := $(HOTSPOT_BUILD_JOBS) |
58 NUM_CORES := $(HOTSPOT_BUILD_JOBS) |
|
59 else |
|
60 NUM_CORES := 1 # fallback |
126 endif |
61 endif |
127 endif |
62 endif |
128 endif |
63 endif |
129 |
64 |
130 ifdef ALT_SLASH_JAVA |
65 # Concurrency based on min(cores / 2, 12) |
131 SLASH_JAVA = $(ALT_SLASH_JAVA) |
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 |
132 endif |
71 endif |
133 |
72 |
134 # Root of this test area (important to use full paths in some places) |
73 # Make sure MaxRAMFraction is high enough to not cause OOM or swapping since we may end up with a lot of JVM's |
135 TEST_ROOT := $(shell pwd) |
74 JTREG_BASIC_OPTIONS += -vmoption:-XX:MaxRAMFraction=$(shell expr $(CONCURRENCY) \* 4) |
136 |
75 |
137 # Root of all test results |
76 # Include the common base file with most of the logic |
138 ifdef TEST_OUTPUT_DIR |
77 include ../../test/TestCommon.gmk |
139 $(shell $(MKDIR) -p $(TEST_OUTPUT_DIR)/jtreg) |
|
140 ABS_TEST_OUTPUT_DIR := \ |
|
141 $(shell $(CD) $(TEST_OUTPUT_DIR)/jtreg && $(PWD)) |
|
142 else |
|
143 ifdef ALT_OUTPUTDIR |
|
144 ABS_OUTPUTDIR = $(shell $(CD) $(ALT_OUTPUTDIR) && $(PWD)) |
|
145 else |
|
146 ABS_OUTPUTDIR = $(shell $(CD) $(TEST_ROOT)/.. && $(PWD)) |
|
147 endif |
|
148 |
|
149 ABS_PLATFORM_BUILD_ROOT = $(ABS_OUTPUTDIR) |
|
150 ABS_TEST_OUTPUT_DIR := $(ABS_PLATFORM_BUILD_ROOT)/testoutput/$(UNIQUE_DIR) |
|
151 endif |
|
152 |
|
153 # Expect JPRT to set PRODUCT_HOME (the product or jdk in this case to test) |
|
154 ifndef PRODUCT_HOME |
|
155 # Try to use images/jdk if it exists |
|
156 ABS_JDK_IMAGE = $(ABS_PLATFORM_BUILD_ROOT)/images/jdk |
|
157 PRODUCT_HOME := \ |
|
158 $(shell \ |
|
159 if [ -d $(ABS_JDK_IMAGE) ] ; then \ |
|
160 $(ECHO) "$(ABS_JDK_IMAGE)"; \ |
|
161 else \ |
|
162 $(ECHO) "$(ABS_PLATFORM_BUILD_ROOT)"; \ |
|
163 fi) |
|
164 PRODUCT_HOME := $(PRODUCT_HOME) |
|
165 endif |
|
166 |
|
167 # Expect JPRT to set JAVA_ARGS (e.g. -server etc.) |
|
168 JAVA_OPTIONS = |
|
169 ifdef JAVA_ARGS |
|
170 JAVA_OPTIONS = $(JAVA_ARGS) |
|
171 endif |
|
172 |
|
173 # jtreg -nativepath <dir> |
|
174 # |
|
175 # Local make tests will be TEST_IMAGE_DIR and JPRT with jprt.use.reg.test.bundle=true |
|
176 # should be JPRT_TESTNATIVE_PATH |
|
177 ifdef TEST_IMAGE_DIR |
|
178 TESTNATIVE_DIR = $(TEST_IMAGE_DIR) |
|
179 else ifdef JPRT_TESTNATIVE_PATH |
|
180 TESTNATIVE_DIR = $(JPRT_TESTNATIVE_PATH) |
|
181 endif |
|
182 ifdef TESTNATIVE_DIR |
|
183 JTREG_NATIVE_PATH = -nativepath:$(shell $(GETMIXEDPATH) "$(TESTNATIVE_DIR)/hotspot/jtreg/native") |
|
184 endif |
|
185 |
|
186 # jtreg failure handler config |
|
187 ifeq ($(FAILURE_HANDLER_DIR), ) |
|
188 ifneq ($(TESTNATIVE_DIR), ) |
|
189 FAILURE_HANDLER_DIR := $(TESTNATIVE_DIR)/failure_handler |
|
190 endif |
|
191 endif |
|
192 ifneq ($(FAILURE_HANDLER_DIR), ) |
|
193 FAILURE_HANDLER_DIR_MIXED := $(shell $(GETMIXEDPATH) "$(FAILURE_HANDLER_DIR)") |
|
194 JTREG_FAILURE_HANDLER_OPTIONS := \ |
|
195 -timeoutHandlerDir:$(FAILURE_HANDLER_DIR_MIXED)/jtregFailureHandler.jar \ |
|
196 -observerDir:$(FAILURE_HANDLER_DIR_MIXED)/jtregFailureHandler.jar \ |
|
197 -timeoutHandler:jdk.test.failurehandler.jtreg.GatherProcessInfoTimeoutHandler \ |
|
198 -observer:jdk.test.failurehandler.jtreg.GatherDiagnosticInfoObserver \ |
|
199 -timeoutHandlerTimeout:0 |
|
200 ifeq ($(PLATFORM), windows) |
|
201 JTREG_FAILURE_HANDLER_OPTIONS += -J-Djava.library.path="$(FAILURE_HANDLER_DIR_MIXED)" |
|
202 endif |
|
203 endif |
|
204 |
|
205 # Expect JPRT to set JPRT_ARCHIVE_BUNDLE (path to zip bundle for results) |
|
206 ARCHIVE_BUNDLE = $(ABS_TEST_OUTPUT_DIR)/ARCHIVE_BUNDLE.zip |
|
207 ifdef JPRT_ARCHIVE_BUNDLE |
|
208 ARCHIVE_BUNDLE = $(JPRT_ARCHIVE_BUNDLE) |
|
209 endif |
|
210 |
|
211 # How to create the test bundle (pass or fail, we want to create this) |
|
212 # Follow command with ";$(BUNDLE_UP_AND_EXIT)", so it always gets executed. |
|
213 ZIP_UP_RESULTS = ( $(MKDIR) -p `$(DIRNAME) $(ARCHIVE_BUNDLE)` \ |
|
214 && $(CD) $(ABS_TEST_OUTPUT_DIR) \ |
|
215 && $(CHMOD) -R a+r . \ |
|
216 && $(ZIPEXE) -q -r $(ARCHIVE_BUNDLE) . ) |
|
217 |
|
218 # important results files |
|
219 SUMMARY_TXT = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTreport/text/summary.txt") |
|
220 STATS_TXT_NAME = Stats.txt |
|
221 STATS_TXT = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/$(STATS_TXT_NAME)") |
|
222 RUNLIST = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/runlist.txt") |
|
223 PASSLIST = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/passlist.txt") |
|
224 FAILLIST = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/faillist.txt") |
|
225 EXITCODE = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/exitcode.txt") |
|
226 |
|
227 TESTEXIT = \ |
|
228 if [ ! -s $(EXITCODE) ] ; then \ |
|
229 $(ECHO) "ERROR: EXITCODE file not filled in."; \ |
|
230 $(ECHO) "1" > $(EXITCODE); \ |
|
231 fi ; \ |
|
232 testExitCode=`$(CAT) $(EXITCODE)`; \ |
|
233 $(ECHO) "EXIT CODE: $${testExitCode}"; \ |
|
234 exit $${testExitCode} |
|
235 |
|
236 BUNDLE_UP_AND_EXIT = \ |
|
237 ( \ |
|
238 jtregExitCode=$$? && \ |
|
239 _summary="$(SUMMARY_TXT)"; \ |
|
240 if [ $${jtregExitCode} = 1 ] ; then \ |
|
241 jtregExitCode=0; \ |
|
242 fi; \ |
|
243 $(RM) -f $(STATS_TXT) $(RUNLIST) $(PASSLIST) $(FAILLIST) $(EXITCODE); \ |
|
244 $(ECHO) "$${jtregExitCode}" > $(EXITCODE); \ |
|
245 if [ -r "$${_summary}" ] ; then \ |
|
246 $(ECHO) "Summary: $(UNIQUE_DIR)" > $(STATS_TXT); \ |
|
247 $(EXPAND) $${_summary} | $(EGREP) -v ' Not run\.' > $(RUNLIST); \ |
|
248 $(EGREP) ' Passed\.' $(RUNLIST) \ |
|
249 | $(EGREP) -v ' Error\.' \ |
|
250 | $(EGREP) -v ' Failed\.' > $(PASSLIST); \ |
|
251 ( $(EGREP) ' Failed\.' $(RUNLIST); \ |
|
252 $(EGREP) ' Error\.' $(RUNLIST); \ |
|
253 $(EGREP) -v ' Passed\.' $(RUNLIST) ) \ |
|
254 | $(SORT) | $(UNIQ) > $(FAILLIST); \ |
|
255 if [ $${jtregExitCode} != 0 -o -s $(FAILLIST) ] ; then \ |
|
256 $(EXPAND) $(FAILLIST) \ |
|
257 | $(CUT) -d' ' -f1 \ |
|
258 | $(SED) -e 's@^@FAILED: @' >> $(STATS_TXT); \ |
|
259 if [ $${jtregExitCode} = 0 ] ; then \ |
|
260 jtregExitCode=1; \ |
|
261 fi; \ |
|
262 fi; \ |
|
263 runc="`$(CAT) $(RUNLIST) | $(WC) -l | $(AWK) '{print $$1;}'`"; \ |
|
264 passc="`$(CAT) $(PASSLIST) | $(WC) -l | $(AWK) '{print $$1;}'`"; \ |
|
265 failc="`$(CAT) $(FAILLIST) | $(WC) -l | $(AWK) '{print $$1;}'`"; \ |
|
266 exclc="FIXME CODETOOLS-7900176"; \ |
|
267 $(ECHO) "TEST STATS: name=$(UNIQUE_DIR) run=$${runc} pass=$${passc} fail=$${failc}" \ |
|
268 >> $(STATS_TXT); \ |
|
269 else \ |
|
270 $(ECHO) "Missing file: $${_summary}" >> $(STATS_TXT); \ |
|
271 fi; \ |
|
272 if [ -f $(STATS_TXT) ] ; then \ |
|
273 $(CAT) $(STATS_TXT); \ |
|
274 fi; \ |
|
275 $(ZIP_UP_RESULTS) ; \ |
|
276 $(TESTEXIT) \ |
|
277 ) |
|
278 |
78 |
279 ################################################################ |
79 ################################################################ |
280 |
|
281 # Default make rule (runs jtreg_tests) |
80 # Default make rule (runs jtreg_tests) |
282 all: hotspot_all |
81 all: hotspot_all |
283 @$(ECHO) "Testing completed successfully" |
82 @$(ECHO) "Testing completed successfully" |
284 |
83 |
285 # Support "hotspot_" prefixed test make targets (too) |
84 # Support "hotspot_" prefixed test make targets (too) |
290 $(MAKE) -j 1 TEST_SELECTION=":$@" UNIQUE_DIR=$@ jtreg_tests; |
89 $(MAKE) -j 1 TEST_SELECTION=":$@" UNIQUE_DIR=$@ jtreg_tests; |
291 |
90 |
292 hotspot_internal: |
91 hotspot_internal: |
293 $(ALT_OUTPUTDIR)/jdk/bin/java -XX:+ExecuteInternalVMTests -XX:+ShowMessageBoxOnError -version |
92 $(ALT_OUTPUTDIR)/jdk/bin/java -XX:+ExecuteInternalVMTests -XX:+ShowMessageBoxOnError -version |
294 |
93 |
295 # Prep for output |
|
296 prep: clean |
|
297 @$(MKDIR) -p $(ABS_TEST_OUTPUT_DIR) |
|
298 @$(MKDIR) -p `dirname $(ARCHIVE_BUNDLE)` |
|
299 |
|
300 # Cleanup |
|
301 clean: |
|
302 @$(RM) -r $(ABS_TEST_OUTPUT_DIR) |
|
303 @$(RM) $(ARCHIVE_BUNDLE) |
|
304 |
|
305 ################################################################ |
94 ################################################################ |
306 |
95 ALT_MAKE ?= closed |
307 # jtreg tests |
|
308 |
|
309 # Expect JT_HOME to be set for jtreg tests. (home for jtreg) |
|
310 ifndef JT_HOME |
|
311 JT_HOME = $(SLASH_JAVA)/re/jtreg/4.1/promoted/latest/binaries/jtreg |
|
312 ifdef JPRT_JTREG_HOME |
|
313 JT_HOME = $(JPRT_JTREG_HOME) |
|
314 endif |
|
315 endif |
|
316 |
|
317 # When called from JPRT the TESTDIRS variable is set to the jtreg tests to run |
|
318 ifdef TESTDIRS |
|
319 TEST_SELECTION = $(TESTDIRS) |
|
320 endif |
|
321 |
|
322 # Concurrency based on min(cores / 2, 12) |
|
323 ifdef NUM_CORES |
|
324 CONCURRENCY := $(shell expr $(NUM_CORES) / 2) |
|
325 ifeq ($(CONCURRENCY), 0) |
|
326 CONCURRENCY := 1 |
|
327 else ifeq ($(shell expr $(CONCURRENCY) \> 12), 1) |
|
328 CONCURRENCY := 12 |
|
329 endif |
|
330 else |
|
331 CONCURRENCY := 1 |
|
332 endif |
|
333 JTREG_BASIC_OPTIONS += -concurrency:$(CONCURRENCY) |
|
334 |
|
335 # Make sure MaxRAMFraction is high enough to not cause OOM or swapping since we may end up with a lot of JVM's |
|
336 JTREG_BASIC_OPTIONS += -vmoption:-XX:MaxRAMFraction=$(shell expr $(CONCURRENCY) \* 4) |
|
337 |
|
338 ifdef EXTRA_JTREG_OPTIONS |
|
339 JTREG_BASIC_OPTIONS += $(EXTRA_JTREG_OPTIONS) |
|
340 endif |
|
341 |
|
342 # Default JTREG to run |
|
343 JTREG = $(JT_HOME)/bin/jtreg |
|
344 |
|
345 # Use agent mode |
|
346 JTREG_BASIC_OPTIONS += -agentvm |
|
347 # Only run automatic tests |
|
348 JTREG_BASIC_OPTIONS += -a |
|
349 # Report details on all failed or error tests, times too |
|
350 JTREG_BASIC_OPTIONS += -v:fail,error,time |
|
351 # Retain all files for failing tests |
|
352 JTREG_BASIC_OPTIONS += -retain:fail,error |
|
353 # Ignore tests are not run and completely silent about it |
|
354 JTREG_IGNORE_OPTION = -ignore:quiet |
|
355 JTREG_BASIC_OPTIONS += $(JTREG_IGNORE_OPTION) |
|
356 # Multiply by 4 the timeout factor |
|
357 JTREG_TIMEOUT_OPTION = -timeoutFactor:4 |
|
358 JTREG_BASIC_OPTIONS += $(JTREG_TIMEOUT_OPTION) |
|
359 # Set other vm and test options |
|
360 JTREG_TEST_OPTIONS = $(JAVA_ARGS:%=-javaoptions:%) $(JAVA_OPTIONS:%=-vmoption:%) $(JAVA_VM_ARGS:%=-vmoption:%) |
|
361 |
|
362 # Option to tell jtreg to not run tests marked with "ignore" |
|
363 ifeq ($(PLATFORM), windows) |
|
364 JTREG_KEY_OPTION = -k:!ignore |
|
365 else |
|
366 JTREG_KEY_OPTION = -k:\!ignore |
|
367 endif |
|
368 JTREG_BASIC_OPTIONS += $(JTREG_KEY_OPTION) |
|
369 |
|
370 -include $(ALT_MAKE)/Makefile |
96 -include $(ALT_MAKE)/Makefile |
371 |
|
372 # Make sure jtreg exists |
|
373 $(JTREG): $(JT_HOME) |
|
374 |
|
375 jtreg_tests: prep $(PRODUCT_HOME) $(JTREG) |
|
376 ( \ |
|
377 ( JT_HOME=$(shell $(GETMIXEDPATH) "$(JT_HOME)"); \ |
|
378 export JT_HOME; \ |
|
379 $(shell $(GETMIXEDPATH) "$(JTREG)") \ |
|
380 $(JTREG_BASIC_OPTIONS) \ |
|
381 -r:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTreport") \ |
|
382 -w:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTwork") \ |
|
383 -jdk:$(shell $(GETMIXEDPATH) "$(PRODUCT_HOME)") \ |
|
384 $(JTREG_NATIVE_PATH) \ |
|
385 $(JTREG_FAILURE_HANDLER_OPTIONS) \ |
|
386 $(JTREG_EXCLUSIONS) \ |
|
387 $(JTREG_TEST_OPTIONS) \ |
|
388 $(TEST_SELECTION) \ |
|
389 ) ; \ |
|
390 $(BUNDLE_UP_AND_EXIT) \ |
|
391 ) 2>&1 | $(TEE) $(ABS_TEST_OUTPUT_DIR)/output.txt ; $(TESTEXIT) |
|
392 |
|
393 PHONY_LIST += jtreg_tests |
|
394 |
97 |
395 # flags used to execute java in test targets |
98 # flags used to execute java in test targets |
396 TEST_FLAGS += -version -Xinternalversion -X -help |
99 TEST_FLAGS += -version -Xinternalversion -X -help |
397 |
100 |
398 sanitytest: prep $(PRODUCT_HOME) |
101 sanitytest: prep $(PRODUCT_HOME) |