test/tools/javah/MissingParamClassTest.sh

Thu, 25 Aug 2011 17:18:25 -0700

author
schien
date
Thu, 25 Aug 2011 17:18:25 -0700
changeset 1067
f497fac86cf9
parent 554
9d9f26857129
child 1223
f3743b82945e
permissions
-rw-r--r--

Added tag jdk8-b02 for changeset b3c059de2a61

     1 #!/bin/sh
     3 #
     4 # Copyright (c) 2003, 2009, Oracle and/or its affiliates. All rights reserved.
     5 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     6 #
     7 # This code is free software; you can redistribute it and/or modify it
     8 # under the terms of the GNU General Public License version 2 only, as
     9 # published by the Free Software Foundation.
    10 #
    11 # This code is distributed in the hope that it will be useful, but WITHOUT
    12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    13 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    14 # version 2 for more details (a copy is included in the LICENSE file that
    15 # accompanied this code).
    16 #
    17 # You should have received a copy of the GNU General Public License version
    18 # 2 along with this work; if not, write to the Free Software Foundation,
    19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    20 #
    21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    22 # or visit www.oracle.com if you need additional information or have any
    23 # questions.
    24 #
    26 # @test	
    27 #
    28 # @bug 4942232
    30 #
    31 # Verifies that javah won't attempt to generate a header file
    32 # if a native method in a supplied class contains a parameter
    33 # type whose corresponding class is missing or not in the 
    34 # classpath
    36 TMP1=OUTPUT.txt
    38 if [ "${TESTSRC}" = "" ]
    39 then
    40   echo "TESTSRC not set.  Test cannot execute.  Failed."
    41   exit 1
    42 fi
    43 echo "TESTSRC=${TESTSRC}"
    44 if [ "${TESTJAVA}" = "" ]
    45 then
    46   echo "TESTJAVA not set.  Test cannot execute.  Failed."
    47   exit 1
    48 fi
    49 echo "TESTJAVA=${TESTJAVA}"
    50 if [ "${TESTCLASSES}" = "" ]
    51 then
    52   echo "TESTCLASSES not set.  Test cannot execute.  Failed."
    53   exit 1
    54 fi
    55 echo "TESTCLASSES=${TESTCLASSES}"
    56 echo "CLASSPATH=${CLASSPATH}"
    58 # set platform-dependent variables
    59 OS=`uname -s`
    60 case "$OS" in
    61   SunOS | Linux | CYGWIN* )
    62     PS=":"
    63     FS="/"
    64     ;;
    65   Windows* )
    66     PS=";"
    67     FS="\\"
    68     ;;
    69   * )
    70     echo "Unrecognized system!"
    71     exit 1;
    72     ;;
    73  esac
    75 GENERATED_HEADER_FILE=ParamClassTest.h
    77 rm -f ParamClassTest.class MissingParamClassException.class ParamClassTest.h
    78 rm -f ${TMP1}
    80 "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . "${TESTSRC}${FS}ParamClassTest.java" "${TESTSRC}${FS}MissingParamClassException.java"
    82 # Before running javah remove dependent class file
    83 rm -f MissingParamClassException.class 
    85 "${TESTJAVA}${FS}bin${FS}javah" ${TESTTOOLVMOPTS} ParamClassTest 2>${TMP1}
    87 if [ -f $GENERATED_HEADER_FILE ]; then
    88      echo "1-- Failed: $GENERATED_HEADER_FILE found"
    89      rc=1
    90 fi
    91 if [ ! -s ${TMP1} ]; then
    92      echo "1-- Failed: ${TMP1} is empty"
    93      rc=1
    94 fi
    96 # Clean out work dir
    97 rm -f MissingParamClassException.class ParamClassTest.class
    98 rm -f $GENERATED_HEADER_FILE $TMP1 
   100 # Re-compile everything
   102 "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . "${TESTSRC}${FS}ParamClassTest.java" "${TESTSRC}${FS}MissingParamClassException.java"
   105 # Before re-run of javah remove dependent class file Param.class 
   106 rm -f Param.class
   108 "${TESTJAVA}${FS}bin${FS}javah" ${TESTTOOLVMOPTS} ParamClassTest 2>${TMP1}
   110 if [ -f $GENERATED_HEADER_FILE ]; then
   111      echo "2-- Failed: $GENERATED_HEADER_FILE found"
   112      rc=1
   113 fi
   114 if [ ! -s ${TMP1} ]; then
   115      echo "2-- Failed: ${TMP1} is empty"
   116      rc=1
   117 fi
   119 if [ "$rc" = "" ]; then
   120     echo Passed
   121 else
   122     echo Failed
   123     exit 1
   124 fi

mercurial