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 33if [ "${TESTSRC}" = "" ] 34then TESTSRC=. 35fi 36 37if [ "${TESTJAVA}" = "" ] 38then 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." 43fi 44 45# set platform-dependent variables 46OS=`uname -s` 47case "$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 *BSD ) 66 NULL=/dev/null 67 PS=":" 68 FS="/" 69 ${TESTJAVA}${FS}bin${FS}java -version 2>&1 | grep '64-Bit' > $NULL 70 if [ $? -eq '0' ] 71 then 72 ARCH="amd64" 73 else 74 ARCH="i386" 75 fi 76 SYST="bsd" 77 MAKEFILE="Makefile.unix" 78 CC="cc" 79 MAKE="make" 80 LD_LIBRARY_PATH="." 81 ;; 82 SunOS ) 83 NULL=/dev/null 84 PS=":" 85 FS="/" 86 if [ `uname -p | grep -c 'sparc'` -gt '0' ] 87 then 88 ARCH="sparc" 89 else 90 ARCH="i386" 91 fi 92 SYST="solaris" 93 MAKEFILE="Makefile.unix" 94 CC="gcc" 95 MAKE="make" 96 LD_LIBRARY_PATH="." 97 ;; 98 Windows* ) 99 NULL=null 100 PS=";" 101 FS="\\" 102 MAKEFILE="Makefile.win" 103 CC="cl" 104 MAKE="nmake" 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="windows" 113 ;; 114 CYGWIN* ) 115 NULL=/dev/null 116 PS=":" 117 FS="/" 118 MAKEFILE="Makefile.cygwin" 119 CC="gcc" 120 ${TESTJAVA}${FS}bin${FS}java -d64 -version 2>&1 | grep '64-Bit' > $NULL 121 if [ "$?" -eq '0' ] 122 then 123 ARCH="amd64" 124 else 125 ARCH="i386" 126 fi 127 SYST="cygwin" 128 MAKE="make" 129 ;; 130 Darwin ) 131 echo "Test passed. This test is not for MacOS" 132 exit 0; 133 ;; 134 * ) 135 echo "Unrecognized system!" 136 exit 1; 137 ;; 138esac 139 140# Skip unsupported platforms 141case `uname -m` in 142 arm* | ppc* ) 143 echo "Test passed. Not supported on current architecture." 144 exit 0 145 ;; 146esac 147 148echo "OS-ARCH is" ${SYST}-${ARCH} 149${TESTJAVA}${FS}jre${FS}bin${FS}java -fullversion 2>&1 150 151which ${MAKE} >${NULL} 2>&1 152if [ "$?" -ne '0' ] 153then 154 echo "No make found. Test passed." 155 exit 0 156fi 157 158which ${CC} >${NULL} 2>&1 159if [ "$?" -ne '0' ] 160then 161 echo "No C compiler found. Test passed." 162 exit 0 163fi 164case "$OS" in 165 SunOS ) 166 ${CC} -v >${NULL} 2>&1 167 if [ "$?" -ne '0' ] 168 then 169 echo "No C compiler found. Test passed." 170 exit 0 171 fi 172esac 173 174cp ${TESTSRC}${FS}${MAKEFILE} . 175 176JAVA=${TESTJAVA}${FS}jre${FS}bin${FS}java 177JAVAC=${TESTJAVA}${FS}bin${FS}javac 178JAVAH=${TESTJAVA}${FS}bin${FS}javah 179 180export CC SYST ARCH LD_LIBRARY_PATH 181 182${JAVAC} -d . ${TESTSRC}${FS}MyCanvas.java 183${JAVAH} -jni -classpath . -d . MyCanvas 184${MAKE} -f ${MAKEFILE} 185${JAVA} -classpath . MyCanvas 186 187exit $? 188 189