Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/javax/imageio/stream/StreamCloserLeak/run_test.sh
41153 views
1
#!/bin/ksh -p
2
#
3
# Copyright (c) 2009, 2020, 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
# @key intermittent
29
# @summary Test simulates the case of multiple applets executed in
30
# the same VM and verifies that ImageIO shutdown hook
31
# StreamCloser does not cause a leak of classloaders.
32
#
33
# @modules java.desktop/sun.awt
34
# @build test.Main
35
# @build testapp.Main
36
# @run shell run_test.sh
37
38
# There are several resources which need to be present before many
39
# shell scripts can run. Following are examples of how to check for
40
# many common ones.
41
#
42
# Note that the shell used is the Korn Shell, KSH
43
#
44
# Also note, it is recommended that make files NOT be used. Rather,
45
# put the individual commands directly into this file. That way,
46
# it is possible to use command line arguments and other shell tech-
47
# niques to find the compiler, etc on different systems. For example,
48
# a different path could be used depending on whether this were a
49
# Solaris or Win32 machine, which is more difficult (if even possible)
50
# in a make file.
51
52
53
# Beginning of subroutines:
54
status=1
55
56
#Call this from anywhere to fail the test with an error message
57
# usage: fail "reason why the test failed"
58
fail()
59
{ echo "The test failed :-("
60
echo "$*" 1>&2
61
echo "exit status was $status"
62
exit $status
63
} #end of fail()
64
65
#Call this from anywhere to pass the test with a message
66
# usage: pass "reason why the test passed if applicable"
67
pass()
68
{ echo "The test passed!!!"
69
echo "$*" 1>&2
70
exit 0
71
} #end of pass()
72
73
# end of subroutines
74
75
76
# The beginning of the script proper
77
78
# Checking for proper OS
79
OS=`uname -s`
80
case "$OS" in
81
Linux )
82
VAR="A different value for Linux"
83
DEFAULT_JDK=/
84
FILESEP="/"
85
PATHSEP=":"
86
TMP="/tmp"
87
;;
88
89
AIX )
90
VAR="A different value for AIX"
91
DEFAULT_JDK=/
92
FILESEP="/"
93
PATHSEP=":"
94
TMP="/tmp"
95
;;
96
97
Darwin )
98
VAR="A different value for MacOSX"
99
DEFAULT_JDK=/usr
100
FILESEP="/"
101
PATHSEP=":"
102
TMP="/tmp"
103
;;
104
105
Windows* )
106
VAR="A different value for Win32"
107
DEFAULT_JDK="C:/Program Files/Java/jdk1.8.0"
108
FILESEP="\\"
109
PATHSEP=";"
110
TMP=`cd "${SystemRoot}/Temp"; echo ${PWD}`
111
;;
112
113
CYGWIN* )
114
VAR="A different value for Cygwin"
115
DEFAULT_JDK="/cygdrive/c/Program\ Files/Java/jdk1.8.0"
116
FILESEP="/"
117
PATHSEP=";"
118
TMP=`cd "${SystemRoot}/Temp"; echo ${PWD}`
119
;;
120
121
# catch all other OSs
122
* )
123
echo "Unrecognized system! $OS"
124
fail "Unrecognized system! $OS"
125
;;
126
esac
127
128
# Want this test to run standalone as well as in the harness, so do the
129
# following to copy the test's directory into the harness's scratch directory
130
# and set all appropriate variables:
131
132
if [ -z "${TESTJAVA}" ] ; then
133
# TESTJAVA is not set, so the test is running stand-alone.
134
# TESTJAVA holds the path to the root directory of the build of the JDK
135
# to be tested. That is, any java files run explicitly in this shell
136
# should use TESTJAVA in the path to the java interpreter.
137
# So, we'll set this to the JDK spec'd on the command line. If none
138
# is given on the command line, tell the user that and use a cheesy
139
# default.
140
# THIS IS THE JDK BEING TESTED.
141
if [ -n "$1" ] ;
142
then TESTJAVA=$1
143
else echo "no JDK specified on command line so using default!"
144
TESTJAVA=$DEFAULT_JDK
145
fi
146
TESTSRC=.
147
TESTCLASSES=.
148
STANDALONE=1;
149
fi
150
echo "JDK under test is: $TESTJAVA"
151
152
153
############### YOUR TEST CODE HERE!!!!!!! #############
154
155
#All files required for the test should be in the same directory with
156
# this file. If converting a standalone test to run with the harness,
157
# as long as all files are in the same directory and it returns 0 for
158
# pass, you should be able to cut and paste it into here and it will
159
# run with the test harness.
160
161
# This is an example of running something -- test
162
# The stuff below catches the exit status of test then passes or fails
163
# this shell test as appropriate ( 0 status is considered a pass here )
164
165
echo "Create TestApp.jar..."
166
167
if [ -f TestApp.jar ] ; then
168
rm -f TestApp.jar
169
fi
170
171
${TESTJAVA}/bin/jar -cvf TestApp.jar -C ${TESTCLASSES} testapp
172
173
if [ $? -ne "0" ] ; then
174
fail "Failed to create TestApp.jar"
175
fi
176
177
echo "Create Test.jar..."
178
if [ -f Test.jar ] ; then
179
rm -f Test.jar
180
fi
181
182
${TESTJAVA}/bin/jar -cvf Test.jar -C ${TESTCLASSES} test
183
184
if [ $? -ne 0 ] ; then
185
fail "Failed to create Test.jar"
186
fi
187
188
# Prepare temp dir for cahce files
189
mkdir ./tmp
190
if [ $? -ne 0 ] ; then
191
fail "Unable to create temp directory."
192
fi
193
194
# Verify that all classloaders are destroyed
195
${TESTJAVA}/bin/java --add-exports java.desktop/sun.awt=ALL-UNNAMED ${TESTVMOPTS} -cp Test.jar test.Main
196
if [ $? -ne 0 ] ; then
197
fail "Test FAILED: some classloaders weren't destroyed."
198
fi
199
200
201
# Verify that ImageIO shutdown hook works correcly
202
${TESTJAVA}/bin/java --add-exports java.desktop/sun.awt=ALL-UNNAMED ${TESTVMOPTS} \
203
-cp Test.jar -DforgetSomeStreams=true test.Main
204
if [ $? -ne 0 ] ; then
205
fail "Test FAILED: some classloaders weren't destroyed of shutdown hook failed."
206
fi
207
208
# sanity check: verify that all cache files were deleted
209
cache_files=`ls tmp`
210
211
if [ "x${cache_files}" != "x" ] ; then
212
echo "WARNING: some cache files was not deleted: ${cache_files}"
213
fi
214
215
echo "Test done."
216
217
status=$?
218
219
if [ $status -eq "0" ] ; then
220
pass ""
221
else
222
fail "Test failed due to test plugin was not found."
223
fi
224
225
226