langtools/test/tools/javac/javazip/Test.sh
author ohair
Wed, 06 Apr 2011 20:33:44 -0700
changeset 9087 e9e44877cd18
parent 8222 28db72eee100
child 10814 7a74d080c7bf
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:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
#! /bin/sh -f
06bc494ca11e Initial load
duke
parents:
diff changeset
     2
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
#
9087
e9e44877cd18 7033660: Update copyright year to 2011 on any files changed in 2011
ohair
parents: 8222
diff changeset
     4
# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
#
06bc494ca11e Initial load
duke
parents:
diff changeset
     7
# This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
# under the terms of the GNU General Public License version 2 only, as
06bc494ca11e Initial load
duke
parents:
diff changeset
     9
# published by the Free Software Foundation.
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
#
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
# This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
# version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
# accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
#
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
# You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
# 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
#
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 3890
diff changeset
    21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 3890
diff changeset
    22
# or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 3890
diff changeset
    23
# questions.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
#
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
# @test
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
# @bug 4098712 6304984 6388453
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
# @summary check that source files inside zip files on the class path are ignored
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
# @run shell Test.sh
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
TS=${TESTSRC-.}
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
TC=${TESTCLASSES-.}
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
SCR=`pwd`
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
if [ "${TESTJAVA}" = "" ]
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
then
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
  echo "TESTJAVA not set.  Test cannot execute.  Failed."
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
  exit 1
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
fi
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
# set platform-dependent variables
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
OS=`uname -s`
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
case "$OS" in
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
  SunOS | Linux )
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
    FS="/"
3772
b55aba011888 6877188: some javac shell tests do not work on Windows
jjg
parents: 10
diff changeset
    46
    SCR=`pwd`
b55aba011888 6877188: some javac shell tests do not work on Windows
jjg
parents: 10
diff changeset
    47
    ;;
b55aba011888 6877188: some javac shell tests do not work on Windows
jjg
parents: 10
diff changeset
    48
  CYGWIN* )
b55aba011888 6877188: some javac shell tests do not work on Windows
jjg
parents: 10
diff changeset
    49
    FS="/"
b55aba011888 6877188: some javac shell tests do not work on Windows
jjg
parents: 10
diff changeset
    50
    SCR=`pwd | cygpath -d`
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
    ;;
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
  Windows* )
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
    FS="\\"
3772
b55aba011888 6877188: some javac shell tests do not work on Windows
jjg
parents: 10
diff changeset
    54
    SCR=`pwd`
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
    ;;
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
  * )
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
    echo "Unrecognized system!"
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
    exit 1;
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
    ;;
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
esac
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
check() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
    expected=$1
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
    shift
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
    # clean old classes
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
    rm -f ${TC}${FS}*.class 
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
8222
28db72eee100 6581775: Fix the white space problem in javac shell tests
jjg
parents: 5520
diff changeset
    69
    echo "$@"
28db72eee100 6581775: Fix the white space problem in javac shell tests
jjg
parents: 5520
diff changeset
    70
    if "$@" 2>&1 ; then
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
      actual=ok
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
    else
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
      actual=err
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
    fi
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
    if [ "$actual" != "$expected" ]; then
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
      case "$actual" in
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
        ok  ) echo "error: unexpected result: command succeeded" ;;
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
        err ) echo "error: unexpected result: command failed"
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
      esac
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
      exit 1
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
    else 
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
      case "$actual" in
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
        ok  ) echo "command succeeded as expected" ;;
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
        err ) echo "command failed as expected."
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
      esac
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
    fi
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
    echo 
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
}
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
echo "# create zip/jar files with source code"
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
check ok   "${TESTJAVA}${FS}bin${FS}jar" cf "${SCR}${FS}good.jar" -C "${TESTSRC}${FS}good" B.java
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
check ok   "${TESTJAVA}${FS}bin${FS}jar" cf "${SCR}${FS}good.zip" -C "${TESTSRC}${FS}good" B.java
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
check ok   "${TESTJAVA}${FS}bin${FS}jar" cf "${SCR}${FS}bad.jar"  -C "${TESTSRC}${FS}bad" B.java
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
check ok   "${TESTJAVA}${FS}bin${FS}jar" cf "${SCR}${FS}bad.zip"  -C "${TESTSRC}${FS}bad" B.java
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
echo "# control tests, with no paths"
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
check ok   "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} "${TESTSRC}${FS}A.java" "${TESTSRC}${FS}good${FS}B.java"
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
check err  "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} "${TESTSRC}${FS}A.java" "${TESTSRC}${FS}bad${FS}B.java"
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
echo "# test that source files are found in directories on path"
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
check ok   "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -classpath "${TESTSRC}${FS}good"   "${TESTSRC}${FS}A.java"
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
check ok   "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -sourcepath "${TESTSRC}${FS}good"  "${TESTSRC}${FS}A.java"
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
check err  "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -classpath "${TESTSRC}${FS}bad"    "${TESTSRC}${FS}A.java"
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
check err  "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -sourcepath "${TESTSRC}${FS}bad"   "${TESTSRC}${FS}A.java"
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
echo "# test that source files are found in zip/jar files on path"
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
check ok   "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -classpath "${SCR}${FS}good.zip"   "${TESTSRC}${FS}A.java"
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
check ok   "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -classpath "${SCR}${FS}good.jar"   "${TESTSRC}${FS}A.java"
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
check err  "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -sourcepath "${SCR}${FS}bad.zip"   "${TESTSRC}${FS}A.java"  
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
check err  "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -sourcepath "${SCR}${FS}bad.jar"   "${TESTSRC}${FS}A.java"