jdk/test/tools/launcher/Arrrghs.sh
changeset 2 90ce3da70b43
child 399 bcc2354430ff
equal deleted inserted replaced
0:fd16c54261b3 2:90ce3da70b43
       
     1 #!/bin/sh
       
     2 # @test Arrrghs.sh
       
     3 # @bug 5030233 6214916 6356475 6571029
       
     4 # @build Arrrghs
       
     5 # @run shell Arrrghs.sh
       
     6 # @summary Argument parsing validation.
       
     7 # @author Joseph E. Kowalski
       
     8 
       
     9 #
       
    10 # Copyright 2004-2007 Sun Microsystems, Inc.  All Rights Reserved.
       
    11 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
    12 #
       
    13 # This code is free software; you can redistribute it and/or modify it
       
    14 # under the terms of the GNU General Public License version 2 only, as
       
    15 # published by the Free Software Foundation.
       
    16 #
       
    17 # This code is distributed in the hope that it will be useful, but WITHOUT
       
    18 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    19 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    20 # version 2 for more details (a copy is included in the LICENSE file that
       
    21 # accompanied this code).
       
    22 #
       
    23 # You should have received a copy of the GNU General Public License version
       
    24 # 2 along with this work; if not, write to the Free Software Foundation,
       
    25 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    26 #
       
    27 # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
       
    28 # CA 95054 USA or visit www.sun.com if you need additional information or
       
    29 # have any questions.
       
    30 #
       
    31 
       
    32 #
       
    33 # This test is intended to validate generic argument parsing and
       
    34 # handling.
       
    35 #
       
    36 # Oh yes, since the response to argument parsing errors is often
       
    37 # a visceral one, the name Arrrghs (pronounced "args") seems rather
       
    38 # appropriate.
       
    39 #
       
    40 
       
    41 # Verify directory context variables are set
       
    42 if [ "${TESTJAVA}" = "" ]
       
    43 then
       
    44   echo "TESTJAVA not set.  Test cannot execute.  Failed."
       
    45   exit 1
       
    46 fi
       
    47 
       
    48 if [ "${TESTSRC}" = "" ]
       
    49 then
       
    50   echo "TESTSRC not set.  Test cannot execute.  Failed."
       
    51   exit 1
       
    52 fi
       
    53 
       
    54 if [ "${TESTCLASSES}" = "" ]
       
    55 then
       
    56   echo "TESTCLASSES not set.  Test cannot execute.  Failed."
       
    57   exit 1
       
    58 fi
       
    59 
       
    60 #
       
    61 # Shell routine to test for the proper handling of the cp/classpath 
       
    62 # option is correct (see 5030233).  This option is unique in that it
       
    63 # is the only option to the java command (and friends) which is
       
    64 # separated from its option argument by a space, rather than an
       
    65 # equals sign.
       
    66 #
       
    67 # Parameters:
       
    68 #	$1	cmd	utility name to be tested (java, javac, ...)
       
    69 #	$2	option	either the -cp or -classpath option to be
       
    70 #			tested.
       
    71 #
       
    72 TestCP() {
       
    73 	mess="`$TESTJAVA/bin/$1 $2 2>&1 1>/dev/null`"
       
    74 	if [ $? -eq 0 ]; then
       
    75 		echo "Invalid $1 $2 syntax accepted"
       
    76 		exit 1
       
    77 	fi
       
    78 	if [ -z "$mess" ]; then
       
    79 		echo "No Usage message from invalid $1 $2 syntax"
       
    80 		exit 1
       
    81 	fi
       
    82 }
       
    83 
       
    84 #
       
    85 # Test for 6356475 "REGRESSION:"java -X" from cmdline fails"
       
    86 #
       
    87 TestXUsage() {
       
    88 	$TESTJAVA/bin/java -X > /dev/null 2>&1
       
    89 	if [ $? -ne 0 ]; then
       
    90 		echo "-X option failed"
       
    91 		exit 1
       
    92 	fi
       
    93 }
       
    94 
       
    95 #
       
    96 # Test if java -help works
       
    97 #
       
    98 TestHelp() {
       
    99 	$TESTJAVA/bin/java -help > /dev/null 2>&1
       
   100 	if [ $? -ne 0 ]; then
       
   101 		echo "-help option failed"
       
   102 		exit 1
       
   103 	fi
       
   104 }
       
   105 
       
   106 #
       
   107 # Main processing:
       
   108 #
       
   109 
       
   110 #
       
   111 # Tests for 5030233
       
   112 #
       
   113 TestCP java -cp
       
   114 TestCP java -classpath
       
   115 TestCP java -jar
       
   116 TestCP javac -cp
       
   117 TestCP javac -classpath
       
   118 TestXUsage
       
   119 TestHelp
       
   120 
       
   121 #
       
   122 # Tests for 6214916
       
   123 #
       
   124 #
       
   125 # These tests require that a JVM (any JVM) be installed in the system registry.
       
   126 # If none is installed, skip this test.
       
   127 $TESTJAVA/bin/java -version:1.1+ -version >/dev/null 2>&1
       
   128 if [ $? -eq 0 ]; then
       
   129    $TESTJAVA/bin/java -classpath $TESTCLASSES Arrrghs $TESTJAVA/bin/java
       
   130    if [ $? -ne 0 ]; then
       
   131       echo "Argument Passing Tests failed"
       
   132       exit 1
       
   133    fi
       
   134 else
       
   135    printf "Warning:Argument Passing Tests were skipped, no java found in system registry."
       
   136 fi
       
   137 exit 0