mseledtsov@5847: # Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. mseledtsov@5847: # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. mseledtsov@5847: # mseledtsov@5847: # This code is free software; you can redistribute it and/or modify it mseledtsov@5847: # under the terms of the GNU General Public License version 2 only, as mseledtsov@5847: # published by the Free Software Foundation. mseledtsov@5847: # mseledtsov@5847: # This code is distributed in the hope that it will be useful, but WITHOUT mseledtsov@5847: # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or mseledtsov@5847: # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License mseledtsov@5847: # version 2 for more details (a copy is included in the LICENSE file that mseledtsov@5847: # accompanied this code). mseledtsov@5847: # mseledtsov@5847: # You should have received a copy of the GNU General Public License version mseledtsov@5847: # 2 along with this work; if not, write to the Free Software Foundation, mseledtsov@5847: # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. mseledtsov@5847: # mseledtsov@5847: # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA mseledtsov@5847: # or visit www.oracle.com if you need additional information or have any mseledtsov@5847: # questions. mseledtsov@5847: # mseledtsov@5847: jcoomes@1845: # @test jcoomes@1845: # @bug 6888954 dcubed@5365: # @bug 8015884 jcoomes@1845: # @summary exercise HotSpot error handling code jcoomes@1845: # @author John Coomes jcoomes@1845: # @run shell vmerrors.sh jcoomes@1845: jcoomes@1845: # Repeatedly invoke java with a command-line option that causes HotSpot to jcoomes@1845: # produce an error report and terminate just after initialization. Each jcoomes@1845: # invocation is identified by a small integer, , which provokes a different jcoomes@1845: # error (assertion failure, guarantee failure, fatal error, etc.). The output jcoomes@1845: # from stdout/stderr is written to .out and the hs_err_pidXXX.log file is jcoomes@1845: # renamed to .log. jcoomes@1845: # jcoomes@1845: # The automated checking done by this script is minimal. When updating the jcoomes@1845: # fatal error handler it is more useful to run it manually or to use the -retain jcoomes@1845: # option with the jtreg so that test directories are not removed automatically. jcoomes@1845: # To run stand-alone: jcoomes@1845: # jcoomes@1845: # TESTJAVA=/java/home/dir jcoomes@1845: # TESTVMOPTS=... jcoomes@1845: # export TESTJAVA TESTVMOPTS jcoomes@1845: # sh test/runtime/6888954/vmerrors.sh jcoomes@1845: jcoomes@1845: ulimit -c 0 # no core files jcoomes@1845: jcoomes@1845: i=1 jcoomes@1845: rc=0 jcoomes@1845: jcoomes@1845: assert_re='(assert|guarantee)[(](str|num).*failed: *' dcubed@5365: # for bad_data_ptr_re: dcubed@5365: # EXCEPTION_ACCESS_VIOLATION - Win-* dcubed@5365: # SIGILL - MacOS X dcubed@5365: # SIGSEGV - Linux-*, Solaris SPARC-*, Solaris X86-* dcubed@5365: # dcubed@5365: bad_data_ptr_re='(SIGILL|SIGSEGV|EXCEPTION_ACCESS_VIOLATION).* at pc=' dcubed@5365: # dcubed@5365: # for bad_func_ptr_re: dcubed@5365: # EXCEPTION_ACCESS_VIOLATION - Win-* dcubed@5365: # SIGBUS - Solaris SPARC-64 dcubed@5365: # SIGSEGV - Linux-*, Solaris SPARC-32, Solaris X86-* dcubed@5365: # dcubed@5365: # Note: would like to use "pc=0x00*0f," in the pattern, but Solaris SPARC-* dcubed@5365: # gets its signal at a PC in test_error_handler(). dcubed@5365: # dcubed@5365: bad_func_ptr_re='(SIGBUS|SIGSEGV|EXCEPTION_ACCESS_VIOLATION).* at pc=' jcoomes@1845: guarantee_re='guarantee[(](str|num).*failed: *' jcoomes@1845: fatal_re='fatal error: *' jcoomes@1845: tail_1='.*expected null' jcoomes@1845: tail_2='.*num=' jcoomes@1845: jcoomes@1845: for re in \ jcoomes@1845: "${assert_re}${tail_1}" "${assert_re}${tail_2}" \ jcoomes@1845: "${guarantee_re}${tail_1}" "${guarantee_re}${tail_2}" \ jcoomes@1845: "${fatal_re}${tail_1}" "${fatal_re}${tail_2}" \ jcoomes@1845: "${fatal_re}.*truncated" "ChunkPool::allocate" \ jcoomes@1845: "ShouldNotCall" "ShouldNotReachHere" \ dcubed@5365: "Unimplemented" "$bad_data_ptr_re" \ dcubed@5365: "$bad_func_ptr_re" dcubed@5365: jcoomes@1845: do jcoomes@1845: i2=$i jcoomes@1845: [ $i -lt 10 ] && i2=0$i jcoomes@1845: jcoomes@1845: "$TESTJAVA/bin/java" $TESTVMOPTS -XX:+IgnoreUnrecognizedVMOptions \ mseledtsov@5847: -XX:-TransmitErrorReport \ jcoomes@1845: -XX:ErrorHandlerTest=${i} -version > ${i2}.out 2>&1 jcoomes@1845: jcoomes@1845: # If ErrorHandlerTest is ignored (product build), stop. jcoomes@1845: # jcoomes@1845: # Using the built-in variable $! to get the pid does not work reliably on jcoomes@1845: # windows; use a wildcard instead. jcoomes@1845: mv hs_err_pid*.log ${i2}.log || exit $rc jcoomes@1845: jcoomes@1845: for f in ${i2}.log ${i2}.out jcoomes@1845: do jcoomes@1845: egrep -- "$re" $f > $$ jcoomes@1845: if [ $? -ne 0 ] jcoomes@1845: then jcoomes@1845: echo "ErrorHandlerTest=$i failed ($f)" jcoomes@1845: rc=1 jcoomes@1845: fi jcoomes@1845: done jcoomes@1845: rm -f $$ jcoomes@1845: jcoomes@1947: i=`expr $i + 1` jcoomes@1845: done jcoomes@1845: jcoomes@1845: exit $rc