JAWT.sh revision 8729:0242fce0f717
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 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 ;; 121esac 122 123# Skip unsupported platforms 124case `uname -m` in 125 arm* | ppc* ) 126 echo "Test passed. Not supported on current architecture." 127 exit 0 128 ;; 129esac 130 131echo "OS-ARCH is" ${SYST}-${ARCH} 132${TESTJAVA}${FS}jre${FS}bin${FS}java -fullversion 2>&1 133 134which ${MAKE} >${NULL} 2>&1 135if [ "$?" -ne '0' ] 136then 137 echo "No make found. Test passed." 138 exit 0 139fi 140 141which ${CC} >${NULL} 2>&1 142if [ "$?" -ne '0' ] 143then 144 echo "No C compiler found. Test passed." 145 exit 0 146fi 147case "$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 155esac 156 157cp ${TESTSRC}${FS}${MAKEFILE} . 158 159JAVA=${TESTJAVA}${FS}jre${FS}bin${FS}java 160JAVAC=${TESTJAVA}${FS}bin${FS}javac 161JAVAH=${TESTJAVA}${FS}bin${FS}javah 162 163export 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 170exit $? 171 172