author | bpb |
Tue, 23 Dec 2014 12:40:06 -0800 | |
changeset 28252 | 4673729e145d |
parent 9035 | 1255eb81cc2f |
permissions | -rw-r--r-- |
2 | 1 |
#! /bin/sh -e |
2 |
||
3 |
# |
|
9035
1255eb81cc2f
7033660: Update copyright year to 2011 on any files changed in 2011
ohair
parents:
8560
diff
changeset
|
4 |
# Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. |
2 | 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. |
|
2 | 24 |
# |
25 |
||
26 |
# @test |
|
28252
4673729e145d
8067964: Native2ascii doesn't close one of the streams it opens
bpb
parents:
9035
diff
changeset
|
27 |
# @bug 4630463 4630971 4636448 4701617 4721296 4710890 6247817 7021987 8067964 |
2 | 28 |
# @summary Tests miscellaneous native2ascii bugfixes and regressions |
29 |
||
30 |
||
31 |
if [ "${TESTSRC}" = "" ]; then TESTSRC=.; fi |
|
32 |
if [ "${TESTJAVA}" = "" ]; then TESTJAVA=$1; shift; fi |
|
33 |
||
34 |
case `uname -s` in |
|
4663
dfea6ffdb0dc
6911104: Tests do not work with CYGWIN: tools, sun/tools, and com/sun/tools
ohair
parents:
2
diff
changeset
|
35 |
Windows* | CYGWIN*) OS=Windows;; |
2 | 36 |
SunOS|Linux) OS=Unix;; |
37 |
esac |
|
38 |
||
39 |
N2A=$TESTJAVA/bin/native2ascii |
|
40 |
||
41 |
check() { |
|
42 |
bug=$1; shift |
|
43 |
expected=$1; shift |
|
44 |
out=$1; shift |
|
45 |
||
46 |
# Strip carriage returns from output when comparing with n2a test output |
|
47 |
# on win32 systems |
|
4663
dfea6ffdb0dc
6911104: Tests do not work with CYGWIN: tools, sun/tools, and com/sun/tools
ohair
parents:
2
diff
changeset
|
48 |
if [ ${OS} = Windows ]; then |
dfea6ffdb0dc
6911104: Tests do not work with CYGWIN: tools, sun/tools, and com/sun/tools
ohair
parents:
2
diff
changeset
|
49 |
sed -e 's@\\r@@g' $out >$out.1 |
dfea6ffdb0dc
6911104: Tests do not work with CYGWIN: tools, sun/tools, and com/sun/tools
ohair
parents:
2
diff
changeset
|
50 |
sed -e 's@\\r@@g' $expected >$out.expected |
2 | 51 |
else |
52 |
cp $out $out.1 |
|
4663
dfea6ffdb0dc
6911104: Tests do not work with CYGWIN: tools, sun/tools, and com/sun/tools
ohair
parents:
2
diff
changeset
|
53 |
cp $expected $out.expected |
2 | 54 |
fi |
4663
dfea6ffdb0dc
6911104: Tests do not work with CYGWIN: tools, sun/tools, and com/sun/tools
ohair
parents:
2
diff
changeset
|
55 |
if (set -x; diff -c $out.expected $out.1); then |
2 | 56 |
echo "$bug passed" |
57 |
else |
|
58 |
echo "$bug failed" |
|
59 |
exit 1 |
|
60 |
fi |
|
61 |
} |
|
62 |
||
63 |
# Check that native2ascii -reverse with an ISO-8859-1 encoded file works |
|
64 |
# as documented. 4630463 fixes a bug in the ISO-8859-1 encoder which |
|
65 |
# prevented encoding of valid ISO-8859-1 chars > 0x7f |
|
66 |
||
67 |
rm -f x.* |
|
68 |
$N2A -reverse -encoding ISO-8859-1 $TESTSRC/A2N_4630463 x.out |
|
69 |
check 4630463 $TESTSRC/A2N_4630463.expected x.out |
|
70 |
||
71 |
# Take file encoded in ISO-8859-1 with range of chars , 0x7f < c < 0xff |
|
72 |
# invoke native2ascii with input filename and output filename identical |
|
73 |
# Ensure that output file is as expected by comparing to expected output. |
|
74 |
# 4636448 Fixed bug whereby output file was clobbered if infile and outfile |
|
75 |
# referred to same filename. This bug only applies to Solaris/Linux, since on |
|
76 |
# Windows you can't write to a file that's open for reading. |
|
77 |
||
78 |
if [ $OS = Unix ]; then |
|
79 |
rm -f x.* |
|
80 |
cp $TESTSRC/N2A_4636448 x.in |
|
81 |
chmod +w x.in |
|
82 |
ls -l x.in |
|
83 |
if $N2A -encoding ISO-8859-1 x.in x.in; then |
|
84 |
check 4636448 $TESTSRC/N2A_4636448.expected x.in |
|
85 |
fi |
|
86 |
fi |
|
87 |
||
88 |
# Ensure that files containing backslashes adjacent to EOF don't |
|
89 |
# hang native2ascii -reverse |
|
90 |
||
91 |
rm -f x.* |
|
92 |
$N2A -reverse -encoding ISO-8859-1 $TESTSRC/A2N_4630971 x.out |
|
93 |
check 4630971 $TESTSRC/A2N_4630971 x.out |
|
94 |
||
95 |
# Check reverse (char -> native) encoding of Japanese Halfwidth |
|
96 |
# Katakana characters for MS932 (default WinNT Japanese encoding) |
|
97 |
# Regression test for bugID 4701617 |
|
98 |
||
99 |
rm -f x.* |
|
100 |
$N2A -reverse -encoding MS932 $TESTSRC/A2N_4701617 x.out |
|
101 |
check 4701617 $TESTSRC/A2N_4701617.expected x.out |
|
102 |
||
8560
f2abd715d39b
7021987: native2ascii "file cannot be read" error message is broken
alanb
parents:
5506
diff
changeset
|
103 |
# Check that the inputfile appears in the error message when not found |
f2abd715d39b
7021987: native2ascii "file cannot be read" error message is broken
alanb
parents:
5506
diff
changeset
|
104 |
|
f2abd715d39b
7021987: native2ascii "file cannot be read" error message is broken
alanb
parents:
5506
diff
changeset
|
105 |
badin="DoesNotExist" |
f2abd715d39b
7021987: native2ascii "file cannot be read" error message is broken
alanb
parents:
5506
diff
changeset
|
106 |
$N2A $badin x.out | grep "$badin" > /dev/null |
f2abd715d39b
7021987: native2ascii "file cannot be read" error message is broken
alanb
parents:
5506
diff
changeset
|
107 |
if [ $? != 0 ]; then |
f2abd715d39b
7021987: native2ascii "file cannot be read" error message is broken
alanb
parents:
5506
diff
changeset
|
108 |
echo "\"$badin\" expected to appear in error message" |
f2abd715d39b
7021987: native2ascii "file cannot be read" error message is broken
alanb
parents:
5506
diff
changeset
|
109 |
exit 1 |
f2abd715d39b
7021987: native2ascii "file cannot be read" error message is broken
alanb
parents:
5506
diff
changeset
|
110 |
fi |
f2abd715d39b
7021987: native2ascii "file cannot be read" error message is broken
alanb
parents:
5506
diff
changeset
|
111 |
|
2 | 112 |
# for win32 only ensure when output file pre-exists that |
113 |
# native2ascii tool will simply overwrite with the expected |
|
114 |
# output file (fixed bugID 4710890) |
|
115 |
||
116 |
if [ OS = Windows ]; then |
|
117 |
rm -f x.* |
|
118 |
cp $TESTSRC/test3 x.in |
|
119 |
chmod a+x x.in |
|
120 |
ls -l x.in |
|
121 |
touch x.out |
|
122 |
$N2A -encoding ISO-8859-1 x.in x.out |
|
123 |
check 4710890 $TESTSRC/test3 x.out |
|
124 |
fi |
|
125 |
||
126 |
rm -rf x.* |
|
127 |
$N2A -reverse $TESTSRC/A2N_6247817 x.out |
|
128 |
check 4701617 $TESTSRC/A2N_6247817 x.out |
|
129 |