test/runtime/RedefineTests/test8178870.sh

Thu, 12 Sep 2019 15:15:22 -0400

author
zgu
date
Thu, 12 Sep 2019 15:15:22 -0400
changeset 9748
628176d22495
permissions
-rw-r--r--

8178870: instrumentation.retransformClasses cause coredump
Summary: Don't double-free cached class bytes on redefinition loading failure.
Reviewed-by: sspitsyn, jiangli

     1 #!/bin/sh
     3 #
     4 # Copyright (c) 2019, Red Hat, Inc. All rights reserved.
     5 #
     6 # This code is free software; you can redistribute it and/or modify it
     7 # under the terms of the GNU General Public License version 2 only, as
     8 # published by the Free Software Foundation.
     9 #
    10 # This code is distributed in the hope that it will be useful, but WITHOUT
    11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    12 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    13 # version 2 for more details (a copy is included in the LICENSE file that
    14 # accompanied this code).
    15 #
    16 # You should have received a copy of the GNU General Public License version
    17 # 2 along with this work; if not, write to the Free Software Foundation,
    18 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    19 #
    20 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    21 # or visit www.oracle.com if you need additional information or have any
    22 # questions.
    23 #
    24 #
    26 ## @test test.sh
    27 ## @bug 8178870
    28 ## @summary test instrumentation.retransformClasses
    29 ## @run shell test.sh
    31 if [ "${TESTSRC}" = "" ]
    32 then
    33   TESTSRC=${PWD}
    34   echo "TESTSRC not set.  Using "${TESTSRC}" as default"
    35 fi
    36 echo "TESTSRC=${TESTSRC}"
    37 ## Adding common setup Variables for running shell tests.
    38 . ${TESTSRC}/../../test_env.sh
    40 LIB_SRC=${TESTSRC}/../../testlibrary/
    42 # set platform-dependent variables
    43 OS=`uname -s`
    44 echo "Testing on " $OS
    45 case "$OS" in
    46   Linux)
    47     cc_cmd=`which gcc`
    48     if [ "x$cc_cmd" == "x" ]; then
    49         echo "WARNING: gcc not found. Cannot execute test." 2>&1
    50         exit 0;
    51     fi
    52     ;;
    53   Solaris)
    54     cc_cmd=`which cc`
    55     if [ "x$cc_cmd" == "x" ]; then
    56         echo "WARNING: cc not found. Cannot execute test." 2>&1
    57         exit 0;
    58     fi
    59     ;;
    60   *)
    61     echo "Test passed. Only on Linux and Solaris"
    62     exit 0;
    63     ;;
    64 esac
    66 THIS_DIR=.
    68 cp ${TESTSRC}/RedefineDoubleDelete.java ${THIS_DIR}
    69 mkdir -p ${THIS_DIR}/classes
    70 ${TESTJAVA}/bin/javac -sourcepath  ${LIB_SRC} -d ${THIS_DIR}/classes ${LIB_SRC}RedefineClassHelper.java
    71 ${TESTJAVA}/bin/javac -cp .:${THIS_DIR}/classes:${TESTJAVA}/lib/tools.jar -d ${THIS_DIR} RedefineDoubleDelete.java
    73 $cc_cmd -fPIC -shared -o ${THIS_DIR}${FS}libRedefineDoubleDelete.so \
    74     -I${TESTJAVA}/include -I${TESTJAVA}/include/linux \
    75     ${TESTSRC}/libRedefineDoubleDelete.c
    77 LD_LIBRARY_PATH=${THIS_DIR}
    78 echo   LD_LIBRARY_PATH = ${LD_LIBRARY_PATH}
    79 export LD_LIBRARY_PATH
    81 # Install redefineagent.jar
    82 ${TESTJAVA}/bin${FS}java -cp ${THIS_DIR}/classes RedefineClassHelper
    84 echo
    85 echo ${TESTJAVA}/bin/java -agentlib:RedefineDoubleDelete RedefineDoubleDelete
    86 ${TESTJAVA}/bin/java -cp .:${THIS_DIR}${FS}classes -javaagent:redefineagent.jar -agentlib:RedefineDoubleDelete RedefineDoubleDelete

mercurial