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