jdk/test/java/lang/instrument/appendToClassLoaderSearch/run_tests.sh
author shurailine
Tue, 27 Oct 2015 20:06:02 -0700
changeset 33402 1156d495a525
parent 30376 2ccf2cf7ea48
permissions -rw-r--r--
8140336: Add @modules for exported dependencies to jdk_core tests Reviewed-by: alanb, mchung
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
#!/bin/sh
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
#
30376
2ccf2cf7ea48 8078896: Add @modules as needed to the jdk_svc tests
ykantser
parents: 15254
diff changeset
     4
# Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
# This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
# under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
# published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
# This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
# version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
# accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
# You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
# 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
#
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
    21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
    22
# or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
    23
# questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
276
57cf064fc997 6491461: 3/3 TEST: java/lang/instrument .sh tests need to use $TESTVMOPTS in their java commands
dcubed
parents: 2
diff changeset
    26
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
# @test
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
# @bug 6173575 6388987
276
57cf064fc997 6491461: 3/3 TEST: java/lang/instrument .sh tests need to use $TESTVMOPTS in their java commands
dcubed
parents: 2
diff changeset
    29
# @summary Unit tests for appendToBootstrapClassLoaderSearch and
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#   appendToSystemClasLoaderSearch methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
# @build Agent AgentSupport BootSupport BasicTest PrematureLoadTest DynamicTest
277
9d9c1747de00 6528548: 4/4 NativeMethodPrefixAgent.java times out intermittently in nightly
dcubed
parents: 276
diff changeset
    33
# @run shell/timeout=240 run_tests.sh
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
if [ "${TESTSRC}" = "" ]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
then
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
  echo "TESTSRC not set.  Test cannot execute.  Failed."
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
  exit 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
fi
276
57cf064fc997 6491461: 3/3 TEST: java/lang/instrument .sh tests need to use $TESTVMOPTS in their java commands
dcubed
parents: 2
diff changeset
    40
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
. ${TESTSRC}/CommonSetup.sh
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
276
57cf064fc997 6491461: 3/3 TEST: java/lang/instrument .sh tests need to use $TESTVMOPTS in their java commands
dcubed
parents: 2
diff changeset
    43
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
# Simple tests
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
echo "Creating jar files for simple tests..."
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
cd ${TESTCLASSES}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
15254
3997a6f357cb 8005978: shell tests need to use the $COMPILEJDK for javac, jar and other tools
alanb
parents: 5506
diff changeset
    50
"$JAR" ${TESTTOOLVMOPTS} -cfm Agent.jar "${TESTSRC}"/manifest.mf Agent.class
3997a6f357cb 8005978: shell tests need to use the $COMPILEJDK for javac, jar and other tools
alanb
parents: 5506
diff changeset
    51
"$JAR" ${TESTTOOLVMOPTS} -cf  AgentSupport.jar AgentSupport.class
3997a6f357cb 8005978: shell tests need to use the $COMPILEJDK for javac, jar and other tools
alanb
parents: 5506
diff changeset
    52
"$JAR" ${TESTTOOLVMOPTS} -cf  BootSupport.jar BootSupport.class
3997a6f357cb 8005978: shell tests need to use the $COMPILEJDK for javac, jar and other tools
alanb
parents: 5506
diff changeset
    53
"$JAR" ${TESTTOOLVMOPTS} -cf  SimpleTests.jar BasicTest.class PrematureLoadTest.class
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
failures=0
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
go() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    echo ''
276
57cf064fc997 6491461: 3/3 TEST: java/lang/instrument .sh tests need to use $TESTVMOPTS in their java commands
dcubed
parents: 2
diff changeset
    59
    sh -xc "$JAVA ${TESTVMOPTS} -javaagent:Agent.jar -classpath SimpleTests.jar  $1 $2 $3" 2>&1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
go BasicTest
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
go PrematureLoadTest
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
# Functional tests
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
echo ''
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
echo "Setup for functional tests..."
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
# Create org.tools.Tracer in temp directory so that it's not seen on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
# system class path
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
mkdir tmp
15254
3997a6f357cb 8005978: shell tests need to use the $COMPILEJDK for javac, jar and other tools
alanb
parents: 5506
diff changeset
    75
"${JAVAC}" ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d tmp "${TESTSRC}"/Tracer.java
3997a6f357cb 8005978: shell tests need to use the $COMPILEJDK for javac, jar and other tools
alanb
parents: 5506
diff changeset
    76
(cd tmp; "${JAR}" ${TESTTOOLVMOPTS} cf ../Tracer.jar org/tools/Tracer.class)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
276
57cf064fc997 6491461: 3/3 TEST: java/lang/instrument .sh tests need to use $TESTVMOPTS in their java commands
dcubed
parents: 2
diff changeset
    78
# InstrumentedApplication is Application+instrmentation - don't copy as
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
# we don't want the original file permission
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
cat "${TESTSRC}"/InstrumentedApplication.java > ./Application.java
15254
3997a6f357cb 8005978: shell tests need to use the $COMPILEJDK for javac, jar and other tools
alanb
parents: 5506
diff changeset
    82
"${JAVAC}" ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -classpath Tracer.jar -d . Application.java
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
mv Application.class InstrumentedApplication.bytes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
cp "${TESTSRC}"/Application.java .
15254
3997a6f357cb 8005978: shell tests need to use the $COMPILEJDK for javac, jar and other tools
alanb
parents: 5506
diff changeset
    86
"${JAVAC}" ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . Application.java
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
276
57cf064fc997 6491461: 3/3 TEST: java/lang/instrument .sh tests need to use $TESTVMOPTS in their java commands
dcubed
parents: 2
diff changeset
    88
sh -xc "$JAVA ${TESTVMOPTS} -classpath . -javaagent:Agent.jar DynamicTest" 2>&1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
# Repeat test with security manager
276
57cf064fc997 6491461: 3/3 TEST: java/lang/instrument .sh tests need to use $TESTVMOPTS in their java commands
dcubed
parents: 2
diff changeset
    92
sh -xc "$JAVA ${TESTVMOPTS} -classpath . -javaagent:Agent.jar -Djava.security.manager DynamicTest" 2>&1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
# Results
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
#
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
echo ''
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
if [ $failures -gt 0 ];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
  then echo "$failures test(s) failed";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
  else echo "All test(s) passed"; fi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
exit $failures