2
|
1 |
#!/bin/sh
|
|
2 |
|
|
3 |
#
|
|
4 |
# Copyright 2003 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 4673940
|
|
29 |
# @bug 4930794
|
|
30 |
# @summary Unit tests for inetd feature
|
|
31 |
#
|
|
32 |
# @build StateTest StateTestService EchoTest EchoService CloseTest Launcher Util
|
|
33 |
# @run shell run_tests.sh
|
|
34 |
|
|
35 |
os=`uname -s`
|
|
36 |
|
|
37 |
if [ "$os" != "Linux" -a "$os" != "SunOS" ]; then
|
|
38 |
echo "Test not designed to run on this operating system, skipping..."
|
|
39 |
exit 0
|
|
40 |
fi
|
|
41 |
|
|
42 |
|
|
43 |
# if TESTJAVA isn't set then we assume an interactive run. So that it's
|
|
44 |
# clear which version of 'java' is running we do a 'which java' and
|
|
45 |
# a 'java -version'.
|
|
46 |
|
|
47 |
if [ -z "$TESTJAVA" ]; then
|
|
48 |
TESTSRC=`pwd`
|
|
49 |
TESTCLASSES=`pwd`
|
|
50 |
JAVA=java
|
|
51 |
which $JAVA
|
|
52 |
${JAVA} -d64 -version > /dev/null 2<&1
|
|
53 |
if [ $? = 1 ]; then
|
|
54 |
${JAVA} -version
|
|
55 |
else
|
|
56 |
${JAVA} -d64 -version
|
|
57 |
fi
|
|
58 |
else
|
|
59 |
JAVA="${TESTJAVA}/bin/java"
|
|
60 |
fi
|
|
61 |
|
|
62 |
CLASSPATH=${TESTCLASSES}
|
|
63 |
export CLASSPATH
|
|
64 |
|
|
65 |
|
|
66 |
# Check that we have libLauncher.so for the right platform.
|
|
67 |
# On Solaris we assume 64-bit if java -d64 works.
|
|
68 |
|
|
69 |
DFLAG=
|
|
70 |
if [ "$os" = "SunOS" ]; then
|
|
71 |
PLATFORM=solaris
|
|
72 |
case "`uname -p`" in
|
|
73 |
i[3-9]86)
|
|
74 |
ARCH=i586
|
|
75 |
;;
|
|
76 |
sparc)
|
|
77 |
ARCH=sparc
|
|
78 |
${JAVA} -d64 -version > /dev/null 2<&1
|
|
79 |
if [ $? = 1 ]; then
|
|
80 |
ARCH=sparc
|
|
81 |
else
|
|
82 |
ARCH=sparcv9
|
|
83 |
DFLAG=-d64
|
|
84 |
fi
|
|
85 |
;;
|
|
86 |
esac
|
|
87 |
fi
|
|
88 |
|
|
89 |
if [ "$os" = "Linux" ]; then
|
|
90 |
PLATFORM=linux
|
|
91 |
ARCH=unknown
|
|
92 |
case "`uname -m`" in
|
|
93 |
i[3-6]86)
|
|
94 |
ARCH=i586
|
|
95 |
;;
|
|
96 |
ia64)
|
|
97 |
ARCH=ia64
|
|
98 |
;;
|
|
99 |
x86_64)
|
|
100 |
ARCH=amd64
|
|
101 |
;;
|
|
102 |
esac
|
|
103 |
fi
|
|
104 |
|
|
105 |
LIBDIR=lib/${PLATFORM}-${ARCH}
|
|
106 |
LAUNCHERLIB=${LIBDIR}/libLauncher.so
|
|
107 |
echo $LIBDIR
|
|
108 |
|
|
109 |
if [ ! -f "${TESTSRC}/${LAUNCHERLIB}" ]; then
|
|
110 |
echo "Cannot find ${LAUNCHERLIB} - library not available for this system"
|
|
111 |
exit 0
|
|
112 |
fi
|
|
113 |
|
|
114 |
LD_LIBRARY_PATH=${TESTSRC}/${LIBDIR}
|
|
115 |
export LD_LIBRARY_PATH
|
|
116 |
|
|
117 |
failures=0
|
|
118 |
|
|
119 |
go() {
|
|
120 |
echo ''
|
|
121 |
sh -xc "$JAVA $DFLAG $1 $2 $3 $4 $5 $6 $7 $8" 2>&1
|
|
122 |
if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
|
|
123 |
}
|
|
124 |
|
|
125 |
# Run the tests
|
|
126 |
|
|
127 |
go StateTest
|
|
128 |
go EchoTest
|
|
129 |
go CloseTest
|
|
130 |
|
|
131 |
# Re-run StateTest with a SecurityManager set
|
|
132 |
# Note that the system properties are arguments to StateTest and not options.
|
|
133 |
# These system properties are passed to the launched service as options:
|
|
134 |
# java [-options] class [args...]
|
|
135 |
|
|
136 |
go StateTest -Djava.security.manager -Djava.security.policy=${TESTSRC}/java.policy.pass
|
|
137 |
go StateTest -expectFail -Djava.security.manager -Djava.security.policy=${TESTSRC}/java.policy.fail
|
|
138 |
|
|
139 |
|
|
140 |
#
|
|
141 |
# Results
|
|
142 |
#
|
|
143 |
echo ''
|
|
144 |
if [ $failures -gt 0 ];
|
|
145 |
then echo "$failures test(s) failed";
|
|
146 |
else echo "All test(s) passed"; fi
|
|
147 |
exit $failures
|