1 #!/bin/sh 
   2 
   3 #
   4 # @test testme.sh
   5 # @summary Stack guard pages should be installed correctly and removed when thread is detached
   6 # @run shell testme.sh
   7 #
   8 
   9 if [ "${TESTSRC}" = "" ]
  10 then
  11   TESTSRC=${PWD}
  12   echo "TESTSRC not set.  Using "${TESTSRC}" as default"
  13 fi
  14 echo "TESTSRC=${TESTSRC}"
  15 ## Adding common setup Variables for running shell tests.
  16 . ${TESTSRC}/../../test_env.sh
  17 
  18 if [ "${VM_OS}" != "linux" ]
  19 then
  20   echo "Test only valid for Linux"
  21   exit 0
  22 fi
  23 
  24 gcc_cmd=`which gcc`
  25 if [ "x$gcc_cmd" = "x" ]; then
  26   echo "WARNING: gcc not found. Cannot execute test." 2>&1
  27   exit 0;
  28 fi
  29 
  30 CFLAGS=-m${VM_BITS}
  31 
  32 LD_LIBRARY_PATH=.:${TESTJAVA}/jre/lib/${VM_CPU}/${VM_TYPE}:${TESTJAVA}/lib/${VM_CPU}/${VM_TYPE}:/usr/lib:$LD_LIBRARY_PATH
  33 export LD_LIBRARY_PATH
  34 
  35 echo "Architecture: ${VM_CPU}"
  36 echo "Compilation flag: ${CFLAGS}"
  37 echo "VM type: ${VM_TYPE}"
  38 echo "LD_LIBRARY_PATH: ${LD_LIBRARY_PATH}"
  39 
  40 # Note pthread may not be found thus invoke creation will fail to be created.
  41 # Check to ensure you have a /usr/lib/libpthread.so if you don't please look
  42 # for /usr/lib/`uname -m`-linux-gnu version ensure to add that path to below compilation.
  43 
  44 cp ${TESTSRC}/DoOverflow.java .
  45 ${COMPILEJAVA}/bin/javac DoOverflow.java
  46 
  47 $gcc_cmd -DLINUX -g3 ${CFLAGS} -o invoke \
  48     -I${TESTJAVA}/include -I${TESTJAVA}/include/linux \
  49     -L${TESTJAVA}/jre/lib/${VM_CPU}/${VM_TYPE} \
  50     -L${TESTJAVA}/lib/${VM_CPU}/${VM_TYPE} \
  51      ${TESTSRC}/invoke.c -ljvm -lpthread
  52 
  53 if [ $? -ne 0 ] ; then
  54     echo "Compile failed, Ignoring failed compilation and forcing the test to pass"
  55     exit 0
  56 fi
  57 
  58 ./invoke test_java_overflow
  59 ./invoke test_native_overflow
  60 exit $?