jdk/test/sun/tools/native2ascii/Native2AsciiTests.sh
author ohair
Tue, 25 May 2010 15:58:33 -0700
changeset 5506 202f599c92aa
parent 4663 dfea6ffdb0dc
child 8560 f2abd715d39b
permissions -rw-r--r--
6943119: Rebrand source copyright notices Reviewed-by: darcy, weijun
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
#
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4663
diff changeset
     4
# Copyright (c) 2002, 2005, 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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
# @bug 4630463 4630971 4636448 4701617 4721296 4710890 6247817
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
# for win32 only ensure when output file pre-exists that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
# native2ascii tool will simply overwrite with the expected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
# output file (fixed bugID 4710890)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
if [ OS = Windows ]; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
   rm -f x.*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
   cp $TESTSRC/test3 x.in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
   chmod a+x x.in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
   ls -l x.in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
   touch x.out
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
   $N2A -encoding ISO-8859-1 x.in x.out
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
   check 4710890 $TESTSRC/test3 x.out
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
rm -rf x.*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
$N2A -reverse $TESTSRC/A2N_6247817 x.out
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
check 4701617 $TESTSRC/A2N_6247817 x.out
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120