1 # @test
   2 # @bug 6888954
   3 # @summary exercise HotSpot error handling code
   4 # @author John Coomes
   5 # @run shell vmerrors.sh
   6 
   7 # Repeatedly invoke java with a command-line option that causes HotSpot to
   8 # produce an error report and terminate just after initialization.  Each
   9 # invocation is identified by a small integer, <n>, which provokes a different
  10 # error (assertion failure, guarantee failure, fatal error, etc.).  The output
  11 # from stdout/stderr is written to <n>.out and the hs_err_pidXXX.log file is
  12 # renamed to <n>.log.
  13 #
  14 # The automated checking done by this script is minimal.  When updating the
  15 # fatal error handler it is more useful to run it manually or to use the -retain
  16 # option with the jtreg so that test directories are not removed automatically.
  17 # To run stand-alone:
  18 #
  19 # TESTJAVA=/java/home/dir
  20 # TESTVMOPTS=...
  21 # export TESTJAVA TESTVMOPTS
  22 # sh test/runtime/6888954/vmerrors.sh
  23 
  24 ulimit -c 0 # no core files
  25 
  26 i=1
  27 rc=0
  28 
  29 assert_re='(assert|guarantee)[(](str|num).*failed: *'
  30 bad_func_re='SIGSEGV.* at pc=0x00*0f,'
  31 guarantee_re='guarantee[(](str|num).*failed: *'
  32 fatal_re='fatal error: *'
  33 signal_re='(SIGSEGV|EXCEPTION_ACCESS_VIOLATION).* at pc='
  34 tail_1='.*expected null'
  35 tail_2='.*num='
  36 
  37 for re in                                                 \
  38     "${assert_re}${tail_1}"    "${assert_re}${tail_2}"    \
  39     "${guarantee_re}${tail_1}" "${guarantee_re}${tail_2}" \
  40     "${fatal_re}${tail_1}"     "${fatal_re}${tail_2}"     \
  41     "${fatal_re}.*truncated"   "ChunkPool::allocate"      \
  42     "ShouldNotCall"            "ShouldNotReachHere"       \
  43     "Unimplemented"            "$signal_re"               \
  44     "$bad_func_re"
  45 
  46 do
  47     i2=$i
  48     [ $i -lt 10 ] && i2=0$i
  49 
  50     "$TESTJAVA/bin/java" $TESTVMOPTS -XX:+IgnoreUnrecognizedVMOptions \
  51         -XX:ErrorHandlerTest=${i} -version > ${i2}.out 2>&1
  52 
  53     # If ErrorHandlerTest is ignored (product build), stop.
  54     #
  55     # Using the built-in variable $! to get the pid does not work reliably on
  56     # windows; use a wildcard instead.
  57     mv hs_err_pid*.log ${i2}.log || exit $rc
  58 
  59     for f in ${i2}.log ${i2}.out
  60     do
  61         egrep -- "$re" $f > $$
  62         if [ $? -ne 0 ]
  63         then
  64             echo "ErrorHandlerTest=$i failed ($f)"
  65             rc=1
  66         fi
  67     done
  68     rm -f $$
  69 
  70     i=`expr $i + 1`
  71 done
  72 
  73 exit $rc