1 #!/bin/sh
   2 
   3 # Copyright (c) 2012, 2020, 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 # @key headful
  26 # @bug 7190587
  27 # @summary Tests Java AWT native interface library
  28 # @author kshefov
  29 # @run shell JAWT.sh
  30 
  31 # NB: To run on Windows with MKS and Visual Studio compiler
  32 # add the following options to jtreg: -e INCLUDE="%INCLUDE%;." -e LIB="%LIB%;."
  33 
  34 if [ "${TESTSRC}" = "" ]
  35 then TESTSRC=.
  36 fi
  37 
  38 if [ "${TESTJAVA}" = "" ]
  39 then
  40   PARENT=`dirname \`which java\``
  41   TESTJAVA=`dirname ${PARENT}`
  42   echo "TESTJAVA not set, selecting " ${TESTJAVA}
  43   echo "If this is incorrect, try setting the variable manually."
  44 fi
  45 
  46 # set platform-dependent variables
  47 OS=`uname -s`
  48 case "$OS" in
  49   Linux )
  50     NULL=/dev/null
  51     PS=":"
  52     FS="/"
  53     ${TESTJAVA}${FS}bin${FS}java -version 2>&1 | grep '64-Bit' > $NULL
  54     if [ $? -eq '0' ]
  55     then
  56         ARCH="amd64"
  57     else
  58         ARCH="i386"
  59     fi
  60     SYST="linux"
  61     MAKEFILE="Makefile.unix"
  62     CC="gcc"
  63         MAKE="make"
  64         LD_LIBRARY_PATH="."
  65     ;;
  66   AIX )
  67       echo "Test passed. Not supported on AIX."
  68       exit 0
  69     ;;
  70   Windows* )
  71     NULL=null
  72     PS=";"
  73     FS="\\"
  74     MAKEFILE="Makefile.win"
  75     CC="cl"
  76         MAKE="nmake"
  77         ${TESTJAVA}${FS}bin${FS}java -version 2>&1 | grep '64-Bit' > $NULL
  78     if [ "$?" -eq '0' ]
  79     then
  80         ARCH="amd64"
  81     else
  82         ARCH="i386"
  83     fi
  84         SYST="windows"
  85     ;;
  86   CYGWIN* )
  87     NULL=/dev/null
  88     PS=":"
  89     FS="/"
  90     MAKEFILE="Makefile.cygwin"
  91     CC="gcc"
  92         ${TESTJAVA}${FS}bin${FS}java -version 2>&1 | grep '64-Bit' > $NULL
  93     if [ "$?" -eq '0' ]
  94     then
  95         ARCH="amd64"
  96     else
  97         ARCH="i386"
  98     fi
  99         SYST="cygwin"
 100         MAKE="make"
 101     ;;
 102   Darwin )
 103     echo "Test passed. This test is not for MacOS."
 104     exit 0;
 105     ;;
 106   * )
 107     echo "Unrecognized system!"
 108     exit 1;
 109     ;;
 110 esac
 111 
 112 # Skip unsupported platforms
 113 case `uname -m` in
 114     arm* | ppc* | s390* )
 115       echo "Test passed. Not supported on current architecture."
 116       exit 0
 117       ;;
 118 esac
 119 
 120 echo "OS-ARCH is" ${SYST}-${ARCH}
 121 ${TESTJAVA}${FS}bin${FS}java -fullversion 2>&1
 122 
 123 which ${MAKE} >${NULL} 2>&1
 124 if [ "$?" -ne '0' ]
 125 then
 126     echo "No make found. Test passed."
 127     exit 0
 128 fi
 129 
 130 which ${CC} >${NULL} 2>&1
 131 if [ "$?" -ne '0' ]
 132 then
 133     echo "No C compiler found. Test passed."
 134     exit 0
 135 fi
 136 
 137 cp ${TESTSRC}${FS}${MAKEFILE} .
 138 
 139 JAVA=${TESTJAVA}${FS}bin${FS}java
 140 JAVAC=${TESTJAVA}${FS}bin${FS}javac
 141 
 142 export CC SYST ARCH LD_LIBRARY_PATH
 143 
 144 ${JAVAC} -d . -h . ${TESTSRC}${FS}MyCanvas.java
 145 ${MAKE} -f ${MAKEFILE}
 146 ${JAVA} ${TESTVMOPTS} -classpath . MyCanvas
 147 
 148 exit $?
 149