langtools/test/tools/javac/versionOpt.sh
changeset 1412 2bb3fe3e00ea
parent 1411 e97ccaa63428
parent 1266 c2036bf76829
child 1413 3f87ec077ba3
equal deleted inserted replaced
1411:e97ccaa63428 1412:2bb3fe3e00ea
     1 #!/bin/sh
       
     2 
       
     3 #
       
     4 # Copyright 2005 Sun Microsystems, Inc.  All Rights Reserved.
       
     5 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     6 #
       
     7 # This code is free software; you can redistribute it and/or modify it
       
     8 # under the terms of the GNU General Public License version 2 only, as
       
     9 # published by the Free Software Foundation.
       
    10 #
       
    11 # This code is distributed in the hope that it will be useful, but WITHOUT
       
    12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    13 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    14 # version 2 for more details (a copy is included in the LICENSE file that
       
    15 # accompanied this code).
       
    16 #
       
    17 # You should have received a copy of the GNU General Public License version
       
    18 # 2 along with this work; if not, write to the Free Software Foundation,
       
    19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    20 #
       
    21 # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
       
    22 # CA 95054 USA or visit www.sun.com if you need additional information or
       
    23 # have any questions.
       
    24 #
       
    25 
       
    26 
       
    27 # @test
       
    28 # @bug 4461214 6227587
       
    29 # @summary support-version and -fullversion
       
    30 # @run shell versionOpt.sh
       
    31 
       
    32 if [ "${TESTJAVA}" = "" ]
       
    33 then
       
    34   echo "TESTJAVA not set.  Test cannot execute.  Failed."
       
    35   exit 1
       
    36 fi
       
    37 echo "TESTJAVA=${TESTJAVA}"
       
    38 
       
    39 # set platform-dependent variables
       
    40 OS=`uname -s`
       
    41 case "$OS" in
       
    42   SunOS | Linux )
       
    43     NULL=/dev/null
       
    44     PS=":"
       
    45     FS="/"
       
    46     ;;
       
    47   Windows* )
       
    48     NULL=NUL
       
    49     PS=";"
       
    50     FS="\\"
       
    51     ;;
       
    52   * )
       
    53     echo "Unrecognized system!"
       
    54     exit 1;
       
    55     ;;
       
    56 esac
       
    57 
       
    58 # create reference files based on java values
       
    59 "${TESTJAVA}${FS}bin${FS}java" ${TESTVMOPTS} -version 2>&1 | \
       
    60     sed -e 's/java version "\([^"]*\)"/javac \1/' -e '2,$d' > version.ref.out
       
    61 
       
    62 "${TESTJAVA}${FS}bin${FS}java" ${TESTVMOPTS} -fullversion 2>&1 | \
       
    63     sed -e 's/java full version/javac full version/' -e '2,$d' > fullversion.ref.out
       
    64 
       
    65 # run javac
       
    66 "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -version 2> version.out
       
    67 cat version.out
       
    68 diff -c version.ref.out version.out
       
    69 version_result=$?
       
    70 
       
    71 "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -fullversion 2> fullversion.out
       
    72 cat fullversion.out
       
    73 diff -c fullversion.ref.out fullversion.out
       
    74 fullversion_result=$?
       
    75 
       
    76 if [ $version_result -eq 0 -a $fullversion_result -eq 0 ]
       
    77 then
       
    78   echo "Passed"
       
    79   exit 0
       
    80 else
       
    81   echo "Failed"
       
    82   exit 1
       
    83 fi
       
    84 
       
    85 
       
    86 
       
    87