1 #!/bin/sh 2 3 # 4 # Copyright (c) 2004, 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 # 25 26 # @test 27 # @bug 5008759 4998341 5018369 5032476 5060121 5096932 5096931 28 # @run shell ../verifyVariables.sh 29 # @run shell print.sh 30 # @summary test availabilty of print option 31 # @author Joseph D. Darcy 32 33 OS=`uname -s`; 34 case "${OS}" in 35 CYGWIN* ) 36 DIFFOPTS="--strip-trailing-cr" 37 ;; 38 39 * ) 40 ;; 41 esac 42 43 # Compile file directly, without TESTJAVACOPTS 44 # Don't use @build or @compile as these implicitly use jtreg -javacoption values 45 # and it is important that this file be compiled as expected, for later comparison 46 # against a golden file. 47 "${TESTJAVA}/bin/javac" ${TESTTOOLVMOPTS} -d ${TESTCLASSES} ${TESTSRC}/Aggregate.java 48 49 # Construct path to apt executable 50 APT="${TESTJAVA}/bin/apt ${TESTTOOLVMOPTS} \ 51 -print " 52 53 printf "%s\n" "APT = ${APT}" 54 55 PRINT_FILES="${TESTSRC}/MisMatch.java \ 56 ${TESTSRC}/GenClass.java \ 57 ${TESTSRC}/Misc.java \ 58 ${TESTSRC}/Lacuna.java" 59 60 for i in ${PRINT_FILES} 61 do 62 # Delete any existing class file 63 FILENAME=`basename $i .java` 64 rm -f ${FILENAME}.class 65 66 printf "%s\n" "Printing ${i}" 67 ${APT} ${i} 68 69 RESULT=$? 70 case "$RESULT" in 71 0 ) 72 ;; 73 74 * ) 75 echo "Problem printing file ${i}." 76 exit 1 77 esac 78 79 # Verify compilation did not occur 80 if [ -f ${FILENAME}.class ]; then 81 printf "Improper compilation occured for %s.\n" ${i} 82 exit 1 83 fi 84 85 done 86 87 # check for mutliple methods and no static initializer 88 89 ${APT} -XclassesAsDecls -cp ${TESTCLASSES} -print Aggregate > aggregate.txt 90 diff ${DIFFOPTS} aggregate.txt ${TESTSRC}/goldenAggregate.txt 91 92 RESULT=$? 93 case "$RESULT" in 94 0 ) 95 ;; 96 97 * ) 98 echo "Expected output not received" 99 exit 1 100 esac 101 102 exit 0