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