test/runtime/7107135/Test7107135.sh

Thu, 19 Sep 2013 09:36:51 -0700

author
cl
date
Thu, 19 Sep 2013 09:36:51 -0700
changeset 5664
34aa07e92d22
parent 5502
57ac7245594c
child 6876
710a3c8b516e
permissions
-rw-r--r--

Added tag jdk8-b108 for changeset 85072013aad4

     1 #!/bin/sh
     3 #
     4 #  Copyright (c) 1998, 2013, 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 ##
    28 ## @test Test7107135.sh
    29 ## @bug 7107135
    30 ## @bug 8021296
    31 ## @summary Stack guard pages lost after loading library with executable stack.
    32 ## @run shell Test7107135.sh
    33 ##
    35 if [ "${TESTSRC}" = "" ]
    36 then
    37   TESTSRC=${PWD}
    38   echo "TESTSRC not set.  Using "${TESTSRC}" as default"
    39 fi
    40 echo "TESTSRC=${TESTSRC}"
    41 ## Adding common setup Variables for running shell tests.
    42 . ${TESTSRC}/../../test_env.sh
    44 # set platform-dependent variables
    45 OS=`uname -s`
    46 case "$OS" in
    47   Linux)
    48     echo "Testing on Linux"
    49     gcc_cmd=`which gcc`
    50     if [ "x$gcc_cmd" == "x" ]; then
    51         echo "WARNING: gcc not found. Cannot execute test." 2>&1
    52         exit 0;
    53     fi
    54     ;;
    55   *)
    56     echo "Test passed; only valid for Linux"
    57     exit 0;
    58     ;;
    59 esac
    61 ARCH=`uname -m`
    63 THIS_DIR=.
    65 cp ${TESTSRC}${FS}*.java ${THIS_DIR}
    66 ${TESTJAVA}${FS}bin${FS}javac *.java
    68 $gcc_cmd -fPIC -shared -c -o test.o \
    69     -I${TESTJAVA}${FS}include -I${TESTJAVA}${FS}include${FS}linux \
    70     ${TESTSRC}${FS}test.c
    72 ld -shared -z   execstack -o libtest-rwx.so test.o
    73 ld -shared -z noexecstack -o libtest-rw.so  test.o
    76 LD_LIBRARY_PATH=${THIS_DIR}
    77 echo   LD_LIBRARY_PATH = ${LD_LIBRARY_PATH}
    78 export LD_LIBRARY_PATH
    80 # This should not fail.
    81 echo Check testprogram. Expected to pass:
    82 echo ${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} Test test-rw
    83 ${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} Test test-rw
    85 echo
    86 echo Test changing of stack protection:
    87 echo ${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} Test test-rwx
    88 ${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} Test test-rwx
    89 JAVA_RETVAL=$?
    91 if [ "$JAVA_RETVAL" == "0" ]
    92 then
    93   echo
    94   echo ${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} TestMT test-rwx
    95   ${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} TestMT test-rwx
    96   JAVA_RETVAL=$?
    97 fi
    99 exit $JAVA_RETVAL

mercurial