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