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