test/com/sun/tools/attach/ApplicationSetup.sh

Print this page




  32 #       stopApplication $1 - stops application via TCP shutdown port $1
  33 
  34 $JAVAC -d "${TESTCLASSES}" "${TESTSRC}"/Application.java "${TESTSRC}"/Shutdown.java
  35 $JAR -cfm "${TESTCLASSES}"/Application.jar "${TESTSRC}"/application.mf \
  36   -C "${TESTCLASSES}" Application.class
  37 
  38 OUTPUTFILE=${TESTCLASSES}/Application.out
  39 rm -f ${OUTPUTFILE}
  40 
  41 startApplication() 
  42 {
  43   ${JAVA} $1 $2 $3 -jar "${TESTCLASSES}"/Application.jar > ${OUTPUTFILE} &
  44   pid="$!"
  45 
  46   # MKS creates an intermediate shell to launch ${JAVA} so
  47   # ${pid} is not the actual pid. We have put in a small sleep
  48   # to give the intermediate shell process time to launch the
  49   # "java" process.
  50   if [ "$OS" = "Windows" ]; then
  51     sleep 2



  52     realpid=`ps -o pid,ppid,comm|grep ${pid}|grep "java"|cut -c1-6`

  53     pid=${realpid}
  54   fi
  55                                                                                                                   
  56   echo "Waiting for Application to initialize..."
  57   attempts=0
  58   while true; do
  59     sleep 1
  60     port=`tail -1 ${OUTPUTFILE}`
  61     if [ ! -z "$port" ]; then
  62       # In case of errors wait time for output to be flushed
  63       sleep 1
  64       cat ${OUTPUTFILE}
  65       break
  66     fi
  67     attempts=`expr $attempts + 1`
  68     echo "Waiting $attempts second(s) ..."
  69   done
  70   echo "Application is process $pid, shutdown port is $port"
  71   return $port
  72 }
  73 
  74 stopApplication() 
  75 {
  76   $JAVA -classpath "${TESTCLASSES}" Shutdown $1
  77 }
  78 


  32 #       stopApplication $1 - stops application via TCP shutdown port $1
  33 
  34 $JAVAC -d "${TESTCLASSES}" "${TESTSRC}"/Application.java "${TESTSRC}"/Shutdown.java
  35 $JAR -cfm "${TESTCLASSES}"/Application.jar "${TESTSRC}"/application.mf \
  36   -C "${TESTCLASSES}" Application.class
  37 
  38 OUTPUTFILE=${TESTCLASSES}/Application.out
  39 rm -f ${OUTPUTFILE}
  40 
  41 startApplication() 
  42 {
  43   ${JAVA} $1 $2 $3 -jar "${TESTCLASSES}"/Application.jar > ${OUTPUTFILE} &
  44   pid="$!"
  45 
  46   # MKS creates an intermediate shell to launch ${JAVA} so
  47   # ${pid} is not the actual pid. We have put in a small sleep
  48   # to give the intermediate shell process time to launch the
  49   # "java" process.
  50   if [ "$OS" = "Windows" ]; then
  51     sleep 2
  52     if [ "${isCygwin}" = "true" ] ; then
  53       realpid=`ps -p ${pid} | tail -1 | awk '{print $4;}'`
  54     else
  55       realpid=`ps -o pid,ppid,comm|grep ${pid}|grep "java"|cut -c1-6`
  56     fi
  57     pid=${realpid}
  58   fi
  59                                                                                                                   
  60   echo "Waiting for Application to initialize..."
  61   attempts=0
  62   while true; do
  63     sleep 1
  64     port=`tail -1 ${OUTPUTFILE} | sed -e 's@\\r@@g' `
  65     if [ ! -z "$port" ]; then
  66       # In case of errors wait time for output to be flushed
  67       sleep 1
  68       cat ${OUTPUTFILE}
  69       break
  70     fi
  71     attempts=`expr $attempts + 1`
  72     echo "Waiting $attempts second(s) ..."
  73   done
  74   echo "Application is process $pid, shutdown port is $port"
  75   return $port
  76 }
  77 
  78 stopApplication() 
  79 {
  80   $JAVA -classpath "${TESTCLASSES}" Shutdown $1
  81 }
  82