提交 f6a5d308 编写于 作者: D dcubed

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
上级 4af1f46a
#!/bin/sh #!/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. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -40,7 +40,8 @@ rm -f ${OUTPUTFILE} ...@@ -40,7 +40,8 @@ rm -f ${OUTPUTFILE}
startApplication() 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="$!" pid="$!"
# MKS creates an intermediate shell to launch ${JAVA} so # MKS creates an intermediate shell to launch ${JAVA} so
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -75,14 +75,23 @@ public class BasicTests { ...@@ -75,14 +75,23 @@ public class BasicTests {
// Test 3 - load an "bad" agent (agentmain throws an exception) // Test 3 - load an "bad" agent (agentmain throws an exception)
System.out.println(" - Test: Load a bad agent"); 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 { try {
vm.loadAgent(badagent); vm.loadAgent(badagent);
throw new RuntimeException(
"AgentInitializationException not thrown as expected!");
} catch (AgentInitializationException x) { } 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) // Test 4 - detach from the VM and attempt a load (should throw IOE)
System.out.println(" - Test: Detach from VM"); 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(); vm.detach();
try { try {
vm.loadAgent(agent); vm.loadAgent(agent);
......
#!/bin/sh #!/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. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -39,11 +39,9 @@ fi ...@@ -39,11 +39,9 @@ fi
# Windows 2000 is a problem here, so we skip it, see 6962615 # Windows 2000 is a problem here, so we skip it, see 6962615
osrev=`uname -a` osrev=`uname -a`
if [ "`echo ${osrev} | grep 'CYGWIN'`" != "" ] ; then if [ "`echo ${osrev} | grep 'CYGWIN[^ ]*-5\.0'`" != "" ] ; then
if [ "`echo ${osrev} | grep '5.0'`" != "" ] ; then echo "Treating as a pass, not testing Windows 2000"
echo "Treating as a pass, not testing Windows 2000" exit 0
exit 0
fi
fi fi
if [ "`echo ${osrev} | grep 'Windows'`" != "" ] ; then if [ "`echo ${osrev} | grep 'Windows'`" != "" ] ; then
if [ "`echo ${osrev} | grep '5 00'`" != "" ] ; then if [ "`echo ${osrev} | grep '5 00'`" != "" ] ; then
...@@ -58,7 +56,7 @@ fi ...@@ -58,7 +56,7 @@ fi
startApplication -Dattach.test=true startApplication -Dattach.test=true
# pid = process-id, port = shutdown port # pid = process-id, port = shutdown port
failures=0 failures=0
echo "Running tests ..." echo "Running tests ..."
...@@ -69,6 +67,18 @@ if [ $? != 0 ]; then failures=`expr $failures + 1`; fi ...@@ -69,6 +67,18 @@ if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
stopApplication $port 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 ]; if [ $failures = 0 ];
then echo "All tests passed."; then echo "All tests passed.";
else echo "$failures test(s) failed:"; cat ${OUTPUTFILE}; else echo "$failures test(s) failed:"; cat ${OUTPUTFILE};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册