0N/A#!/bin/sh
0N/A
0N/A#
2362N/A# Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
0N/A# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A#
0N/A# This code is free software; you can redistribute it and/or modify it
0N/A# under the terms of the GNU General Public License version 2 only, as
0N/A# published by the Free Software Foundation.
0N/A#
0N/A# This code is distributed in the hope that it will be useful, but WITHOUT
0N/A# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A# version 2 for more details (a copy is included in the LICENSE file that
0N/A# accompanied this code).
0N/A#
0N/A# You should have received a copy of the GNU General Public License version
0N/A# 2 along with this work; if not, write to the Free Software Foundation,
0N/A# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A#
2362N/A# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A# or visit www.oracle.com if you need additional information or have any
2362N/A# questions.
0N/A#
0N/A
136N/A
0N/A# @test
0N/A# @bug 6173575 6388987
136N/A# @summary Unit tests for appendToBootstrapClassLoaderSearch and
0N/A# appendToSystemClasLoaderSearch methods.
0N/A#
0N/A# @build Agent AgentSupport BootSupport BasicTest PrematureLoadTest DynamicTest
137N/A# @run shell/timeout=240 run_tests.sh
0N/A
0N/Aif [ "${TESTSRC}" = "" ]
0N/Athen
0N/A echo "TESTSRC not set. Test cannot execute. Failed."
0N/A exit 1
0N/Afi
136N/A
0N/A. ${TESTSRC}/CommonSetup.sh
0N/A
136N/A
0N/A# Simple tests
0N/A
0N/Aecho "Creating jar files for simple tests..."
0N/A
0N/Acd ${TESTCLASSES}
0N/A
0N/A"$JAR" -cfm Agent.jar "${TESTSRC}"/manifest.mf Agent.class
0N/A"$JAR" -cf AgentSupport.jar AgentSupport.class
0N/A"$JAR" -cf BootSupport.jar BootSupport.class
136N/A"$JAR" -cf SimpleTests.jar BasicTest.class PrematureLoadTest.class
0N/A
0N/Afailures=0
0N/A
0N/Ago() {
0N/A echo ''
136N/A sh -xc "$JAVA ${TESTVMOPTS} -javaagent:Agent.jar -classpath SimpleTests.jar $1 $2 $3" 2>&1
0N/A if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
0N/A}
0N/A
0N/Ago BasicTest
0N/Ago PrematureLoadTest
0N/A
0N/A# Functional tests
0N/A
0N/Aecho ''
0N/Aecho "Setup for functional tests..."
0N/A
0N/A# Create org.tools.Tracer in temp directory so that it's not seen on the
0N/A# system class path
0N/A
0N/Amkdir tmp
0N/A"${JAVAC}" -d tmp "${TESTSRC}"/Tracer.java
0N/A(cd tmp; "${JAR}" cf ../Tracer.jar org/tools/Tracer.class)
0N/A
136N/A# InstrumentedApplication is Application+instrmentation - don't copy as
0N/A# we don't want the original file permission
0N/A
0N/Acat "${TESTSRC}"/InstrumentedApplication.java > ./Application.java
0N/A"${JAVAC}" -classpath Tracer.jar -d . Application.java
0N/Amv Application.class InstrumentedApplication.bytes
0N/A
0N/Acp "${TESTSRC}"/Application.java .
0N/A"${JAVAC}" -d . Application.java
0N/A
136N/Ash -xc "$JAVA ${TESTVMOPTS} -classpath . -javaagent:Agent.jar DynamicTest" 2>&1
0N/Aif [ $? != 0 ]; then failures=`expr $failures + 1`; fi
0N/A
0N/A# Repeat test with security manager
136N/Ash -xc "$JAVA ${TESTVMOPTS} -classpath . -javaagent:Agent.jar -Djava.security.manager DynamicTest" 2>&1
0N/Aif [ $? != 0 ]; then failures=`expr $failures + 1`; fi
0N/A
0N/A#
0N/A# Results
0N/A#
0N/Aecho ''
0N/Aif [ $failures -gt 0 ];
0N/A then echo "$failures test(s) failed";
0N/A else echo "All test(s) passed"; fi
0N/Aexit $failures