1 #!/bin/ksh -p 2 3 # 4 # Copyright (c) 20015, Oracle and/or its affiliates. All rights reserved. 5 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6 # 7 # This code is free software; you can redistribute it and/or modify it 8 # under the terms of the GNU General Public License version 2 only, as 9 # published by the Free Software Foundation. 10 # 11 # This code is distributed in the hope that it will be useful, but WITHOUT 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 # version 2 for more details (a copy is included in the LICENSE file that 15 # accompanied this code). 16 # 17 # You should have received a copy of the GNU General Public License version 18 # 2 along with this work; if not, write to the Free Software Foundation, 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 # 21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 # or visit www.oracle.com if you need additional information or have any 23 # questions. 24 # 25 26 # 27 # @test EventQueuePushAutoshutdown.sh 28 # @bug 8081485 29 # @summary tests that a program terminates automatically 30 # after EventQueue.push() 31 # @author Anton Nashatyrev : area=toolkit 32 # 33 # @compile EventQueuePushAutoshutdown.java 34 # @run shell EventQueuePushAutoshutdown.sh 35 36 37 # Beginning of subroutines: 38 status=1 39 40 #Call this from anywhere to fail the test with an error message 41 # usage: fail "reason why the test failed" 42 fail() 43 { echo "The test failed :-(" 44 echo "$*" 1>&2 45 echo "exit status was $status" 46 exit $status 47 } #end of fail() 48 49 #Call this from anywhere to pass the test with a message 50 # usage: pass "reason why the test passed if applicable" 51 pass() 52 { echo "The test passed!!!" 53 echo "$*" 1>&2 54 exit 0 55 } #end of pass() 56 57 # end of subroutines 58 59 60 # The beginning of the script proper 61 OS=`uname -s` 62 case "$OS" in 63 SunOS ) 64 VAR="One value for Sun" 65 DEFAULT_JDK=/usr/local/java/jdk1.2/solaris 66 FILESEP="/" 67 ;; 68 69 Linux ) 70 VAR="A different value for Linux" 71 DEFAULT_JDK=/usr/local/java/jdk1.4/linux-i386 72 FILESEP="/" 73 ;; 74 75 Windows_95 | Windows_98 | Windows_NT | Windows_ME ) 76 VAR="A different value for Win32" 77 DEFAULT_JDK=/usr/local/java/jdk1.2/win32 78 FILESEP="\\" 79 ;; 80 81 CYGWIN* ) 82 VAR="A different value for Cygwin" 83 DEFAULT_JDK=/usr/local/java/jdk1.2/win32 84 FILESEP="/" 85 ;; 86 87 # catch all other OSs 88 * ) 89 echo "Unrecognized system! $OS" 90 fail "Unrecognized system! $OS" 91 ;; 92 esac 93 94 95 # Want this test to run standalone as well as in the harness, so do the 96 # following to copy the test's directory into the harness's scratch directory 97 # and set all appropriate variables: 98 99 if [ -z "${TESTJAVA}" ] ; then 100 # TESTJAVA is not set, so the test is running stand-alone. 101 # TESTJAVA holds the path to the root directory of the build of the JDK 102 # to be tested. That is, any java files run explicitly in this shell 103 # should use TESTJAVA in the path to the java interpreter. 104 # So, we'll set this to the JDK spec'd on the command line. If none 105 # is given on the command line, tell the user that and use a cheesy 106 # default. 107 # THIS IS THE JDK BEING TESTED. 108 if [ -n "$1" ] ; 109 then TESTJAVA=$1 110 else fail "no JDK specified on command line!" 111 fi 112 TESTSRC=. 113 TESTCLASSES=. 114 STANDALONE=1; 115 fi 116 echo "JDK under test is: $TESTJAVA" 117 118 #Deal with .class files: 119 if [ -n "${STANDALONE}" ] ; 120 then 121 #if standalone, remind user to cd to dir. containing test before running it 122 echo "Just a reminder: cd to the dir containing this test when running it" 123 # then compile all .java files (if there are any) into .class files 124 if [ -a *.java ] ; 125 then echo "Reminder, this test should be in its own directory with all" 126 echo "supporting files it needs in the directory with it." 127 ${TESTJAVA}/bin/javac ./*.java ; 128 fi 129 # else in harness so copy all the class files from where jtreg put them 130 # over to the scratch directory this test is running in. 131 else cp ${TESTCLASSES}/*.class . ; 132 fi 133 134 #if in test harness, then copy the entire directory that the test is in over 135 # to the scratch directory. This catches any support files needed by the test. 136 if [ -z "${STANDALONE}" ] ; 137 then cp ${TESTSRC}/* . 138 fi 139 140 #Just before executing anything, make sure it has executable permission! 141 chmod 777 ./* 142 143 ############### YOUR TEST CODE HERE!!!!!!! ############# 144 145 #All files required for the test should be in the same directory with 146 # this file. If converting a standalone test to run with the harness, 147 # as long as all files are in the same directory and it returns 0 for 148 # pass, you should be able to cut and paste it into here and it will 149 # run with the test harness. 150 151 ${TESTJAVA}/bin/java EventQueuePushAutoshutdown 152 153 ############### END YOUR TEST CODE !!!!! ############ 154 #Be sure the last command executed above this line returns 0 for success, 155 # something non-zero for failure. 156 status=$? 157 158 # pass or fail the test based on status of the command 159 case "$status" in 160 0 ) 161 pass "" 162 ;; 163 164 1 ) 165 fail "The program didn't automatically shut down" 166 ;; 167 168 * ) 169 fail "The program terminated unexpectedly!" 170 ;; 171 esac 172 173 #For additional examples of how to write platform independent KSH scripts, 174 # see the jtreg file itself. It is a KSH script for both Solaris and Win32 175