jdk/test/tools/launcher/MultipleJRE.sh
author kvn
Thu, 21 Feb 2008 14:03:41 -0800
changeset 199 fb51d01039ff
parent 2 90ce3da70b43
child 2598 6f980e1d6e31
permissions -rw-r--r--
6621084: ciMethodBlocks::split_block_at() is broken for methods with exception handler Summary: After an exception handler block is split the exception information is not moved to the new block which starts in exception handler BCI. Reviewed-by: jrose
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
# @test MultipleJRE.sh
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
# @bug 4811102 4953711 4955505 4956301 4991229 4998210 5018605 6387069
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
# @build PrintVersion
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
# @build UglyPrintVersion
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
# @run shell MultipleJRE.sh
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
# @summary Verify Multiple JRE version support
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
# @author Joseph E. Kowalski
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
# Copyright 2003-2007 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
# This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
# under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
# published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
# This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
# version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
# accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
# You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
# 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
# CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
# have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
# Verify directory context variables are set
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
if [ "${TESTJAVA}" = "" ]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
then
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
  echo "TESTJAVA not set.  Test cannot execute.  Failed."
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
  exit 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
if [ "${TESTSRC}" = "" ]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
then
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
  echo "TESTSRC not set.  Test cannot execute.  Failed."
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
  exit 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
if [ "${TESTCLASSES}" = "" ]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
then
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
  exit 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
JAVA="$TESTJAVA/bin/java -classpath $TESTCLASSES"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
JAR="$TESTJAVA/bin/jar"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
OS=`uname -s`;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
# Shell routine to test for the proper rejection of syntactically incorrect
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
# version specifications.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
TestSyntax() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
	mess="`$JAVA -version:\"$1\" -version 2>&1`"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
	if [ $? -eq 0 ]; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
		echo "Invalid version syntax $1 accepted"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
		exit 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
	fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
	prefix="`echo "$mess" | cut -d ' ' -f 1-3`"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
	if [ "$prefix" != "Error: Syntax error" ]; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
		echo "Unexpected error message for invalid syntax $1"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
		exit 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
	fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
# Just as the name says.  We sprinkle these in the appropriate location
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
# in the test file system and they just say who they are pretending to be.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
CreateMockVM() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
	mkdir -p jdk/j2re$1/bin
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
	echo "#!/bin/sh"    > jdk/j2re$1/bin/java
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
	echo "echo \"$1\"" >> jdk/j2re$1/bin/java
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
	chmod +x jdk/j2re$1/bin/java
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
# Constructs the jar file needed by these tests.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
CreateJar() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
	mkdir -p META-INF
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
	echo "Manifest-Version: 1.0" > META-INF/MANIFEST.MF
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
	echo "Main-Class: PrintVersion" >> META-INF/MANIFEST.MF
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
	if [ "$1" != "" ]; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
		echo "JRE-Version: $1" >> META-INF/MANIFEST.MF
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
	fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
	cp $TESTCLASSES/PrintVersion.class .
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
	$JAR $2cmf META-INF/MANIFEST.MF PrintVersion PrintVersion.class
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
# Constructs a jar file using zip.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
CreateZippyJar() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
	mkdir -p META-INF
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
	echo "Manifest-Version: 1.0" > META-INF/MANIFEST.MF
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
	echo "Main-Class: PrintVersion" >> META-INF/MANIFEST.MF
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
	if [ "$1" != "" ]; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
		echo "JRE-Version: $1" >> META-INF/MANIFEST.MF
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
	fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
	cp $TESTCLASSES/PrintVersion.class .
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
	/usr/bin/zip $2 PrintVersion META-INF/MANIFEST.MF PrintVersion.class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
