Fri, 24 Apr 2020 03:58:51 +0100
Merge
duke@1 | 1 | # |
ohair@554 | 2 | # Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved. |
duke@1 | 3 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@1 | 4 | # |
duke@1 | 5 | # This code is free software; you can redistribute it and/or modify it |
duke@1 | 6 | # under the terms of the GNU General Public License version 2 only, as |
duke@1 | 7 | # published by the Free Software Foundation. |
duke@1 | 8 | # |
duke@1 | 9 | # This code is distributed in the hope that it will be useful, but WITHOUT |
duke@1 | 10 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@1 | 11 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@1 | 12 | # version 2 for more details (a copy is included in the LICENSE file that |
duke@1 | 13 | # accompanied this code). |
duke@1 | 14 | # |
duke@1 | 15 | # You should have received a copy of the GNU General Public License version |
duke@1 | 16 | # 2 along with this work; if not, write to the Free Software Foundation, |
duke@1 | 17 | # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@1 | 18 | # |
ohair@554 | 19 | # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@554 | 20 | # or visit www.oracle.com if you need additional information or have any |
ohair@554 | 21 | # questions. |
duke@1 | 22 | # |
duke@1 | 23 | |
duke@1 | 24 | # Utilities for shell tests |
duke@1 | 25 | |
duke@1 | 26 | : ${TESTSRC=.} ${TESTCLASSES=.} |
duke@1 | 27 | java="${TESTJAVA+${TESTJAVA}/bin/}java" |
duke@1 | 28 | javac="${TESTJAVA+${TESTJAVA}/bin/}javac" |
duke@1 | 29 | jar="${TESTJAVA+${TESTJAVA}/bin/}jar" |
duke@1 | 30 | |
duke@1 | 31 | case `uname -s` in |
duke@1 | 32 | Windows*|CYGWIN*) |
duke@1 | 33 | WindowsOnly() { "$@"; } |
duke@1 | 34 | UnixOnly() { :; } |
duke@1 | 35 | PS=";" ;; |
duke@1 | 36 | *) |
duke@1 | 37 | UnixOnly() { "$@"; } |
duke@1 | 38 | WindowsOnly() { :; } |
duke@1 | 39 | PS=":";; |
duke@1 | 40 | esac |
duke@1 | 41 | |
duke@1 | 42 | failed="" |
duke@1 | 43 | Fail() { echo "FAIL: $1"; failed="${failed}."; } |
duke@1 | 44 | |
duke@1 | 45 | Die() { printf "%s\n" "$*"; exit 1; } |
duke@1 | 46 | |
duke@1 | 47 | Sys() { |
duke@1 | 48 | printf "%s\n" "$*"; "$@"; rc="$?"; |
duke@1 | 49 | test "$rc" -eq 0 || Die "Command \"$*\" failed with exitValue $rc"; |
duke@1 | 50 | } |
duke@1 | 51 | |
duke@1 | 52 | CheckFiles() { |
duke@1 | 53 | for f in "$@"; do test -r "$f" || Die "File $f not found"; done |
duke@1 | 54 | } |
duke@1 | 55 | |
duke@1 | 56 | Report() { |
duke@1 | 57 | test "$#" != 2 && Die "Usage: Report success|failure rc" |
duke@1 | 58 | |
duke@1 | 59 | if test "$1" = "success" -a "$2" = 0; then |
duke@1 | 60 | echo "PASS: succeeded as expected" |
duke@1 | 61 | elif test "$1" = "failure" -a "$2" != 0; then |
duke@1 | 62 | echo "PASS: failed as expected" |
duke@1 | 63 | elif test "$1" = "success" -a "$2" != 0; then |
duke@1 | 64 | Fail "test failed unexpectedly" |
duke@1 | 65 | elif test "$1" = "failure" -a "$2" = 0; then |
duke@1 | 66 | Fail "test succeeded unexpectedly" |
duke@1 | 67 | else |
duke@1 | 68 | Die "Usage: Report success|failure rc" |
duke@1 | 69 | fi |
duke@1 | 70 | } |
duke@1 | 71 | |
duke@1 | 72 | MkManifestWithClassPath() { |
duke@1 | 73 | (echo "Manifest-Version: 1.0"; echo "Class-Path: $*") > MANIFEST.MF |
duke@1 | 74 | } |
duke@1 | 75 | |
duke@1 | 76 | HorizontalRule() { |
duke@1 | 77 | echo "-----------------------------------------------------------------" |
duke@1 | 78 | } |
duke@1 | 79 | |
duke@1 | 80 | Test() { |
duke@1 | 81 | HorizontalRule |
duke@1 | 82 | expectedResult="$1"; shift |
duke@1 | 83 | printf "%s\n" "$*" |
duke@1 | 84 | "$@" |
duke@1 | 85 | Report "$expectedResult" "$?" |
duke@1 | 86 | } |
duke@1 | 87 | |
duke@1 | 88 | Failure() { Test failure "$@"; } |
duke@1 | 89 | Success() { Test success "$@"; } |
duke@1 | 90 | |
duke@1 | 91 | Bottom() { |
duke@1 | 92 | test "$#" = 1 -a "$1" = "Line" || Die "Usage: Bottom Line" |
duke@1 | 93 | |
duke@1 | 94 | if test -n "$failed"; then |
duke@1 | 95 | count=`printf "%s" "$failed" | wc -c | tr -d ' '` |
duke@1 | 96 | echo "FAIL: $count tests failed" |
duke@1 | 97 | exit 1 |
duke@1 | 98 | else |
duke@1 | 99 | echo "PASS: all tests gave expected results" |
duke@1 | 100 | exit 0 |
duke@1 | 101 | fi |
duke@1 | 102 | } |
duke@1 | 103 | |
duke@1 | 104 | BadJarFile() { |
duke@1 | 105 | for jarfilename in "$@"; do pwd > "$jarfilename"; done |
duke@1 | 106 | } |
duke@1 | 107 | |
duke@1 | 108 | #---------------------------------------------------------------- |
duke@1 | 109 | # Usage: BCP=`DefaultBootClassPath` |
duke@1 | 110 | # Returns default bootclasspath, discarding non-existent entries |
duke@1 | 111 | #---------------------------------------------------------------- |
duke@1 | 112 | DefaultBootClassPath() { |
duke@1 | 113 | echo 'public class B {public static void main(String[] a) { |
duke@1 | 114 | System.out.println(System.getProperty("sun.boot.class.path"));}}' > B.java |
duke@1 | 115 | "$javac" ${TESTTOOLVMOPTS} B.java |
duke@1 | 116 | _BCP_="" |
duke@1 | 117 | for elt in `"$java" ${TESTVMOPTS} B | tr "${PS}" " "`; do |
duke@1 | 118 | test -r "$elt" -a -n "$elt" && _BCP_="${_BCP_:+${_BCP_}${PS}}${elt}" |
duke@1 | 119 | done |
duke@1 | 120 | rm -f B.java B.class |
duke@1 | 121 | printf "%s" "$_BCP_" # Don't use echo -- unsafe on Windows |
duke@1 | 122 | } |
duke@1 | 123 | |
duke@1 | 124 | #---------------------------------------------------------------- |
duke@1 | 125 | # Foil message localization |
duke@1 | 126 | #---------------------------------------------------------------- |
duke@1 | 127 | DiagnosticsInEnglishPlease() { |
duke@1 | 128 | LANG="C" LC_ALL="C" LC_MESSAGES="C"; export LANG LC_ALL LC_MESSAGES |
duke@1 | 129 | } |