0N/A#! /bin/sh -e
0N/A
0N/A#
3909N/A# Copyright (c) 2002, 2011, 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,
0N/A# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A#
2362N/A# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A# or visit www.oracle.com if you need additional information or have any
2362N/A# questions.
0N/A#
0N/A
0N/A# @test
3663N/A# @bug 4630463 4630971 4636448 4701617 4721296 4710890 6247817 7021987
0N/A# @summary Tests miscellaneous native2ascii bugfixes and regressions
0N/A
0N/A
0N/Aif [ "${TESTSRC}" = "" ]; then TESTSRC=.; fi
0N/Aif [ "${TESTJAVA}" = "" ]; then TESTJAVA=$1; shift; fi
0N/A
0N/Acase `uname -s` in
2078N/A Windows* | CYGWIN*) OS=Windows;;
0N/A SunOS|Linux) OS=Unix;;
0N/Aesac
0N/A
0N/AN2A=$TESTJAVA/bin/native2ascii
0N/A
0N/Acheck() {
0N/A bug=$1; shift
0N/A expected=$1; shift
0N/A out=$1; shift
0N/A
0N/A # Strip carriage returns from output when comparing with n2a test output
0N/A # on win32 systems
2078N/A if [ ${OS} = Windows ]; then
2078N/A sed -e 's@\\r@@g' $out >$out.1
2078N/A sed -e 's@\\r@@g' $expected >$out.expected
0N/A else
0N/A cp $out $out.1
2078N/A cp $expected $out.expected
0N/A fi
2078N/A if (set -x; diff -c $out.expected $out.1); then
0N/A echo "$bug passed"
0N/A else
0N/A echo "$bug failed"
0N/A exit 1
0N/A fi
0N/A}
0N/A
0N/A# Check that native2ascii -reverse with an ISO-8859-1 encoded file works
0N/A# as documented. 4630463 fixes a bug in the ISO-8859-1 encoder which
0N/A# prevented encoding of valid ISO-8859-1 chars > 0x7f
0N/A
0N/Arm -f x.*
0N/A$N2A -reverse -encoding ISO-8859-1 $TESTSRC/A2N_4630463 x.out
0N/Acheck 4630463 $TESTSRC/A2N_4630463.expected x.out
0N/A
0N/A# Take file encoded in ISO-8859-1 with range of chars , 0x7f < c < 0xff
0N/A# invoke native2ascii with input filename and output filename identical
0N/A# Ensure that output file is as expected by comparing to expected output.
0N/A# 4636448 Fixed bug whereby output file was clobbered if infile and outfile
0N/A# referred to same filename. This bug only applies to Solaris/Linux, since on
0N/A# Windows you can't write to a file that's open for reading.
0N/A
0N/Aif [ $OS = Unix ]; then
0N/A rm -f x.*
0N/A cp $TESTSRC/N2A_4636448 x.in
0N/A chmod +w x.in
0N/A ls -l x.in
0N/A if $N2A -encoding ISO-8859-1 x.in x.in; then
0N/A check 4636448 $TESTSRC/N2A_4636448.expected x.in
0N/A fi
0N/Afi
0N/A
0N/A# Ensure that files containing backslashes adjacent to EOF don't
0N/A# hang native2ascii -reverse
0N/A
0N/Arm -f x.*
0N/A$N2A -reverse -encoding ISO-8859-1 $TESTSRC/A2N_4630971 x.out
0N/Acheck 4630971 $TESTSRC/A2N_4630971 x.out
0N/A
0N/A# Check reverse (char -> native) encoding of Japanese Halfwidth
0N/A# Katakana characters for MS932 (default WinNT Japanese encoding)
0N/A# Regression test for bugID 4701617
0N/A
0N/Arm -f x.*
0N/A$N2A -reverse -encoding MS932 $TESTSRC/A2N_4701617 x.out
0N/Acheck 4701617 $TESTSRC/A2N_4701617.expected x.out
0N/A
3663N/A# Check that the inputfile appears in the error message when not found
3663N/A
3663N/Abadin="DoesNotExist"
3663N/A$N2A $badin x.out | grep "$badin" > /dev/null
3663N/Aif [ $? != 0 ]; then
3663N/A echo "\"$badin\" expected to appear in error message"
3663N/A exit 1
3663N/Afi
3663N/A
0N/A# for win32 only ensure when output file pre-exists that
0N/A# native2ascii tool will simply overwrite with the expected
0N/A# output file (fixed bugID 4710890)
0N/A
0N/Aif [ OS = Windows ]; then
0N/A rm -f x.*
0N/A cp $TESTSRC/test3 x.in
0N/A chmod a+x x.in
0N/A ls -l x.in
0N/A touch x.out
0N/A $N2A -encoding ISO-8859-1 x.in x.out
0N/A check 4710890 $TESTSRC/test3 x.out
0N/Afi
0N/A
0N/Arm -rf x.*
0N/A$N2A -reverse $TESTSRC/A2N_6247817 x.out
0N/Acheck 4701617 $TESTSRC/A2N_6247817 x.out
0N/A