test/runtime/7107135/Test7107135.sh

Print this page
rev 4503 : 8009152: A number of jtreg tests need review/improvement
Summary: Added a new test_env.txt file to capture common shell variable. Added concept of COMPILEJAVA for use when TESTJAVA is a JRE. If COMPILEJAVA not set then TESTJAVA will be the default with assumption it is a JDK.
Reviewed-by: kvn, brutisso, coleenp


  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 ## @summary Stack guard pages lost after loading library with executable stack.
  31 ## @run shell Test7107135.sh
  32 ##
  33 
  34 if [ "${TESTSRC}" = "" ]
  35 then TESTSRC=.
  36 fi
  37 
  38 if [ "${TESTJAVA}" = "" ]
  39 then
  40   PARENT=`dirname \`which java\``
  41   TESTJAVA=`dirname ${PARENT}`
  42   echo "TESTJAVA not set, selecting " ${TESTJAVA}
  43   echo "If this is incorrect, try setting the variable manually."
  44 fi



  45 
  46 BIT_FLAG=""
  47 
  48 # set platform-dependent variables
  49 OS=`uname -s`
  50 case "$OS" in
  51   Linux)
  52     NULL=/dev/null
  53     PS=":"
  54     FS="/"
  55     ;;
  56   *)
  57     NULL=NUL
  58     PS=";"
  59     FS="\\"
  60     echo "Test passed; only valid for Linux"
  61     exit 0;
  62     ;;
  63 esac
  64 
  65 ARCH=`uname -m`
  66 
  67 THIS_DIR=`pwd`
  68 
  69 cp ${TESTSRC}${FS}*.java ${THIS_DIR}
  70 ${TESTJAVA}${FS}bin${FS}javac *.java
  71 
  72 gcc -fPIC -shared -c -o test.o -I${TESTJAVA}${FS}include -I${TESTJAVA}${FS}include${FS}linux ${TESTSRC}${FS}test.c
  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:


  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 ## @summary Stack guard pages lost after loading library with executable stack.
  31 ## @run shell Test7107135.sh
  32 ##
  33 
  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
  42 


  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
  57 
  58 ARCH=`uname -m`
  59 
  60 THIS_DIR=.
  61 
  62 cp ${TESTSRC}${FS}*.java ${THIS_DIR}
  63 ${TESTJAVA}${FS}bin${FS}javac *.java
  64 
  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
  68 
  69 
  70 LD_LIBRARY_PATH=${THIS_DIR}
  71 echo   LD_LIBRARY_PATH = ${LD_LIBRARY_PATH}
  72 export LD_LIBRARY_PATH
  73 
  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
  78 
  79 echo
  80 echo Test changing of stack protection: