1 #!/bin/ksh -p 2 3 # 4 # Copyright (c) 2007, 2012, 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 ShowExitTest.sh 28 # @bug 6513421 29 # @summary Java process does not terminate on closing the Main Application Frame 30 # 31 # @compile ShowExitTest.java 32 # @run shell/timeout=60 ShowExitTest.sh 33 34 # NOTE: The following error message means that the regression test failed: 35 # "Execution failed: Program `sh' interrupted! (timed out?)" 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 62 # Checking for proper OS 63 OS=`uname -s` 64 case "$OS" in 65 SunOS ) 66 VAR="One value for Sun" 67 DEFAULT_JDK=/ 68 FILESEP="/" 69 PATHSEP=":" 70 TMP="/tmp" 71 ;; 72 73 Linux ) 74 VAR="A different value for Linux" 75 DEFAULT_JDK=/ 76 FILESEP="/" 77 PATHSEP=":" 78 TMP="/tmp" 79 ;; 80 81 Darwin ) 82 VAR="A different value for MacOSX" 83 DEFAULT_JDK=/usr 84 FILESEP="/" 85 PATHSEP=":" 86 TMP="/tmp" 87 ;; 88 89 Windows* ) 90 VAR="A different value for Win32" 91 DEFAULT_JDK="C:/Program Files/Java/jdk1.8.0" 92 FILESEP="\\" 93 PATHSEP=";" 94 TMP=`cd "${SystemRoot}/Temp"; echo ${PWD}` 95 ;; 96 97 CYGWIN* ) 98 VAR="A different value for Cygwin" 99 DEFAULT_JDK="/cygdrive/c/Program\ Files/Java/jdk1.8.0" 100 FILESEP="/" 101 PATHSEP=";" 102 TMP=`cd "${SystemRoot}/Temp"; echo ${PWD}` 103 ;; 104 105 AIX ) 106 VAR="A different value for AIX" 107 DEFAULT_JDK=/ 108 FILESEP="/" 109 PATHSEP=":" 110 TMP="/tmp" 111 ;; 112 113 # catch all other OSs 114 * ) 115 echo "Unrecognized system! $OS" 116 fail "Unrecognized system! $OS" 117 ;; 118 esac 119 120 121 # Want this test to run standalone as well as in the harness, so do the 122 # following to copy the test's directory into the harness's scratch directory 123 # and set all appropriate variables: 124 125 if [ -z "${TESTJAVA}" ] ; then 126 # TESTJAVA is not set, so the test is running stand-alone. 127 # TESTJAVA holds the path to the root directory of the build of the JDK 128 # to be tested. That is, any java files run explicitly in this shell 129 # should use TESTJAVA in the path to the java interpreter. 130 # So, we'll set this to the JDK spec'd on the command line. If none 131 # is given on the command line, tell the user that and use a cheesy 132 # default. 133 # THIS IS THE JDK BEING TESTED. 134 if [ -n "$1" ] ; 135 then TESTJAVA=$1 136 else echo "no JDK specified on command line so using default!" 137 TESTJAVA=$DEFAULT_JDK 138 fi 139 TESTSRC=. 140 TESTCLASSES=. 141 STANDALONE=1; 142 fi 143 echo "JDK under test is: $TESTJAVA" 144 145 #Deal with .class files: 146 if [ -n "${STANDALONE}" ] ; 147 then 148 #if standalone, remind user to cd to dir. containing test before running it 149 echo "Just a reminder: cd to the dir containing this test when running it" 150 # then compile all .java files (if there are any) into .class files 151 if [ -a *.java ] ; 152 then echo "Reminder, this test should be in its own directory with all" 153 echo "supporting files it needs in the directory with it." 154 ${TESTJAVA}/bin/javac ./*.java ; 155 fi 156 # else in harness so copy all the class files from where jtreg put them 157 # over to the scratch directory this test is running in. 158 else cp ${TESTCLASSES}/*.class . ; 159 fi 160 161 #if in test harness, then copy the entire directory that the test is in over 162 # to the scratch directory. This catches any support files needed by the test. 163 if [ -z "${STANDALONE}" ] ; 164 then cp ${TESTSRC}/* . 165 fi 166 167 #Just before executing anything, make sure it has executable permission! 168 chmod 777 ./* 169 170 ############### YOUR TEST CODE HERE!!!!!!! ############# 171 172 #All files required for the test should be in the same directory with 173 # this file. If converting a standalone test to run with the harness, 174 # as long as all files are in the same directory and it returns 0 for 175 # pass, you should be able to cut and paste it into here and it will 176 # run with the test harness. 177 178 ${TESTJAVA}/bin/java ShowExitTest 179 180 ############### END YOUR TEST CODE !!!!! ############ 181 #Be sure the last command executed above this line returns 0 for success, 182 # something non-zero for failure. 183 status=$? 184 185 # pass or fail the test based on status of the command 186 if [ $status -eq "0" ]; 187 then pass "" 188 189 else fail "The program didn't terminate automatically!" 190 fi 191 192 #For additional examples of how to write platform independent KSH scripts, 193 # see the jtreg file itself. It is a KSH script for both Solaris and Win32 194