jdk/test/sun/tools/jcmd/jcmd-big-script.sh
changeset 22459 def24c6b5019
parent 22458 6a74da13c52f
parent 22455 b32e2219736e
child 22473 210fdf11f9df
equal deleted inserted replaced
22458:6a74da13c52f 22459:def24c6b5019
     1 #!/bin/sh
       
     2 
       
     3 #
       
     4 # Copyright (c) 2012, 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 
       
    27 # @test
       
    28 # @bug 7154822
       
    29 # @summary test if we can send a file over 1024 bytes large via jcmd -f
       
    30 # @author David Buck
       
    31 #
       
    32 # @library ../common
       
    33 # @build SimpleApplication ShutdownSimpleApplication
       
    34 # @run shell jcmd-big-script.sh
       
    35 
       
    36 . ${TESTSRC}/../common/CommonSetup.sh
       
    37 . ${TESTSRC}/../common/ApplicationSetup.sh
       
    38 
       
    39 # Start application and use PORTFILE for coordination
       
    40 PORTFILE="${TESTCLASSES}"/shutdown.port
       
    41 startApplication SimpleApplication "${PORTFILE}"
       
    42 
       
    43 failed=0;
       
    44 
       
    45 # -f <script>
       
    46 rm -f jcmd.out 2>/dev/null
       
    47 set +e # even if jcmd fails, we do not want abort the script yet.
       
    48 ${JCMD} -J-XX:+UsePerfData $appJavaPid -f ${TESTSRC}/dcmd-big-script.txt > jcmd.out 2>&1
       
    49 status="$?"
       
    50 set -e
       
    51 if [ "$status" != 0 ]; then
       
    52   echo "jcmd command returned non-zero exit code (status=$status). Failed."
       
    53   failed=1;
       
    54 fi
       
    55 cat jcmd.out
       
    56 set +e # if the test passes, grep will "fail" with an exit code of 1
       
    57 grep Exception jcmd.out > /dev/null 2>&1
       
    58 status="$?"
       
    59 set -e
       
    60 if [ "$status" = 0 ]; then
       
    61   echo "Output of \"jcmd [pid] -f dcmd-big-script.txt\" contains string \"Exception\". Failed."
       
    62   failed=1;
       
    63 fi
       
    64 
       
    65 # clean up
       
    66 rm -f jcmd.out 2>/dev/null
       
    67 stopApplication "${PORTFILE}"
       
    68 waitForApplication
       
    69 
       
    70 exit $failed