test/hotspot/jtreg/runtime/ErrorHandling/TestOnError.java
author mikael
Wed, 29 Aug 2018 13:04:50 -0700
changeset 51579 d7fc38d3fc8d
parent 51287 7b1ddbafa134
permissions -rw-r--r--
8209856: Obsolete error reporter Reviewed-by: coleenp, stuefe
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
30745
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
     1
/*
51287
7b1ddbafa134 8208655: use JTreg skipped status in hotspot tests
iignatyev
parents: 47815
diff changeset
     2
 * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
30745
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
     4
 *
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
     7
 * published by the Free Software Foundation.
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
     8
 *
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
    13
 * accompanied this code).
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
    14
 *
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
    18
 *
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
    21
 * questions.
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
    22
 */
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
    23
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
    24
/*
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
    25
 * @test TestOnError
51287
7b1ddbafa134 8208655: use JTreg skipped status in hotspot tests
iignatyev
parents: 47815
diff changeset
    26
 * @bug 8078470
30745
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
    27
 * @summary Test using -XX:OnError=<cmd>
38152
80e5da81fb2c 8154258: [TESTBUG] Various serviceability tests fail compilation
dsamersoff
parents: 31789
diff changeset
    28
 * @modules java.base/jdk.internal.misc
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 38152
diff changeset
    29
 * @library /test/lib
51287
7b1ddbafa134 8208655: use JTreg skipped status in hotspot tests
iignatyev
parents: 47815
diff changeset
    30
 * @requires vm.debug
30745
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
    31
 * @run main TestOnError
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
    32
 */
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
    33
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 38152
diff changeset
    34
import jdk.test.lib.process.ProcessTools;
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 38152
diff changeset
    35
import jdk.test.lib.process.OutputAnalyzer;
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 38152
diff changeset
    36
import jdk.test.lib.Platform;
30745
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
    37
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
    38
public class TestOnError {
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
    39
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
    40
    public static void main(String[] args) throws Exception {
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
    41
        String msg = "Test Succeeded";
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
    42
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
    43
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
31789
c8c579616fc8 8080733: [TESTBUG] several runtime/ErrorHandling/* tests time out on Windows
ctornqvi
parents: 30745
diff changeset
    44
           "-XX:-CreateCoredumpOnCrash",
30745
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
    45
           "-XX:ErrorHandlerTest=12", // trigger potential SEGV
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
    46
           "-XX:OnError=echo " + msg,
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
    47
           TestOnError.class.getName());
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
    48
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
    49
        OutputAnalyzer output = new OutputAnalyzer(pb.start());
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
    50
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
    51
        /* Actual output will include:
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
    52
           #
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
    53
           # -XX:OnError="echo Test Succeeded"
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
    54
           #   Executing /bin/sh -c "echo Test Succeeded"...
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
    55
           Test Succeeded
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
    56
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
    57
           So we don't want to match on the "# Executing ..." line, and they
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
    58
           both get written to stdout.
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
    59
        */
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
    60
        output.stdoutShouldMatch("^" + msg); // match start of line only
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
    61
        System.out.println("PASSED");
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
    62
    }
8ebe80838174 8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
diff changeset
    63
}