jdk/test/java/nio/charset/spi/basic.sh
author katleman
Thu, 05 Jan 2012 08:42:37 -0800
changeset 11376 075fe3928b7f
parent 10149 3b6ad02f4a40
child 12047 320a714614e9
permissions -rw-r--r--
Added tag jdk8-b20 for changeset 90e14ec89395
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4817
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
     1
#!/bin/sh
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
     2
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
     3
#
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4817
diff changeset
     4
# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
4817
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
     5
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
     6
#
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
     7
# This code is free software; you can redistribute it and/or modify it
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
     8
# under the terms of the GNU General Public License version 2 only, as
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
     9
# published by the Free Software Foundation.
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    10
#
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    11
# This code is distributed in the hope that it will be useful, but WITHOUT
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    13
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    14
# version 2 for more details (a copy is included in the LICENSE file that
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    15
# accompanied this code).
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    16
#
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    17
# You should have received a copy of the GNU General Public License version
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    18
# 2 along with this work; if not, write to the Free Software Foundation,
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    20
#
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4817
diff changeset
    21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4817
diff changeset
    22
# or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4817
diff changeset
    23
# questions.
4817
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    24
#
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    25
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    26
# @test
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    27
# @bug 4429040 4591027 4814743
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    28
# @summary Unit test for charset providers
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    29
#
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    30
# @build Test FooCharset FooProvider
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    31
# @run shell basic.sh
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    32
# @run shell basic.sh ja_JP.eucJP
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    33
# @run shell basic.sh tr_TR
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    34
#
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    35
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    36
# Command-line usage: sh basic.sh /path/to/build [locale]
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    37
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    38
if [ -z "$TESTJAVA" ]; then
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    39
  if [ $# -lt 1 ]; then exit 1; fi
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    40
  TESTJAVA=$1; shift
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    41
  TESTSRC=`pwd`
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    42
  TESTCLASSES=`pwd`
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    43
fi
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    44
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    45
JAVA=$TESTJAVA/bin/java
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    46
JAR=$TESTJAVA/bin/jar
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    47
10149
3b6ad02f4a40 7012365: TEST_BUG: test/java/nio/charset/spi/basic.sh can be run with Cygwin
mchung
parents: 5506
diff changeset
    48
DIR=`pwd`
3b6ad02f4a40 7012365: TEST_BUG: test/java/nio/charset/spi/basic.sh can be run with Cygwin
mchung
parents: 5506
diff changeset
    49
case `uname` in
3b6ad02f4a40 7012365: TEST_BUG: test/java/nio/charset/spi/basic.sh can be run with Cygwin
mchung
parents: 5506
diff changeset
    50
  SunOS | Linux ) CPS=':' ;;
3b6ad02f4a40 7012365: TEST_BUG: test/java/nio/charset/spi/basic.sh can be run with Cygwin
mchung
parents: 5506
diff changeset
    51
  Windows* )      CPS=';' ;;
3b6ad02f4a40 7012365: TEST_BUG: test/java/nio/charset/spi/basic.sh can be run with Cygwin
mchung
parents: 5506
diff changeset
    52
  CYGWIN*  )
3b6ad02f4a40 7012365: TEST_BUG: test/java/nio/charset/spi/basic.sh can be run with Cygwin
mchung
parents: 5506
diff changeset
    53
    DIR=`/usr/bin/cygpath -a -s -m $DIR`
3b6ad02f4a40 7012365: TEST_BUG: test/java/nio/charset/spi/basic.sh can be run with Cygwin
mchung
parents: 5506
diff changeset
    54
    CPS=";";;
3b6ad02f4a40 7012365: TEST_BUG: test/java/nio/charset/spi/basic.sh can be run with Cygwin
mchung
parents: 5506
diff changeset
    55
  *)              echo "Unknown platform: `uname`"; exit 1 ;;
3b6ad02f4a40 7012365: TEST_BUG: test/java/nio/charset/spi/basic.sh can be run with Cygwin
mchung
parents: 5506
diff changeset
    56
