39 fi 40 41 . ${TESTSRC}/CommonSetup.sh 42 43 44 # Simple tests 45 46 echo "Creating jar files for simple tests..." 47 48 cd ${TESTCLASSES} 49 50 "$JAR" ${TESTTOOLVMOPTS} -cfm Agent.jar "${TESTSRC}"/manifest.mf Agent.class 51 "$JAR" ${TESTTOOLVMOPTS} -cf AgentSupport.jar AgentSupport.class 52 "$JAR" ${TESTTOOLVMOPTS} -cf BootSupport.jar BootSupport.class 53 "$JAR" ${TESTTOOLVMOPTS} -cf SimpleTests.jar BasicTest.class PrematureLoadTest.class 54 55 failures=0 56 57 go() { 58 echo '' 59 sh -xc "$JAVA ${TESTVMOPTS} -javaagent:Agent.jar -classpath SimpleTests.jar $1 $2 $3" 2>&1 60 if [ $? != 0 ]; then failures=`expr $failures + 1`; fi 61 } 62 63 go BasicTest 64 go PrematureLoadTest 65 66 # Functional tests 67 68 echo '' 69 echo "Setup for functional tests..." 70 71 # Create org.tools.Tracer in temp directory so that it's not seen on the 72 # system class path 73 74 mkdir tmp 75 "${JAVAC}" ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d tmp "${TESTSRC}"/Tracer.java 76 (cd tmp; "${JAR}" ${TESTTOOLVMOPTS} cf ../Tracer.jar org/tools/Tracer.class) 77 78 # InstrumentedApplication is Application+instrmentation - don't copy as 79 # we don't want the original file permission 80 81 cat "${TESTSRC}"/InstrumentedApplication.java > ./Application.java 82 "${JAVAC}" ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -classpath Tracer.jar -d . Application.java 83 mv Application.class InstrumentedApplication.bytes 84 85 cp "${TESTSRC}"/Application.java . 86 "${JAVAC}" ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . Application.java 87 88 sh -xc "$JAVA ${TESTVMOPTS} -classpath . -javaagent:Agent.jar DynamicTest" 2>&1 89 if [ $? != 0 ]; then failures=`expr $failures + 1`; fi 90 91 # Repeat test with security manager 92 sh -xc "$JAVA ${TESTVMOPTS} -classpath . -javaagent:Agent.jar -Djava.security.manager DynamicTest" 2>&1 93 if [ $? != 0 ]; then failures=`expr $failures + 1`; fi 94 95 # 96 # Results 97 # 98 echo '' 99 if [ $failures -gt 0 ]; 100 then echo "$failures test(s) failed"; 101 else echo "All test(s) passed"; fi 102 exit $failures | 39 fi 40 41 . ${TESTSRC}/CommonSetup.sh 42 43 44 # Simple tests 45 46 echo "Creating jar files for simple tests..." 47 48 cd ${TESTCLASSES} 49 50 "$JAR" ${TESTTOOLVMOPTS} -cfm Agent.jar "${TESTSRC}"/manifest.mf Agent.class 51 "$JAR" ${TESTTOOLVMOPTS} -cf AgentSupport.jar AgentSupport.class 52 "$JAR" ${TESTTOOLVMOPTS} -cf BootSupport.jar BootSupport.class 53 "$JAR" ${TESTTOOLVMOPTS} -cf SimpleTests.jar BasicTest.class PrematureLoadTest.class 54 55 failures=0 56 57 go() { 58 echo '' 59 sh -xc "$JAVA ${TESTVMOPTS} ${TESTJAVAOPTS} -javaagent:Agent.jar -classpath SimpleTests.jar $1 $2 $3" 2>&1 60 if [ $? != 0 ]; then failures=`expr $failures + 1`; fi 61 } 62 63 go BasicTest 64 go PrematureLoadTest 65 66 # Functional tests 67 68 echo '' 69 echo "Setup for functional tests..." 70 71 # Create org.tools.Tracer in temp directory so that it's not seen on the 72 # system class path 73 74 mkdir tmp 75 "${JAVAC}" ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d tmp "${TESTSRC}"/Tracer.java 76 (cd tmp; "${JAR}" ${TESTTOOLVMOPTS} cf ../Tracer.jar org/tools/Tracer.class) 77 78 # InstrumentedApplication is Application+instrmentation - don't copy as 79 # we don't want the original file permission 80 81 cat "${TESTSRC}"/InstrumentedApplication.java > ./Application.java 82 "${JAVAC}" ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -classpath Tracer.jar -d . Application.java 83 mv Application.class InstrumentedApplication.bytes 84 85 cp "${TESTSRC}"/Application.java . 86 "${JAVAC}" ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . Application.java 87 88 sh -xc "$JAVA ${TESTVMOPTS} ${TESTJAVAOPTS} -classpath . -javaagent:Agent.jar DynamicTest" 2>&1 89 if [ $? != 0 ]; then failures=`expr $failures + 1`; fi 90 91 # Repeat test with security manager 92 sh -xc "$JAVA ${TESTVMOPTS} ${TESTJAVAOPTS} -classpath . -javaagent:Agent.jar -Djava.security.manager DynamicTest" 2>&1 93 if [ $? != 0 ]; then failures=`expr $failures + 1`; fi 94 95 # 96 # Results 97 # 98 echo '' 99 if [ $failures -gt 0 ]; 100 then echo "$failures test(s) failed"; 101 else echo "All test(s) passed"; fi 102 exit $failures |