annotate test/tools/javah/ConstMacroTest.sh @ 387:477c5bf1149c

6876765: javah tests fail on Windows Reviewed-by: darcy
author jjg
date Thu, 27 Aug 2009 18:25:21 -0700
parents 9a66ca7c79fa
children 14735c7932d7
rev   line source
duke@0 1 #!/bin/sh
duke@0 2
duke@0 3 #
duke@0 4 # Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved.
duke@0 5 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@0 6 #
duke@0 7 # This code is free software; you can redistribute it and/or modify it
duke@0 8 # under the terms of the GNU General Public License version 2 only, as
duke@0 9 # published by the Free Software Foundation.
duke@0 10 #
duke@0 11 # This code is distributed in the hope that it will be useful, but WITHOUT
duke@0 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@0 13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@0 14 # version 2 for more details (a copy is included in the LICENSE file that
duke@0 15 # accompanied this code).
duke@0 16 #
duke@0 17 # You should have received a copy of the GNU General Public License version
duke@0 18 # 2 along with this work; if not, write to the Free Software Foundation,
duke@0 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@0 20 #
duke@0 21 # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@0 22 # CA 95054 USA or visit www.sun.com if you need additional information or
duke@0 23 # have any questions.
duke@0 24 #
duke@0 25
duke@0 26 # @test
duke@0 27 #
duke@0 28 # @bug 4786406 4781221 4780341 6214324
duke@0 29
duke@0 30 # Validates rewritten javah handling of class defined constants
duke@0 31 # and ensures that the appropriate macro definitions are placed
duke@0 32 # in the generated header file.
duke@0 33
duke@0 34 if [ "${TESTSRC}" = "" ]
duke@0 35 then
duke@0 36 echo "TESTSRC not set. Test cannot execute. Failed."
duke@0 37 exit 1
duke@0 38 fi
duke@0 39 echo "TESTSRC=${TESTSRC}"
duke@0 40 if [ "${TESTJAVA}" = "" ]
duke@0 41 then
duke@0 42 echo "TESTJAVA not set. Test cannot execute. Failed."
duke@0 43 exit 1
duke@0 44 fi
duke@0 45 echo "TESTJAVA=${TESTJAVA}"
duke@0 46 if [ "${TESTCLASSES}" = "" ]
duke@0 47 then
duke@0 48 echo "TESTCLASSES not set. Test cannot execute. Failed."
duke@0 49 exit 1
duke@0 50 fi
duke@0 51 echo "TESTCLASSES=${TESTCLASSES}"
duke@0 52 echo "CLASSPATH=${CLASSPATH}"
duke@0 53
duke@0 54 EXPECTED_JAVAH_OUT_FILE=SubClassConsts.out
duke@0 55
duke@0 56 # set platform-dependent variables
duke@0 57 OS=`uname -s`
duke@0 58 case "$OS" in
duke@0 59 SunOS | Linux )
duke@0 60 PS=":"
duke@0 61 FS="/"
duke@0 62 ;;
jjg@387 63 CYGWIN* )
jjg@387 64 PS=":"
jjg@387 65 FS="/"
jjg@387 66 DIFFOPTS="--strip-trailing-cr"
jjg@387 67 EXPECTED_JAVAH_OUT_FILE=SubClassConsts.win
jjg@387 68 ;;
duke@0 69 Windows* )
duke@0 70 PS=";"
duke@0 71 FS="\\"
duke@0 72 EXPECTED_JAVAH_OUT_FILE=SubClassConsts.win
duke@0 73 ;;
duke@0 74 * )
duke@0 75 echo "Unrecognized system!"
duke@0 76 exit 1;
duke@0 77 ;;
duke@0 78 esac
duke@0 79
duke@0 80 GENERATED_HEADER_FILE=SubClassConsts.h
duke@0 81 HEADER_FILE_FILTERED=SubClassConsts.h.linefeed-filtered
duke@0 82
duke@0 83 rm -rf SuperClassConsts.class SubClassConsts.class
duke@0 84
duke@0 85 cp "${TESTSRC}${FS}SuperClassConsts.java" .
duke@0 86 cp "${TESTSRC}${FS}SubClassConsts.java" .
duke@0 87
duke@0 88 "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . "${TESTSRC}${FS}SubClassConsts.java"
duke@0 89
duke@0 90 "${TESTJAVA}${FS}bin${FS}javah" ${TESTTOOLVMOPTS} SubClassConsts
duke@0 91
jjg@387 92 diff ${DIFFOPTS} "${TESTSRC}${FS}${EXPECTED_JAVAH_OUT_FILE}" "${GENERATED_HEADER_FILE}"
duke@0 93 result=$?
duke@0 94 rm ${GENERATED_HEADER_FILE}
duke@0 95
duke@0 96 if [ $result -eq 0 ]
duke@0 97 then
duke@0 98 echo "Passed"
duke@0 99 else
duke@0 100 echo "Failed"
duke@0 101 fi
duke@0 102 exit $result