7035555: 4/4 attach/BasicTests.sh needs another tweak for Cygwin
authordcubed
Tue, 12 Apr 2011 13:36:38 -0700
changeset 9259 f63768ad58c5
parent 9258 b5a28d36265b
child 9260 d01f7f35fdf4
7035555: 4/4 attach/BasicTests.sh needs another tweak for Cygwin Summary: Test needs to properly detect missing AgentInitializationException. Clarify when exceptions are expected. Another Cygwin tweak. Reviewed-by: dsamersoff, ohair
jdk/test/com/sun/tools/attach/ApplicationSetup.sh
jdk/test/com/sun/tools/attach/BasicTests.java
jdk/test/com/sun/tools/attach/BasicTests.sh
--- a/jdk/test/com/sun/tools/attach/ApplicationSetup.sh	Tue Apr 12 14:32:03 2011 -0400
+++ b/jdk/test/com/sun/tools/attach/ApplicationSetup.sh	Tue Apr 12 13:36:38 2011 -0700
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 #
-# Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -40,7 +40,8 @@
 
 startApplication() 
 {
-  ${JAVA} $1 $2 $3 -jar "${TESTCLASSES}"/Application.jar > ${OUTPUTFILE} &
+  # put all output from the app into ${OUTPUTFILE}
+  ${JAVA} $1 $2 $3 -jar "${TESTCLASSES}"/Application.jar > ${OUTPUTFILE} 2>&1 &
   pid="$!"
 
   # MKS creates an intermediate shell to launch ${JAVA} so
--- a/jdk/test/com/sun/tools/attach/BasicTests.java	Tue Apr 12 14:32:03 2011 -0400
+++ b/jdk/test/com/sun/tools/attach/BasicTests.java	Tue Apr 12 13:36:38 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -75,14 +75,23 @@
 
         // Test 3 - load an "bad" agent (agentmain throws an exception)
         System.out.println(" - Test: Load a bad agent");
+        System.out.println("INFO: This test will cause error messages "
+            + "to appear in the application log about SilverBullet.jar "
+            + "not being found and an agent failing to start.");
         try {
             vm.loadAgent(badagent);
+            throw new RuntimeException(
+                "AgentInitializationException not thrown as expected!");
         } catch (AgentInitializationException x) {
-            System.out.println(" - AgentInitializationException throws as expected!");
+            System.out.println(
+                " - AgentInitializationException thrown as expected!");
         }
 
         // Test 4 - detach from the VM and attempt a load (should throw IOE)
         System.out.println(" - Test: Detach from VM");
+        System.out.println("INFO: This test will cause error messages "
+            + "to appear in the application log about a BadAgent including "
+            + "a RuntimeException and an InvocationTargetException.");
         vm.detach();
         try {
             vm.loadAgent(agent);
--- a/jdk/test/com/sun/tools/attach/BasicTests.sh	Tue Apr 12 14:32:03 2011 -0400
+++ b/jdk/test/com/sun/tools/attach/BasicTests.sh	Tue Apr 12 13:36:38 2011 -0700
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 #
-# Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -39,11 +39,9 @@
 
 # Windows 2000 is a problem here, so we skip it, see 6962615
 osrev=`uname -a`
-if [ "`echo ${osrev} | grep 'CYGWIN'`" != "" ] ; then
-  if [ "`echo ${osrev} | grep '5.0'`" != "" ] ; then
-     echo "Treating as a pass, not testing Windows 2000"
-     exit 0
-  fi
+if [ "`echo ${osrev} | grep 'CYGWIN[^ ]*-5\.0'`" != "" ] ; then
+  echo "Treating as a pass, not testing Windows 2000"
+  exit 0
 fi
 if [ "`echo ${osrev} | grep 'Windows'`" != "" ] ; then
   if [ "`echo ${osrev} | grep '5 00'`" != "" ] ; then
@@ -58,7 +56,7 @@
 
 startApplication -Dattach.test=true
 # pid = process-id, port = shutdown port
-                                                                                                      
+
 failures=0
 
 echo "Running tests ..."
@@ -69,6 +67,18 @@
 
 stopApplication $port
 
+# Add these info messages to $OUTPUTFILE just in case someone
+# looks at it and wonders about the failures. We have to do
+# this after the application is stopped because it is writing
+# to $OUTPUTFILE.
+(
+echo ""
+echo "INFO: Test 2 will cause error messages about SilverBullet.jar" \
+    "and an agent failing to start."
+echo "INFO: Test 3 will cause error messages about BadAgent" \
+    "including a RuntimeException and an InvocationTargetException."
+) >> ${OUTPUTFILE}
+
 if [ $failures = 0 ]; 
   then echo "All tests passed.";
   else echo "$failures test(s) failed:"; cat ${OUTPUTFILE};