changeset 6607:85a94425d233

8009213: sun/management/jdp/JdpTest.sh fails with exit code 1 Summary: There's no guarantee that the java process has executed far enough to be found by jps when we try to obtain it's pid. Reviewed-by: sla
author dsamersoff
date Thu, 03 Oct 2013 23:24:26 +0400
parents 94098d8ee492
children 1744fc1a2228
files test/sun/management/jdp/JdpTest.sh
diffstat 1 files changed, 23 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/test/sun/management/jdp/JdpTest.sh	Thu Oct 03 17:32:01 2013 +0400
+++ b/test/sun/management/jdp/JdpTest.sh	Thu Oct 03 23:24:26 2013 +0400
@@ -84,15 +84,29 @@
   ${TESTJAVA}/bin/java -server $* -cp ${_testclasses} ${testappname}  >> ${_logname} 2>&1 &
  _last_pid=$!
 
-  npid=`_get_pid`
-  if [ "${npid}" = "" ]
-  then
-     echo "ERROR: Test app not started. Please check machine resources before filing a bug."
-     if [ "${_jtreg}" = "yes" ]
-     then
-       exit 255
-     fi
-  fi
+# wait until VM is actually starts. 
+# please note, if vm doesn't start for some reason
+# jtreg kills the test by timeout. Don't file a bug.
+  cnt=1 
+  while true
+  do
+    npid=`_get_pid`
+    if [ "${npid}" != "" ]
+    then
+      break
+    fi
+    if [ "${cnt}" = "10" ]
+    then
+      echo "ERROR: Test app not started. Please check machine resources before filing a bug."
+      if [ "${_jtreg}" = "yes" ]
+      then
+          exit 255
+      fi
+      break
+    fi
+    cnt=`expr $cnt + 1`
+    sleep 1
+  done
 }
 
 _get_pid(){