Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/tools/native2ascii/Native2AsciiTests.sh
38840 views
1
#! /bin/sh -e
2
3
#
4
# Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
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
#
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.
24
#
25
26
# @test
27
# @bug 4630463 4630971 4636448 4701617 4721296 4710890 6247817 7021987 8067964
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
35
Windows* | CYGWIN*) OS=Windows;;
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
48
if [ ${OS} = Windows ]; then
49
sed -e 's@\\r@@g' $out >$out.1
50
sed -e 's@\\r@@g' $expected >$out.expected
51
else
52
cp $out $out.1
53
cp $expected $out.expected
54
fi
55
if (set -x; diff -c $out.expected $out.1); then
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
103
# Check that the inputfile appears in the error message when not found
104
105
badin="DoesNotExist"
106
$N2A $badin x.out | grep "$badin" > /dev/null
107
if [ $? != 0 ]; then
108
echo "\"$badin\" expected to appear in error message"
109
exit 1
110
fi
111
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
130
131