jdk/test/tools/launcher/UnicodeTest.sh
changeset 11859 71611f5496d6
parent 11858 20e46927b54d
parent 11746 6c805d8ed4e5
child 11860 e50af542fdbe
equal deleted inserted replaced
11858:20e46927b54d 11859:71611f5496d6
     1 # Copyright (c) 2007, 2010, 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 it
       
     5 # under the terms of the GNU General Public License version 2 only, as
       
     6 # published by the Free Software Foundation.
       
     7 #
       
     8 # This code is distributed in the hope that it will be useful, but WITHOUT
       
     9 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    10 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    11 # version 2 for more details (a copy is included in the LICENSE file that
       
    12 # accompanied this code).
       
    13 #
       
    14 # You should have received a copy of the GNU General Public License version
       
    15 # 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 USA
       
    19 # or visit www.oracle.com if you need additional information or have any
       
    20 # questions.
       
    21 
       
    22 # @test
       
    23 # @bug 5030265
       
    24 # @summary Verify that the J2RE can handle all legal Unicode characters
       
    25 #          in class names unless limited by the file system encoding
       
    26 #          or the encoding used for command line arguments.
       
    27 # @author Norbert Lindenberg
       
    28 
       
    29 
       
    30 # Verify directory context variables are set
       
    31 if [ "${TESTJAVA}" = "" ]
       
    32 then
       
    33   echo "TESTJAVA not set.  Test cannot execute.  Failed."
       
    34   exit 1
       
    35 fi
       
    36 
       
    37 if [ "${TESTSRC}" = "" ]
       
    38 then
       
    39   echo "TESTSRC not set.  Test cannot execute.  Failed."
       
    40   exit 1
       
    41 fi
       
    42 
       
    43 if [ "${TESTCLASSES}" = "" ]
       
    44 then
       
    45   echo "TESTCLASSES not set.  Test cannot execute.  Failed."
       
    46   exit 1
       
    47 fi
       
    48 
       
    49 JAVAC="${TESTJAVA}"/bin/javac
       
    50 JAVA="${TESTJAVA}"/bin/java
       
    51 JAR="${TESTJAVA}"/bin/jar
       
    52 
       
    53 mkdir UnicodeTest-src UnicodeTest-classes
       
    54 
       
    55 echo "creating test source files"
       
    56 "$JAVAC" -d . "${TESTSRC}"/UnicodeTest.java
       
    57 if [ "`uname -s | grep CYGWIN`" != "" ] ; then
       
    58   CLASS_NAME=`"$JAVA" UnicodeTest | sed -e 's@\\r@@g' `
       
    59 else
       
    60   CLASS_NAME=`"$JAVA" UnicodeTest`
       
    61 fi
       
    62 
       
    63 if [ "$CLASS_NAME" = "" ]
       
    64 then
       
    65   echo "CLASS_NAME not generated.  Test failed."
       
    66   exit 1
       
    67 fi
       
    68 
       
    69 echo "building test apps"
       
    70 "$JAVAC" -encoding UTF-8 -sourcepath UnicodeTest-src \
       
    71     -d UnicodeTest-classes UnicodeTest-src/"${CLASS_NAME}".java || exit 1
       
    72 "$JAR" -cvfm UnicodeTest.jar UnicodeTest-src/MANIFEST.MF \
       
    73     -C UnicodeTest-classes . || exit 1
       
    74 
       
    75 echo "running test app using class file"
       
    76 "$JAVA" -classpath UnicodeTest-classes "$CLASS_NAME" || exit 1
       
    77 
       
    78 echo "delete generated files with non-ASCII names"
       
    79 # do it now because on Unix they may not be accessible when locale changes
       
    80 # do it in Java because shells on Windows can't handle full Unicode
       
    81 "$JAVAC" -d . "${TESTSRC}"/UnicodeCleanup.java || exit 1
       
    82 "$JAVA" UnicodeCleanup UnicodeTest-src UnicodeTest-classes || exit 1
       
    83 
       
    84 echo "running test app using newly built jar file"
       
    85 "$JAVA" -jar UnicodeTest.jar || exit 1
       
    86 
       
    87 echo "running test app using jar file built in Solaris UTF-8 locale"
       
    88 "$JAVA" -jar "${TESTSRC}"/UnicodeTest.jar || exit 1
       
    89 
       
    90 # if we can switch to a C locale, then test whether jar files with
       
    91 # non-ASCII characters in the manifest still work in this crippled
       
    92 # environment
       
    93 if test -n "`locale -a 2>/dev/null | grep '^C$'`"
       
    94 then
       
    95     LC_ALL=C
       
    96     export LC_ALL
       
    97 
       
    98     echo "running test app using newly built jar file in C locale"
       
    99     "$JAVA" -jar UnicodeTest.jar || exit 1
       
   100 
       
   101     echo "running test app using premade jar file in C locale"
       
   102     "$JAVA" -jar "${TESTSRC}"/UnicodeTest.jar || exit 1
       
   103 fi
       
   104 
       
   105 exit 0
       
   106