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