test/runtime/7107135/Test7107135.sh

Thu, 18 Jul 2013 03:38:10 -0700

author
cl
date
Thu, 18 Jul 2013 03:38:10 -0700
changeset 5396
bb416ee2a79b
parent 4831
04d6d4322c6a
child 5453
f9ee986a9fea
permissions
-rw-r--r--

Added tag jdk8-b99 for changeset 81b6cb70717c

     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 ## @summary Stack guard pages lost after loading library with executable stack.
    31 ## @run shell Test7107135.sh
    32 ##
    34 if [ "${TESTSRC}" = "" ]
    35 then
    36   TESTSRC=${PWD}
    37   echo "TESTSRC not set.  Using "${TESTSRC}" as default"
    38 fi
    39 echo "TESTSRC=${TESTSRC}"
    40 ## Adding common setup Variables for running shell tests.
    41 . ${TESTSRC}/../../test_env.sh
    43 # set platform-dependent variables
    44 OS=`uname -s`
    45 case "$OS" in
    46   Linux)
    47     echo "Testing on Linux"
    48     ;;
    49   *)
    50     NULL=NUL
    51     PS=";"
    52     FS="\\"
    53     echo "Test passed; only valid for Linux"
    54     exit 0;
    55     ;;
    56 esac
    58 ARCH=`uname -m`
    60 THIS_DIR=.
    62 cp ${TESTSRC}${FS}*.java ${THIS_DIR}
    63 ${TESTJAVA}${FS}bin${FS}javac *.java
    65 gcc -fPIC -shared -c -o test.o -I${TESTJAVA}${FS}include -I${TESTJAVA}${FS}include${FS}linux ${TESTSRC}${FS}test.c
    66 ld -shared -z   execstack -o libtest-rwx.so test.o
    67 ld -shared -z noexecstack -o libtest-rw.so  test.o
    70 LD_LIBRARY_PATH=${THIS_DIR}
    71 echo   LD_LIBRARY_PATH = ${LD_LIBRARY_PATH}
    72 export LD_LIBRARY_PATH
    74 # This should not fail.
    75 echo Check testprogram. Expected to pass:
    76 echo ${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} Test test-rw
    77 ${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} Test test-rw
    79 echo
    80 echo Test changing of stack protection:
    81 echo ${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} Test test-rw
    82 ${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} Test test-rwx
    84 if [ "$?" == "0" ]
    85 then
    86   echo
    87   echo ${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} TestMT test-rwx
    88   ${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} TestMT test-rwx
    89 fi
    91 exit $?

mercurial