1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/test/runtime/6888954/vmerrors.sh Wed Apr 27 01:25:04 2016 +0800 1.3 @@ -0,0 +1,111 @@ 1.4 +# Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 1.5 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.6 +# 1.7 +# This code is free software; you can redistribute it and/or modify it 1.8 +# under the terms of the GNU General Public License version 2 only, as 1.9 +# published by the Free Software Foundation. 1.10 +# 1.11 +# This code is distributed in the hope that it will be useful, but WITHOUT 1.12 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.13 +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.14 +# version 2 for more details (a copy is included in the LICENSE file that 1.15 +# accompanied this code). 1.16 +# 1.17 +# You should have received a copy of the GNU General Public License version 1.18 +# 2 along with this work; if not, write to the Free Software Foundation, 1.19 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.20 +# 1.21 +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.22 +# or visit www.oracle.com if you need additional information or have any 1.23 +# questions. 1.24 +# 1.25 + 1.26 +# @test 1.27 +# @bug 6888954 1.28 +# @bug 8015884 1.29 +# @summary exercise HotSpot error handling code 1.30 +# @author John Coomes 1.31 +# @run shell vmerrors.sh 1.32 + 1.33 +# Repeatedly invoke java with a command-line option that causes HotSpot to 1.34 +# produce an error report and terminate just after initialization. Each 1.35 +# invocation is identified by a small integer, <n>, which provokes a different 1.36 +# error (assertion failure, guarantee failure, fatal error, etc.). The output 1.37 +# from stdout/stderr is written to <n>.out and the hs_err_pidXXX.log file is 1.38 +# renamed to <n>.log. 1.39 +# 1.40 +# The automated checking done by this script is minimal. When updating the 1.41 +# fatal error handler it is more useful to run it manually or to use the -retain 1.42 +# option with the jtreg so that test directories are not removed automatically. 1.43 +# To run stand-alone: 1.44 +# 1.45 +# TESTJAVA=/java/home/dir 1.46 +# TESTVMOPTS=... 1.47 +# export TESTJAVA TESTVMOPTS 1.48 +# sh test/runtime/6888954/vmerrors.sh 1.49 + 1.50 +ulimit -c 0 # no core files 1.51 + 1.52 +i=1 1.53 +rc=0 1.54 + 1.55 +assert_re='(assert|guarantee)[(](str|num).*failed: *' 1.56 +# for bad_data_ptr_re: 1.57 +# EXCEPTION_ACCESS_VIOLATION - Win-* 1.58 +# SIGILL - MacOS X 1.59 +# SIGSEGV - Linux-*, Solaris SPARC-*, Solaris X86-* 1.60 +# 1.61 +bad_data_ptr_re='(SIGILL|SIGSEGV|EXCEPTION_ACCESS_VIOLATION).* at pc=' 1.62 +# 1.63 +# for bad_func_ptr_re: 1.64 +# EXCEPTION_ACCESS_VIOLATION - Win-* 1.65 +# SIGBUS - Solaris SPARC-64 1.66 +# SIGSEGV - Linux-*, Solaris SPARC-32, Solaris X86-* 1.67 +# 1.68 +# Note: would like to use "pc=0x00*0f," in the pattern, but Solaris SPARC-* 1.69 +# gets its signal at a PC in test_error_handler(). 1.70 +# 1.71 +bad_func_ptr_re='(SIGBUS|SIGSEGV|EXCEPTION_ACCESS_VIOLATION).* at pc=' 1.72 +guarantee_re='guarantee[(](str|num).*failed: *' 1.73 +fatal_re='fatal error: *' 1.74 +tail_1='.*expected null' 1.75 +tail_2='.*num=' 1.76 + 1.77 +for re in \ 1.78 + "${assert_re}${tail_1}" "${assert_re}${tail_2}" \ 1.79 + "${guarantee_re}${tail_1}" "${guarantee_re}${tail_2}" \ 1.80 + "${fatal_re}${tail_1}" "${fatal_re}${tail_2}" \ 1.81 + "${fatal_re}.*truncated" "ChunkPool::allocate" \ 1.82 + "ShouldNotCall" "ShouldNotReachHere" \ 1.83 + "Unimplemented" "$bad_data_ptr_re" \ 1.84 + "$bad_func_ptr_re" 1.85 + 1.86 +do 1.87 + i2=$i 1.88 + [ $i -lt 10 ] && i2=0$i 1.89 + 1.90 + "$TESTJAVA/bin/java" $TESTVMOPTS -XX:+IgnoreUnrecognizedVMOptions \ 1.91 + -XX:-TransmitErrorReport \ 1.92 + -XX:ErrorHandlerTest=${i} -version > ${i2}.out 2>&1 1.93 + 1.94 + # If ErrorHandlerTest is ignored (product build), stop. 1.95 + # 1.96 + # Using the built-in variable $! to get the pid does not work reliably on 1.97 + # windows; use a wildcard instead. 1.98 + mv hs_err_pid*.log ${i2}.log || exit $rc 1.99 + 1.100 + for f in ${i2}.log ${i2}.out 1.101 + do 1.102 + egrep -- "$re" $f > $$ 1.103 + if [ $? -ne 0 ] 1.104 + then 1.105 + echo "ErrorHandlerTest=$i failed ($f)" 1.106 + rc=1 1.107 + fi 1.108 + done 1.109 + rm -f $$ 1.110 + 1.111 + i=`expr $i + 1` 1.112 +done 1.113 + 1.114 +exit $rc