1 # 2 # Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 # 5 # This code is free software; you can redistribute it and/or modify it 6 # under the terms of the GNU General Public License version 2 only, as 7 # published by the Free Software Foundation. 8 # 9 # This code is distributed in the hope that it will be useful, but WITHOUT 10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 # version 2 for more details (a copy is included in the LICENSE file that 13 # accompanied this code). 14 # 15 # You should have received a copy of the GNU General Public License version 16 # 2 along with this work; if not, write to the Free Software Foundation, 17 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 # 19 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 # or visit www.oracle.com if you need additional information or have any 21 # questions. 22 # 23 24 # @test 25 # @bug 4990825 26 # @run shell/timeout=90 jstatdExternalRegistry.sh 27 # @summary Test functionality of 'jstatd -p<port>&' with an external RMI registry 28 29 . ${TESTSRC-.}/../../jvmstat/testlibrary/utils.sh 30 31 setup 32 verify_os 33 34 cleanup() { 35 kill_proc ${RMIREGISTRY_PID} 36 kill_proc ${JSTATD_PID} 37 } 38 39 trap 'cleanup' 0 HUP INT QUIT TERM 40 41 RMIREGISTRY="${TESTJAVA}/bin/rmiregistry" 42 JSTATD="${TESTJAVA}/bin/jstatd" 43 JPS="${TESTJAVA}/bin/jps" 44 JSTAT="${TESTJAVA}/bin/jstat" 45 46 HOSTNAME=`uname -n` 47 PORT=2099 48 49 RMIREGISTRY_OUT="rmiregistry_$$.out" 50 JSTATD_OUT="jstatd_$$.out" 51 52 ${RMIREGISTRY} ${PORT} > ${RMIREGISTRY_OUT} 2>&1 & 53 RMIREGISTRY_PID=$! 54 55 echo "rmiregistry started on port ${PORT} as pid ${RMIREGISTRY_PID}" 56 sleep 3 57 58 ${JSTATD} -J-Djava.security.policy=${TESTSRC}/all.policy -p ${PORT} > ${JSTATD_OUT} 2>&1 & 59 JSTATD_PID=$! 60 61 echo "jstatd started as pid ${JSTATD_PID}" 62 sleep 3 63 64 ${JPS} ${HOSTNAME}:${PORT} 2>&1 | awk -f ${TESTSRC}/jpsOutput1.awk 65 66 if [ $? -ne 0 ] 67 then 68 echo "Output of jps differs from expected output. Failed." 69 exit 1 70 fi 71 72 # get the process id for the target app (jstatd). note, don't rely 73 # on JSTATD_PID as mks interposes a shell when starting a process in 74 # the background 75 TARGET_PID=`${JPS} | grep "Jstatd" | cut -d" " -f1` 76 77 ${JSTAT} -gcutil ${TARGET_PID}@${HOSTNAME}:${PORT} 250 5 2>&1 | awk -f ${TESTSRC}/jstatGcutilOutput1.awk 78 RC=$? 79 80 if [ ${RC} -ne 0 ] 81 then 82 echo "jstat output differs from expected output" 83 fi 84 85 if [ -s ${JSTATD_OUT} ] 86 then 87 echo "jstatd generated unexpected output: see ${JSTATD_OUT}" 88 RC=1 89 fi 90 91 if [ -s ${RMIREGISTRY_OUT} ] 92 then 93 echo "rmiregistry generated unexpected output: see ${RMIREGISTRY_OUT}" 94 RC=1 95 fi 96 97 exit ${RC}