Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/javax/imageio/metadata/IIOMetadataFormat/runMetadataFormatThreadTest.sh
38855 views
#!/bin/ksh -p1#2# Copyright (c) 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 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" in85SunOS )86VAR="One value for Sun"87DEFAULT_JDK=/none88#DEFAULT_JDK=/usr/local/java/jdk1.2/solaris89FILESEP="/"90;;9192Linux | Darwin | AIX )93VAR="A different value for Linux"94DEFAULT_JDK=/none95#DEFAULT_JDK=/usr/local/java/jdk1.4/linux-i38696FILESEP="/"97;;9899Windows_95 | Windows_98 | Windows_NT | Windows_ME )100VAR="A different value for Win32"101DEFAULT_JDK=/none102#DEFAULT_JDK=/usr/local/java/jdk1.2/win32103FILESEP="\\"104;;105106CYGWIN* )107VAR="A different value for CYGWIN"108DEFAULT_JDK=/none109FILESEP="/"110;;111112# catch all other OSs113* )114echo "Unrecognized system! $OS"115fail "Unrecognized system! $OS"116;;117esac118119# check that some executable or other file you need is available, abort if not120# note that the name of the executable is in the fail string as well.121# this is how to check for presence of the compiler, etc.122#RESOURCE=`whence SomeProgramOrFileNeeded`123#if [ "${RESOURCE}" = "" ] ;124# then fail "Need SomeProgramOrFileNeeded to perform the test" ;125#fi126127# IT'S FINE TO DELETE THIS IF NOT NEEDED!128# check if an environment variable you need is set, give it a default if not129#if [ -z "${NEEDED_VAR}" ] ; then130# # The var is NOT set, so give it a default131# NEEDED_VAR=/some/default/value/such/as/a/path132#fi133134# IT'S FINE TO DELETE THIS IF NOT NEEDED!135#if [ -z "${NEEDED_LATER_VAR}" ] ; then136# # The var is NOT set, so give it a default137# # will need it in other scripts called from this one, so export it138# NEEDED_LATER_VAR="/a/different/path/note/the/quotes"139# export NEEDED_LATER_VAR140#fi141142# Want this test to run standalone as well as in the harness, so do the143# following to copy the test's directory into the harness's scratch directory144# and set all appropriate variables:145146if [ -z "${TESTJAVA}" ] ; then147# TESTJAVA is not set, so the test is running stand-alone.148# TESTJAVA holds the path to the root directory of the build of the JDK149# to be tested. That is, any java files run explicitly in this shell150# should use TESTJAVA in the path to the java interpreter.151# So, we'll set this to the JDK spec'd on the command line. If none152# is given on the command line, tell the user that and use a cheesy153# default.154# THIS IS THE JDK BEING TESTED.155if [ -n "$1" ] ;156then TESTJAVA=$1157else echo "no JDK specified on command line so using default!"158TESTJAVA=$DEFAULT_JDK159fi160TESTSRC=.161TESTCLASSES=.162STANDALONE=1;163fi164echo "JDK under test is: $TESTJAVA"165166#Deal with .class files:167if [ -n "${STANDALONE}" ] ;168then169#if standalone, remind user to cd to dir. containing test before running it170echo "Just a reminder: cd to the dir containing this test when running it"171# then compile all .java files (if there are any) into .class files172if [ -a *.java ] ;173then echo "Reminder, this test should be in its own directory with all"174echo "supporting files it needs in the directory with it."175${TESTJAVA}/bin/javac ./*.java ;176fi177# else in harness so copy all the class files from where jtreg put them178# over to the scratch directory this test is running in.179else cp ${TESTCLASSES}/*.class . ;180fi181182#if in test harness, then copy the entire directory that the test is in over183# to the scratch directory. This catches any support files needed by the test.184185#if [ -z "${STANDALONE}" ] ;186# then cp ${TESTSRC}/* .187#fi188189#Just before executing anything, make sure it has executable permission!190chmod 777 ./*191192############### YOUR TEST CODE HERE!!!!!!! #############193194#All files required for the test should be in the same directory with195# this file. If converting a standalone test to run with the harness,196# as long as all files are in the same directory and it returns 0 for197# pass, you should be able to cut and paste it into here and it will198# run with the test harness.199200# This is an example of running something -- test201# The stuff below catches the exit status of test then passes or fails202# this shell test as appropriate ( 0 status is considered a pass here )203#./test # DELETE THIS LINE AND REPLACE WITH YOUR OWN COMMAND!!!204205if [ -d ./test_classes ] ; then206rm -rf ./test_calsses207fi208209mkdir ./test_classes210211# split application classes and test plugin classes212mv ./UserPluginMetadataFormatTest*.class ./test_classes213214$TESTJAVA/bin/java MetadataFormatThreadTest test_classes UserPluginMetadataFormatTest215216############### END YOUR TEST CODE !!!!! ############217status=$?218219# pass or fail the test based on status of the command220if [ $status -eq "0" ];221then pass "Test passed - no stack trace printing"222223else fail "Test failure - stack trace was printed"224fi225226#For additional examples of how to write platform independent KSH scripts,227# see the jtreg file itself. It is a KSH script for both Solaris and Win32228229230231