Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/rmi/rmic/manifestClassPath/Util.sh
38855 views
#1# Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.2# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3#4# This code is free software; you can redistribute it and/or modify it5# under the terms of the GNU General Public License version 2 only, as6# published by the Free Software Foundation.7#8# This code is distributed in the hope that it will be useful, but WITHOUT9# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11# version 2 for more details (a copy is included in the LICENSE file that12# accompanied this code).13#14# You should have received a copy of the GNU General Public License version15# 2 along with this work; if not, write to the Free Software Foundation,16# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17#18# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19# or visit www.oracle.com if you need additional information or have any20# questions.21#2223# Utilities for shell tests24#2526: ${TESTSRC=.} ${TESTCLASSES=.}27java="${TESTJAVA+${TESTJAVA}/bin/}java"28javac="${TESTJAVA+${TESTJAVA}/bin/}javac"29jar="${TESTJAVA+${TESTJAVA}/bin/}jar"30rmic="${TESTJAVA+${TESTJAVA}/bin/}rmic"3132case `uname -s` in33Windows*|CYGWIN*)34WindowsOnly() { "$@"; }35UnixOnly() { :; }36PS=";" ;;37*)38UnixOnly() { "$@"; }39WindowsOnly() { :; }40PS=":";;41esac4243failed=""44Fail() { echo "FAIL: $1"; failed="${failed}."; }4546Die() { printf "%s\n" "$*"; exit 1; }4748Sys() {49printf "%s\n" "$*"; "$@"; rc="$?";50test "$rc" -eq 0 || Die "Command \"$*\" failed with exitValue $rc";51}5253CheckFiles() {54for f in "$@"; do test -r "$f" || Die "File $f not found"; done55}5657Report() {58test "$#" != 2 && Die "Usage: Report success|failure rc"5960if test "$1" = "success" -a "$2" = 0; then61echo "PASS: succeeded as expected"62elif test "$1" = "failure" -a "$2" != 0; then63echo "PASS: failed as expected"64elif test "$1" = "success" -a "$2" != 0; then65Fail "test failed unexpectedly"66elif test "$1" = "failure" -a "$2" = 0; then67Fail "test succeeded unexpectedly"68else69Die "Usage: Report success|failure rc"70fi71}7273MkManifestWithClassPath() {74(echo "Manifest-Version: 1.0"; echo "Class-Path: $*") > MANIFEST.MF75}7677HorizontalRule() {78echo "-----------------------------------------------------------------"79}8081Test() {82HorizontalRule83expectedResult="$1"; shift84printf "%s\n" "$*"85"$@"86Report "$expectedResult" "$?"87}8889Failure() { Test failure "$@"; }90Success() { Test success "$@"; }9192Bottom() {93test "$#" = 1 -a "$1" = "Line" || Die "Usage: Bottom Line"9495if test -n "$failed"; then96count=`printf "%s" "$failed" | wc -c | tr -d ' '`97echo "FAIL: $count tests failed"98exit 199else100echo "PASS: all tests gave expected results"101exit 0102fi103}104105BadJarFile() {106for jarfilename in "$@"; do pwd > "$jarfilename"; done107}108109#----------------------------------------------------------------110# Usage: BCP=`DefaultBootClassPath`111# Returns default bootclasspath, discarding non-existent entries112#----------------------------------------------------------------113DefaultBootClassPath() {114echo 'public class B {public static void main(String[] a) {115System.out.println(System.getProperty("sun.boot.class.path"));}}' > B.java116"$javac" B.java117_BCP_=""118for elt in `"$java" B | tr "${PS}" " "`; do119test -r "$elt" -a -n "$elt" && _BCP_="${_BCP_:+${_BCP_}${PS}}${elt}"120done121rm -f B.java B.class122printf "%s" "$_BCP_" # Don't use echo -- unsafe on Windows123}124125#----------------------------------------------------------------126# Foil message localization127#----------------------------------------------------------------128DiagnosticsInEnglishPlease() {129LANG="C" LC_ALL="C" LC_MESSAGES="C"; export LANG LC_ALL LC_MESSAGES130}131132133