hotspot/test/runtime/7107135/Test7107135.sh
changeset 40098 8db886f4617c
parent 39922 e613affb88d1
parent 40020 20738e6bef83
child 40099 24807846ffe1
equal deleted inserted replaced
39922:e613affb88d1 40098:8db886f4617c
     1 #!/bin/sh
       
     2 
       
     3 #
       
     4 #  Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
       
     5 #  Copyright (c) 2011 SAP SE. 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 #
       
    26 
       
    27 ##
       
    28 ## @test Test7107135.sh
       
    29 ## @bug 7107135
       
    30 ## @bug 8021296
       
    31 ## @bug 8025519
       
    32 ## @summary Stack guard pages lost after loading library with executable stack.
       
    33 ## @run shell Test7107135.sh
       
    34 ##
       
    35 
       
    36 if [ "${TESTSRC}" = "" ]
       
    37 then
       
    38   TESTSRC=${PWD}
       
    39   echo "TESTSRC not set.  Using "${TESTSRC}" as default"
       
    40 fi
       
    41 echo "TESTSRC=${TESTSRC}"
       
    42 ## Adding common setup Variables for running shell tests.
       
    43 . ${TESTSRC}/../../test_env.sh
       
    44 
       
    45 # set platform-dependent variables
       
    46 OS=`uname -s`
       
    47 case "$OS" in
       
    48   Linux)
       
    49     echo "Testing on Linux"
       
    50     gcc_cmd=`which gcc`
       
    51     if [ "x$gcc_cmd" == "x" ]; then
       
    52         echo "WARNING: gcc not found. Cannot execute test." 2>&1
       
    53         exit 0;
       
    54     fi
       
    55     ;;
       
    56   *)
       
    57     echo "Test passed; only valid for Linux"
       
    58     exit 0;
       
    59     ;;
       
    60 esac
       
    61 
       
    62 ARCH=`uname -m`
       
    63 
       
    64 THIS_DIR=.
       
    65 
       
    66 cp ${TESTSRC}${FS}*.java ${THIS_DIR}
       
    67 ${COMPILEJAVA}${FS}bin${FS}javac *.java
       
    68 
       
    69 $gcc_cmd -fPIC -shared -c -o test.o \
       
    70     -I${COMPILEJAVA}${FS}include -I${COMPILEJAVA}${FS}include${FS}linux \
       
    71     ${TESTSRC}${FS}test.c
       
    72 
       
    73 ld -shared -z   execstack -o libtest-rwx.so test.o
       
    74 ld -shared -z noexecstack -o libtest-rw.so  test.o
       
    75 
       
    76 
       
    77 LD_LIBRARY_PATH=${THIS_DIR}
       
    78 echo   LD_LIBRARY_PATH = ${LD_LIBRARY_PATH}
       
    79 export LD_LIBRARY_PATH
       
    80 
       
    81 # This should not fail.
       
    82 echo Check testprogram. Expected to pass:
       
    83 echo ${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} Test test-rw
       
    84 ${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} Test test-rw
       
    85 
       
    86 echo
       
    87 echo Test changing of stack protection:
       
    88 echo ${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} Test test-rwx
       
    89 ${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} Test test-rwx
       
    90 JAVA_RETVAL=$?
       
    91 
       
    92 if [ "$JAVA_RETVAL" == "0" ]
       
    93 then
       
    94   echo
       
    95   echo ${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} TestMT test-rwx
       
    96   ${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} TestMT test-rwx
       
    97   JAVA_RETVAL=$?
       
    98 fi
       
    99 
       
   100 exit $JAVA_RETVAL