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