1 | #!/bin/sh
|
---|
2 |
|
---|
3 | #
|
---|
4 | # Copyright (c) 2007, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
---|
22 | # or visit www.oracle.com if you need additional information or have any
|
---|
23 | # questions.
|
---|
24 | #
|
---|
25 |
|
---|
26 |
|
---|
27 | # @test
|
---|
28 | # @bug 6545058
|
---|
29 | # @summary test -version and -fullversion and compare with -J option
|
---|
30 | # @run shell versionOpt.sh
|
---|
31 |
|
---|
32 | if [ "${TESTJAVA}" = "" ]; then
|
---|
33 | echo "TESTJAVA not set. Test cannot execute. Failed."
|
---|
34 | exit 1
|
---|
35 | fi
|
---|
36 | echo "TESTJAVA=${TESTJAVA}"
|
---|
37 |
|
---|
38 | # set platform-dependent variables
|
---|
39 | OS=`uname -s`
|
---|
40 | case "$OS" in
|
---|
41 | SunOS | Linux )
|
---|
42 | NULL=/dev/null
|
---|
43 | PS=":"
|
---|
44 | FS="/"
|
---|
45 | ;;
|
---|
46 | Windows*|CYGWIN* )
|
---|
47 | NULL=NUL
|
---|
48 | PS=";"
|
---|
49 | FS="\\"
|
---|
50 | ;;
|
---|
51 | * )
|
---|
52 | echo "Unrecognized system!"
|
---|
53 | exit 1;
|
---|
54 | ;;
|
---|
55 | esac
|
---|
56 |
|
---|
57 | # create reference files based on java values
|
---|
58 | ${TESTJAVA}${FS}bin${FS}java -version 2>&1 | \
|
---|
59 | grep -v HotSpot > version.ref.out
|
---|
60 |
|
---|
61 | ${TESTJAVA}${FS}bin${FS}java -fullversion > fullversion.ref.out 2>&1
|
---|
62 |
|
---|
63 |
|
---|
64 | # A list of all the known (common to Unix and Windows) programs in the bin
|
---|
65 | # directory, which accept -J argument and outputs the version strings to stderr.
|
---|
66 | PLIST="\
|
---|
67 | appletviewer \
|
---|
68 | apt \
|
---|
69 | extcheck \
|
---|
70 | idlj \
|
---|
71 | jar \
|
---|
72 | jarsigner \
|
---|
73 | javac \
|
---|
74 | javadoc \
|
---|
75 | javah \
|
---|
76 | javap \
|
---|
77 | jconsole \
|
---|
78 | jdb \
|
---|
79 | jhat \
|
---|
80 | jinfo \
|
---|
81 | jmap \
|
---|
82 | jps \
|
---|
83 | jstack \
|
---|
84 | jstat \
|
---|
85 | jstatd \
|
---|
86 | keytool \
|
---|
87 | native2ascii \
|
---|
88 | orbd \
|
---|
89 | pack200 \
|
---|
90 | policytool \
|
---|
91 | rmic \
|
---|
92 | rmid \
|
---|
93 | rmiregistry \
|
---|
94 | schemagen \
|
---|
95 | serialver \
|
---|
96 | servertool \
|
---|
97 | tnameserv \
|
---|
98 | wsgen \
|
---|
99 | wsimport \
|
---|
100 | xjc"
|
---|
101 |
|
---|
102 |
|
---|
103 | for prog in $PLIST; do
|
---|
104 | versionOut="$prog.version.out"
|
---|
105 | fversionOut="$prog.full.version.out"
|
---|
106 |
|
---|
107 | ${TESTJAVA}${FS}bin${FS}${prog} -J-version 2>&1 | \
|
---|
108 | grep -v HotSpot > $versionOut
|
---|
109 |
|
---|
110 | cat $versionOut
|
---|
111 | diff -c version.ref.out $versionOut
|
---|
112 | version_result=$?
|
---|
113 |
|
---|
114 | ${TESTJAVA}${FS}bin${FS}${prog} -J-fullversion > $fversionOut 2>&1
|
---|
115 |
|
---|
116 | cat $fversionOut
|
---|
117 | diff -c fullversion.ref.out $fversionOut
|
---|
118 | fullversion_result=$?
|
---|
119 |
|
---|
120 | if [ $version_result -eq 0 -a $fullversion_result -eq 0 ]; then
|
---|
121 | printf "%s:Pass\n" $prog
|
---|
122 | else
|
---|
123 | printf "%s:Fail\n" $prog
|
---|
124 | exit 1
|
---|
125 | fi
|
---|
126 | done
|
---|
127 | exit 0
|
---|