langtools/test/tools/javac/Paths/Util.sh
changeset 27579 d1a63c99cdd5
parent 5520 86e4b9a9da40
child 38517 51a0187f11f6
equal deleted inserted replaced
27578:d61af14a5cf7 27579:d1a63c99cdd5
     1 #
     1 #
     2 # Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
     2 # Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
     3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4 #
     4 #
     5 # This code is free software; you can redistribute it and/or modify it
     5 # This code is free software; you can redistribute it and/or modify it
     6 # under the terms of the GNU General Public License version 2 only, as
     6 # under the terms of the GNU General Public License version 2 only, as
     7 # published by the Free Software Foundation.
     7 # published by the Free Software Foundation.
    55 
    55 
    56 Report() {
    56 Report() {
    57     test "$#" != 2 && Die "Usage: Report success|failure rc"
    57     test "$#" != 2 && Die "Usage: Report success|failure rc"
    58 
    58 
    59     if   test "$1" = "success" -a "$2" = 0; then
    59     if   test "$1" = "success" -a "$2" = 0; then
    60 	echo "PASS: succeeded as expected"
    60         echo "PASS: succeeded as expected"
    61     elif test "$1" = "failure" -a "$2" != 0; then
    61     elif test "$1" = "failure" -a "$2" != 0; then
    62 	echo "PASS: failed as expected"
    62         echo "PASS: failed as expected"
    63     elif test "$1" = "success" -a "$2" != 0; then
    63     elif test "$1" = "success" -a "$2" != 0; then
    64 	Fail "test failed unexpectedly"
    64         Fail "test failed unexpectedly"
    65     elif test "$1" = "failure" -a "$2" = 0; then
    65     elif test "$1" = "failure" -a "$2" = 0; then
    66 	Fail "test succeeded unexpectedly"
    66         Fail "test succeeded unexpectedly"
    67     else
    67     else
    68 	Die "Usage: Report success|failure rc"
    68         Die "Usage: Report success|failure rc"
    69     fi
    69     fi
    70 }
    70 }
    71 
    71 
    72 MkManifestWithClassPath() {
    72 MkManifestWithClassPath() {
    73     (echo "Manifest-Version: 1.0"; echo "Class-Path: $*") > MANIFEST.MF
    73     (echo "Manifest-Version: 1.0"; echo "Class-Path: $*") > MANIFEST.MF
    90 
    90 
    91 Bottom() {
    91 Bottom() {
    92     test "$#" = 1 -a "$1" = "Line" || Die "Usage: Bottom Line"
    92     test "$#" = 1 -a "$1" = "Line" || Die "Usage: Bottom Line"
    93 
    93 
    94     if test -n "$failed"; then
    94     if test -n "$failed"; then
    95 	count=`printf "%s" "$failed" | wc -c | tr -d ' '`
    95         count=`printf "%s" "$failed" | wc -c | tr -d ' '`
    96 	echo "FAIL: $count tests failed"
    96         echo "FAIL: $count tests failed"
    97 	exit 1
    97         exit 1
    98     else
    98     else
    99 	echo "PASS: all tests gave expected results"
    99         echo "PASS: all tests gave expected results"
   100 	exit 0
   100         exit 0
   101     fi
   101     fi
   102 }
   102 }
   103 
   103 
   104 BadJarFile() {
   104 BadJarFile() {
   105     for jarfilename in "$@"; do pwd > "$jarfilename"; done
   105     for jarfilename in "$@"; do pwd > "$jarfilename"; done
   106 }
   106 }
   107 
   107 
   108 #----------------------------------------------------------------
   108 # #----------------------------------------------------------------
   109 # Usage: BCP=`DefaultBootClassPath`
   109 # # Usage: BCP=`DefaultBootClassPath`
   110 # Returns default bootclasspath, discarding non-existent entries
   110 # # Returns default bootclasspath, discarding non-existent entries
   111 #----------------------------------------------------------------
   111 # #----------------------------------------------------------------
   112 DefaultBootClassPath() {
   112 # DefaultBootClassPath() {
   113     echo 'public class B {public static void main(String[] a) {
   113 #     echo 'public class B {public static void main(String[] a) {
   114     System.out.println(System.getProperty("sun.boot.class.path"));}}' > B.java
   114 #     System.out.println(System.getProperty("sun.boot.class.path"));}}' > B.java
   115     "$javac" ${TESTTOOLVMOPTS} B.java
   115 #     "$javac" ${TESTTOOLVMOPTS} B.java
   116     _BCP_=""
   116 #     _BCP_=""
   117     for elt in `"$java" ${TESTVMOPTS} B | tr "${PS}" " "`; do
   117 #     for elt in `"$java" ${TESTVMOPTS} B | tr "${PS}" " "`; do
   118 	test -r "$elt" -a -n "$elt" && _BCP_="${_BCP_:+${_BCP_}${PS}}${elt}"
   118 #       test -r "$elt" -a -n "$elt" && _BCP_="${_BCP_:+${_BCP_}${PS}}${elt}"
   119     done
   119 #     done
   120     rm -f B.java B.class
   120 #     rm -f B.java B.class
   121     printf "%s" "$_BCP_"	# Don't use echo -- unsafe on Windows
   121 #     printf "%s" "$_BCP_"      # Don't use echo -- unsafe on Windows
   122 }
   122 # }
   123 
   123 
   124 #----------------------------------------------------------------
   124 #----------------------------------------------------------------
   125 # Foil message localization
   125 # Foil message localization
   126 #----------------------------------------------------------------
   126 #----------------------------------------------------------------
   127 DiagnosticsInEnglishPlease() {
   127 DiagnosticsInEnglishPlease() {