hotspot/test/runtime/ErrorHandling/ErrorHandler.java
author alanb
Thu, 01 Dec 2016 15:54:39 +0000
changeset 42309 21f9f3fbc302
parent 40631 ed82623d7831
permissions -rw-r--r--
8170599: compiler/** tests using ToolProvider.getSystemClassLoader failing Reviewed-by: hseigel
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33135
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
     1
/*
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 38152
diff changeset
     2
 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
33135
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
     4
 *
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
     7
 * published by the Free Software Foundation.
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
     8
 *
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    13
 * accompanied this code).
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    14
 *
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    18
 *
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    21
 * questions.
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    22
 */
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    23
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    24
/*
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    25
 * @test
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    26
 * @bug 6888954
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    27
 * @bug 8015884
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    28
 * @summary Exercise HotSpot error handling code by invoking java with
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    29
 *          -XX:ErrorHandlerTest option to cause an error report. Check the results.
38152
80e5da81fb2c 8154258: [TESTBUG] Various serviceability tests fail compilation
dsamersoff
parents: 33135
diff changeset
    30
 * @modules java.base/jdk.internal.misc
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 38152
diff changeset
    31
 * @library /test/lib
33135
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    32
 * @run driver ErrorHandler
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    33
 */
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    34
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 38152
diff changeset
    35
import jdk.test.lib.Platform;
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 38152
diff changeset
    36
import jdk.test.lib.process.ProcessTools;
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 38152
diff changeset
    37
import jdk.test.lib.process.OutputAnalyzer;
33135
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    38
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    39
public class ErrorHandler {
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    40
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    41
    public static OutputAnalyzer runTest(int testcase) throws Exception {
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    42
        return new OutputAnalyzer(
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    43
            ProcessTools.createJavaProcessBuilder(
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    44
            "-XX:-TransmitErrorReport", "-XX:-CreateCoredumpOnCrash", "-XX:ErrorHandlerTest=" + testcase)
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    45
            .start());
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    46
    }
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    47
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    48
    public static void main(String[] args) throws Exception {
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    49
        // Test is only applicable for debug builds
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    50
        if (!Platform.isDebugBuild()) {
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    51
            return;
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    52
        }
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    53
        // Keep this in sync with hotspot/src/share/vm/utilities/debug.cpp
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    54
        int i = 1;
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    55
        String[] strings = {
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    56
            "assert(str == NULL) failed: expected null",
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    57
            "assert(num == 1023 && *str == 'X') failed: num=",
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    58
            "guarantee(str == NULL) failed: expected null",
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    59
            "guarantee(num == 1023 && *str == 'X') failed: num=",
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    60
            "fatal error: expected null",
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    61
            "fatal error: num=",
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    62
            "fatal error: this message should be truncated during formatting",
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    63
            "ChunkPool::allocate",
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    64
            "Error: ShouldNotCall()",
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    65
            "Error: ShouldNotReachHere()",
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    66
            "Error: Unimplemented()"
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    67
        };
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    68
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    69
        String[] patterns = {
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    70
            "(SIGILL|SIGSEGV|EXCEPTION_ACCESS_VIOLATION).* at pc=",
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    71
            "(SIGBUS|SIGSEGV|SIGILL|EXCEPTION_ACCESS_VIOLATION).* at pc="
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    72
        };
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    73
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    74
        for (String s : strings) {
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    75
            runTest(i++).shouldContain(s);
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    76
        }
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    77
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    78
        for (String p : patterns) {
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    79
            runTest(i++).shouldMatch(p);
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    80
        }
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    81
    }
aa536100693c 8134432: [TESTBUG] Rewrite test/runtime/6888954/vmerrors.sh in Java
gtriantafill
parents:
diff changeset
    82
}