test/Makefile

Sat, 01 Dec 2007 00:00:00 +0000

author
duke
date
Sat, 01 Dec 2007 00:00:00 +0000
changeset 435
a61af66fc99e
child 763
68e0443dfd9c
permissions
-rw-r--r--

Initial load

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

mercurial