Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/tools/native2ascii/Native2AsciiTests.sh
38840 views
#! /bin/sh -e12#3# Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.4# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.5#6# This code is free software; you can redistribute it and/or modify it7# under the terms of the GNU General Public License version 2 only, as8# published by the Free Software Foundation.9#10# This code is distributed in the hope that it will be useful, but WITHOUT11# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13# version 2 for more details (a copy is included in the LICENSE file that14# accompanied this code).15#16# You should have received a copy of the GNU General Public License version17# 2 along with this work; if not, write to the Free Software Foundation,18# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19#20# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21# or visit www.oracle.com if you need additional information or have any22# questions.23#2425# @test26# @bug 4630463 4630971 4636448 4701617 4721296 4710890 6247817 7021987 806796427# @summary Tests miscellaneous native2ascii bugfixes and regressions282930if [ "${TESTSRC}" = "" ]; then TESTSRC=.; fi31if [ "${TESTJAVA}" = "" ]; then TESTJAVA=$1; shift; fi3233case `uname -s` in34Windows* | CYGWIN*) OS=Windows;;35SunOS|Linux) OS=Unix;;36esac3738N2A=$TESTJAVA/bin/native2ascii3940check() {41bug=$1; shift42expected=$1; shift43out=$1; shift4445# Strip carriage returns from output when comparing with n2a test output46# on win32 systems47if [ ${OS} = Windows ]; then48sed -e 's@\\r@@g' $out >$out.149sed -e 's@\\r@@g' $expected >$out.expected50else51cp $out $out.152cp $expected $out.expected53fi54if (set -x; diff -c $out.expected $out.1); then55echo "$bug passed"56else57echo "$bug failed"58exit 159fi60}6162# Check that native2ascii -reverse with an ISO-8859-1 encoded file works63# as documented. 4630463 fixes a bug in the ISO-8859-1 encoder which64# prevented encoding of valid ISO-8859-1 chars > 0x7f6566rm -f x.*67$N2A -reverse -encoding ISO-8859-1 $TESTSRC/A2N_4630463 x.out68check 4630463 $TESTSRC/A2N_4630463.expected x.out6970# Take file encoded in ISO-8859-1 with range of chars , 0x7f < c < 0xff71# invoke native2ascii with input filename and output filename identical72# Ensure that output file is as expected by comparing to expected output.73# 4636448 Fixed bug whereby output file was clobbered if infile and outfile74# referred to same filename. This bug only applies to Solaris/Linux, since on75# Windows you can't write to a file that's open for reading.7677if [ $OS = Unix ]; then78rm -f x.*79cp $TESTSRC/N2A_4636448 x.in80chmod +w x.in81ls -l x.in82if $N2A -encoding ISO-8859-1 x.in x.in; then83check 4636448 $TESTSRC/N2A_4636448.expected x.in84fi85fi8687# Ensure that files containing backslashes adjacent to EOF don't88# hang native2ascii -reverse8990rm -f x.*91$N2A -reverse -encoding ISO-8859-1 $TESTSRC/A2N_4630971 x.out92check 4630971 $TESTSRC/A2N_4630971 x.out9394# Check reverse (char -> native) encoding of Japanese Halfwidth95# Katakana characters for MS932 (default WinNT Japanese encoding)96# Regression test for bugID 47016179798rm -f x.*99$N2A -reverse -encoding MS932 $TESTSRC/A2N_4701617 x.out100check 4701617 $TESTSRC/A2N_4701617.expected x.out101102# Check that the inputfile appears in the error message when not found103104badin="DoesNotExist"105$N2A $badin x.out | grep "$badin" > /dev/null106if [ $? != 0 ]; then107echo "\"$badin\" expected to appear in error message"108exit 1109fi110111# for win32 only ensure when output file pre-exists that112# native2ascii tool will simply overwrite with the expected113# output file (fixed bugID 4710890)114115if [ OS = Windows ]; then116rm -f x.*117cp $TESTSRC/test3 x.in118chmod a+x x.in119ls -l x.in120touch x.out121$N2A -encoding ISO-8859-1 x.in x.out122check 4710890 $TESTSRC/test3 x.out123fi124125rm -rf x.*126$N2A -reverse $TESTSRC/A2N_6247817 x.out127check 4701617 $TESTSRC/A2N_6247817 x.out128129130131