Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/javax/imageio/metadata/IIOMetadataFormat/runMetadataFormatTest.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 is able to load correspnding29# IIOMetadataFormat implementations.30# @author Andrew Brygin31#32# @compile UserPluginMetadataFormatTest.java MetadataFormatTest.java MetadataTest.java33# @run shell/timeout=60 runMetadataFormatTest.sh3435# Note!!!! JavaCodeForYourTest_CHANGE_THIS.java must be changed or deleted.36# If there is any java code which will be executed during the test, it must37# be compiled by the line above. If multiple .java files, separate the38# files by spaces on that line. See testing page of AWT home page for39# pointers to the testharness spec. and FAQ.40# Note!!!! Change AppletDeadlock.sh to the name of your test!!!!4142# There are several resources which need to be present before many43# shell scripts can run. Following are examples of how to check for44# many common ones.45#46# Note that the shell used is the Korn Shell, KSH47#48# Also note, it is recommended that make files NOT be used. Rather,49# put the individual commands directly into this file. That way,50# it is possible to use command line arguments and other shell tech-51# niques to find the compiler, etc on different systems. For example,52# a different path could be used depending on whether this were a53# Solaris or Win32 machine, which is more difficult (if even possible)54# in a make file.555657# Beginning of subroutines:58status=15960#Call this from anywhere to fail the test with an error message61# usage: fail "reason why the test failed"62fail()63{ echo "The test failed :-("64echo "$*" 1>&265exit 166} #end of fail()6768#Call this from anywhere to pass the test with a message69# usage: pass "reason why the test passed if applicable"70pass()71{ echo "The test passed!!!"72echo "$*" 1>&273exit 074} #end of pass()7576# end of subroutines777879# The beginning of the script proper8081# Checking for proper OS82OS=`uname -s`83case "$OS" in84SunOS )85VAR="One value for Sun"86DEFAULT_JDK=/none87#DEFAULT_JDK=/usr/local/java/jdk1.2/solaris88FILESEP="/"89;;9091Linux | Darwin | AIX )92VAR="A different value for Linux"93DEFAULT_JDK=/none94#DEFAULT_JDK=/usr/local/java/jdk1.4/linux-i38695FILESEP="/"96;;9798Windows_95 | Windows_98 | Windows_NT | Windows_ME )99VAR="A different value for Win32"100DEFAULT_JDK=/none101#DEFAULT_JDK=/usr/local/java/jdk1.2/win32102FILESEP="\\"103;;104105CYGWIN* )106VAR="A different value for CYGWIN"107DEFAULT_JDK=/none108FILESEP="/"109;;110111# catch all other OSs112* )113echo "Unrecognized system! $OS"114fail "Unrecognized system! $OS"115;;116esac117118# check that some executable or other file you need is available, abort if not119# note that the name of the executable is in the fail string as well.120# this is how to check for presence of the compiler, etc.121#RESOURCE=`whence SomeProgramOrFileNeeded`122#if [ "${RESOURCE}" = "" ] ;123# then fail "Need SomeProgramOrFileNeeded to perform the test" ;124#fi125126# IT'S FINE TO DELETE THIS IF NOT NEEDED!127# check if an environment variable you need is set, give it a default if not128#if [ -z "${NEEDED_VAR}" ] ; then129# # The var is NOT set, so give it a default130# NEEDED_VAR=/some/default/value/such/as/a/path131#fi132133# IT'S FINE TO DELETE THIS IF NOT NEEDED!134#if [ -z "${NEEDED_LATER_VAR}" ] ; then135# # The var is NOT set, so give it a default136# # will need it in other scripts called from this one, so export it137# NEEDED_LATER_VAR="/a/different/path/note/the/quotes"138# export NEEDED_LATER_VAR139#fi140141# Want this test to run standalone as well as in the harness, so do the142# following to copy the test's directory into the harness's scratch directory143# and set all appropriate variables:144145if [ -z "${TESTJAVA}" ] ; then146# TESTJAVA is not set, so the test is running stand-alone.147# TESTJAVA holds the path to the root directory of the build of the JDK148# to be tested. That is, any java files run explicitly in this shell149# should use TESTJAVA in the path to the java interpreter.150# So, we'll set this to the JDK spec'd on the command line. If none151# is given on the command line, tell the user that and use a cheesy152# default.153# THIS IS THE JDK BEING TESTED.154if [ -n "$1" ] ;155then TESTJAVA=$1156else echo "no JDK specified on command line so using default!"157TESTJAVA=$DEFAULT_JDK158fi159TESTSRC=.160TESTCLASSES=.161STANDALONE=1;162fi163echo "JDK under test is: $TESTJAVA"164165#Deal with .class files:166if [ -n "${STANDALONE}" ] ;167then168#if standalone, remind user to cd to dir. containing test before running it169echo "Just a reminder: cd to the dir containing this test when running it"170# then compile all .java files (if there are any) into .class files171if [ -a *.java ] ;172then echo "Reminder, this test should be in its own directory with all"173echo "supporting files it needs in the directory with it."174${TESTJAVA}/bin/javac ./*.java ;175fi176# else in harness so copy all the class files from where jtreg put them177# over to the scratch directory this test is running in.178else cp ${TESTCLASSES}/*.class . ;179fi180181#if in test harness, then copy the entire directory that the test is in over182# to the scratch directory. This catches any support files needed by the test.183184#if [ -z "${STANDALONE}" ] ;185# then cp ${TESTSRC}/* .186#fi187188#Just before executing anything, make sure it has executable permission!189chmod 777 ./*190191############### YOUR TEST CODE HERE!!!!!!! #############192193#All files required for the test should be in the same directory with194# this file. If converting a standalone test to run with the harness,195# as long as all files are in the same directory and it returns 0 for196# pass, you should be able to cut and paste it into here and it will197# run with the test harness.198199# This is an example of running something -- test200# The stuff below catches the exit status of test then passes or fails201# this shell test as appropriate ( 0 status is considered a pass here )202#./test # DELETE THIS LINE AND REPLACE WITH YOUR OWN COMMAND!!!203204if [ -d ./test_classes ] ; then205rm -rf ./test_calsses206fi207208mkdir ./test_classes209210# split application classes and test plugin classes211mv ./UserPluginMetadataFormatTest*.class ./test_classes212213$TESTJAVA/bin/java MetadataFormatTest test_classes UserPluginMetadataFormatTest214215############### END YOUR TEST CODE !!!!! ############216status=$?217218# pass or fail the test based on status of the command219if [ $status -eq "0" ];220then pass "Test passed - no stack trace printing"221222else fail "Test failure - stack trace was printed"223fi224225#For additional examples of how to write platform independent KSH scripts,226# see the jtreg file itself. It is a KSH script for both Solaris and Win32227228229230