1 #!/bin/sh 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. Oracle designates this 9 # particular file as subject to the "Classpath" exception as provided 10 # by Oracle in the LICENSE file that accompanied this code. 11 # 12 # This code is distributed in the hope that it will be useful, but WITHOUT 13 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 # version 2 for more details (a copy is included in the LICENSE file that 16 # accompanied this code). 17 # 18 # You should have received a copy of the GNU General Public License version 19 # 2 along with this work; if not, write to the Free Software Foundation, 20 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 21 # 22 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 23 # or visit www.oracle.com if you need additional information or have any 24 # questions. 25 26 # @test JAWT.sh 27 # @bug 7190587 28 # @summary Tests Java AWT native interface library 29 # @author kshefov 30 # @run shell JAWT.sh 31 32 # NB: To run on Windows with MKS and Visual Studio compiler 33 # add the following options to jtreg: -e INCLUDE="%INCLUDE%;." -e LIB="%LIB%;." 34 35 if [ "${TESTSRC}" = "" ] 36 then TESTSRC=. 37 fi 38 39 if [ "${TESTJAVA}" = "" ] 40 then 41 PARENT=`dirname \`which java\`` 42 TESTJAVA=`dirname ${PARENT}` 43 echo "TESTJAVA not set, selecting " ${TESTJAVA} 44 echo "If this is incorrect, try setting the variable manually." 45 fi 46 47 # set platform-dependent variables 48 OS=`uname -s` 49 case "$OS" in 50 Linux ) 51 NULL=/dev/null 52 PS=":" 53 FS="/" 54 ${TESTJAVA}${FS}bin${FS}java -version 2>&1 | grep '64-Bit' > $NULL 55 if [ $? -eq '0' ] 56 then 57 ARCH="amd64" 58 else 59 ARCH="i386" 60 fi 61 SYST="linux" 62 MAKEFILE="Makefile.unix" 63 CC="gcc" 64 MAKE="make" 65 LD_LIBRARY_PATH="." 66 ;; 67 SunOS ) 68 NULL=/dev/null 69 PS=":" 70 FS="/" 71 if [ `uname -p | grep -c 'sparc'` -gt '0' ] 72 then 73 ARCH="sparc" 74 else 75 ARCH="i386" 76 fi 77 SYST="solaris" 78 MAKEFILE="Makefile.unix" 79 CC="gcc" 80 MAKE="make" 81 LD_LIBRARY_PATH="." 82 ;; 83 Windows* ) 84 NULL=null 85 PS=";" 86 FS="\\" 87 MAKEFILE="Makefile.win" 88 CC="cl" 89 MAKE="nmake" 90 ${TESTJAVA}${FS}bin${FS}java -d64 -version 2>&1 | grep '64-Bit' > $NULL 91 if [ "$?" -eq '0' ] 92 then 93 ARCH="amd64" 94 else 95 ARCH="i386" 96 fi 97 SYST="windows" 98 ;; 99 CYGWIN* ) 100 NULL=/dev/null 101 PS=":" 102 FS="/" 103 MAKEFILE="Makefile.cygwin" 104 CC="gcc" 105 ${TESTJAVA}${FS}bin${FS}java -d64 -version 2>&1 | grep '64-Bit' > $NULL 106 if [ "$?" -eq '0' ] 107 then 108 ARCH="amd64" 109 else 110 ARCH="i386" 111 fi 112 SYST="cygwin" 113 MAKE="make" 114 ;; 115 Darwin ) 116 echo "Test passed. This test is not for MacOS." 117 exit 0; 118 ;; 119 * ) 120 echo "Unrecognized system!" 121 exit 1; 122 ;; 123 esac 124 125 # Skip unsupported platforms 126 case `uname -m` in 127 arm* | ppc* ) 128 echo "Test passed. Not supported on current architecture." 129 exit 0 130 ;; 131 esac 132 133 echo "OS-ARCH is" ${SYST}-${ARCH} 134 ${TESTJAVA}${FS}jre${FS}bin${FS}java -fullversion 2>&1 135 136 which ${MAKE} >${NULL} 2>&1 137 if [ "$?" -ne '0' ] 138 then 139 echo "No make found. Test passed." 140 exit 0 141 fi 142 143 which ${CC} >${NULL} 2>&1 144 if [ "$?" -ne '0' ] 145 then 146 echo "No C compiler found. Test passed." 147 exit 0 148 fi 149 case "$OS" in 150 SunOS ) 151 ${CC} -v >${NULL} 2>&1 152 if [ "$?" -ne '0' ] 153 then 154 echo "No C compiler found. Test passed." 155 exit 0 156 fi 157 esac 158 159 cp ${TESTSRC}${FS}${MAKEFILE} . 160 161 JAVA=${TESTJAVA}${FS}jre${FS}bin${FS}java 162 JAVAC=${TESTJAVA}${FS}bin${FS}javac 163 JAVAH=${TESTJAVA}${FS}bin${FS}javah 164 165 export CC SYST ARCH LD_LIBRARY_PATH 166 167 ${JAVAC} -d . ${TESTSRC}${FS}MyCanvas.java 168 ${JAVAH} -jni -classpath . -d . MyCanvas 169 ${MAKE} -f ${MAKEFILE} 170 ${JAVA} -classpath . MyCanvas 171 172 exit $? 173