Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/javax/imageio/stream/StreamCloserLeak/run_test.sh
38855 views
#!/bin/ksh -p1#2# Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.3# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.4#5# This code is free software; you can redistribute it and/or modify it6# under the terms of the GNU General Public License version 2 only, as7# published by the Free Software Foundation.8#9# This code is distributed in the hope that it will be useful, but WITHOUT10# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12# version 2 for more details (a copy is included in the LICENSE file that13# accompanied this code).14#15# You should have received a copy of the GNU General Public License version16# 2 along with this work; if not, write to the Free Software Foundation,17# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.18#19# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA20# or visit www.oracle.com if you need additional information or have any21# questions.22#2324#25# @test26# @bug 678809627# @summary Test simulates the case of multiple applets executed in28# the same VM and verifies that ImageIO shutdown hook29# StreamCloser does not cause a leak of classloaders.30#31# @build test.Main32# @build testapp.Main33# @run shell run_test.sh3435# There are several resources which need to be present before many36# shell scripts can run. Following are examples of how to check for37# many common ones.38#39# Note that the shell used is the Korn Shell, KSH40#41# Also note, it is recommended that make files NOT be used. Rather,42# put the individual commands directly into this file. That way,43# it is possible to use command line arguments and other shell tech-44# niques to find the compiler, etc on different systems. For example,45# a different path could be used depending on whether this were a46# Solaris or Win32 machine, which is more difficult (if even possible)47# in a make file.484950# Beginning of subroutines:51status=15253#Call this from anywhere to fail the test with an error message54# usage: fail "reason why the test failed"55fail()56{ echo "The test failed :-("57echo "$*" 1>&258echo "exit status was $status"59exit $status60} #end of fail()6162#Call this from anywhere to pass the test with a message63# usage: pass "reason why the test passed if applicable"64pass()65{ echo "The test passed!!!"66echo "$*" 1>&267exit 068} #end of pass()6970# end of subroutines717273# The beginning of the script proper7475# Checking for proper OS76OS=`uname -s`77case "$OS" in78SunOS )79VAR="One value for Sun"80DEFAULT_JDK=/81FILESEP="/"82PATHSEP=":"83TMP="/tmp"84;;8586Linux )87VAR="A different value for Linux"88DEFAULT_JDK=/89FILESEP="/"90PATHSEP=":"91TMP="/tmp"92;;9394AIX )95VAR="A different value for AIX"96DEFAULT_JDK=/97FILESEP="/"98PATHSEP=":"99TMP="/tmp"100;;101102Darwin )103VAR="A different value for MacOSX"104DEFAULT_JDK=/usr105FILESEP="/"106PATHSEP=":"107TMP="/tmp"108;;109110Windows* )111VAR="A different value for Win32"112DEFAULT_JDK="C:/Program Files/Java/jdk1.8.0"113FILESEP="\\"114PATHSEP=";"115TMP=`cd "${SystemRoot}/Temp"; echo ${PWD}`116;;117118CYGWIN* )119VAR="A different value for Cygwin"120DEFAULT_JDK="/cygdrive/c/Program\ Files/Java/jdk1.8.0"121FILESEP="/"122PATHSEP=";"123TMP=`cd "${SystemRoot}/Temp"; echo ${PWD}`124;;125126# catch all other OSs127* )128echo "Unrecognized system! $OS"129fail "Unrecognized system! $OS"130;;131esac132133# Want this test to run standalone as well as in the harness, so do the134# following to copy the test's directory into the harness's scratch directory135# and set all appropriate variables:136137if [ -z "${TESTJAVA}" ] ; then138# TESTJAVA is not set, so the test is running stand-alone.139# TESTJAVA holds the path to the root directory of the build of the JDK140# to be tested. That is, any java files run explicitly in this shell141# should use TESTJAVA in the path to the java interpreter.142# So, we'll set this to the JDK spec'd on the command line. If none143# is given on the command line, tell the user that and use a cheesy144# default.145# THIS IS THE JDK BEING TESTED.146if [ -n "$1" ] ;147then TESTJAVA=$1148else echo "no JDK specified on command line so using default!"149TESTJAVA=$DEFAULT_JDK150fi151TESTSRC=.152TESTCLASSES=.153STANDALONE=1;154fi155echo "JDK under test is: $TESTJAVA"156157158############### YOUR TEST CODE HERE!!!!!!! #############159160#All files required for the test should be in the same directory with161# this file. If converting a standalone test to run with the harness,162# as long as all files are in the same directory and it returns 0 for163# pass, you should be able to cut and paste it into here and it will164# run with the test harness.165166# This is an example of running something -- test167# The stuff below catches the exit status of test then passes or fails168# this shell test as appropriate ( 0 status is considered a pass here )169170echo "Create TestApp.jar..."171172if [ -f TestApp.jar ] ; then173rm -f TestApp.jar174fi175176${TESTJAVA}/bin/jar -cvf TestApp.jar -C ${TESTCLASSES} testapp177178if [ $? -ne "0" ] ; then179fail "Failed to create TestApp.jar"180fi181182echo "Create Test.jar..."183if [ -f Test.jar ] ; then184rm -f Test.jar185fi186187${TESTJAVA}/bin/jar -cvf Test.jar -C ${TESTCLASSES} test188189if [ $? -ne 0 ] ; then190fail "Failed to create Test.jar"191fi192193# Prepare temp dir for cahce files194mkdir ./tmp195if [ $? -ne 0 ] ; then196fail "Unable to create temp directory."197fi198199# Verify that all classoladers are destroyed200${TESTJAVA}/bin/java -cp Test.jar test.Main201if [ $? -ne 0 ] ; then202fail "Test FAILED: some classloaders weren't destroyed."203fi204205206# Verify that ImageIO shutdown hook works correcly207${TESTJAVA}/bin/java -cp Test.jar -DforgetSomeStreams=true test.Main208if [ $? -ne 0 ] ; then209fail "Test FAILED: some classloaders weren't destroyed of shutdown hook failed."210fi211212# sanity check: verify that all cache files were deleted213cache_files=`ls tmp`214215if [ "x${cache_files}" != "x" ] ; then216echo "WARNING: some cache files was not deleted: ${cache_files}"217fi218219echo "Test done."220221status=$?222223if [ $status -eq "0" ] ; then224pass ""225else226fail "Test failed due to test plugin was not found."227fi228229230231