test/runtime/7107135/Test7107135.sh

changeset 4710
9058789475af
child 4831
04d6d4322c6a
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/runtime/7107135/Test7107135.sh	Tue Mar 05 13:55:56 2013 -0800
     1.3 @@ -0,0 +1,98 @@
     1.4 +#!/bin/sh
     1.5 +
     1.6 +#
     1.7 +#  Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
     1.8 +#  Copyright (c) 2011 SAP AG.  All Rights Reserved.
     1.9 +#  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    1.10 +#
    1.11 +#  This code is free software; you can redistribute it and/or modify it
    1.12 +#  under the terms of the GNU General Public License version 2 only, as
    1.13 +#  published by the Free Software Foundation.
    1.14 +#
    1.15 +#  This code is distributed in the hope that it will be useful, but WITHOUT
    1.16 +#  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.17 +#  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.18 +#  version 2 for more details (a copy is included in the LICENSE file that
    1.19 +#  accompanied this code).
    1.20 +#
    1.21 +#  You should have received a copy of the GNU General Public License version
    1.22 +#  2 along with this work; if not, write to the Free Software Foundation,
    1.23 +#  Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.24 +#
    1.25 +#  Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.26 +#  or visit www.oracle.com if you need additional information or have any
    1.27 +#  questions.
    1.28 +#
    1.29 +
    1.30 +##
    1.31 +## @test Test7107135.sh
    1.32 +## @bug 7107135
    1.33 +## @summary Stack guard pages lost after loading library with executable stack.
    1.34 +## @run shell Test7107135.sh
    1.35 +##
    1.36 +
    1.37 +if [ "${TESTSRC}" = "" ]
    1.38 +then TESTSRC=.
    1.39 +fi
    1.40 +
    1.41 +if [ "${TESTJAVA}" = "" ]
    1.42 +then
    1.43 +  PARENT=`dirname \`which java\``
    1.44 +  TESTJAVA=`dirname ${PARENT}`
    1.45 +  echo "TESTJAVA not set, selecting " ${TESTJAVA}
    1.46 +  echo "If this is incorrect, try setting the variable manually."
    1.47 +fi
    1.48 +
    1.49 +BIT_FLAG=""
    1.50 +
    1.51 +# set platform-dependent variables
    1.52 +OS=`uname -s`
    1.53 +case "$OS" in
    1.54 +  Linux)
    1.55 +    NULL=/dev/null
    1.56 +    PS=":"
    1.57 +    FS="/"
    1.58 +    ;;
    1.59 +  *)
    1.60 +    NULL=NUL
    1.61 +    PS=";"
    1.62 +    FS="\\"
    1.63 +    echo "Test passed; only valid for Linux"
    1.64 +    exit 0;
    1.65 +    ;;
    1.66 +esac
    1.67 +
    1.68 +ARCH=`uname -m`
    1.69 +
    1.70 +THIS_DIR=`pwd`
    1.71 +
    1.72 +cp ${TESTSRC}${FS}*.java ${THIS_DIR}
    1.73 +${TESTJAVA}${FS}bin${FS}javac *.java
    1.74 +
    1.75 +gcc -fPIC -shared -c -o test.o -I${TESTJAVA}${FS}include -I${TESTJAVA}${FS}include${FS}linux ${TESTSRC}${FS}test.c
    1.76 +ld -shared -z   execstack -o libtest-rwx.so test.o
    1.77 +ld -shared -z noexecstack -o libtest-rw.so  test.o
    1.78 +
    1.79 +
    1.80 +LD_LIBRARY_PATH=${THIS_DIR}
    1.81 +echo   LD_LIBRARY_PATH = ${LD_LIBRARY_PATH}
    1.82 +export LD_LIBRARY_PATH
    1.83 +
    1.84 +# This should not fail.
    1.85 +echo Check testprogram. Expected to pass:
    1.86 +echo ${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} Test test-rw
    1.87 +${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} Test test-rw
    1.88 +
    1.89 +echo
    1.90 +echo Test changing of stack protection:
    1.91 +echo ${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} Test test-rw
    1.92 +${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} Test test-rwx
    1.93 +
    1.94 +if [ "$?" == "0" ]
    1.95 +then
    1.96 +  echo
    1.97 +  echo ${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} TestMT test-rwx
    1.98 +  ${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} TestMT test-rwx
    1.99 +fi
   1.100 +
   1.101 +exit $?

mercurial