jdk/test/sun/tools/common/CommonSetup.sh
changeset 30779 92bb39a2a876
parent 30778 43087a23d825
parent 30736 ff3fc75f3214
child 30780 b83f001a855d
child 30886 d2a0ec86d6ef
equal deleted inserted replaced
30778:43087a23d825 30779:92bb39a2a876
     1 #!/bin/sh
       
     2 
       
     3 #
       
     4 # Copyright (c) 2005, 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 
       
    27 # Common setup for tool tests and other tests that use jtools.
       
    28 # Checks that TESTJAVA, TESTSRC, and TESTCLASSES environment variables are set.
       
    29 #
       
    30 # Creates the following constants for use by the caller:
       
    31 #   JAVA        - java launcher
       
    32 #   JHAT        - jhat utility
       
    33 #   JINFO       - jinfo utility
       
    34 #   JMAP        - jmap utility
       
    35 #   JPS         - jps utility
       
    36 #   JSTACK      - jstack utility
       
    37 #   JCMD        - jcmd utility
       
    38 #   OS          - operating system name
       
    39 #   PATTERN_EOL - grep or sed end-of-line pattern
       
    40 #   PATTERN_WS  - grep or sed whitespace pattern
       
    41 #   PS          - path separator (";" or ":")
       
    42 #
       
    43 # Sets the following variables:
       
    44 #
       
    45 #   isCygwin  - true if environment is Cygwin
       
    46 #   isMKS     - true if environment is MKS
       
    47 #   isLinux   - true if OS is Linux
       
    48 #   isSolaris - true if OS is Solaris
       
    49 #   isWindows - true if OS is Windows
       
    50 #   isMacos   - true if OS is Macos X
       
    51 #   isAIX     - true if OS is AIX
       
    52 
       
    53 
       
    54 if [ -z "${TESTJAVA}" ]; then
       
    55   echo "ERROR: TESTJAVA not set.  Test cannot execute.  Failed."
       
    56   exit 1
       
    57 fi
       
    58 
       
    59 if [ -z "${TESTSRC}" ]; then
       
    60   echo "ERROR: TESTSRC not set.  Test cannot execute.  Failed."
       
    61   exit 1
       
    62 fi
       
    63 
       
    64 if [ -z "${TESTCLASSES}" ]; then
       
    65   echo "ERROR: TESTCLASSES not set.  Test cannot execute.  Failed."
       
    66   exit 1
       
    67 fi
       
    68 
       
    69 # only enable these after checking the expected incoming env variables
       
    70 set -eu
       
    71 
       
    72 JAVA="${TESTJAVA}/bin/java"
       
    73 JHAT="${TESTJAVA}/bin/jhat"
       
    74 JINFO="${TESTJAVA}/bin/jinfo"
       
    75 JMAP="${TESTJAVA}/bin/jmap"
       
    76 JPS="${TESTJAVA}/bin/jps"
       
    77 JSTACK="${TESTJAVA}/bin/jstack"
       
    78 JCMD="${TESTJAVA}/bin/jcmd"
       
    79 
       
    80 isCygwin=false
       
    81 isMKS=false
       
    82 isLinux=false
       
    83 isSolaris=false
       
    84 isUnknownOS=false
       
    85 isWindows=false
       
    86 isMacos=false
       
    87 isAIX=false
       
    88 
       
    89 OS=`uname -s`
       
    90 
       
    91 # start with some UNIX like defaults
       
    92 PATTERN_EOL='$'
       
    93 # blank and tab
       
    94 PATTERN_WS='[ 	]'
       
    95 PS=":"
       
    96 
       
    97 case "$OS" in
       
    98   CYGWIN* )
       
    99     OS="Windows"
       
   100     PATTERN_EOL='[
       
   101 ]*$'
       
   102     # blank and tab
       
   103     PATTERN_WS='[ \t]'
       
   104     isCygwin=true
       
   105     isWindows=true
       
   106     ;;
       
   107   Linux )
       
   108     OS="Linux"
       
   109     isLinux=true
       
   110     ;;
       
   111   Darwin )
       
   112     OS="Mac OS X"
       
   113     isMacos=true
       
   114     ;;
       
   115   SunOS )
       
   116     OS="Solaris"
       
   117     isSolaris=true
       
   118     ;;
       
   119   AIX )
       
   120     OS="AIX"
       
   121     isAIX=true
       
   122     ;;
       
   123   Windows* )
       
   124     OS="Windows"
       
   125     PATTERN_EOL='[
       
   126 ]*$'
       
   127     PS=";"
       
   128     isWindows=true
       
   129     ;;
       
   130   * )
       
   131     isUnknownOS=true
       
   132     ;;
       
   133 esac