1 #!/bin/sh
   2 #
   3 # Copyright (c) 2007, 2015, 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 it
   7 # under the terms of the GNU General Public License version 2 only, as
   8 # published by the Free Software Foundation.
   9 #
  10 # This code is distributed in the hope that it will be useful, but WITHOUT
  11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13 # version 2 for more details (a copy is included in the LICENSE file that
  14 # accompanied this code).
  15 #
  16 # You should have received a copy of the GNU General Public License version
  17 # 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 USA
  21 # or visit www.oracle.com if you need additional information or have any
  22 # questions.
  23 #
  24 #
  25 #
  26 #
  27 # This script is the actual launcher of each locale service provider test.
  28 # fooprovider.jar contains localized object providers and barprovider.jar
  29 # contains localized name providers.  This way, we can test providers that
  30 # can relate to each other (such as, DateFormatSymbolsProvider and
  31 # TimeZoneNameProvider) separately.
  32 #
  33 # Parameters:
  34 #    providersToTest: [foo|bar|foobar]
  35 #    java class name: <class name>
  36 #    java security policy file: (Optional. Installs security manager if exists)
  37 
  38 if [ "${TESTSRC}" = "" ]
  39 then
  40   echo "TESTSRC not set.  Test cannot execute.  Failed."
  41   exit 1
  42 fi
  43 echo "TESTSRC=${TESTSRC}"
  44 if [ "${TESTJAVA}" = "" ]
  45 then
  46   echo "TESTJAVA not set.  Test cannot execute.  Failed."
  47   exit 1
  48 fi
  49 if [ "${COMPILEJAVA}" = "" ]
  50 then
  51   COMPILEJAVA="${TESTJAVA}"
  52 fi
  53 echo "TESTJAVA=${TESTJAVA}"
  54 if [ "${TESTCLASSES}" = "" ]
  55 then
  56   echo "TESTCLASSES not set.  Test cannot execute.  Failed."
  57   exit 1
  58 fi
  59 echo "TESTCLASSES=${TESTCLASSES}"
  60 echo "CLASSPATH=${CLASSPATH}"
  61 
  62 # set platform-dependent variables
  63 OS=`uname -s`
  64 case "$OS" in
  65   SunOS | Linux | Darwin | AIX )
  66     PS=":"
  67     FS="/"
  68     ;;
  69   Windows* | CYGWIN* )
  70     PS=";"
  71     FS="\\"
  72     ;;
  73   * )
  74     echo "Unrecognized system!"
  75     exit 1;
  76     ;;
  77 esac
  78 
  79 case "$1" in
  80   "foo" )
  81     cp ${TESTSRC}${FS}fooprovider.jar ${TESTCLASSES}
  82     CLASSPATHARG=".${PS}${TESTSRC}${PS}${TESTSRC}${FS}fooprovider.jar"
  83     ;;
  84   "bar" )
  85     cp ${TESTSRC}${FS}barprovider.jar ${TESTCLASSES}
  86     CLASSPATHARG=".${PS}${TESTSRC}${PS}${TESTSRC}${FS}barprovider.jar"
  87     ;;
  88   "foobar" )
  89     cp ${TESTSRC}${FS}fooprovider.jar ${TESTCLASSES}
  90     cp ${TESTSRC}${FS}barprovider.jar ${TESTCLASSES}
  91     CLASSPATHARG=".${PS}${TESTSRC}${PS}${TESTSRC}${FS}fooprovider.jar${PS}${TESTSRC}${PS}${TESTSRC}${FS}barprovider.jar"
  92     ;;
  93 esac
  94 
  95 # compile
  96 cp ${TESTSRC}${FS}ProviderTest.java .
  97 cp ${TESTSRC}${FS}$2.java .
  98 COMPILE="${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} \
  99     -XDignore.symbol.file -d . -classpath ${CLASSPATHARG} $2.java"
 100 echo ${COMPILE}
 101 ${COMPILE}
 102 result=$?
 103 
 104 if [ $result -eq 0 ]
 105 then
 106   echo "Compilation of the test case was successful."
 107 else
 108   echo "Compilation of the test case failed."
 109   # Cleanup
 110   rm -f ${TESTCLASSES}${FS}$2*.class
 111   rm -f ${TESTCLASSES}${FS}fooprovider.jar
 112   rm -f ${TESTCLASSES}${FS}barprovider.jar
 113   exit $result
 114 fi
 115 
 116 # security options
 117 if [ "$3" != "" ]
 118 then
 119   SECURITYOPTS="-Djava.security.manager -Djava.security.policy=${TESTSRC}${FS}$3"
 120 fi
 121 
 122 # run
 123 RUNCMD="${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} ${SECURITYOPTS} -classpath ${CLASSPATHARG} -Djava.locale.providers=JRE,SPI $2 "
 124 
 125 echo ${RUNCMD}
 126 ${RUNCMD}
 127 result=$?
 128 
 129 if [ $result -eq 0 ]
 130 then
 131   echo "Execution successful"
 132 else
 133   echo "Execution of the test case failed."
 134 fi
 135 
 136 # Cleanup
 137 rm -f ${TESTCLASSES}${FS}$2*.class
 138 rm -f ${TESTCLASSES}${FS}fooprovider.jar
 139 rm -f ${TESTCLASSES}${FS}barprovider.jar
 140 
 141 exit $result