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