esac
3b6ad02f4a40 7012365: TEST_BUG: test/java/nio/charset/spi/basic.sh can be run with Cygwin
mchung
parents: 5506
diff changeset
    57
3b6ad02f4a40 7012365: TEST_BUG: test/java/nio/charset/spi/basic.sh can be run with Cygwin
mchung
parents: 5506
diff changeset
    58
JARD=$DIR/x.jar
3b6ad02f4a40 7012365: TEST_BUG: test/java/nio/charset/spi/basic.sh can be run with Cygwin
mchung
parents: 5506
diff changeset
    59
EXTD=$DIR/x.ext
3b6ad02f4a40 7012365: TEST_BUG: test/java/nio/charset/spi/basic.sh can be run with Cygwin
mchung
parents: 5506
diff changeset
    60
TESTD=$DIR/x.test
4817
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    61
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    62
CSS='US-ASCII 8859_1 iso-ir-6 UTF-16 windows-1252 !BAR cp1252'
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    63
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    64
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    65
if [ \! -d $EXTD ]; then
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    66
    # Initialize
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    67
    echo Initializing...
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    68
    rm -rf $JARD $EXTD $TESTD
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    69
    mkdir -p $JARD/META-INF/services x.ext
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    70
    echo FooProvider \
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    71
      >$JARD/META-INF/services/java.nio.charset.spi.CharsetProvider
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    72
    cp $TESTCLASSES/FooProvider.class $TESTCLASSES/FooCharset.class $JARD
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    73
    mkdir $TESTD
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    74
    cp $TESTCLASSES/Test.class $TESTD
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    75
    (cd $JARD; $JAR -cf $EXTD/test.jar *)
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    76
fi
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    77
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    78
if [ $# -gt 0 ]; then
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    79
    # Use locale specified on command line, if it's supported
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    80
    L="$1"
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    81
    shift
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    82
    s=`uname -s`
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    83
    if [ $s != Linux -a $s != SunOS ]; then
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    84
      echo "$L: Locales not supported on this system, skipping..."
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    85
      exit 0
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    86
    fi
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    87
    if [ "x`locale -a | grep $L`" != "x$L" ]; then
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    88
      echo "$L: Locale not supported, skipping..."
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    89
      exit 0
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    90
    fi
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    91
    LC_ALL=$L; export LC_ALL
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    92
fi
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    93
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    94
TMP=${TMP:-$TEMP}; TMP=${TMP:-/tmp}
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    95
cd $TMP
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    96
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    97
failures=0
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    98
for where in ext app; do
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    99
  for security in none minimal-policy cp-policy; do
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   100
    echo '';
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   101
    echo "LC_ALL=$LC_ALL where=$where security=$security"
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   102
    av=''
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   103
    if [ $where = ext ]; then
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   104
      av="$av -cp $TESTD -Djava.ext.dirs=$EXTD";
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   105
    else
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   106
      av="$av -cp $TESTD$CPS$EXTD/test.jar";
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   107
    fi
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   108
    case $security in
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   109
      none)          css="$CSS FOO";;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   110
      # Minimal policy in this case is more or less carbon copy of jre default
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   111
      # security policy and doesn't give explicit runtime permission
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   112
      # for user provided runtime loadable charsets
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   113
      minimal-policy)  css="$CSS !FOO";
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   114
		     av="$av -Djava.security.manager -Djava.security.policy==$TESTSRC/default-pol";;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   115
      cp-policy)     css="$CSS FOO";
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   116
		     av="$av -Djava.security.manager
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   117
		         -Djava.security.policy==$TESTSRC/charsetProvider.sp";;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   118
    esac
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   119
    if (set -x; $JAVA $av Test $css) 2>&1; then
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   120
      continue;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   121
    else
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   122
      failures=`expr $failures + 1`
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   123
    fi
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   124
  done
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   125
done
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   126
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   127
echo ''
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   128
if [ $failures -gt 0 ];
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   129
  then echo "$failures cases failed";
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   130
  else echo "All cases passed"; fi
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
   131
exit $failures