1 #! /bin/sh
   2 
   3 #
   4 # Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
   5 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   6 #
   7 # This code is free software; you can redistribute it and/or modify it
   8 # under the terms of the GNU General Public License version 2 only, as
   9 # published by the Free Software Foundation.
  10 #
  11 # This code is distributed in the hope that it will be useful, but WITHOUT
  12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14 # version 2 for more details (a copy is included in the LICENSE file that
  15 # accompanied this code).
  16 #
  17 # You should have received a copy of the GNU General Public License version
  18 # 2 along with this work; if not, write to the Free Software Foundation,
  19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20 #
  21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22 # or visit www.oracle.com if you need additional information or have any
  23 # questions.
  24 #
  25 
  26 # @test
  27 # @author  Ram Marti
  28 # @bug 4350951
  29 # @summary 4350951 assumes permission constructor with 2 string params
  30 
  31 # set a few environment variables so that the shell-script can run stand-alone
  32 # in the source directory
  33 if [ "${TESTSRC}" = "" ] ; then
  34    TESTSRC="."
  35 fi
  36 
  37 if [ "${TESTCLASSES}" = "" ] ; then
  38    TESTCLASSES="."
  39 fi
  40 
  41 if [ "${TESTJAVA}" = "" ] ; then
  42    echo "TESTJAVA not set.  Test cannot execute."
  43    echo "FAILED!!!"
  44    exit 1
  45 fi
  46 
  47 if [ "${COMPILEJAVA}" = "" ]; then
  48     COMPILEJAVA="${TESTJAVA}"
  49 fi
  50 
  51 # set platform-dependent variables
  52 OS=`uname -s`
  53 case "$OS" in
  54   SunOS )
  55     PS=":"
  56     FS="/"
  57     ;;
  58   Linux )
  59     PS=":"
  60     FS="/"
  61     ;;
  62   Darwin )
  63     PS=":"
  64     FS="/"
  65     ;;
  66   AIX )
  67     PS=":"
  68     FS="/"
  69     ;;
  70   CYGWIN* )
  71     PS=";"
  72     FS="/"
  73     ;;
  74   Windows* )
  75     PS=";"
  76     FS="\\"
  77     ;;
  78   * )
  79     echo "Unrecognized system!"
  80     exit 1;
  81     ;;
  82 esac
  83 
  84 if [ ! -d ${TESTCLASSES}${FS}boot ]; then
  85         mkdir -p ${TESTCLASSES}${FS}boot
  86 fi
  87 if [ ! -d ${TESTCLASSES}${FS}app ]; then
  88         mkdir -p ${TESTCLASSES}${FS}app
  89 fi
  90 
  91 cd ${TESTSRC}${FS}
  92 ${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d ${TESTCLASSES}${FS}boot \
  93         ${TESTSRC}${FS}NoArgPermission.java
  94 ${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d ${TESTCLASSES}${FS}boot \
  95         ${TESTSRC}${FS}OneArgPermission.java
  96 ${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d ${TESTCLASSES}${FS}boot \
  97         ${TESTSRC}${FS}TwoArgPermission.java
  98 ${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d ${TESTCLASSES}${FS}boot \
  99         ${TESTSRC}${FS}TwoArgNullActionsPermission.java
 100 ${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d ${TESTCLASSES}${FS}app \
 101         ${TESTSRC}${FS}GetInstance.java
 102 
 103 ${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS}  \
 104 -Xbootclasspath/a:"${TESTCLASSES}${FS}boot" \
 105 -classpath "${TESTCLASSES}${FS}app" -Djava.security.manager \
 106 -Djava.security.policy=GetInstance.policy \
 107 GetInstance
 108 
 109 # Save error status
 110 status1=$?
 111 
 112 # print error message
 113 if [ $status1 -ne 0 ]; then
 114      echo "Failed on first test"
 115 fi
 116 
 117 ${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS}  \
 118 -classpath "${TESTCLASSES}${FS}boot${PS}${TESTCLASSES}${FS}app" \
 119 -Djava.security.manager \
 120 -Djava.security.policy=GetInstance.policy \
 121 GetInstance
 122 
 123 # Save error status
 124 status2=$?
 125 
 126 # print error message
 127 if [ $status2 -ne 0 ]; then
 128      echo "Failed on second test"
 129 fi
 130 
 131 #
 132 # Exit ok?
 133 #
 134 if [ $status1 -ne 0 ]; then
 135      exit $status1
 136 fi
 137 
 138 if [ $status2 -ne 0 ]; then
 139      exit $status2
 140 fi