1# 2# Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. 3# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4# 5# This code is free software; you can redistribute it and/or modify it 6# under the terms of the GNU General Public License version 2 only, as 7# published by the Free Software Foundation. 8# 9# This code is distributed in the hope that it will be useful, but WITHOUT 10# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12# version 2 for more details (a copy is included in the LICENSE file that 13# accompanied this code). 14# 15# You should have received a copy of the GNU General Public License version 16# 2 along with this work; if not, write to the Free Software Foundation, 17# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18# 19# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20# or visit www.oracle.com if you need additional information or have any 21# questions. 22# 23 24 25# @test Test6842838.sh 26# @bug 6842838 27# @summary Test 6842838 64-bit launcher failure due to corrupt jar 28# @compile CreateBadJar.java 29# @run shell Test6842838.sh 30 31set -x 32 33if [ "${TESTJAVA}" = "" ]; then 34 PARENT=`dirname \`which java\`` 35 TESTJAVA=`dirname ${PARENT}` 36 printf "TESTJAVA not set. Test cannot execute. Failed.\n" 37fi 38 39if [ "${TESTCLASSES}" = "" ]; then 40 printf "TESTCLASSES not set. Test cannot execute. Failed.\n" 41 exit 1 42fi 43 44# set platform-dependent variables 45OS=`uname -s` 46case "$OS" in 47 SunOS ) 48 NULL=/dev/null 49 PS=":" 50 FS="/" 51 JAVA_EXE=${TESTJAVA}${FS}bin${FS}java 52 ;; 53 * ) 54 printf "Only testing on solaris 64-bit (use libumem to reliably catch buffer overrun)\n" 55 exit 0; 56 ;; 57esac 58 59if [ ! -x ${JAVA_EXE} ]; then 60 printf "Warning: 64-bit components not installed - skipping test.\n" 61 exit 0 62fi 63 64LIBUMEM=/lib/64/libumem.so 65if [ ! -x ${LIBUMEM} ]; then 66 printf "Warning: libumem not installed - skipping test.\n" 67 exit 0 68fi 69 70BADFILE=newbadjar.jar 71${JAVA_EXE} ${TESTVMOPTS} -version 72${JAVA_EXE} ${TESTVMOPTS} -cp ${TESTCLASSES} CreateBadJar ${BADFILE} "META-INF/MANIFEST.MF" 73LD_PRELOAD=${LIBUMEM} ${JAVA_EXE} -jar ${BADFILE} > test.out 2>&1 74 75grep "Invalid or corrupt jarfile" test.out 76exit $? 77