# Constructs a jar file with a Main-Class attribute of greater than
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
# 80 characters to validate the continuation line processing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
# Make this just long enough to require two continuation lines.  Longer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
# paths take too much away from the restricted Windows maximum path length.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
# Note: see the variable UGLYCLASS and its check for path length.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
# Make sure that 5018605 remains fixed by including additional sections
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
# in the Manifest which contain the same names as those allowed in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
# main section.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
PACKAGE=reallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallyreallylongpackagename
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
UGLYCLASS=$TESTCLASSES/$PACKAGE/UglyPrintVersion.class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
CreateUglyJar() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
	mkdir -p META-INF
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
	echo "Manifest-Version: 1.0" > META-INF/MANIFEST.MF
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
	echo "Main-Class: $PACKAGE.UglyPrintVersion" >> META-INF/MANIFEST.MF
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
	if [ "$1" != "" ]; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
		echo "JRE-Version: $1" >> META-INF/MANIFEST.MF
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
	fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
	echo "" >> META-INF/MANIFEST.MF
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
	echo "Name: NotToBeFound.class" >> META-INF/MANIFEST.MF
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
	echo "Main-Class: NotToBeFound" >> META-INF/MANIFEST.MF
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
	mkdir -p $PACKAGE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
	cp $UGLYCLASS $PACKAGE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
	$JAR $2cmf META-INF/MANIFEST.MF PrintVersion \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
	    $PACKAGE/UglyPrintVersion.class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
# Constructs a jar file with a fair number of "zip directory" entries and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
# the MANIFEST.MF entry at or near the end of that directory to validate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
# the ability to transverse that directory.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
CreateFullJar() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
	mkdir -p META-INF
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
	echo "Manifest-Version: 1.0" > META-INF/MANIFEST.MF
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
	echo "Main-Class: PrintVersion" >> META-INF/MANIFEST.MF
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
	if [ "$1" != "" ]; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
	    echo "JRE-Version: $1" >> META-INF/MANIFEST.MF
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
	fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
	cp $TESTCLASSES/PrintVersion.class .
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
	for i in 0 1 2 3 4 5 6 7 8 9 ; do
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
		for j in 0 1 2 3 4 5 6 7 8 9 ; do
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
			touch AfairlyLongNameEatsUpDirectorySpaceBetter$i$j
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
		done
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
	done
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
	$JAR $2cMf PrintVersion PrintVersion.class AfairlyLong*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
	$JAR $2umf META-INF/MANIFEST.MF PrintVersion
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
	rm -f AfairlyLong*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
# Creates a jar file with the attributes which caused the failure
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
# described in 4991229.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
# Generate a bunch of CENTAB entries, each of which is 64 bytes long
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
# which practically guarentees we will hit the appropriate power of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
# two buffer (initially 1K).  Note that due to the perversity of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
# zip/jar files, the first entry gets extra stuff so it needs a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
# shorter name to compensate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
CreateAlignedJar() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
	mkdir -p META-INF
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
	echo "Manifest-Version: 1.0" > META-INF/MANIFEST.MF
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
	echo "Main-Class: PrintVersion" >> META-INF/MANIFEST.MF
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
	if [ "$1" != "" ]; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
	    echo "JRE-Version: $1" >> META-INF/MANIFEST.MF
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
	fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
	cp $TESTCLASSES/PrintVersion.class .
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
	touch 57BytesSpecial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
	for i in 0 1 2 3 4 5 6 7 8 9 ; do
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
		for j in 0 1 2 3 4 5 6 7 8 9 ; do
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
			touch 64BytesPerEntry-$i$j
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
		done
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
	done
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
	$JAR $2cMf PrintVersion 57* 64* PrintVersion.class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
	$JAR $2umf META-INF/MANIFEST.MF PrintVersion
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
	rm -f 57* 64*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
