1 #!/bin/ksh -p 2 # 3 # Copyright (c) 2012, 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 4929170 7078379 28 # @summary Tests that user-supplied IIOMetadata implementations 29 # loaded by separate classloader in separate thread 30 # is able to load correspnding IIOMetadataFormat 31 # implementations. 32 # @author Andrew Brygin 33 # 34 # @compile UserPluginMetadataFormatTest.java MetadataFormatThreadTest.java MetadataTest.java 35 # @run shell/timeout=60 runMetadataFormatThreadTest.sh 36 37 # Note!!!! JavaCodeForYourTest_CHANGE_THIS.java must be changed or deleted. 38 # If there is any java code which will be executed during the test, it must 39 # be compiled by the line above. If multiple .java files, separate the 40 # files by spaces on that line. See testing page of AWT home page for 41 # pointers to the testharness spec. and FAQ. 42 # Note!!!! Change AppletDeadlock.sh to the name of your test!!!! 43 44 # There are several resources which need to be present before many 45 # shell scripts can run. Following are examples of how to check for 46 # many common ones. 47 # 48 # Note that the shell used is the Korn Shell, KSH 49 # 50 # Also note, it is recommended that make files NOT be used. Rather, 51 # put the individual commands directly into this file. That way, 52 # it is possible to use command line arguments and other shell tech- 53 # niques to find the compiler, etc on different systems. For example, 54 # a different path could be used depending on whether this were a 55 # Solaris or Win32 machine, which is more difficult (if even possible) 56 # in a make file. 57 58 59 # Beginning of subroutines: 60 status=1 61 62 #Call this from anywhere to fail the test with an error message 63 # usage: fail "reason why the test failed" 64 fail() 65 { echo "The test failed :-(" 66 echo "$*" 1>&2 67 exit 1 68 } #end of fail() 69 70 #Call this from anywhere to pass the test with a message 71 # usage: pass "reason why the test passed if applicable" 72 pass() 73 { echo "The test passed!!!" 74 echo "$*" 1>&2 75 exit 0 76 } #end of pass() 77 78 # end of subroutines 79 80 81 # The beginning of the script proper 82 83 # Checking for proper OS 84 OS=`uname -s` 85 case "$OS" in 86 SunOS ) 87 VAR="One value for Sun" 88 DEFAULT_JDK=/none 89 #DEFAULT_JDK=/usr/local/java/jdk1.2/solaris 90 FILESEP="/" 91 ;; 92 93 Linux | Darwin ) 94 VAR="A different value for Linux" 95 DEFAULT_JDK=/none 96 #DEFAULT_JDK=/usr/local/java/jdk1.4/linux-i386 97 FILESEP="/" 98 ;; 99 100 Windows_95 | Windows_98 | Windows_NT | Windows_ME ) 101 VAR="A different value for Win32" 102 DEFAULT_JDK=/none 103 #DEFAULT_JDK=/usr/local/java/jdk1.2/win32 104 FILESEP="\\" 105 ;; 106 107 CYGWIN* ) 108 VAR="A different value for CYGWIN" 109 DEFAULT_JDK=/none 110 FILESEP="/" 111 ;; 112 113 # catch all other OSs 114 * ) 115 echo "Unrecognized system! $OS" 116 fail "Unrecognized system! $OS" 117 ;; 118 esac 119 120 # check that some executable or other file you need is available, abort if not 121 # note that the name of the executable is in the fail string as well. 122 # this is how to check for presence of the compiler, etc. 123 #RESOURCE=`whence SomeProgramOrFileNeeded` 124 #if [ "${RESOURCE}" = "" ] ; 125 # then fail "Need SomeProgramOrFileNeeded to perform the test" ; 126 #fi 127 128 # IT'S FINE TO DELETE THIS IF NOT NEEDED! 129 # check if an environment variable you need is set, give it a default if not 130 #if [ -z "${NEEDED_VAR}" ] ; then 131 # # The var is NOT set, so give it a default 132 # NEEDED_VAR=/some/default/value/such/as/a/path 133 #fi 134 135 # IT'S FINE TO DELETE THIS IF NOT NEEDED! 136 #if [ -z "${NEEDED_LATER_VAR}" ] ; then 137 # # The var is NOT set, so give it a default 138 # # will need it in other scripts called from this one, so export it 139 # NEEDED_LATER_VAR="/a/different/path/note/the/quotes" 140 # export NEEDED_LATER_VAR 141 #fi 142 143 # Want this test to run standalone as well as in the harness, so do the 144 # following to copy the test's directory into the harness's scratch directory 145 # and set all appropriate variables: 146 147 if [ -z "${TESTJAVA}" ] ; then 148 # TESTJAVA is not set, so the test is running stand-alone. 149 # TESTJAVA holds the path to the root directory of the build of the JDK 150 # to be tested. That is, any java files run explicitly in this shell 151 # should use TESTJAVA in the path to the java interpreter. 152 # So, we'll set this to the JDK spec'd on the command line. If none 153 # is given on the command line, tell the user that and use a cheesy 154 # default. 155 # THIS IS THE JDK BEING TESTED. 156 if [ -n "$1" ] ; 157 then TESTJAVA=$1 158 else echo "no JDK specified on command line so using default!" 159 TESTJAVA=$DEFAULT_JDK 160 fi 161 TESTSRC=. 162 TESTCLASSES=. 163 STANDALONE=1; 164 fi 165 echo "JDK under test is: $TESTJAVA" 166 167 #Deal with .class files: 168 if [ -n "${STANDALONE}" ] ; 169 then 170 #if standalone, remind user to cd to dir. containing test before running it 171 echo "Just a reminder: cd to the dir containing this test when running it" 172 # then compile all .java files (if there are any) into .class files 173 if [ -a *.java ] ; 174 then echo "Reminder, this test should be in its own directory with all" 175 echo "supporting files it needs in the directory with it." 176 ${TESTJAVA}/bin/javac ./*.java ; 177 fi 178 # else in harness so copy all the class files from where jtreg put them 179 # over to the scratch directory this test is running in. 180 else cp ${TESTCLASSES}/*.class . ; 181 fi 182 183 #if in test harness, then copy the entire directory that the test is in over 184 # to the scratch directory. This catches any support files needed by the test. 185 186 #if [ -z "${STANDALONE}" ] ; 187 # then cp ${TESTSRC}/* . 188 #fi 189 190 #Just before executing anything, make sure it has executable permission! 191 chmod 777 ./* 192 193 ############### YOUR TEST CODE HERE!!!!!!! ############# 194 195 #All files required for the test should be in the same directory with 196 # this file. If converting a standalone test to run with the harness, 197 # as long as all files are in the same directory and it returns 0 for 198 # pass, you should be able to cut and paste it into here and it will 199 # run with the test harness. 200 201 # This is an example of running something -- test 202 # The stuff below catches the exit status of test then passes or fails 203 # this shell test as appropriate ( 0 status is considered a pass here ) 204 #./test # DELETE THIS LINE AND REPLACE WITH YOUR OWN COMMAND!!! 205 206 if [ -d ./test_classes ] ; then 207 rm -rf ./test_calsses 208 fi 209 210 mkdir ./test_classes 211 212 # split application classes and test plugin classes 213 mv ./UserPluginMetadataFormatTest*.class ./test_classes 214 215 $TESTJAVA/bin/java MetadataFormatThreadTest test_classes UserPluginMetadataFormatTest 216 217 ############### END YOUR TEST CODE !!!!! ############ 218 status=$? 219 220 # pass or fail the test based on status of the command 221 if [ $status -eq "0" ]; 222 then pass "Test passed - no stack trace printing" 223 224 else fail "Test failure - stack trace was printed" 225 fi 226 227 #For additional examples of how to write platform independent KSH scripts, 228 # see the jtreg file itself. It is a KSH script for both Solaris and Win32 229