1 #!/bin/sh
   2 
   3 # Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
   4 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   5 
   6 # This code is free software; you can redistribute it and/or modify it
   7 # under the terms of the GNU General Public License version 2 only, as
   8 # published by the Free Software Foundation.
   9 
  10 # This code is distributed in the hope that it will be useful, but WITHOUT
  11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13 # version 2 for more details (a copy is included in the LICENSE file that
  14 # accompanied this code).
  15 
  16 # You should have received a copy of the GNU General Public License version
  17 # 2 along with this work; if not, write to the Free Software Foundation,
  18 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19 
  20 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21 # or visit www.oracle.com if you need additional information or have any
  22 # questions.
  23 
  24 ## @test
  25 ## @bug 8001071
  26 ## @summary Add simple range check into VM implemenation of Unsafe access methods 
  27 ## @compile Test8001071.java
  28 ## @run shell Test8001071.sh
  29 ## @author filipp.zhinkin@oracle.com
  30 
  31 BIT_FLAG=""
  32 
  33 OS=`uname -s`
  34 if [ ${OS} = "SunOS" -a -f ${HOME}/JDK64BIT ]
  35 then
  36   BIT_FLAG=`cat ${HOME}/JDK64BIT | grep -v '^#'`
  37 fi
  38 
  39 BUILD_TYPE=`${TESTJAVA}/bin/java ${BIT_FLAG} -version 2>&1 | grep debug`
  40 
  41 if [ -n "$BUILD_TYPE" ]; then
  42         echo "Build type check passed"
  43         echo "Continue testing"
  44 else
  45         echo "Fastdebug build is required for this test"
  46         exit 0
  47 fi
  48 
  49 ${TESTJAVA}/bin/java -cp ${TESTCLASSES} ${BIT_FLAG} Test8001071 2>&1 
  50 
  51 if [ ! -f hs_err_pid* ]
  52 then
  53     echo "hs_err_pid file was not found"
  54     echo "Test failed"
  55     exit 1
  56 fi
  57 
  58 grep "assert(byte_offset < p_size) failed: Unsafe access: offset.*> object's size.*" hs_err_pid*
  59 
  60 if [ "0" = "$?" ];
  61 then
  62     echo "Range check assertion failed as expected"
  63     echo "Test passed"
  64     exit 0
  65 else
  66     echo "Range check assertion was not failed"
  67     echo "Test failed"
  68     exit 1
  69 fi