annotate test/tools/javah/MissingParamClassTest.sh @ 1218:d8e7e2ccbd41

7130704: Few of the jtreg tests need to be ported for mac builds Reviewed-by: ohair
author jjh
date Tue, 24 Jan 2012 10:24:42 -0800
parents 9d9f26857129
children d7efb58d0dfd
rev   line source
duke@0 1 #!/bin/sh
duke@0 2
duke@0 3 #
ohair@590 4 # Copyright (c) 2003, 2009, Oracle and/or its affiliates. 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 #
ohair@590 21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@590 22 # or visit www.oracle.com if you need additional information or have any
ohair@590 23 # questions.
duke@0 24 #
duke@0 25
duke@0 26 # @test
duke@0 27 #
duke@0 28 # @bug 4942232
duke@0 29
duke@0 30 #
duke@0 31 # Verifies that javah won't attempt to generate a header file
duke@0 32 # if a native method in a supplied class contains a parameter
duke@0 33 # type whose corresponding class is missing or not in the
duke@0 34 # classpath
duke@0 35
duke@0 36 TMP1=OUTPUT.txt
duke@0 37
duke@0 38 if [ "${TESTSRC}" = "" ]
duke@0 39 then
duke@0 40 echo "TESTSRC not set. Test cannot execute. Failed."
duke@0 41 exit 1
duke@0 42 fi
duke@0 43 echo "TESTSRC=${TESTSRC}"
duke@0 44 if [ "${TESTJAVA}" = "" ]
duke@0 45 then
duke@0 46 echo "TESTJAVA not set. Test cannot execute. Failed."
duke@0 47 exit 1
duke@0 48 fi
duke@0 49 echo "TESTJAVA=${TESTJAVA}"
duke@0 50 if [ "${TESTCLASSES}" = "" ]
duke@0 51 then
duke@0 52 echo "TESTCLASSES not set. Test cannot execute. Failed."
duke@0 53 exit 1
duke@0 54 fi
duke@0 55 echo "TESTCLASSES=${TESTCLASSES}"
duke@0 56 echo "CLASSPATH=${CLASSPATH}"
duke@0 57
duke@0 58 # set platform-dependent variables
duke@0 59 OS=`uname -s`
duke@0 60 case "$OS" in
jjh@1218 61 SunOS | Linux | Darwin | CYGWIN* )
duke@0 62 PS=":"
duke@0 63 FS="/"
duke@0 64 ;;
duke@0 65 Windows* )
duke@0 66 PS=";"
duke@0 67 FS="\\"
duke@0 68 ;;
duke@0 69 * )
duke@0 70 echo "Unrecognized system!"
duke@0 71 exit 1;
duke@0 72 ;;
duke@0 73 esac
duke@0 74
duke@0 75 GENERATED_HEADER_FILE=ParamClassTest.h
duke@0 76
duke@0 77 rm -f ParamClassTest.class MissingParamClassException.class ParamClassTest.h
duke@0 78 rm -f ${TMP1}
duke@0 79
jjg@438 80 "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . "${TESTSRC}${FS}ParamClassTest.java" "${TESTSRC}${FS}MissingParamClassException.java"
duke@0 81
duke@0 82 # Before running javah remove dependent class file
duke@0 83 rm -f MissingParamClassException.class
duke@0 84
duke@0 85 "${TESTJAVA}${FS}bin${FS}javah" ${TESTTOOLVMOPTS} ParamClassTest 2>${TMP1}
duke@0 86
duke@0 87 if [ -f $GENERATED_HEADER_FILE ]; then
jjg@438 88 echo "1-- Failed: $GENERATED_HEADER_FILE found"
jjg@438 89 rc=1
duke@0 90 fi
jjg@438 91 if [ ! -s ${TMP1} ]; then
jjg@438 92 echo "1-- Failed: ${TMP1} is empty"
jjg@438 93 rc=1
duke@0 94 fi
duke@0 95
duke@0 96 # Clean out work dir
duke@0 97 rm -f MissingParamClassException.class ParamClassTest.class
duke@0 98 rm -f $GENERATED_HEADER_FILE $TMP1
duke@0 99
duke@0 100 # Re-compile everything
jjg@438 101
jjg@438 102 "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . "${TESTSRC}${FS}ParamClassTest.java" "${TESTSRC}${FS}MissingParamClassException.java"
jjg@438 103
duke@0 104
duke@0 105 # Before re-run of javah remove dependent class file Param.class
duke@0 106 rm -f Param.class
duke@0 107
duke@0 108 "${TESTJAVA}${FS}bin${FS}javah" ${TESTTOOLVMOPTS} ParamClassTest 2>${TMP1}
duke@0 109
duke@0 110 if [ -f $GENERATED_HEADER_FILE ]; then
jjg@438 111 echo "2-- Failed: $GENERATED_HEADER_FILE found"
jjg@438 112 rc=1
duke@0 113 fi
jjg@438 114 if [ ! -s ${TMP1} ]; then
jjg@438 115 echo "2-- Failed: ${TMP1} is empty"
jjg@438 116 rc=1
jjg@438 117 fi
jjg@438 118
jjg@438 119 if [ "$rc" = "" ]; then
jjg@438 120 echo Passed
duke@0 121 else
jjg@438 122 echo Failed
jjg@438 123 exit 1
duke@0 124 fi