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