test/runtime/6878713/Test6878713.sh

changeset 4802
eca90b8a06eb
parent 4022
83b6305a5638
child 4832
d1897e7e0488
     1.1 --- a/test/runtime/6878713/Test6878713.sh	Tue Mar 19 13:44:26 2013 +0100
     1.2 +++ b/test/runtime/6878713/Test6878713.sh	Tue Mar 19 11:33:11 2013 -0700
     1.3 @@ -1,10 +1,38 @@
     1.4  #!/bin/sh
     1.5  
     1.6 +# 
     1.7 +#  Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
     1.8 +#  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.9 +# 
    1.10 +#  This code is free software; you can redistribute it and/or modify it
    1.11 +#  under the terms of the GNU General Public License version 2 only, as
    1.12 +#  published by the Free Software Foundation.
    1.13 +# 
    1.14 +#  This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 +#  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 +#  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 +#  version 2 for more details (a copy is included in the LICENSE file that
    1.18 +#  accompanied this code).
    1.19 +# 
    1.20 +#  You should have received a copy of the GNU General Public License version
    1.21 +#  2 along with this work; if not, write to the Free Software Foundation,
    1.22 +#  Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 +# 
    1.24 +#  Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.25 +#  or visit www.oracle.com if you need additional information or have any
    1.26 +#  questions.
    1.27 +# 
    1.28 +
    1.29 + 
    1.30 +
    1.31  ##
    1.32  ## @test
    1.33  ## @bug 6878713
    1.34 +## @bug 7030610
    1.35 +## @bug 7037122
    1.36 +## @bug 7123945
    1.37  ## @summary Verifier heap corruption, relating to backward jsrs
    1.38 -## @run shell/timeout=120 Test6878713.sh
    1.39 +## @run shell Test6878713.sh
    1.40  ##
    1.41  
    1.42  if [ "${TESTSRC}" = "" ]
    1.43 @@ -49,23 +77,98 @@
    1.44      ;;
    1.45  esac
    1.46  
    1.47 -JEMMYPATH=${CPAPPEND}
    1.48 -CLASSPATH=.${PS}${TESTCLASSES}${PS}${JEMMYPATH} ; export CLASSPATH
    1.49 -
    1.50 -THIS_DIR=`pwd`
    1.51 +CLASSPATH=.${PS}${TESTCLASSES} ; export CLASSPATH
    1.52  
    1.53  ${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -version
    1.54  
    1.55 -${TESTJAVA}${FS}bin${FS}jar xvf ${TESTSRC}${FS}testcase.jar
    1.56 +TARGET_CLASS=OOMCrashClass1960_2
    1.57  
    1.58 -${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} OOMCrashClass1960_2 > test.out 2>&1
    1.59 +echo "INFO: extracting the target class."
    1.60 +${TESTJAVA}${FS}bin${FS}jar xvf \
    1.61 +    ${TESTSRC}${FS}testcase.jar ${TARGET_CLASS}.class
    1.62  
    1.63 -if [ -s core -o -s "hs_*.log" ]
    1.64 -then
    1.65 -    cat hs*.log
    1.66 -    echo "Test Failed"
    1.67 -    exit 1
    1.68 +# remove any hs_err_pid that might exist here
    1.69 +rm -f hs_err_pid*.log
    1.70 +
    1.71 +echo "INFO: checking for 32-bit versus 64-bit VM."
    1.72 +${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -version 2>&1 \
    1.73 +    | grep "64-Bit [^ ][^ ]* VM" > /dev/null 2>&1
    1.74 +status="$?"
    1.75 +if [ "$status" = 0 ]; then
    1.76 +    echo "INFO: testing a 64-bit VM."
    1.77 +    is_64_bit=true
    1.78  else
    1.79 -    echo "Test Passed"
    1.80 -    exit 0
    1.81 +    echo "INFO: testing a 32-bit VM."
    1.82  fi
    1.83 +
    1.84 +if [ "$is_64_bit" = true ]; then
    1.85 +    # limit is 768MB in 8-byte words (1024 * 1024 * 768 / 8) == 100663296
    1.86 +    MALLOC_MAX=100663296
    1.87 +else
    1.88 +    # limit is 768MB in 4-byte words (1024 * 1024 * 768 / 4) == 201326592
    1.89 +    MALLOC_MAX=201326592
    1.90 +fi
    1.91 +echo "INFO: MALLOC_MAX=$MALLOC_MAX"
    1.92 +
    1.93 +echo "INFO: executing the target class."
    1.94 +# -XX:+PrintCommandLineFlags for debugging purposes
    1.95 +# -XX:+IgnoreUnrecognizedVMOptions so test will run on a VM without
    1.96 +#     the new -XX:MallocMaxTestWords option
    1.97 +# -XX:+UnlockDiagnosticVMOptions so we can use -XX:MallocMaxTestWords
    1.98 +# -XX:MallocMaxTestWords limits malloc to $MALLOC_MAX
    1.99 +${TESTJAVA}${FS}bin${FS}java \
   1.100 +    -XX:+PrintCommandLineFlags \
   1.101 +    -XX:+IgnoreUnrecognizedVMOptions \
   1.102 +    -XX:+UnlockDiagnosticVMOptions \
   1.103 +    -XX:MallocMaxTestWords=$MALLOC_MAX \
   1.104 +    ${TESTVMOPTS} ${TARGET_CLASS} > test.out 2>&1
   1.105 +
   1.106 +echo "INFO: begin contents of test.out:"
   1.107 +cat test.out
   1.108 +echo "INFO: end contents of test.out."
   1.109 +
   1.110 +echo "INFO: checking for memory allocation error message."
   1.111 +# We are looking for this specific memory allocation failure mesg so
   1.112 +# we know we exercised the right allocation path with the test class:
   1.113 +MESG1="Native memory allocation (malloc) failed to allocate 25696531[0-9][0-9] bytes"
   1.114 +grep "$MESG1" test.out
   1.115 +status="$?"
   1.116 +if [ "$status" = 0 ]; then
   1.117 +    echo "INFO: found expected memory allocation error message."
   1.118 +else
   1.119 +    echo "INFO: did not find expected memory allocation error message."
   1.120 +
   1.121 +    # If we didn't find MESG1 above, then there are several scenarios:
   1.122 +    # 1) -XX:MallocMaxTestWords is not supported by the current VM and we
   1.123 +    #    didn't fail TARGET_CLASS's memory allocation attempt; instead
   1.124 +    #    we failed to find TARGET_CLASS's main() method. The TARGET_CLASS
   1.125 +    #    is designed to provoke a memory allocation failure during class
   1.126 +    #    loading; we actually don't care about running the class which is
   1.127 +    #    why it doesn't have a main() method.
   1.128 +    # 2) we failed a memory allocation, but not the one we were looking
   1.129 +    #    so it might be that TARGET_CLASS no longer tickles the same
   1.130 +    #    memory allocation code path
   1.131 +    # 3) TARGET_CLASS reproduces the failure mode (SIGSEGV) fixed by
   1.132 +    #    6878713 because the test is running on a pre-fix VM.
   1.133 +    echo "INFO: checking for no main() method message."
   1.134 +    MESG2="Error: Main method not found in class"
   1.135 +    grep "$MESG2" test.out
   1.136 +    status="$?"
   1.137 +    if [ "$status" = 0 ]; then
   1.138 +        echo "INFO: found no main() method message."
   1.139 +    else
   1.140 +        echo "FAIL: did not find no main() method message."
   1.141 +        # status is non-zero for exit below
   1.142 +
   1.143 +        if [ -s hs_err_pid*.log ]; then
   1.144 +            echo "INFO: begin contents of hs_err_pid file:"
   1.145 +            cat hs_err_pid*.log
   1.146 +            echo "INFO: end contents of hs_err_pid file."
   1.147 +        fi
   1.148 +    fi
   1.149 +fi
   1.150 +
   1.151 +if [ "$status" = 0 ]; then
   1.152 +    echo "PASS: test found one of the expected messages."
   1.153 +fi
   1.154 +exit "$status"

mercurial