test/runtime/jni/ReturnJNIWeak/test.sh

Fri, 10 May 2019 18:50:40 +0000

author
phh
date
Fri, 10 May 2019 18:50:40 +0000
changeset 9671
e86bc9786d83
permissions
-rw-r--r--

8223664: Add jtreg tests for 8223528, backport to jdk8u of 8176100
Summary: Add hotspot/test/runtime/jni directory with two tests for 8176100
Reviewed-by: kbarrett, coleenp, tschatzl

     1 #!/bin/sh
     3 #
     4 #  Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
     5 #  Copyright (c) 2011 SAP AG.  All Rights Reserved.
     6 #  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     7 #
     8 #  This code is free software; you can redistribute it and/or modify it
     9 #  under the terms of the GNU General Public License version 2 only, as
    10 #  published by the Free Software Foundation.
    11 #
    12 #  This code is distributed in the hope that it will be useful, but WITHOUT
    13 #  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    14 #  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    15 #  version 2 for more details (a copy is included in the LICENSE file that
    16 #  accompanied this code).
    17 #
    18 #  You should have received a copy of the GNU General Public License version
    19 #  2 along with this work; if not, write to the Free Software Foundation,
    20 #  Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    21 #
    22 #  Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    23 #  or visit www.oracle.com if you need additional information or have any
    24 #  questions.
    25 #
    27 ## @test test.sh
    28 ## @bug 8166188
    29 ## @requires vm.opt.ExplicitGCInvokesConcurrent != true
    30 ## @summary Test return of JNI weak global refs from native calls.
    31 ## @run shell test.sh
    33 if [ "${TESTSRC}" = "" ]
    34 then
    35   TESTSRC=${PWD}
    36   echo "TESTSRC not set.  Using "${TESTSRC}" as default"
    37 fi
    38 echo "TESTSRC=${TESTSRC}"
    39 ## Adding common setup Variables for running shell tests.
    40 . ${TESTSRC}/../../../test_env.sh
    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 valid for Linux and Solaris"
    62     exit 0;
    63     ;;
    64 esac
    66 THIS_DIR=.
    68 cp ${TESTSRC}${FS}*.java ${THIS_DIR}
    69 ${TESTJAVA}${FS}bin${FS}javac *.java
    71 $cc_cmd -fPIC -shared -o libReturnJNIWeak.so \
    72     -I${TESTJAVA}${FS}include -I${TESTJAVA}${FS}include${FS}linux \
    73     ${TESTSRC}${FS}ReturnJNIWeak.c
    75 LD_LIBRARY_PATH=${THIS_DIR}
    76 echo   LD_LIBRARY_PATH = ${LD_LIBRARY_PATH}
    77 export LD_LIBRARY_PATH
    79 echo
    80 echo ${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} -Xint ReturnJNIWeak
    81 ${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} -Xint ReturnJNIWeak
    82 JAVA_RETVAL=$?
    84 if [ "$JAVA_RETVAL" == "0" ]
    85 then
    86   echo
    87   echo ${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} -Xcomp ReturnJNIWeak
    88   ${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} -Xcomp ReturnJNIWeak
    90   JAVA_RETVAL=$?
    91 fi
    93 exit $JAVA_RETVAL

mercurial