Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/tools/common/CommonSetup.sh
38839 views
#!/bin/sh12#3# Copyright (c) 2005, 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 it7# under the terms of the GNU General Public License version 2 only, as8# published by the Free Software Foundation.9#10# This code is distributed in the hope that it will be useful, but WITHOUT11# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13# version 2 for more details (a copy is included in the LICENSE file that14# accompanied this code).15#16# You should have received a copy of the GNU General Public License version17# 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 USA21# or visit www.oracle.com if you need additional information or have any22# questions.23#242526# Common setup for tool tests and other tests that use jtools.27# Checks that TESTJAVA, TESTSRC, and TESTCLASSES environment variables are set.28#29# Creates the following constants for use by the caller:30# JAVA - java launcher31# JHAT - jhat utility32# JINFO - jinfo utility33# JMAP - jmap utility34# JPS - jps utility35# JSTACK - jstack utility36# JCMD - jcmd utility37# HSDB - hsdb utility (gui)38# CLHSDB - clhsdb utility (cli)39# OS - operating system name40# PATTERN_EOL - grep or sed end-of-line pattern41# PATTERN_WS - grep or sed whitespace pattern42# PS - path separator (";" or ":")43#44# Sets the following variables:45#46# isCygwin - true if environment is Cygwin47# isMKS - true if environment is MKS48# isLinux - true if OS is Linux49# isSolaris - true if OS is Solaris50# isWindows - true if OS is Windows51# isMacos - true if OS is Macos X52# isAIX - true if OS is AIX535455if [ -z "${TESTJAVA}" ]; then56echo "ERROR: TESTJAVA not set. Test cannot execute. Failed."57exit 158fi5960if [ -z "${TESTSRC}" ]; then61echo "ERROR: TESTSRC not set. Test cannot execute. Failed."62exit 163fi6465if [ -z "${TESTCLASSES}" ]; then66echo "ERROR: TESTCLASSES not set. Test cannot execute. Failed."67exit 168fi6970# only enable these after checking the expected incoming env variables71set -eu7273JAVA="${TESTJAVA}/bin/java"74JHAT="${TESTJAVA}/bin/jhat"75JINFO="${TESTJAVA}/bin/jinfo"76JMAP="${TESTJAVA}/bin/jmap"77JPS="${TESTJAVA}/bin/jps"78JSTACK="${TESTJAVA}/bin/jstack"79JCMD="${TESTJAVA}/bin/jcmd"80HSDB="${TESTJAVA}/bin/hsdb"81CLHSDB="${TESTJAVA}/bin/clhsdb"8283isCygwin=false84isMKS=false85isLinux=false86isSolaris=false87isUnknownOS=false88isWindows=false89isMacos=false90isAIX=false9192OS=`uname -s`9394# start with some UNIX like defaults95PATTERN_EOL='$'96# blank and tab97PATTERN_WS='[ ]'98PS=":"99100case "$OS" in101CYGWIN* )102OS="Windows"103PATTERN_EOL='[104]*$'105# blank and tab106PATTERN_WS='[ \t]'107isCygwin=true108isWindows=true109;;110Linux )111OS="Linux"112isLinux=true113;;114Darwin )115OS="Mac OS X"116isMacos=true117;;118SunOS )119OS="Solaris"120isSolaris=true121;;122AIX )123OS="AIX"124isAIX=true125;;126Windows* )127OS="Windows"128PATTERN_EOL='[129]*$'130PS=";"131isWindows=true132;;133* )134isUnknownOS=true135;;136esac137138139