test/compiler/ciReplay/common.sh

Wed, 27 Apr 2016 01:25:04 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:25:04 +0800
changeset 0
f90c822e73f8
child 6876
710a3c8b516e
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/
changeset: 6782:28b50d07f6f8
tag: jdk8u25-b17

aoqi@0 1 #!/bin/sh
aoqi@0 2 #
aoqi@0 3 # Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
aoqi@0 4 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 5 #
aoqi@0 6 # This code is free software; you can redistribute it and/or modify it
aoqi@0 7 # under the terms of the GNU General Public License version 2 only, as
aoqi@0 8 # published by the Free Software Foundation.
aoqi@0 9 #
aoqi@0 10 # This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 13 # version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 14 # accompanied this code).
aoqi@0 15 #
aoqi@0 16 # You should have received a copy of the GNU General Public License version
aoqi@0 17 # 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 18 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 19 #
aoqi@0 20 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 21 # or visit www.oracle.com if you need additional information or have any
aoqi@0 22 # questions.
aoqi@0 23 #
aoqi@0 24 #
aoqi@0 25
aoqi@0 26 # $1 - error code
aoqi@0 27 # $2 - test name
aoqi@0 28 # $3,.. - decription
aoqi@0 29 test_fail() {
aoqi@0 30 error=$1
aoqi@0 31 shift
aoqi@0 32 name=$1
aoqi@0 33 shift
aoqi@0 34 echo "TEST [$name] FAILED:"
aoqi@0 35 echo "$@"
aoqi@0 36 exit $error
aoqi@0 37 }
aoqi@0 38
aoqi@0 39 # $@ - additional vm opts
aoqi@0 40 start_test() {
aoqi@0 41 # disable core dump on *nix
aoqi@0 42 ulimit -S -c 0
aoqi@0 43 # disable core dump on windows
aoqi@0 44 VMOPTS="$@ -XX:-CreateMinidumpOnCrash"
aoqi@0 45 cmd="${JAVA} ${VMOPTS} -XX:+ReplayCompiles -XX:ReplayDataFile=${replay_data}"
aoqi@0 46 echo $cmd
aoqi@0 47 $cmd
aoqi@0 48 return $?
aoqi@0 49 }
aoqi@0 50
aoqi@0 51 # $1 - error_code
aoqi@0 52 # $2 - test name
aoqi@0 53 # $3,.. - additional vm opts
aoqi@0 54 positive_test() {
aoqi@0 55 error=$1
aoqi@0 56 shift
aoqi@0 57 name=$1
aoqi@0 58 shift
aoqi@0 59 VMOPTS="${TESTVMOPTS} $@"
aoqi@0 60 echo "POSITIVE TEST [$name]"
aoqi@0 61 start_test ${VMOPTS}
aoqi@0 62 exit_code=$?
aoqi@0 63 if [ ${exit_code} -ne 0 ]
aoqi@0 64 then
aoqi@0 65 test_fail $error "$name" "exit_code[${exit_code}] != 0 during replay "\
aoqi@0 66 "w/ vmopts: ${VMOPTS}"
aoqi@0 67 fi
aoqi@0 68 }
aoqi@0 69
aoqi@0 70 # $1 - error_code
aoqi@0 71 # $2 - test name
aoqi@0 72 # $2,.. - additional vm opts
aoqi@0 73 negative_test() {
aoqi@0 74 error=$1
aoqi@0 75 shift
aoqi@0 76 name=$1
aoqi@0 77 shift
aoqi@0 78 VMOPTS="${TESTVMOPTS} $@"
aoqi@0 79 echo "NEGATIVE TEST [$name]"
aoqi@0 80 start_test ${VMOPTS}
aoqi@0 81 exit_code=$?
aoqi@0 82 if [ ${exit_code} -eq 0 ]
aoqi@0 83 then
aoqi@0 84 test_fail $error "$name" "exit_code[${exit_code}] == 0 during replay "\
aoqi@0 85 "w/ vmopts: ${VMOPTS}"
aoqi@0 86 fi
aoqi@0 87 }
aoqi@0 88
aoqi@0 89 # $1 - initial error_code
aoqi@0 90 common_tests() {
aoqi@0 91 positive_test $1 "COMMON :: THE SAME FLAGS"
aoqi@0 92 if [ $tiered_available -eq 1 ]
aoqi@0 93 then
aoqi@0 94 positive_test `expr $1 + 1` "COMMON :: TIERED" -XX:+TieredCompilation
aoqi@0 95 fi
aoqi@0 96 }
aoqi@0 97
aoqi@0 98 # $1 - initial error_code
aoqi@0 99 # $2 - non-tiered comp_level
aoqi@0 100 nontiered_tests() {
aoqi@0 101 level=`grep "^compile " $replay_data | awk '{print $6}'`
aoqi@0 102 # is level available in non-tiered
aoqi@0 103 if [ "$level" -eq $2 ]
aoqi@0 104 then
aoqi@0 105 positive_test $1 "NON-TIERED :: AVAILABLE COMP_LEVEL" \
aoqi@0 106 -XX:-TieredCompilation
aoqi@0 107 else
aoqi@0 108 negative_test `expr $1 + 1` "NON-TIERED :: UNAVAILABLE COMP_LEVEL" \
aoqi@0 109 -XX:-TieredCompilation
aoqi@0 110 fi
aoqi@0 111 }
aoqi@0 112
aoqi@0 113 # $1 - initial error_code
aoqi@0 114 client_tests() {
aoqi@0 115 # testing in opposite VM
aoqi@0 116 if [ $server_available -eq 1 ]
aoqi@0 117 then
aoqi@0 118 negative_test $1 "SERVER :: NON-TIERED" -XX:-TieredCompilation \
aoqi@0 119 -server
aoqi@0 120 if [ $tiered_available -eq 1 ]
aoqi@0 121 then
aoqi@0 122 positive_test `expr $1 + 1` "SERVER :: TIERED" -XX:+TieredCompilation \
aoqi@0 123 -server
aoqi@0 124 fi
aoqi@0 125 fi
aoqi@0 126 nontiered_tests `expr $1 + 2` $client_level
aoqi@0 127 }
aoqi@0 128
aoqi@0 129 # $1 - initial error_code
aoqi@0 130 server_tests() {
aoqi@0 131 # testing in opposite VM
aoqi@0 132 if [ $client_available -eq 1 ]
aoqi@0 133 then
aoqi@0 134 # tiered is unavailable in client vm, so results w/ flags will be the same as w/o flags
aoqi@0 135 negative_test $1 "CLIENT" -client
aoqi@0 136 fi
aoqi@0 137 nontiered_tests `expr $1 + 2` $server_level
aoqi@0 138 }
aoqi@0 139
aoqi@0 140 cleanup() {
aoqi@0 141 ${RM} -f core*
aoqi@0 142 ${RM} -f replay*.txt
aoqi@0 143 ${RM} -f hs_err_pid*.log
aoqi@0 144 ${RM} -f test_core
aoqi@0 145 ${RM} -f test_replay.txt
aoqi@0 146 }
aoqi@0 147
aoqi@0 148 JAVA=${TESTJAVA}${FS}bin${FS}java
aoqi@0 149
aoqi@0 150 replay_data=test_replay.txt
aoqi@0 151
aoqi@0 152 ${JAVA} ${TESTVMOPTS} -Xinternalversion 2>&1 | grep debug
aoqi@0 153
aoqi@0 154 # Only test fastdebug
aoqi@0 155 if [ $? -ne 0 ]
aoqi@0 156 then
aoqi@0 157 echo TEST SKIPPED: product build
aoqi@0 158 exit 0
aoqi@0 159 fi
aoqi@0 160
aoqi@0 161 is_int=`${JAVA} ${TESTVMOPTS} -version 2>&1 | grep -c "interpreted mode"`
aoqi@0 162 # Not applicable for Xint
aoqi@0 163 if [ $is_int -ne 0 ]
aoqi@0 164 then
aoqi@0 165 echo TEST SKIPPED: interpreted mode
aoqi@0 166 exit 0
aoqi@0 167 fi
aoqi@0 168
aoqi@0 169 cleanup
aoqi@0 170
aoqi@0 171 client_available=`${JAVA} ${TESTVMOPTS} -client -Xinternalversion 2>&1 | \
aoqi@0 172 grep -c Client`
aoqi@0 173 server_available=`${JAVA} ${TESTVMOPTS} -server -Xinternalversion 2>&1 | \
aoqi@0 174 grep -c Server`
aoqi@0 175 tiered_available=`${JAVA} ${TESTVMOPTS} -XX:+TieredCompilation -XX:+PrintFlagsFinal -version | \
aoqi@0 176 grep TieredCompilation | \
aoqi@0 177 grep -c true`
aoqi@0 178 is_tiered=`${JAVA} ${TESTVMOPTS} -XX:+PrintFlagsFinal -version | \
aoqi@0 179 grep TieredCompilation | \
aoqi@0 180 grep -c true`
aoqi@0 181 # CompLevel_simple -- C1
aoqi@0 182 client_level=1
aoqi@0 183 # CompLevel_full_optimization -- C2 or Shark
aoqi@0 184 server_level=4
aoqi@0 185
aoqi@0 186 echo "client_available=$client_available"
aoqi@0 187 echo "server_available=$server_available"
aoqi@0 188 echo "tiered_available=$tiered_available"
aoqi@0 189 echo "is_tiered=$is_tiered"
aoqi@0 190
aoqi@0 191 # crash vm in compiler thread with generation replay data and 'small' dump-file
aoqi@0 192 # $@ - additional vm opts
aoqi@0 193 generate_replay() {
aoqi@0 194 if [ $VM_OS != "windows" ]
aoqi@0 195 then
aoqi@0 196 # enable core dump
aoqi@0 197 ulimit -c unlimited
aoqi@0 198
aoqi@0 199 if [ $VM_OS = "solaris" ]
aoqi@0 200 then
aoqi@0 201 coreadm -p core $$
aoqi@0 202 fi
aoqi@0 203 fi
aoqi@0 204
aoqi@0 205 cmd="${JAVA} ${TESTVMOPTS} $@ \
aoqi@0 206 -Xms8m \
aoqi@0 207 -Xmx32m \
aoqi@0 208 -XX:MetaspaceSize=4m \
aoqi@0 209 -XX:MaxMetaspaceSize=16m \
aoqi@0 210 -XX:InitialCodeCacheSize=512k \
aoqi@0 211 -XX:ReservedCodeCacheSize=4m \
aoqi@0 212 -XX:ThreadStackSize=512 \
aoqi@0 213 -XX:VMThreadStackSize=512 \
aoqi@0 214 -XX:CompilerThreadStackSize=512 \
aoqi@0 215 -XX:ParallelGCThreads=1 \
aoqi@0 216 -XX:CICompilerCount=1 \
aoqi@0 217 -Xcomp \
aoqi@0 218 -XX:CICrashAt=1 \
aoqi@0 219 -XX:+CreateMinidumpOnCrash \
aoqi@0 220 -XX:+DumpReplayDataOnError \
aoqi@0 221 -XX:ReplayDataFile=${replay_data} \
aoqi@0 222 -version"
aoqi@0 223 echo GENERATION OF REPLAY.TXT:
aoqi@0 224 echo $cmd
aoqi@0 225
aoqi@0 226 ${cmd} > crash.out 2>&1
aoqi@0 227
aoqi@0 228 core_locations=`grep -i core crash.out | grep "location:" | \
aoqi@0 229 sed -e 's/.*location: //'`
aoqi@0 230 rm crash.out
aoqi@0 231 # processing core locations for *nix
aoqi@0 232 if [ $VM_OS != "windows" ]
aoqi@0 233 then
aoqi@0 234 # remove 'or' between '/core.<pid>' and 'core'
aoqi@0 235 core_locations=`echo $core_locations | \
aoqi@0 236 sed -e 's/\([^ ]*\) or \([^ ]*\)/\1 \2/'`
aoqi@0 237 # add <core_path>/core.<pid> core.<pid>
aoqi@0 238 core_with_dir=`echo $core_locations | awk '{print $1}'`
aoqi@0 239 dir=`dirname $core_with_dir`
aoqi@0 240 core_with_pid=`echo $core_locations | awk '{print $2}'`
aoqi@0 241 if [ -n ${core_with_pid} ]
aoqi@0 242 then
aoqi@0 243 core_locations="$core_locations $dir${FS}$core_with_pid $core_with_pid"
aoqi@0 244 fi
aoqi@0 245 fi
aoqi@0 246
aoqi@0 247 echo "LOOKING FOR CORE IN ${core_locations}"
aoqi@0 248 for core in $core_locations
aoqi@0 249 do
aoqi@0 250 if [ -r "$core" ]
aoqi@0 251 then
aoqi@0 252 core_file=$core
aoqi@0 253 fi
aoqi@0 254 done
aoqi@0 255
aoqi@0 256 # core-file was found
aoqi@0 257 if [ -n "$core_file" ]
aoqi@0 258 then
aoqi@0 259 ${MV} "${core_file}" test_core
aoqi@0 260 core_file=test_core
aoqi@0 261 fi
aoqi@0 262
aoqi@0 263 ${RM} -f hs_err_pid*.log
aoqi@0 264 }
aoqi@0 265

mercurial