From 3d4a927981e05ab5a95126f862a78fd2cece4236 Mon Sep 17 00:00:00 2001 From: "Daniel D. Daugherty" Date: Tue, 12 Apr 2011 13:36:38 -0700 Subject: [PATCH] 7035555: 4/4 attach/BasicTests.sh needs another tweak for Cygwin Test needs to properly detect missing AgentInitializationException. Clarify when exceptions are expected. Another Cygwin tweak. Reviewed-by: dsamersoff, ohair --- .../com/sun/tools/attach/ApplicationSetup.sh | 5 ++-- jdk/test/com/sun/tools/attach/BasicTests.java | 13 ++++++++-- jdk/test/com/sun/tools/attach/BasicTests.sh | 24 +++++++++++++------ 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/jdk/test/com/sun/tools/attach/ApplicationSetup.sh b/jdk/test/com/sun/tools/attach/ApplicationSetup.sh index a07fac420e2..0537cb6e401 100644 --- a/jdk/test/com/sun/tools/attach/ApplicationSetup.sh +++ b/jdk/test/com/sun/tools/attach/ApplicationSetup.sh @@ -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 @@ rm -f ${OUTPUTFILE} 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 diff --git a/jdk/test/com/sun/tools/attach/BasicTests.java b/jdk/test/com/sun/tools/attach/BasicTests.java index 39c1c2d56bf..79056e614b3 100644 --- a/jdk/test/com/sun/tools/attach/BasicTests.java +++ b/jdk/test/com/sun/tools/attach/BasicTests.java @@ -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 @@ public class BasicTests { // 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); diff --git a/jdk/test/com/sun/tools/attach/BasicTests.sh b/jdk/test/com/sun/tools/attach/BasicTests.sh index 3f8f8571411..b63d7528ff9 100644 --- a/jdk/test/com/sun/tools/attach/BasicTests.sh +++ b/jdk/test/com/sun/tools/attach/BasicTests.sh @@ -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 @@ fi # 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 @@ fi startApplication -Dattach.test=true # pid = process-id, port = shutdown port - + failures=0 echo "Running tests ..." @@ -69,6 +67,18 @@ if [ $? != 0 ]; then failures=`expr $failures + 1`; fi 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};