jdk/test/sun/tools/native2ascii/Native2AsciiTests.sh
author ohair
Wed, 06 Apr 2011 22:06:11 -0700
changeset 9035 1255eb81cc2f
parent 8560 f2abd715d39b
child 28252 4673729e145d
permissions -rw-r--r--
7033660: Update copyright year to 2011 on any files changed in 2011 Reviewed-by: dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
#! /bin/sh -e
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     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
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
# This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
# under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
# published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
# This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
# version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
# accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
# You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
# 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
#
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4663
diff changeset
    21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4663
diff changeset
    22
# or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4663
diff changeset
    23
# questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
# @test
8560
f2abd715d39b 7021987: native2ascii "file cannot be read" error message is broken
alanb
parents: 5506
diff changeset
    27
# @bug 4630463 4630971 4636448 4701617 4721296 4710890 6247817 7021987
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
# @summary Tests miscellaneous native2ascii bugfixes and regressions
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
if [ "${TESTSRC}" = "" ]; then TESTSRC=.; fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
if [ "${TESTJAVA}" = "" ]; then TESTJAVA=$1; shift; fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
  SunOS|Linux) OS=Unix;;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
esac
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
N2A=$TESTJAVA/bin/native2ascii
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
check() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
  bug=$1; shift
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
  expected=$1; shift
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
  out=$1; shift
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
  # Strip carriage returns from output when comparing with n2a test output
90ce3da70b43 Initial load
duke
parents:
diff changeset
    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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
  else
90ce3da70b43 Initial load
duke
parents:
diff changeset
    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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    echo "$bug passed"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
  else
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    echo "$bug failed"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    exit 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
  fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
# Check that native2ascii -reverse with an ISO-8859-1 encoded file works
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
# as documented. 4630463 fixes a bug in the ISO-8859-1 encoder which
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
# prevented encoding of valid ISO-8859-1 chars > 0x7f
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
rm -f x.*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
$N2A -reverse -encoding ISO-8859-1 $TESTSRC/A2N_4630463 x.out
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
check 4630463 $TESTSRC/A2N_4630463.expected x.out
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
# Take file encoded in ISO-8859-1 with range of chars ,  0x7f < c < 0xff
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
# invoke native2ascii with input filename and output filename identical
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
# Ensure that output file is as expected by comparing to expected output.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
# 4636448 Fixed bug whereby output file was clobbered if infile and outfile
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
# referred to same filename.  This bug only applies to Solaris/Linux, since on
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
# Windows you can't write to a file that's open for reading.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
if [ $OS = Unix ]; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
  rm -f x.*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
  cp $TESTSRC/N2A_4636448 x.in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
  chmod +w x.in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
  ls -l x.in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
  if $N2A -encoding ISO-8859-1 x.in x.in; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    check 4636448 $TESTSRC/N2A_4636448.expected x.in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
  fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
# Ensure that files containing backslashes adjacent to EOF don't
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
# hang native2ascii -reverse
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
rm -f x.*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
$N2A -reverse -encoding ISO-8859-1 $TESTSRC/A2N_4630971 x.out
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
check 4630971 $TESTSRC/A2N_4630971 x.out
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
# Check reverse (char -> native) encoding of Japanese Halfwidth
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
# Katakana characters for MS932 (default WinNT Japanese encoding)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
# Regression test for bugID 4701617
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
rm -f x.*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
$N2A -reverse -encoding MS932 $TESTSRC/A2N_4701617 x.out
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
check 4701617 $TESTSRC/A2N_4701617.expected x.out
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
# for win32 only ensure when output file pre-exists that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
# native2ascii tool will simply overwrite with the expected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
# output file (fixed bugID 4710890)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
if [ OS = Windows ]; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
   rm -f x.*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
   cp $TESTSRC/test3 x.in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
   chmod a+x x.in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
   ls -l x.in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
   touch x.out
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
   $N2A -encoding ISO-8859-1 x.in x.out
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
   check 4710890 $TESTSRC/test3 x.out
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
rm -rf x.*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
$N2A -reverse $TESTSRC/A2N_6247817 x.out
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
check 4701617 $TESTSRC/A2N_6247817 x.out
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129