Path: blob/master/test/jdk/javax/imageio/metadata/IIOMetadataFormat/runMetadataFormatTest.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 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" in84Linux | Darwin | AIX )85VAR="A different value for Linux"86DEFAULT_JDK=/none87#DEFAULT_JDK=/usr/local/java/jdk1.4/linux-i38688FILESEP="/"89;;9091Windows_95 | Windows_98 | Windows_NT | Windows_ME )92VAR="A different value for Win32"93DEFAULT_JDK=/none94#DEFAULT_JDK=/usr/local/java/jdk1.2/win3295FILESEP="\\"96;;9798CYGWIN* )99VAR="A different value for CYGWIN"100DEFAULT_JDK=/none101FILESEP="/"102;;103104# catch all other OSs105* )106echo "Unrecognized system! $OS"107fail "Unrecognized system! $OS"108;;109esac110111# check that some executable or other file you need is available, abort if not112# note that the name of the executable is in the fail string as well.113# this is how to check for presence of the compiler, etc.114#RESOURCE=`whence SomeProgramOrFileNeeded`115#if [ "${RESOURCE}" = "" ] ;116# then fail "Need SomeProgramOrFileNeeded to perform the test" ;117#fi118119# IT'S FINE TO DELETE THIS IF NOT NEEDED!120# check if an environment variable you need is set, give it a default if not121#if [ -z "${NEEDED_VAR}" ] ; then122# # The var is NOT set, so give it a default123# NEEDED_VAR=/some/default/value/such/as/a/path124#fi125126# IT'S FINE TO DELETE THIS IF NOT NEEDED!127#if [ -z "${NEEDED_LATER_VAR}" ] ; then128# # The var is NOT set, so give it a default129# # will need it in other scripts called from this one, so export it130# NEEDED_LATER_VAR="/a/different/path/note/the/quotes"131# export NEEDED_LATER_VAR132#fi133134# Want this test to run standalone as well as in the harness, so do the135# following to copy the test's directory into the harness's scratch directory136# and set all appropriate variables:137138if [ -z "${TESTJAVA}" ] ; then139# 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 JDK141# to be tested. That is, any java files run explicitly in this shell142# 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 none144# is given on the command line, tell the user that and use a cheesy145# default.146# THIS IS THE JDK BEING TESTED.147if [ -n "$1" ] ;148then TESTJAVA=$1149else echo "no JDK specified on command line so using default!"150TESTJAVA=$DEFAULT_JDK151fi152TESTSRC=.153TESTCLASSES=.154STANDALONE=1;155fi156echo "JDK under test is: $TESTJAVA"157158#Deal with .class files:159if [ -n "${STANDALONE}" ] ;160then161#if standalone, remind user to cd to dir. containing test before running it162echo "Just a reminder: cd to the dir containing this test when running it"163# then compile all .java files (if there are any) into .class files164if [ -a *.java ] ;165then echo "Reminder, this test should be in its own directory with all"166echo "supporting files it needs in the directory with it."167${TESTJAVA}/bin/javac ./*.java ;168fi169# else in harness so copy all the class files from where jtreg put them170# over to the scratch directory this test is running in.171else cp ${TESTCLASSES}/*.class . ;172fi173174#if in test harness, then copy the entire directory that the test is in over175# to the scratch directory. This catches any support files needed by the test.176177#if [ -z "${STANDALONE}" ] ;178# then cp ${TESTSRC}/* .179#fi180181#Just before executing anything, make sure it has executable permission!182chmod 777 ./*183184############### YOUR TEST CODE HERE!!!!!!! #############185186#All files required for the test should be in the same directory with187# this file. If converting a standalone test to run with the harness,188# as long as all files are in the same directory and it returns 0 for189# pass, you should be able to cut and paste it into here and it will190# run with the test harness.191192# This is an example of running something -- test193# The stuff below catches the exit status of test then passes or fails194# this shell test as appropriate ( 0 status is considered a pass here )195#./test # DELETE THIS LINE AND REPLACE WITH YOUR OWN COMMAND!!!196197if [ -d ./test_classes ] ; then198rm -rf ./test_calsses199fi200201mkdir ./test_classes202203# split application classes and test plugin classes204mv ./UserPluginMetadataFormatTest*.class ./test_classes205206$TESTJAVA/bin/java ${TESTVMOPTS} \207MetadataFormatTest test_classes UserPluginMetadataFormatTest208209############### END YOUR TEST CODE !!!!! ############210status=$?211212# pass or fail the test based on status of the command213if [ $status -eq "0" ];214then pass "Test passed - no stack trace printing"215216else fail "Test failure - stack trace was printed"217fi218219#For additional examples of how to write platform independent KSH scripts,220# see the jtreg file itself. It is a KSH script for both Solaris and Win32221222223224