annotate test/javax/imageio/stream/StreamCloserLeak/run_test.sh @ 5518:37fe00ff4f40

7072120: No mac os x support in several regression tests Reviewed-by: anthony, serb
author kshefov
date Fri, 30 Nov 2012 15:21:53 +0000
parents 12819477ce5a
children
rev   line source
bae@985 1 #!/bin/ksh -p
bae@985 2 #
kshefov@5518 3 # Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
bae@985 4 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
bae@985 5 #
bae@985 6 # This code is free software; you can redistribute it and/or modify it
bae@985 7 # under the terms of the GNU General Public License version 2 only, as
bae@985 8 # published by the Free Software Foundation.
bae@985 9 #
bae@985 10 # This code is distributed in the hope that it will be useful, but WITHOUT
bae@985 11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
bae@985 12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
bae@985 13 # version 2 for more details (a copy is included in the LICENSE file that
bae@985 14 # accompanied this code).
bae@985 15 #
bae@985 16 # You should have received a copy of the GNU General Public License version
bae@985 17 # 2 along with this work; if not, write to the Free Software Foundation,
bae@985 18 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
bae@985 19 #
ohair@2362 20 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@2362 21 # or visit www.oracle.com if you need additional information or have any
ohair@2362 22 # questions.
bae@985 23 #
bae@985 24
bae@985 25 #
bae@985 26 # @test
bae@985 27 # @bug 6788096
bae@985 28 # @summary Test simulates the case of multiple applets executed in
bae@985 29 # the same VM and verifies that ImageIO shutdown hook
bae@985 30 # StreamCloser does not cause a leak of classloaders.
bae@985 31 #
bae@985 32 # @build test.Main
bae@985 33 # @build testapp.Main
bae@985 34 # @run shell run_test.sh
bae@985 35
bae@985 36 # There are several resources which need to be present before many
bae@985 37 # shell scripts can run. Following are examples of how to check for
bae@985 38 # many common ones.
bae@985 39 #
bae@985 40 # Note that the shell used is the Korn Shell, KSH
bae@985 41 #
bae@985 42 # Also note, it is recommended that make files NOT be used. Rather,
bae@985 43 # put the individual commands directly into this file. That way,
bae@985 44 # it is possible to use command line arguments and other shell tech-
bae@985 45 # niques to find the compiler, etc on different systems. For example,
bae@985 46 # a different path could be used depending on whether this were a
bae@985 47 # Solaris or Win32 machine, which is more difficult (if even possible)
bae@985 48 # in a make file.
bae@985 49
bae@985 50
bae@985 51 # Beginning of subroutines:
bae@985 52 status=1
bae@985 53
bae@985 54 #Call this from anywhere to fail the test with an error message
bae@985 55 # usage: fail "reason why the test failed"
bae@985 56 fail()
bae@985 57 { echo "The test failed :-("
bae@985 58 echo "$*" 1>&2
bae@985 59 echo "exit status was $status"
bae@985 60 exit $status
bae@985 61 } #end of fail()
bae@985 62
bae@985 63 #Call this from anywhere to pass the test with a message
bae@985 64 # usage: pass "reason why the test passed if applicable"
bae@985 65 pass()
bae@985 66 { echo "The test passed!!!"
bae@985 67 echo "$*" 1>&2
bae@985 68 exit 0
bae@985 69 } #end of pass()
bae@985 70
bae@985 71 # end of subroutines
bae@985 72
bae@985 73
bae@985 74 # The beginning of the script proper
bae@985 75
bae@985 76 # Checking for proper OS
bae@985 77 OS=`uname -s`
bae@985 78 case "$OS" in
bae@985 79 SunOS )
bae@985 80 VAR="One value for Sun"
kshefov@5518 81 DEFAULT_JDK=/
bae@985 82 FILESEP="/"
bae@985 83 PATHSEP=":"
bae@985 84 TMP="/tmp"
bae@985 85 ;;
bae@985 86
kshefov@5518 87 Linux )
bae@985 88 VAR="A different value for Linux"
kshefov@5518 89 DEFAULT_JDK=/
bae@985 90 FILESEP="/"
bae@985 91 PATHSEP=":"
bae@985 92 TMP="/tmp"
bae@985 93 ;;
bae@985 94
kshefov@5518 95 Darwin )
kshefov@5518 96 VAR="A different value for MacOSX"
kshefov@5518 97 DEFAULT_JDK=/usr
kshefov@5518 98 FILESEP="/"
kshefov@5518 99 PATHSEP=":"
kshefov@5518 100 TMP="/tmp"
kshefov@5518 101 ;;
kshefov@5518 102
kshefov@5518 103 Windows* )
bae@985 104 VAR="A different value for Win32"
kshefov@5518 105 DEFAULT_JDK="C:/Program Files/Java/jdk1.8.0"
bae@985 106 FILESEP="\\"
bae@985 107 PATHSEP=";"
bae@985 108 TMP=`cd "${SystemRoot}/Temp"; echo ${PWD}`
bae@985 109 ;;
bae@985 110
kshefov@5518 111 CYGWIN* )
kshefov@5518 112 VAR="A different value for Cygwin"
kshefov@5518 113 DEFAULT_JDK="/cygdrive/c/Program\ Files/Java/jdk1.8.0"
kshefov@5518 114 FILESEP="/"
kshefov@5518 115 PATHSEP=";"
kshefov@5518 116 TMP=`cd "${SystemRoot}/Temp"; echo ${PWD}`
kshefov@5518 117 ;;
kshefov@5518 118
bae@985 119 # catch all other OSs
bae@985 120 * )
bae@985 121 echo "Unrecognized system! $OS"
bae@985 122 fail "Unrecognized system! $OS"
bae@985 123 ;;
bae@985 124 esac
bae@985 125
bae@985 126 # Want this test to run standalone as well as in the harness, so do the
bae@985 127 # following to copy the test's directory into the harness's scratch directory
bae@985 128 # and set all appropriate variables:
bae@985 129
bae@985 130 if [ -z "${TESTJAVA}" ] ; then
bae@985 131 # TESTJAVA is not set, so the test is running stand-alone.
bae@985 132 # TESTJAVA holds the path to the root directory of the build of the JDK
bae@985 133 # to be tested. That is, any java files run explicitly in this shell
bae@985 134 # should use TESTJAVA in the path to the java interpreter.
bae@985 135 # So, we'll set this to the JDK spec'd on the command line. If none
bae@985 136 # is given on the command line, tell the user that and use a cheesy
bae@985 137 # default.
bae@985 138 # THIS IS THE JDK BEING TESTED.
bae@985 139 if [ -n "$1" ] ;
bae@985 140 then TESTJAVA=$1
bae@985 141 else echo "no JDK specified on command line so using default!"
michaelm@4634 142 TESTJAVA=$DEFAULT_JDK
bae@985 143 fi
bae@985 144 TESTSRC=.
bae@985 145 TESTCLASSES=.
bae@985 146 STANDALONE=1;
bae@985 147 fi
bae@985 148 echo "JDK under test is: $TESTJAVA"
bae@985 149
bae@985 150
bae@985 151 ############### YOUR TEST CODE HERE!!!!!!! #############
bae@985 152
bae@985 153 #All files required for the test should be in the same directory with
bae@985 154 # this file. If converting a standalone test to run with the harness,
bae@985 155 # as long as all files are in the same directory and it returns 0 for
bae@985 156 # pass, you should be able to cut and paste it into here and it will
bae@985 157 # run with the test harness.
bae@985 158
bae@985 159 # This is an example of running something -- test
bae@985 160 # The stuff below catches the exit status of test then passes or fails
bae@985 161 # this shell test as appropriate ( 0 status is considered a pass here )
bae@985 162
bae@985 163 echo "Create TestApp.jar..."
bae@985 164
bae@985 165 if [ -f TestApp.jar ] ; then
bae@985 166 rm -f TestApp.jar
bae@985 167 fi
bae@985 168
bae@985 169 ${TESTJAVA}/bin/jar -cvf TestApp.jar -C ${TESTCLASSES} testapp
bae@985 170
bae@985 171 if [ $? -ne "0" ] ; then
bae@985 172 fail "Failed to create TestApp.jar"
bae@985 173 fi
bae@985 174
bae@985 175 echo "Create Test.jar..."
bae@985 176 if [ -f Test.jar ] ; then
bae@985 177 rm -f Test.jar
bae@985 178 fi
bae@985 179
bae@985 180 ${TESTJAVA}/bin/jar -cvf Test.jar -C ${TESTCLASSES} test
bae@985 181
bae@985 182 if [ $? -ne 0 ] ; then
bae@985 183 fail "Failed to create Test.jar"
bae@985 184 fi
bae@985 185
bae@985 186 # Prepare temp dir for cahce files
bae@985 187 mkdir ./tmp
bae@985 188 if [ $? -ne 0 ] ; then
bae@985 189 fail "Unable to create temp directory."
bae@985 190 fi
bae@985 191
bae@985 192 # Verify that all classoladers are destroyed
bae@985 193 ${TESTJAVA}/bin/java -cp Test.jar test.Main
bae@985 194 if [ $? -ne 0 ] ; then
bae@985 195 fail "Test FAILED: some classloaders weren't destroyed."
bae@985 196 fi
bae@985 197
bae@985 198
bae@985 199 # Verify that ImageIO shutdown hook works correcly
bae@985 200 ${TESTJAVA}/bin/java -cp Test.jar -DforgetSomeStreams=true test.Main
bae@985 201 if [ $? -ne 0 ] ; then
bae@985 202 fail "Test FAILED: some classloaders weren't destroyed of shutdown hook failed."
bae@985 203 fi
bae@985 204
bae@985 205 # sanity check: verify that all cache files were deleted
bae@985 206 cache_files=`ls tmp`
bae@985 207
bae@985 208 if [ "x${cache_files}" != "x" ] ; then
bae@985 209 echo "WARNING: some cache files was not deleted: ${cache_files}"
bae@985 210 fi
bae@985 211
bae@985 212 echo "Test done."
bae@985 213
bae@985 214 status=$?
bae@985 215
bae@985 216 if [ $status -eq "0" ] ; then
bae@985 217 pass ""
bae@985 218 else
bae@985 219 fail "Test failed due to test plugin was not found."
bae@985 220 fi
bae@985 221