basic.sh revision 4718
0N/A#!/bin/sh
1472N/A
0N/A#
0N/A# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
0N/A# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A#
0N/A# This code is free software; you can redistribute it and/or modify it
0N/A# under the terms of the GNU General Public License version 2 only, as
0N/A# published by the Free Software Foundation.
0N/A#
0N/A# This code is distributed in the hope that it will be useful, but WITHOUT
0N/A# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A# version 2 for more details (a copy is included in the LICENSE file that
0N/A# accompanied this code).
0N/A#
0N/A# You should have received a copy of the GNU General Public License version
0N/A# 2 along with this work; if not, write to the Free Software Foundation,
1472N/A# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1472N/A#
1472N/A# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0N/A# or visit www.oracle.com if you need additional information or have any
0N/A# questions.
0N/A#
0N/A
0N/A# @test
0N/A# @bug 4429040 4591027 4814743
0N/A# @summary Unit test for charset providers
0N/A#
0N/A# @build Test FooCharset FooProvider
0N/A# @run shell basic.sh
0N/A# @run shell basic.sh ja_JP.eucJP
0N/A# @run shell basic.sh tr_TR
0N/A#
0N/A
0N/A# Command-line usage: sh basic.sh /path/to/build [locale]
0N/A
0N/Aif [ -z "$TESTJAVA" ]; then
0N/A if [ $# -lt 1 ]; then exit 1; fi
0N/A TESTJAVA=$1; shift
0N/A TESTSRC=`pwd`
0N/A TESTCLASSES=`pwd`
0N/Afi
0N/A
0N/AJAVA=$TESTJAVA/bin/java
0N/AJAR=$TESTJAVA/bin/jar
0N/A
0N/AJARD=`pwd`/x.jar
0N/AEXTD=`pwd`/x.ext
0N/ATESTD=`pwd`/x.test
0N/A
0N/ACSS='US-ASCII 8859_1 iso-ir-6 UTF-16 windows-1252 !BAR cp1252'
0N/A
0N/A
0N/Aif [ \! -d $EXTD ]; then
0N/A # Initialize
0N/A echo Initializing...
0N/A rm -rf $JARD $EXTD $TESTD
0N/A mkdir -p $JARD/META-INF/services x.ext
0N/A echo FooProvider \
0N/A >$JARD/META-INF/services/java.nio.charset.spi.CharsetProvider
0N/A cp $TESTCLASSES/FooProvider.class $TESTCLASSES/FooCharset.class $JARD
0N/A mkdir $TESTD
0N/A cp $TESTCLASSES/Test.class $TESTD
0N/A (cd $JARD; $JAR -cf $EXTD/test.jar *)
0N/Afi
0N/A
0N/Aif [ $# -gt 0 ]; then
0N/A # Use locale specified on command line, if it's supported
0N/A L="$1"
0N/A shift
0N/A s=`uname -s`
0N/A if [ $s != Linux -a $s != SunOS -a $s != Darwin ]; then
0N/A echo "$L: Locales not supported on this system, skipping..."
0N/A exit 0
0N/A fi
0N/A if [ "x`locale -a | grep $L`" != "x$L" ]; then
0N/A echo "$L: Locale not supported, skipping..."
0N/A exit 0
0N/A fi
0N/A LC_ALL=$L; export LC_ALL
0N/Afi
0N/A
0N/ATMP=${TMP:-$TEMP}; TMP=${TMP:-/tmp}
0N/Acd $TMP
0N/A
0N/Acase `uname` in
0N/A SunOS | Linux | Darwin ) CPS=':' ;;
0N/A Windows* ) CPS=';' ;;
0N/A *) echo "Unknown platform: `uname`"; exit 1 ;;
0N/Aesac
0N/A
0N/Afailures=0
0N/Afor where in ext app; do
0N/A for security in none minimal-policy cp-policy; do
0N/A echo '';
0N/A echo "LC_ALL=$LC_ALL where=$where security=$security"
0N/A av=''
0N/A if [ $where = ext ]; then
0N/A av="$av -cp $TESTD -Djava.ext.dirs=$EXTD";
0N/A else
0N/A av="$av -cp $TESTD$CPS$EXTD/test.jar";
0N/A fi
0N/A case $security in
0N/A none) css="$CSS FOO";;
0N/A # Minimal policy in this case is more or less carbon copy of jre default
0N/A # security policy and doesn't give explicit runtime permission
0N/A # for user provided runtime loadable charsets
0N/A minimal-policy) css="$CSS !FOO";
0N/A av="$av -Djava.security.manager -Djava.security.policy==$TESTSRC/default-pol";;
0N/A cp-policy) css="$CSS FOO";
0N/A av="$av -Djava.security.manager
0N/A -Djava.security.policy==$TESTSRC/charsetProvider.sp";;
0N/A esac
0N/A if (set -x; $JAVA $av Test $css) 2>&1; then
0N/A continue;
0N/A else
0N/A failures=`expr $failures + 1`
0N/A fi
0N/A done
0N/Adone
0N/A
0N/Aecho ''
0N/Aif [ $failures -gt 0 ];
0N/A then echo "$failures cases failed";
0N/A else echo "All cases passed"; fi
0N/Aexit $failures
0N/A