Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/nio/charset/spi/basic.sh
38828 views
#!/bin/sh12#3# Copyright (c) 2010, 2012, 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 it7# under the terms of the GNU General Public License version 2 only, as8# published by the Free Software Foundation.9#10# This code is distributed in the hope that it will be useful, but WITHOUT11# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13# version 2 for more details (a copy is included in the LICENSE file that14# accompanied this code).15#16# You should have received a copy of the GNU General Public License version17# 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 USA21# or visit www.oracle.com if you need additional information or have any22# questions.23#2425# @test26# @bug 4429040 4591027 481474327# @summary Unit test for charset providers28#29# @build Test FooCharset FooProvider30# @run shell basic.sh31# @run shell basic.sh ja_JP.eucJP32# @run shell basic.sh tr_TR33#3435# Command-line usage: sh basic.sh /path/to/build [locale]3637if [ -z "$TESTJAVA" ]; then38if [ $# -lt 1 ]; then exit 1; fi39TESTJAVA=$1; shift40COMPILEJDK="${TESTJAVA}"41TESTSRC=`pwd`42TESTCLASSES=`pwd`43fi4445JAVA=$TESTJAVA/bin/java46JAR=$COMPILEJAVA/bin/jar4748DIR=`pwd`49case `uname` in50SunOS | Linux | Darwin | AIX ) CPS=':' ;;51Windows* ) CPS=';' ;;52CYGWIN* )53DIR=`/usr/bin/cygpath -a -s -m $DIR`54CPS=";";;55*) echo "Unknown platform: `uname`"; exit 1 ;;56esac5758JARD=$DIR/x.jar59EXTD=$DIR/x.ext60TESTD=$DIR/x.test6162CSS='US-ASCII 8859_1 iso-ir-6 UTF-16 windows-1252 !BAR cp1252'636465if [ \! -d $EXTD ]; then66# Initialize67echo Initializing...68rm -rf $JARD $EXTD $TESTD69mkdir -p $JARD/META-INF/services x.ext70echo FooProvider \71>$JARD/META-INF/services/java.nio.charset.spi.CharsetProvider72cp $TESTCLASSES/FooProvider.class $TESTCLASSES/FooCharset.class $JARD73mkdir $TESTD74cp $TESTCLASSES/Test.class $TESTD75(cd $JARD; $JAR ${TESTTOOLVMOPTS} -cf $EXTD/test.jar *)76fi7778if [ $# -gt 0 ]; then79# Use locale specified on command line, if it's supported80L="$1"81shift82s=`uname -s`83if [ $s != Linux -a $s != SunOS -a $s != Darwin -a $s != AIX ]; then84echo "$L: Locales not supported on this system, skipping..."85exit 086fi87if [ "x`locale -a | grep $L`" != "x$L" ]; then88echo "$L: Locale not supported, skipping..."89exit 090fi91LC_ALL=$L; export LC_ALL92fi9394TMP=${TMP:-$TEMP}; TMP=${TMP:-/tmp}95cd $TMP9697failures=098for where in ext app; do99for security in none minimal-policy cp-policy; do100echo '';101echo "LC_ALL=$LC_ALL where=$where security=$security"102av=''103if [ $where = ext ]; then104av="$av -cp $TESTD -Djava.ext.dirs=$EXTD";105else106av="$av -cp $TESTD$CPS$EXTD/test.jar";107fi108case $security in109none) css="$CSS FOO";;110# Minimal policy in this case is more or less carbon copy of jre default111# security policy and doesn't give explicit runtime permission112# for user provided runtime loadable charsets113minimal-policy) css="$CSS !FOO";114av="$av -Djava.security.manager -Djava.security.policy==$TESTSRC/default-pol";;115cp-policy) css="$CSS FOO";116av="$av -Djava.security.manager117-Djava.security.policy==$TESTSRC/charsetProvider.sp";;118esac119if (set -x; $JAVA ${TESTVMOPTS} $av Test $css) 2>&1; then120continue;121else122failures=`expr $failures + 1`123fi124done125done126127echo ''128if [ $failures -gt 0 ];129then echo "$failures cases failed";130else echo "All cases passed"; fi131exit $failures132133134