test/hotspot/jtreg/vmTestbase/heapdump/JMapMetaspaceCore/run.sh
author iignatyev
Tue, 15 May 2018 11:28:29 -0700
changeset 50112 7a2a740815b7
permissions -rw-r--r--
8202392: [TESTBUG] open source vm testbase heapdump tests Reviewed-by: sspitsyn, mseledtsov
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50112
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
     1
#!/bin/sh
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
     2
#
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
     3
# Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
     4
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
     5
#
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
     6
# This code is free software; you can redistribute it and/or modify it
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
     7
# under the terms of the GNU General Public License version 2 only, as
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
     8
# published by the Free Software Foundation.
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
     9
#
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    10
# This code is distributed in the hope that it will be useful, but WITHOUT
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    11
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    12
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    13
# version 2 for more details (a copy is included in the LICENSE file that
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    14
# accompanied this code).
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    15
#
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    16
# You should have received a copy of the GNU General Public License version
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    17
# 2 along with this work; if not, write to the Free Software Foundation,
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    18
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    19
#
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    20
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    21
# or visit www.oracle.com if you need additional information or have any
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    22
# questions.
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    23
#
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    24
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    25
. $TESTSRC/../share/common.sh
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    26
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    27
JAVA_OPTS="${JAVA_OPTS} -XX:-UseGCOverheadLimit -XX:MaxMetaspaceSize=64m -XX:-TransmitErrorReport"
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    28
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    29
if [ $CORE_SUPPORTED -eq 0 ]; then
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    30
        pass "Core dump is not supported"
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    31
fi
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    32
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    33
DUMPFILE=heap.bin
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    34
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    35
rm -f ${DUMPFILE}
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    36
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    37
ulimit -c unlimited || true
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    38
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    39
echo "Below 'Unexpected error' is actually expected - JVM is forced to dump core"
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    40
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    41
${JAVA} ${JAVA_OPTS} heapdump.share.EatMemory -metaspace -core &
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    42
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    43
pid=$!
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    44
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    45
wait $pid
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    46
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    47
status=$?
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    48
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    49
if [ $status -eq 0 ]; then
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    50
        pass "Java exited with exit status: $status"
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    51
fi
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    52
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    53
for CORE in core* /cores/core.$pid; do
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    54
        [ -e "$CORE" ] && break;
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    55
done
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    56
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    57
if [ ! -f "$CORE" ]; then
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    58
        fail "Java exited with exit status $status, but core file was not created"
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    59
fi
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    60
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    61
echo "Found core file: $CORE"
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    62
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    63
JMAP_DUMP_OPT="--binaryheap --dumpfile=${DUMPFILE}"
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    64
EXE_OPT="--exe"
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    65
CORE_OPT="--core"
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    66
JHSDB_OPT="jmap"
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    67
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    68
${JHSDB} ${JHSDB_OPT} ${JMAP_DUMP_OPT} ${EXE_OPT} ${JAVA} ${CORE_OPT} ${CORE}
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    69
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    70
status=$?
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    71
if [ $status -ne 0 ]; then
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    72
        fail "jmap exited with exit status $status"
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    73
fi
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    74
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    75
if [ ! -f "${DUMPFILE}" ]; then
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    76
        fail "Dump file was not created: $DUMPFILE"
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    77
fi
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    78
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    79
verify_heapdump ${DUMPFILE}
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    80
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    81
if [ $? -ne 0 ]; then
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    82
        fail "Verification of heap dump failed"
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    83
fi
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    84
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    85
if [ "$TEST_CLEANUP" != "false" ]; then
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    86
        rm -f ${CORE}
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    87
        rm -f hs_err_pid*
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    88
fi
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    89
7a2a740815b7 8202392: [TESTBUG] open source vm testbase heapdump tests
iignatyev
parents:
diff changeset
    90
pass