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 
  25 # For now this is constructed as a manual test since there's no guarantee that a
  26 # C compiler is available in the test environment
  27 
  28 ##
  29 ## @test Test7145024.sh
  30 ## @bug 7145024
  31 ## @summary Crashes in ucrypto related to C2
  32 ## @run shell/manual Test7145024.sh
  33 ##
  34 
  35 if [ "${TESTSRC}" = "" ]
  36 then TESTSRC=.
  37 fi
  38 
  39 if [ "${TESTJAVA}" = "" ]
  40 then
  41   PARENT=`dirname \`which java\``
  42   TESTJAVA=`dirname ${PARENT}`
  43   echo "TESTJAVA not set, selecting " ${TESTJAVA}
  44   echo "If this is incorrect, try setting the variable manually."
  45 fi
  46 
  47 # set platform-dependent variables
  48 OS=`uname -s`
  49 case "$OS" in
  50   *BSD)
  51     FS="/"
  52     CC=gcc
  53     CFLAGS="-fPIC -shared"
  54     ;;
  55   Linux)
  56     FS="/"
  57     CC=gcc
  58     CFLAGS="-fPIC -shared"
  59     OS=linux
  60     ;;
  61   SunOS)
  62     FS="/"
  63     CC=cc
  64     CFLAGS="-G -KPIC"
  65     OS=solaris
  66     COMPILE64=-m64
  67     ;;
  68    Windows_*)
  69     FS="\\"
  70     echo "Test passed; not currently valid on Windows"
  71     exit 0;
  72     ;;
  73   * )
  74     echo "Unrecognized system!"
  75     exit 1;
  76     ;;
  77 esac
  78 
  79 
  80 
  81 LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH
  82 export LD_LIBRARY_PATH
  83 
  84 THIS_DIR=`pwd`
  85 
  86 cp ${TESTSRC}${FS}Generate.java ${THIS_DIR}
  87 
  88 set -e
  89 
  90 ${TESTJAVA}${FS}bin${FS}java -fullversion
  91 
  92 ${TESTJAVA}${FS}bin${FS}javac Generate.java
  93 ${TESTJAVA}${FS}bin${FS}java Generate
  94 ${TESTJAVA}${FS}bin${FS}javac JNITest.java
  95 ${TESTJAVA}${FS}bin${FS}javah JNITest
  96 
  97 if [ "${COMPILE64}" != "" ]; then
  98   $CC ${COMPILE64} -g ${CFLAGS} -o libjnitest.so  -I${TESTJAVA}/include -I${TESTJAVA}/include/$OS JNITest.c
  99   ${TESTJAVA}${FS}bin${FS}java -d64 JNITest
 100   exitcode=$?
 101   if [ $exitcode -ne 0 ]; then
 102     exit $exitcode
 103   fi
 104 fi
 105 
 106 $CC -g ${CFLAGS} -o libjnitest.so  -I${TESTJAVA}/include -I${TESTJAVA}/include/$OS JNITest.c
 107 
 108 EXTRA_OPTS="-XX:+IgnoreUnrecognizedVMOptions"
 109 
 110 ${TESTJAVA}${FS}bin${FS}java -server ${EXTRA_OPTS} JNITest
 111 exitcode=$?
 112 if [ $exitcode -ne 0 ]; then
 113   exit $exitcode
 114 fi
 115 
 116 ${TESTJAVA}${FS}bin${FS}java -client ${EXTRA_OPTS} -XX:UseSSE=1 JNITest
 117 exitcode=$?
 118 if [ $exitcode -ne 0 ]; then
 119   exit $exitcode
 120 fi
 121 ${TESTJAVA}${FS}bin${FS}java -client ${EXTRA_OPTS} -XX:UseSSE=0 JNITest
 122 exitcode=$?
 123 if [ $exitcode -ne 0 ]; then
 124   exit $exitcode
 125 fi
 126 
 127 ${TESTJAVA}${FS}bin${FS}java -client ${EXTRA_OPTS} JNITest
 128 exitcode=$?
 129 if [ $exitcode -ne 0 ]; then
 130   exit $exitcode
 131 fi
 132 
 133 exit $?