1 #!/bin/sh
   2 #
   3 #  Copyright (c) 2013, 2015, 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 #
  26 # This Environment script was written to capture typically used environment
  27 # setup for a given shell test. 
  28 #
  29 
  30 # TESTJAVA can be a JDK or JRE. If JRE you need to set COMPILEJAVA
  31 if [ "${TESTJAVA}" = "" ]
  32 then
  33   echo "TESTJAVA not set.  Test cannot execute.  Failed."
  34   exit 1
  35 fi
  36 echo "TESTJAVA=${TESTJAVA}"
  37 
  38 # COMPILEJAVA requires a JDK, some shell test use javac,jar,etc 
  39 if [ "${COMPILEJAVA}" = "" ]
  40 then
  41  echo "COMPILEJAVA not set.  Using TESTJAVA as default"
  42  COMPILEJAVA=${TESTJAVA}
  43 fi
  44 echo "COMPILEJAVA=${COMPILEJAVA}"
  45 
  46 if [ "${TESTCLASSES}" = "" ]
  47 then
  48   echo "TESTCLASES not set.  Using "." as default"
  49   TESTCLASSES=.
  50 fi
  51 echo "TESTCLASSES=${TESTCLASSES}"
  52 
  53 # set platform-dependent variables
  54 OS=`uname -s`
  55 case "$OS" in
  56   AIX | Darwin | Linux | SunOS )
  57     NULL=/dev/null
  58     PS=":"
  59     FS="/"
  60     RM=/bin/rm
  61     CP=/bin/cp
  62     MV=/bin/mv
  63     ;;
  64   Windows_* )
  65     NULL=NUL
  66     PS=";"
  67     FS="\\"
  68     RM=rm
  69     CP=cp
  70     MV=mv
  71     ;;
  72   CYGWIN_* )
  73     NULL=/dev/null
  74     PS=";"
  75     FS="/"
  76     RM=rm
  77     CP=cp
  78     MV=mv
  79     ;;
  80   * )
  81     echo "Unrecognized system!"
  82     exit 1;
  83     ;;
  84 esac
  85 
  86 export NULL PS FS RM CP MV
  87 echo "NULL =${NULL}"
  88 echo "PS =${PS}"
  89 echo "FS =${FS}"
  90 echo "RM =${RM}"
  91 echo "CP =${CP}"
  92 echo "MV =${MV}"
  93 
  94 # jtreg -classpathappend:<path>
  95 JEMMYPATH=${CPAPPEND}
  96 CLASSPATH=.${PS}${TESTCLASSES}${PS}${JEMMYPATH} ; export CLASSPATH
  97 echo "CLASSPATH =${CLASSPATH}"
  98 
  99 # Current directory is scratch directory 
 100 THIS_DIR=.
 101 echo "THIS_DIR=${THIS_DIR}"
 102 
 103 # Check to ensure the java defined actually works
 104 ${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -version
 105 if [ $? != 0 ]; then
 106   echo "Wrong TESTJAVA or TESTVMOPTS:"
 107   echo $TESTJAVA TESTVMOPTS
 108   exit 1
 109 fi
 110 
 111 ${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -Xinternalversion > vm_version.out 2>&1
 112 
 113 VM_TYPE="unknown"
 114 grep "Server" vm_version.out > ${NULL}
 115 if [ $? = 0 ]
 116 then
 117   VM_TYPE="server"
 118 fi
 119 grep "Client" vm_version.out > ${NULL}
 120 if [ $? = 0 ]
 121 then
 122   VM_TYPE="client"
 123 fi
 124 
 125 VM_BITS="32"
 126 grep "64-Bit" vm_version.out > ${NULL}
 127 if [ $? = 0 ]
 128 then
 129   VM_BITS="64"
 130 fi
 131 
 132 VM_OS="unknown"
 133 grep "aix" vm_version.out > ${NULL}
 134 if [ $? = 0 ]
 135 then
 136   VM_OS="aix"
 137 fi
 138 grep "bsd" vm_version.out > ${NULL}
 139 if [ $? = 0 ]
 140 then
 141   VM_OS="bsd"
 142 fi
 143 grep "linux" vm_version.out > ${NULL}
 144 if [ $? = 0 ]
 145 then
 146   VM_OS="linux"
 147 fi
 148 grep "solaris" vm_version.out > ${NULL}
 149 if [ $? = 0 ]
 150 then
 151   VM_OS="solaris"
 152 fi
 153 grep "windows" vm_version.out > ${NULL}
 154 if [ $? = 0 ]
 155 then
 156   VM_OS="windows"
 157 fi
 158 
 159 VM_CPU="unknown"
 160 grep "sparc" vm_version.out > ${NULL}
 161 if [ $? = 0 ]
 162 then
 163   VM_CPU="sparc"
 164   if [ $VM_BITS = "64" ]
 165   then
 166     VM_CPU="sparcv9"
 167   fi
 168 fi
 169 grep "x86" vm_version.out > ${NULL}
 170 if [ $? = 0 ]
 171 then
 172   VM_CPU="i386"
 173 fi
 174 grep "amd64" vm_version.out > ${NULL}
 175 if [ $? = 0 ]
 176 then
 177   VM_CPU="amd64"
 178 fi
 179 grep "arm" vm_version.out > ${NULL}
 180 if [ $? = 0 ]
 181 then
 182   VM_CPU="arm"
 183 fi
 184 grep "ppc" vm_version.out > ${NULL}
 185 if [ $? = 0 ]
 186 then
 187   VM_CPU="ppc"
 188 fi
 189 grep "ia64" vm_version.out > ${NULL}
 190 if [ $? = 0 ]
 191 then
 192   VM_CPU="ia64"
 193 fi
 194 export VM_TYPE VM_BITS VM_OS VM_CPU
 195 echo "VM_TYPE=${VM_TYPE}"
 196 echo "VM_BITS=${VM_BITS}"
 197 echo "VM_OS=${VM_OS}"
 198 echo "VM_CPU=${VM_CPU}"