Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/management/jdp/JdpTest.sh
38841 views
#!/bin/sh -x12# Copyright (c) 2011, 2013, 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 it6# under the terms of the GNU General Public License version 2 only, as7# published by the Free Software Foundation.8#9# This code is distributed in the hope that it will be useful, but WITHOUT10# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12# version 2 for more details (a copy is included in the LICENSE file that13# accompanied this code).14#15# You should have received a copy of the GNU General Public License version16# 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 USA20# or visit www.oracle.com if you need additional information or have any21# questions.2223# @test24# @bug 716988825# @compile -XDignore.symbol.file JdpUnitTest.java JdpClient.java JdpDoSomething.java26# @run shell JdpTest.sh --jtreg --no-compile27# @summary No word Failed expected in the test output2829_verbose=no30_jtreg=no31_compile=yes3233# temporary disable jcmd related tests34# _testsuite="01,02,03,04,05"35_testsuite="01"3637_pwd=`pwd`3839_testclasses=".classes"40_testsrc="${_pwd}"41_lockFileName="JdpDoSomething.lck"4243_logname=".classes/output.txt"44_last_pid=""4546_ip="224.0.23.178"47_port="7095"48_jmxport="4545"4950_do_compile(){51# If the test run without JTReg, we have to compile it by our self52# Under JTReg see @compile statement above53# sun.* packages is not included to symbol file lib/ct.sym so we have54# to ignore it5556if [ ! -d ${_testclasses} ]57then58mkdir -p ${_testclasses}59fi6061rm -f ${_testclasses}/*.class6263# Compile testcase64${COMPILEJAVA}/bin/javac -XDignore.symbol.file -d ${_testclasses} \65JdpUnitTest.java \66JdpDoSomething.java \67JdpClient.java686970if [ ! -f ${_testclasses}/JdpDoSomething.class -o ! -f ${_testclasses}/JdpClient.class -o ! -f ${_testclasses}/JdpUnitTest.class ]71then72echo "ERROR: Can't compile"73exit 25574fi75}767778_app_start(){7980testappname=$181shift8283${TESTJAVA}/bin/java -server $* -cp ${_testclasses} ${testappname} >> ${_logname} 2>&1 &84_last_pid=$!8586# wait until VM is actually starts.87# please note, if vm doesn't start for some reason88# jtreg kills the test by timeout. Don't file a bug.89cnt=190while true91do92npid=`_get_pid`93if [ "${npid}" != "" ]94then95break96fi97if [ "${cnt}" = "10" ]98then99echo "ERROR: Test app not started. Please check machine resources before filing a bug."100if [ "${_jtreg}" = "yes" ]101then102exit 255103fi104break105fi106cnt=`expr $cnt + 1`107sleep 1108done109}110111_get_pid(){112${TESTJAVA}/bin/jps | sed -n "/Jdp/s/ .*//p"113}114115_app_stop(){116rm ${_lockFileName}117118# wait until VM is actually shuts down119while true120do121npid=`_get_pid`122if [ "${npid}" = "" ]123then124break125fi126sleep 1127done128}129130_testme(){131${TESTJAVA}/bin/java \132-cp ${_testclasses} \133$* \134-Dcom.sun.management.jdp.port=${_port} \135-Dcom.sun.management.jdp.address=${_ip} \136JdpClient137}138139140_jcmd(){141${TESTJAVA}/bin/jcmd JdpDoSomething $* > /dev/null 2>/dev/null142}143144145_echo(){146echo "$*"147echo "$*" >> ${_logname}148}149150# ============= TESTS ======================================151152test_01(){153154_echo "**** Test one ****"155156_app_start JdpUnitTest \157-Dcom.sun.management.jdp.port=${_port} \158-Dcom.sun.management.jdp.address=${_ip} \159-Dcom.sun.management.jdp.name=testme \160-Djava.rmi.server.hostname=localhost \161-Dcom.sun.management.jdp.pause=5162163res=`_testme`164165case "${res}" in166OK*)167_echo "Passed"168;;169*)170_echo "Failed!"171;;172esac173174_app_stop175}176177test_02(){178179_echo "**** Test two ****"180181_app_start JdpDoSomething \182-Dcom.sun.management.jdp.port=${_port} \183-Dcom.sun.management.jdp.address=${_ip} \184-Dcom.sun.management.jdp.pause=5 \185-Dcom.sun.management.jdp.name=testme \186-Djava.rmi.server.hostname=localhost \187-Dcom.sun.management.jmxremote.port=${_jmxport} \188-Dcom.sun.management.jmxremote.authenticate=false \189-Dcom.sun.management.jmxremote.ssl=false190191res=`_testme`192193case "${res}" in194OK*)195_echo "Passed"196;;197*)198_echo "Failed!"199;;200esac201202_app_stop203}204205test_03(){206207_echo "**** Test three ****"208209_app_start JdpDoSomething210211_jcmd ManagementAgent.start\212jdp.port=${_port} \213jdp.address=${_ip} \214jdp.pause=5 \215jdp.name=jcmdtest \216jmxremote.port=${_jmxport} \217jmxremote.authenticate=false \218jmxremote.ssl=false219220res=`_testme`221222case "${res}" in223OK*)224_echo "Passed"225;;226*)227_echo "Failed!"228;;229esac230231_app_stop232}233234test_04(){235236_echo "**** Test four ****"237238_app_start JdpDoSomething \239-Dcom.sun.management.jmxremote.autodiscovery=true \240-Dcom.sun.management.jdp.name=testme \241-Djava.rmi.server.hostname=localhost \242-Dcom.sun.management.jmxremote.port=${_jmxport} \243-Dcom.sun.management.jmxremote.authenticate=false \244-Dcom.sun.management.jmxremote.ssl=false245246res=`_testme`247248case "${res}" in249OK*)250_echo "Passed"251;;252*)253_echo "Failed!"254;;255esac256257_app_stop258}259260test_05(){261262_echo "**** Test five ****"263264_app_start JdpDoSomething265266_jcmd ManagementAgent.start\267jmxremote.autodiscovery=true \268jmxremote.port=${_jmxport} \269jmxremote.authenticate=false \270jmxremote.ssl=false271272273res=`_testme`274275case "${res}" in276OK*)277_echo "Passed"278;;279*)280_echo "Failed!"281;;282esac283284_app_stop285}286287288# ============= MAIN =======================================289290if [ "x${TESTJAVA}" = "x" ]291then292echo "TESTJAVA env have to be set"293exit294fi295296# COMPILEJAVA variable is set when we test jre297if [ "x${COMPILEJAVA}" = "x" ]298then299COMPILEJAVA="${TESTJAVA}"300fi301302303#------------------------------------------------------------------------------304# reading parameters305306for parm in "$@"307do308case $parm in309--verbose) _verbose=yes ;;310--jtreg) _jtreg=yes ;;311--no-compile) _compile=no ;;312--testsuite=*) _testsuite=`_echo $parm | sed "s,^--.*=\(.*\),\1,"` ;;313*)314echo "Undefined parameter $parm. Try --help for help"315exit316;;317esac318done319320if [ "${_compile}" = "yes" ]321then322_do_compile323fi324325if [ "${_jtreg}" = "yes" ]326then327_testclasses=${TESTCLASSES}328_testsrc=${TESTSRC}329_logname="output.txt"330fi331332# Make sure _tesclasses is absolute path333tt=`echo ${_testclasses} | sed -e 's,/,,'`334if [ "${tt}" = "${_testclasses}" ]335then336_testclasses="${_pwd}/${_testclasses}"337fi338339_policyname="${_testclasses}/policy"340341rm -f ${_logname}342rm -f ${_policyname}343344if [ -f ${_testsrc}/policy.tpl ]345then346347cat ${_testsrc}/policy.tpl | \348sed -e "s,@_TESTCLASSES@,${_testclasses},g" -e "s,@TESTJAVA@,${TESTJAVA},g" \349> ${_policyname}350351fi352353# Local mode tests354for i in `echo ${_testsuite} | sed -e "s/,/ /g"`355do356test_${i}357done358359360