1
|
1 |
#
|
|
2 |
# Copyright 2006 Sun Microsystems, Inc. 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.
|
|
8 |
#
|
|
9 |
# This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 |
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 |
# version 2 for more details (a copy is included in the LICENSE file that
|
|
13 |
# accompanied this code).
|
|
14 |
#
|
|
15 |
# You should have received a copy of the GNU General Public License version
|
|
16 |
# 2 along with this work; if not, write to the Free Software Foundation,
|
|
17 |
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18 |
#
|
|
19 |
# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
20 |
# CA 95054 USA or visit www.sun.com if you need additional information or
|
|
21 |
# have any questions.
|
|
22 |
#
|
|
23 |
#
|
|
24 |
|
|
25 |
#
|
|
26 |
# Makefile to run jtreg
|
|
27 |
#
|
|
28 |
|
|
29 |
OSNAME = $(shell uname -s)
|
|
30 |
ifeq ($(OSNAME), SunOS)
|
|
31 |
PLATFORM = solaris
|
|
32 |
JCT_PLATFORM = solaris
|
|
33 |
ARCH = $(shell uname -p)
|
|
34 |
ifeq ($(ARCH), i386)
|
|
35 |
ARCH=i586
|
|
36 |
endif
|
|
37 |
endif
|
|
38 |
ifeq ($(OSNAME), Linux)
|
|
39 |
PLATFORM = linux
|
|
40 |
JCT_PLATFORM = linux
|
|
41 |
ARCH = $(shell uname -m)
|
|
42 |
ifeq ($(ARCH), i386)
|
|
43 |
ARCH=i586
|
|
44 |
endif
|
|
45 |
endif
|
|
46 |
ifeq ($(OSNAME), Windows_NT)
|
|
47 |
PLATFORM = windows
|
|
48 |
JCT_PLATFORM = win32
|
|
49 |
ifeq ($(word 1, $(PROCESSOR_IDENTIFIER)),ia64)
|
|
50 |
ARCH=ia64
|
|
51 |
else
|
|
52 |
ifeq ($(word 1, $(PROCESSOR_IDENTIFIER)),AMD64)
|
|
53 |
ARCH=x64
|
|
54 |
else
|
|
55 |
ifeq ($(word 1, $(PROCESSOR_IDENTIFIER)),EM64T)
|
|
56 |
ARCH=x64
|
|
57 |
else
|
|
58 |
ARCH=i586
|
|
59 |
endif
|
|
60 |
endif
|
|
61 |
endif
|
|
62 |
endif
|
|
63 |
|
|
64 |
# Default bundle of all test results (passed or not)
|
|
65 |
JPRT_ARCHIVE_BUNDLE=$(TEST_ROOT)/JPRT_ARCHIVE_BUNDLE.zip
|
|
66 |
|
|
67 |
# Default home for JTREG
|
|
68 |
ifeq ($(PLATFORM), windows)
|
|
69 |
JT_HOME = J:/svc/jct-tools3.2.2_01
|
|
70 |
else
|
|
71 |
JT_HOME = /java/svc/jct-tools3.2.2_01
|
|
72 |
endif
|
|
73 |
|
|
74 |
# Default JTREG to run
|
|
75 |
JTREG = $(JT_HOME)/$(JCT_PLATFORM)/bin/jtreg
|
|
76 |
|
|
77 |
# Root of this test area
|
|
78 |
TEST_ROOT := $(shell pwd)
|
|
79 |
|
|
80 |
# Default JDK to test
|
|
81 |
JAVA_HOME = $(TEST_ROOT)/../build/$(PLATFORM)-$(ARCH)
|
|
82 |
|
|
83 |
# The test directories to run
|
|
84 |
DEFAULT_TESTDIRS = serviceability
|
|
85 |
TESTDIRS = $(DEFAULT_TESTDIRS)
|
|
86 |
|
|
87 |
# Files that hold total passed and failed counts (passed==0 is bad)
|
|
88 |
JTREG_TOTALS_DIR = $(TEST_ROOT)/JTREG_TOTALS_$(PLATFORM)_$(ARCH)
|
|
89 |
JTREG_FAILED = $(JTREG_TOTALS_DIR)/failed_count
|
|
90 |
JTREG_PASSED = $(JTREG_TOTALS_DIR)/passed_count
|
|
91 |
|
|
92 |
# Root of all test results
|
|
93 |
JTREG_ALL_OUTPUT_DIRNAME = JTREG_OUTPUT_$(PLATFORM)_$(ARCH)
|
|
94 |
JTREG_ALL_OUTPUT_DIR = $(TEST_ROOT)/$(JTREG_ALL_OUTPUT_DIRNAME)
|
|
95 |
|
|
96 |
# Test results for one test directory
|
|
97 |
JTREG_TEST_OUTPUT_DIR = $(JTREG_ALL_OUTPUT_DIR)/$@
|
|
98 |
JTREG_TEST_REPORT_DIR = $(JTREG_TEST_OUTPUT_DIR)/JTreport
|
|
99 |
JTREG_TEST_WORK_DIR = $(JTREG_TEST_OUTPUT_DIR)/JTwork
|
|
100 |
JTREG_TEST_SUMMARY = $(JTREG_TEST_REPORT_DIR)/summary.txt
|
|
101 |
|
|
102 |
# Temp files used by this Makefile
|
|
103 |
JTREG_TEST_TEMP_DIR = $(JTREG_ALL_OUTPUT_DIR)/$@/temp
|
|
104 |
JTREG_TEMP_PASSED = $(JTREG_TEST_TEMP_DIR)/passed
|
|
105 |
JTREG_TEMP_FAILED = $(JTREG_TEST_TEMP_DIR)/failed
|
|
106 |
JTREG_TEMP_OUTPUT = $(JTREG_TEST_TEMP_DIR)/output
|
|
107 |
JTREG_TEMP_RESULTS = $(JTREG_TEST_TEMP_DIR)/results
|
|
108 |
|
|
109 |
# JTREG options (different for 2.1.6 and 3.2.2_01)
|
|
110 |
JTREG_COMMON_OPTIONS = -r:$(JTREG_TEST_REPORT_DIR) \
|
|
111 |
-w:$(JTREG_TEST_WORK_DIR) \
|
|
112 |
-testjdk:$(JAVA_HOME) \
|
|
113 |
-automatic \
|
|
114 |
-verbose:all
|
|
115 |
JTREG_216_OPTIONS = $(JTREG_COMMON_OPTIONS) $@ $(JAVA_ARGS)
|
|
116 |
JTREG_322_OPTIONS = $(JTREG_COMMON_OPTIONS) $(JAVA_ARGS:%=-vmoption:%) $@
|
|
117 |
|
|
118 |
# Default make rule
|
|
119 |
all: clean check tests
|
|
120 |
|
|
121 |
# Chaeck to make sure these directories exist
|
|
122 |
check: $(JT_HOME) $(JAVA_HOME) $(JTREG)
|
|
123 |
|
|
124 |
# Prime the test run
|
|
125 |
primecounts: FRC
|
|
126 |
@rm -f -r $(JTREG_TOTALS_DIR)
|
|
127 |
@mkdir -p $(JTREG_TOTALS_DIR)
|
|
128 |
@echo "0" > $(JTREG_FAILED)
|
|
129 |
@echo "0" > $(JTREG_PASSED)
|
|
130 |
|
|
131 |
# Run the tests and determine the 'make' command exit status
|
|
132 |
# Ultimately we determine the make exit code based on the passed/failed count
|
|
133 |
tests: primecounts $(TESTDIRS)
|
|
134 |
@echo "JTREG TOTAL: passed=`cat $(JTREG_PASSED)` failed=`cat $(JTREG_FAILED)`"
|
|
135 |
zip -q -r $(JPRT_ARCHIVE_BUNDLE) $(JTREG_ALL_OUTPUT_DIRNAME)
|
|
136 |
@if [ `cat $(JTREG_FAILED)` -ne 0 -o \
|
|
137 |
`cat $(JTREG_PASSED)` -le 0 ] ; then \
|
|
138 |
echo "JTREG FAILED"; \
|
|
139 |
exit 1; \
|
|
140 |
else \
|
|
141 |
echo "JTREG PASSED"; \
|
|
142 |
exit 0; \
|
|
143 |
fi
|
|
144 |
|
|
145 |
# Just make sure these directires exist
|
|
146 |
$(JT_HOME) $(JAVA_HOME): FRC
|
|
147 |
@if [ ! -d $@ ] ; then \
|
|
148 |
echo "ERROR: Directory $@ does not exist"; \
|
|
149 |
exit 1; \
|
|
150 |
fi
|
|
151 |
|
|
152 |
# Make sure this file exists
|
|
153 |
$(JTREG): FRC
|
|
154 |
@if [ ! -f $@ ] ; then \
|
|
155 |
echo "ERROR: File $@ does not exist"; \
|
|
156 |
exit 1; \
|
|
157 |
fi
|
|
158 |
|
|
159 |
# Process each test directory one by one, this rule always completes.
|
|
160 |
# Note that the use of 'tee' tosses the jtreg process exit status, this
|
|
161 |
# is as expected because even if jtreg fails, we need to save the
|
|
162 |
# output. So we update the JTREG_PASSED and JTREG_FAILED count files.
|
|
163 |
# Note that missing the 'results:' line in the last few lines of output
|
|
164 |
# will indicate a failure (or a bump by one of the JTREG_FAILED file.
|
|
165 |
# Note that passed: 0 or no passed: indication means a failure.
|
|
166 |
# Note that any indication of the word 'failed' indicates failure.
|
|
167 |
# Ultimately if the contents of JTREG_FAILED is not 0, we have failed
|
|
168 |
# tests, and if the contents of JTREG_PASSED is 0, we consider that a
|
|
169 |
# failure.
|
|
170 |
$(TESTDIRS): FRC
|
|
171 |
@if [ ! -d $@ ] ; then \
|
|
172 |
echo "ERROR: Directory $@ does not exist"; \
|
|
173 |
exit 1; \
|
|
174 |
fi
|
|
175 |
@echo "---------------------------------------------------"
|
|
176 |
@rm -f -r $(JTREG_TEST_OUTPUT_DIR)
|
|
177 |
@mkdir -p $(JTREG_TEST_OUTPUT_DIR)
|
|
178 |
@mkdir -p $(JTREG_TEST_WORK_DIR)
|
|
179 |
@mkdir -p $(JTREG_TEST_WORK_DIR)/scratch
|
|
180 |
@mkdir -p $(JTREG_TEST_REPORT_DIR)
|
|
181 |
@mkdir -p $(JTREG_TEST_TEMP_DIR)
|
|
182 |
@echo "Testing $@"
|
|
183 |
@echo "Using JAVA_HOME=$(JAVA_HOME)"
|
|
184 |
@echo "Using JAVA_ARGS=$(JAVA_ARGS)"
|
|
185 |
@if [ "`$(JTREG) -help 2>&1 | fgrep -- -vmoption`" != "" ] ; then \
|
|
186 |
echo "Assume we are using jtreg 3.2.2_01 or newer"; \
|
|
187 |
echo "$(JTREG) $(JTREG_322_OPTIONS)"; \
|
|
188 |
$(JTREG) $(JTREG_322_OPTIONS) 2>&1 | tee $(JTREG_TEMP_OUTPUT) ; \
|
|
189 |
else \
|
|
190 |
echo "Assume we are using jtreg 2.1.6"; \
|
|
191 |
echo "$(JTREG) $(JTREG_216_OPTIONS)"; \
|
|
192 |
$(JTREG) $(JTREG_216_OPTIONS) 2>&1 | tee $(JTREG_TEMP_OUTPUT) ; \
|
|
193 |
fi
|
|
194 |
@echo "---------------------------------------------------"
|
|
195 |
@echo "Extracting passed and failed counts from jtreg output"
|
|
196 |
@tail -10 $(JTREG_TEMP_OUTPUT) | fgrep -i 'results:' | \
|
|
197 |
tail -1 | tee $(JTREG_TEMP_RESULTS)
|
|
198 |
@sed -e 's@.*\ passed:\ \([1-9][0-9]*\).*@\1@' $(JTREG_TEMP_RESULTS) \
|
|
199 |
> $(JTREG_TEMP_PASSED)
|
|
200 |
@if [ "`cat $(JTREG_TEMP_PASSED)`" = "" ] ; then \
|
|
201 |
echo "ERROR: No passed indication in results"; \
|
|
202 |
expr `cat $(JTREG_FAILED)` '+' 1 > $(JTREG_FAILED); \
|
|
203 |
elif [ `cat $(JTREG_TEMP_PASSED)` -le 0 ] ; then \
|
|
204 |
echo "ERROR: Passed count appears to be 0"; \
|
|
205 |
expr `cat $(JTREG_FAILED)` '+' 1 > $(JTREG_FAILED); \
|
|
206 |
elif [ "`fgrep -i failed $(JTREG_TEMP_RESULTS)`" = "" ] ; then \
|
|
207 |
echo "No indication anything failed"; \
|
|
208 |
expr `cat $(JTREG_PASSED)` '+' `cat $(JTREG_TEMP_PASSED)` \
|
|
209 |
> $(JTREG_PASSED); \
|
|
210 |
else \
|
|
211 |
sed -e 's@.*\ failed:\ \([1-9][0-9]*\).*@\1@' $(JTREG_TEMP_FAILED) \
|
|
212 |
> $(JTREG_TEMP_FAILED); \
|
|
213 |
if [ "`cat $(JTREG_TEMP_FAILED)`" = "" ] ; then \
|
|
214 |
echo "ERROR: Failed pattern but no failed count in results"; \
|
|
215 |
expr `cat $(JTREG_FAILED)` '+' 1 > $(JTREG_FAILED); \
|
|
216 |
elif [ `cat $(JTREG_TEMP_FAILED)` -le 0 ] ; then \
|
|
217 |
echo "ERROR: Failed count is 0, did something failed or not?"; \
|
|
218 |
expr `cat $(JTREG_FAILED)` '+' 1 > $(JTREG_FAILED); \
|
|
219 |
else \
|
|
220 |
expr `cat $(JTREG_FAILED)` '+' `cat $(JTREG_TEMP_FAILED)` \
|
|
221 |
> $(JTREG_FAILED); \
|
|
222 |
fi; \
|
|
223 |
fi
|
|
224 |
@echo "---------------------------------------------------"
|
|
225 |
@echo "Summary: "
|
|
226 |
@if [ -f $(JTREG_TEST_SUMMARY) ] ; then \
|
|
227 |
cat $(JTREG_TEST_SUMMARY) ; \
|
|
228 |
else \
|
|
229 |
echo "ERROR: Missing $(JTREG_TEST_SUMMARY)"; \
|
|
230 |
fi
|
|
231 |
@echo "---------------------------------------------------"
|
|
232 |
|
|
233 |
# Cleanup
|
|
234 |
clean:
|
|
235 |
rm -f -r $(JTREG_ALL_OUTPUT_DIR)
|
|
236 |
rm -f $(JPRT_ARCHIVE_BUNDLE)
|
|
237 |
|
|
238 |
FRC:
|
|
239 |
|