test/runtime/6878713/Test6878713.sh

Tue, 19 Mar 2013 11:33:11 -0700

author
rdurbin
date
Tue, 19 Mar 2013 11:33:11 -0700
changeset 4802
eca90b8a06eb
parent 4022
83b6305a5638
child 4832
d1897e7e0488
permissions
-rw-r--r--

7030610: runtime/6878713/Test6878713.sh fails Error. failed to clean up files after test
7123945: runtime/6878713/Test6878713.sh require about 2G of native memory, swaps and times out
Summary: Add new diagnostic option -XX:MallocMaxTestWords=NNN and fix Test6878713.sh.
Reviewed-by: dcubed, coleenp, dholmes, iklam

     1 #!/bin/sh
     3 # 
     4 #  Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
     5 #  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     6 # 
     7 #  This code is free software; you can redistribute it and/or modify it
     8 #  under the terms of the GNU General Public License version 2 only, as
     9 #  published by the Free Software Foundation.
    10 # 
    11 #  This code is distributed in the hope that it will be useful, but WITHOUT
    12 #  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    13 #  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    14 #  version 2 for more details (a copy is included in the LICENSE file that
    15 #  accompanied this code).
    16 # 
    17 #  You should have received a copy of the GNU General Public License version
    18 #  2 along with this work; if not, write to the Free Software Foundation,
    19 #  Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    20 # 
    21 #  Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    22 #  or visit www.oracle.com if you need additional information or have any
    23 #  questions.
    24 # 
    28 ##
    29 ## @test
    30 ## @bug 6878713
    31 ## @bug 7030610
    32 ## @bug 7037122
    33 ## @bug 7123945
    34 ## @summary Verifier heap corruption, relating to backward jsrs
    35 ## @run shell Test6878713.sh
    36 ##
    38 if [ "${TESTSRC}" = "" ]
    39 then TESTSRC=.
    40 fi
    42 if [ "${TESTJAVA}" = "" ]
    43 then
    44   PARENT=`dirname \`which java\``
    45   TESTJAVA=`dirname ${PARENT}`
    46   echo "TESTJAVA not set, selecting " ${TESTJAVA}
    47   echo "If this is incorrect, try setting the variable manually."
    48 fi
    50 if [ "${TESTCLASSES}" = "" ]
    51 then
    52   echo "TESTCLASSES not set.  Test cannot execute.  Failed."
    53   exit 1
    54 fi
    56 # set platform-dependent variables
    57 OS=`uname -s`
    58 case "$OS" in
    59   SunOS | Linux | Darwin )
    60     NULL=/dev/null
    61     PS=":"
    62     FS="/"
    63     ;;
    64   Windows_* )
    65     NULL=NUL
    66     PS=";"
    67     FS="\\"
    68     ;;
    69   CYGWIN_* )
    70     NULL=/dev/null
    71     PS=";"
    72     FS="/"
    73     ;;
    74   * )
    75     echo "Unrecognized system!"
    76     exit 1;
    77     ;;
    78 esac
    80 CLASSPATH=.${PS}${TESTCLASSES} ; export CLASSPATH
    82 ${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -version
    84 TARGET_CLASS=OOMCrashClass1960_2
    86 echo "INFO: extracting the target class."
    87 ${TESTJAVA}${FS}bin${FS}jar xvf \
    88     ${TESTSRC}${FS}testcase.jar ${TARGET_CLASS}.class
    90 # remove any hs_err_pid that might exist here
    91 rm -f hs_err_pid*.log
    93 echo "INFO: checking for 32-bit versus 64-bit VM."
    94 ${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -version 2>&1 \
    95     | grep "64-Bit [^ ][^ ]* VM" > /dev/null 2>&1
    96 status="$?"
    97 if [ "$status" = 0 ]; then
    98     echo "INFO: testing a 64-bit VM."
    99     is_64_bit=true
   100 else
   101     echo "INFO: testing a 32-bit VM."
   102 fi
   104 if [ "$is_64_bit" = true ]; then
   105     # limit is 768MB in 8-byte words (1024 * 1024 * 768 / 8) == 100663296
   106     MALLOC_MAX=100663296
   107 else
   108     # limit is 768MB in 4-byte words (1024 * 1024 * 768 / 4) == 201326592
   109     MALLOC_MAX=201326592
   110 fi
   111 echo "INFO: MALLOC_MAX=$MALLOC_MAX"
   113 echo "INFO: executing the target class."
   114 # -XX:+PrintCommandLineFlags for debugging purposes
   115 # -XX:+IgnoreUnrecognizedVMOptions so test will run on a VM without
   116 #     the new -XX:MallocMaxTestWords option
   117 # -XX:+UnlockDiagnosticVMOptions so we can use -XX:MallocMaxTestWords
   118 # -XX:MallocMaxTestWords limits malloc to $MALLOC_MAX
   119 ${TESTJAVA}${FS}bin${FS}java \
   120     -XX:+PrintCommandLineFlags \
   121     -XX:+IgnoreUnrecognizedVMOptions \
   122     -XX:+UnlockDiagnosticVMOptions \
   123     -XX:MallocMaxTestWords=$MALLOC_MAX \
   124     ${TESTVMOPTS} ${TARGET_CLASS} > test.out 2>&1
   126 echo "INFO: begin contents of test.out:"
   127 cat test.out
   128 echo "INFO: end contents of test.out."
   130 echo "INFO: checking for memory allocation error message."
   131 # We are looking for this specific memory allocation failure mesg so
   132 # we know we exercised the right allocation path with the test class:
   133 MESG1="Native memory allocation (malloc) failed to allocate 25696531[0-9][0-9] bytes"
   134 grep "$MESG1" test.out
   135 status="$?"
   136 if [ "$status" = 0 ]; then
   137     echo "INFO: found expected memory allocation error message."
   138 else
   139     echo "INFO: did not find expected memory allocation error message."
   141     # If we didn't find MESG1 above, then there are several scenarios:
   142     # 1) -XX:MallocMaxTestWords is not supported by the current VM and we
   143     #    didn't fail TARGET_CLASS's memory allocation attempt; instead
   144     #    we failed to find TARGET_CLASS's main() method. The TARGET_CLASS
   145     #    is designed to provoke a memory allocation failure during class
   146     #    loading; we actually don't care about running the class which is
   147     #    why it doesn't have a main() method.
   148     # 2) we failed a memory allocation, but not the one we were looking
   149     #    so it might be that TARGET_CLASS no longer tickles the same
   150     #    memory allocation code path
   151     # 3) TARGET_CLASS reproduces the failure mode (SIGSEGV) fixed by
   152     #    6878713 because the test is running on a pre-fix VM.
   153     echo "INFO: checking for no main() method message."
   154     MESG2="Error: Main method not found in class"
   155     grep "$MESG2" test.out
   156     status="$?"
   157     if [ "$status" = 0 ]; then
   158         echo "INFO: found no main() method message."
   159     else
   160         echo "FAIL: did not find no main() method message."
   161         # status is non-zero for exit below
   163         if [ -s hs_err_pid*.log ]; then
   164             echo "INFO: begin contents of hs_err_pid file:"
   165             cat hs_err_pid*.log
   166             echo "INFO: end contents of hs_err_pid file."
   167         fi
   168     fi
   169 fi
   171 if [ "$status" = 0 ]; then
   172     echo "PASS: test found one of the expected messages."
   173 fi
   174 exit "$status"

mercurial