# Adds comments to a jar/zip file.  This serves two purposes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
#   1)	Make sure zip file comments (both per file and per archive) are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
#	properly processed and ignored.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
#   2)	A long file comment creates a mondo "Central Directory" entry in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
#	the zip file. Such a "mondo" entry could also be due to a very
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
#	long file name (path) or a long "Ext" entry, but adding the long
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
#	comment is the easiest way.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
CommentZipFile() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    file=
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    tail="is designed to take up space - lots and lots of space."
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    mv PrintVersion PrintVersion.zip
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    /usr/bin/zipnote PrintVersion.zip > zipout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    while read ampersand line; do
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
	if [ "$ampersand" = "@" ]; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
	    if [ "$line" = "(comment above this line)" ]; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
		echo "File Comment Line." >> zipin
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
		if [ "$file" = "$1" ]; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
		    for i in 0 1 2 3 4 5 6 7 8 9 a b c d e f; do
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
			for j in 0 1 2 3 4 5 6 7 8 9 a b c d e f; do
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
			    echo "Mondo comment line $i$j $tail" >> zipin
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
			done
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
		    done
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
		fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
	    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
		file=$line
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
	    fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
	fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
	echo "$ampersand $line" >> zipin
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
	if [ "$ampersand" = "@" ]; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
	    if [ "$line" = "(zip file comment below this line)" ]; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
		echo "Zip File Comment Line number 1" >> zipin
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
		echo "Zip File Comment Line number 2" >> zipin
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
	    fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
	fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    done < zipout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    /usr/bin/zipnote -w PrintVersion.zip < zipin
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    mv PrintVersion.zip PrintVersion
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    rm zipout zipin
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
# Attempt to launch a vm using a version specifier and make sure the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
# resultant launch (probably a "mock vm") is appropriate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
LaunchVM() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
	if [ "$1" != "" ]; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
		mess="`$JAVA -version:\"$1\" -jar PrintVersion 2>&1`"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
	else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
		mess="`$JAVA -jar PrintVersion 2>&1`"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
	fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
	if [ $? -ne 0 ]; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
		prefix=`echo "$mess" | cut -d ' ' -f 1-3`
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
		if [ "$prefix" != "Unable to locate" ]; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
			echo "$mess"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
			exit 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
		fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
		echo "Unexpected error in attempting to locate $1"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
		exit 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
	fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
	echo $mess | grep "$2" > /dev/null 2>&1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
	if [ $? != 0 ]; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
	    echo "Launched $mess, expected $2"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
	    exit 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
	fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
# Main test sequence starts here
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
RELEASE=`$JAVA -version 2>&1 | head -n 1 | cut -d ' ' -f 3 | \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
  sed -e "s/\"//g"`
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
BASE_RELEASE=`echo $RELEASE | sed -e "s/-.*//g"`
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
# Make sure that the generic jar/manifest reading code works. Test both
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
# compressed and "stored" jar files.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
# The "Ugly" jar (long manifest line) tests are only run if the combination
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
# of the file name length restrictions and the length of the cwd allow it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
CreateJar "" ""
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
LaunchVM "" "${RELEASE}"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
CreateJar "" "0"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
LaunchVM "" "${RELEASE}"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
case "$OS" in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
	Windows* | CYGWIN* )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
		MAXIMUM_PATH=255;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
	;;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
	*)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
		MAXIMUM_PATH=1024;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
	;;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
esac
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
PATH_LENGTH=`printf "%s" "$UGLYCLASS" | wc -c`
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
if [ ${PATH_LENGTH} -lt ${MAXIMUM_PATH} ]; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
	CreateUglyJar "" ""
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
	LaunchVM "" "${RELEASE}"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
	CreateUglyJar "" "0"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
	LaunchVM "" "${RELEASE}"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    printf "Warning: Skipped UglyJar test, path length exceeded, %d" $MAXIMUM_PATH
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    printf " allowed, the current path is %d\n" $PATH_LENGTH
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
CreateAlignedJar "" ""
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
LaunchVM "" "${RELEASE}"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
CreateFullJar "" ""
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
LaunchVM "" "${RELEASE}"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
# 4998210 shows that some very strange behaviors are semi-supported.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
# In this case, it's the ability to prepend any kind of stuff to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
# jar file and require that the jar file still work.  Note that this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
# "interface" isn't publically supported and we may choose to break
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
# it in the future, but this test guarantees that we won't break it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
# without informed consent. We take advantage the fact that the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
# "FullJar" we just tested is probably the best jar to begin with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
# for this test.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
echo "This is just meaningless bytes to prepend to the jar" > meaningless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
mv PrintVersion meaningfull
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
cat meaningless meaningfull > PrintVersion
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
LaunchVM "" "${RELEASE}" 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
rm meaningless meaningfull
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
# Officially, one must use "the jar command to create a jar file.  However,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
# all the comments about jar commands **imply** that jar files and zip files
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
# are equivalent.  (Note: this isn't true due to the "0xcafe" insertion.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
# On systems which have a command line zip, test the ability to use zip
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
# to construct a jar and then use it (6387069).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
if [ -x /usr/bin/zip ]; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
	CreateZippyJar "" "-q"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
	LaunchVM "" "${RELEASE}"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
