Path: blob/master/test/jdk/javax/imageio/metadata/IIOMetadataFormat/runMetadataFormatThreadTest.sh
41155 views
#!/bin/ksh -p1#2# Copyright (c) 2012, 2020, 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 4929170 707837927# @summary Tests that user-supplied IIOMetadata implementations28# loaded by separate classloader in separate thread29# is able to load correspnding IIOMetadataFormat30# implementations.31# @author Andrew Brygin32#33# @compile UserPluginMetadataFormatTest.java MetadataFormatThreadTest.java MetadataTest.java34# @run shell/timeout=60 runMetadataFormatThreadTest.sh3536# Note!!!! JavaCodeForYourTest_CHANGE_THIS.java must be changed or deleted.37# If there is any java code which will be executed during the test, it must38# be compiled by the line above. If multiple .java files, separate the39# files by spaces on that line. See testing page of AWT home page for40# pointers to the testharness spec. and FAQ.41# Note!!!! Change AppletDeadlock.sh to the name of your test!!!!4243# There are several resources which need to be present before many44# shell scripts can run. Following are examples of how to check for45# many common ones.46#47# Note that the shell used is the Korn Shell, KSH48#49# Also note, it is recommended that make files NOT be used. Rather,50# put the individual commands directly into this file. That way,51# it is possible to use command line arguments and other shell tech-52# niques to find the compiler, etc on different systems. For example,53# a different path could be used depending on whether this were a54# Solaris or Win32 machine, which is more difficult (if even possible)55# in a make file.565758# Beginning of subroutines:59status=16061#Call this from anywhere to fail the test with an error message62# usage: fail "reason why the test failed"63fail()64{ echo "The test failed :-("65echo "$*" 1>&266exit 167} #end of fail()6869#Call this from anywhere to pass the test with a message70# usage: pass "reason why the test passed if applicable"71pass()72{ echo "The test passed!!!"73echo "$*" 1>&274exit 075} #end of pass()7677# end of subroutines787980# The beginning of the script proper8182# Checking for proper OS83OS=`uname -s`84case "$OS" in85Linux | Darwin | AIX )86VAR="A different value for Linux"87DEFAULT_JDK=/none88#DEFAULT_JDK=/usr/local/java/jdk1.4/linux-i38689FILESEP="/"90;;9192Windows_95 | Windows_98 | Windows_NT | Windows_ME )93VAR="A different value for Win32"94DEFAULT_JDK=/none95#DEFAULT_JDK=/usr/local/java/jdk1.2/win3296FILESEP="\\"97;;9899CYGWIN* )100VAR="A different value for CYGWIN"101DEFAULT_JDK=/none102FILESEP="/"103;;104105# catch all other OSs106* )107echo "Unrecognized system! $OS"108fail "Unrecognized system! $OS"109;;110esac111112# check that some executable or other file you need is available, abort if not113# note that the name of the executable is in the fail string as well.114# this is how to check for presence of the compiler, etc.115#RESOURCE=`whence SomeProgramOrFileNeeded`116#if [ "${RESOURCE}" = "" ] ;117# then fail "Need SomeProgramOrFileNeeded to perform the test" ;118#fi119120# IT'S FINE TO DELETE THIS IF NOT NEEDED!121# check if an environment variable you need is set, give it a default if not122#if [ -z "${NEEDED_VAR}" ] ; then123# # The var is NOT set, so give it a default124# NEEDED_VAR=/some/default/value/such/as/a/path125#fi126127# IT'S FINE TO DELETE THIS IF NOT NEEDED!128#if [ -z "${NEEDED_LATER_VAR}" ] ; then129# # The var is NOT set, so give it a default130# # will need it in other scripts called from this one, so export it131# NEEDED_LATER_VAR="/a/different/path/note/the/quotes"132# export NEEDED_LATER_VAR133#fi134135# Want this test to run standalone as well as in the harness, so do the136# following to copy the test's directory into the harness's scratch directory137# and set all appropriate variables:138139if [ -z "${TESTJAVA}" ] ; then140# TESTJAVA is not set, so the test is running stand-alone.141# TESTJAVA holds the path to the root directory of the build of the JDK142# to be tested. That is, any java files run explicitly in this shell143# should use TESTJAVA in the path to the java interpreter.144# So, we'll set this to the JDK spec'd on the command line. If none145# is given on the command line, tell the user that and use a cheesy146# default.147# THIS IS THE JDK BEING TESTED.148if [ -n "$1" ] ;149then TESTJAVA=$1150else echo "no JDK specified on command line so using default!"151TESTJAVA=$DEFAULT_JDK152fi153TESTSRC=.154TESTCLASSES=.155STANDALONE=1;156fi157echo "JDK under test is: $TESTJAVA"158159#Deal with .class files:160if [ -n "${STANDALONE}" ] ;161then162#if standalone, remind user to cd to dir. containing test before running it163echo "Just a reminder: cd to the dir containing this test when running it"164# then compile all .java files (if there are any) into .class files165if [ -a *.java ] ;166then echo "Reminder, this test should be in its own directory with all"167echo "supporting files it needs in the directory with it."168${TESTJAVA}/bin/javac ./*.java ;169fi170# else in harness so copy all the class files from where jtreg put them171# over to the scratch directory this test is running in.172else cp ${TESTCLASSES}/*.class . ;173fi174175#if in test harness, then copy the entire directory that the test is in over176# to the scratch directory. This catches any support files needed by the test.177178#if [ -z "${STANDALONE}" ] ;179# then cp ${TESTSRC}/* .180#fi181182#Just before executing anything, make sure it has executable permission!183chmod 777 ./*184185############### YOUR TEST CODE HERE!!!!!!! #############186187#All files required for the test should be in the same directory with188# this file. If converting a standalone test to run with the harness,189# as long as all files are in the same directory and it returns 0 for190# pass, you should be able to cut and paste it into here and it will191# run with the test harness.192193# This is an example of running something -- test194# The stuff below catches the exit status of test then passes or fails195# this shell test as appropriate ( 0 status is considered a pass here )196#./test # DELETE THIS LINE AND REPLACE WITH YOUR OWN COMMAND!!!197198if [ -d ./test_classes ] ; then199rm -rf ./test_calsses200fi201202mkdir ./test_classes203204# split application classes and test plugin classes205mv ./UserPluginMetadataFormatTest*.class ./test_classes206207$TESTJAVA/bin/java ${TESTVMOPTS} \208MetadataFormatThreadTest test_classes UserPluginMetadataFormatTest209210############### END YOUR TEST CODE !!!!! ############211status=$?212213# pass or fail the test based on status of the command214if [ $status -eq "0" ];215then pass "Test passed - no stack trace printing"216217else fail "Test failure - stack trace was printed"218fi219220#For additional examples of how to write platform independent KSH scripts,221# see the jtreg file itself. It is a KSH script for both Solaris and Win32222223224225