# jar files shouldn't have comments, but it is possible that somebody added
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
# one by using zip -c, zip -z, zipnote or a similar utility.  On systems
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
# that have "zipnote", verify this functionality.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
# This serves a dual purpose of creating a very large "central directory
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
# entry" which validates to code to read such entries.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
if [ -x /usr/bin/zipnote ]; then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
	CreateFullJar "" ""
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
	CommentZipFile "AfairlyLongNameEatsUpDirectorySpaceBetter20"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
	LaunchVM "" "${RELEASE}"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
# Throw some syntactically challenged (illegal) version specifiers at
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
# the interface.  Failure (of the launcher) is success for the test.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
TestSyntax "1.2..3"				# Two adjacent separators
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
TestSyntax "_1.2.3"				# Begins with a separator
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
TestSyntax "1.2.3-"				# Ends with a separator
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
TestSyntax "1.2+.3"				# Embedded modifier
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
TestSyntax "1.2.4+&1.2*&1++"			# Long and invalid
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
# Because scribbling in the registry can be rather destructive, only a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
# subset of the tests are run on Windows.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
case "$OS" in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
	Windows* | CYGWIN* )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
		exit 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
	;;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
esac
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
# Additional version specifiers containing spaces.  (Sigh, unable to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
# figure out the glomming on Windows)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
TestSyntax "1.2.3_99 1.3.2+ 1.2.4+&1.2*&1++"	# Long and invalid
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
# Create a mock installation of a number of shell scripts named as though
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
# they were installed JREs.  Then test to see if the launcher can cause
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
# the right shell scripts to be invoked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
# Note, that as a side effect, this test verifies that JAVA_VERSION_PATH
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
# works.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
rm -rf jdk
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
JAVA_VERSION_PATH="`pwd`/jdk"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
export JAVA_VERSION_PATH
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
CreateMockVM 1.10
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
CreateMockVM 1.11.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
CreateMockVM 1.11.3_03
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
CreateMockVM 1.11.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
CreateMockVM 1.12.3_03
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
CreateMockVM 1.12.3_03-lastweek
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
CreateMockVM 1.13.3_03
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
CreateMockVM 1.13.3_03-lastweek
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
CreateMockVM 1.13.3_03_lastweek
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
CreateMockVM 1.20.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
# Test extracting the version information from the jar file:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
#	  Requested		Expected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
CreateJar "1.10+" ""
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
LaunchVM  ""			"1.20.0"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
CreateJar "1.11.3_03+&1.11*" ""
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
LaunchVM  ""			"1.11.4"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
CreateJar "1.12.3_03+&1.12.3*" ""
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
LaunchVM  ""			"1.12.3_03"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
CreateJar "1.13.3_03+&1.13.3*" ""
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
LaunchVM  ""			"1.13.3_03_lastweek"	# Strange but true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
# Test obtaining the version information from the command line (and that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
# it overrides the manifest).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
CreateJar "${BASERELEASE}*" ""
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
LaunchVM  "1.10+"		"1.20.0"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
LaunchVM  "1.11.3_03+&1.11*"	"1.11.4"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
LaunchVM  "1.12.3_03+&1.12.3*"	"1.12.3_03"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
LaunchVM  "1.13.3_03+&1.13.3*"	"1.13.3_03_lastweek"	# Strange but true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
[ -d jdk ] && rm -rf jdk
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
[ -d META_INF ] && rm -rf META_INF
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
exit 0