Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/runtime/ErrorHandling/TestOnError.java
32284 views
/*1* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test TestOnError25* @summary Test using -XX:OnError=<cmd>26* @library /testlibrary27* @build TestOnError com.oracle.java.testlibrary.*28* @run main TestOnError29* @bug 807847030*/3132import com.oracle.java.testlibrary.*;3334public class TestOnError {3536public static void main(String[] args) throws Exception {37if (!Platform.isDebugBuild()) {38System.out.println("Test requires a non-product build - skipping");39return;40}4142String msg = "Test Succeeded";4344// Execute the VM so that a45ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(46"-XX:-TransmitErrorReport",47"-XX:ErrorHandlerTest=12", // trigger potential SEGV48"-XX:OnError=echo " + msg,49TestOnError.class.getName());5051OutputAnalyzer output = new OutputAnalyzer(pb.start());5253/* Actual output will include:54#55# -XX:OnError="echo Test Succeeded"56# Executing /bin/sh -c "echo Test Succeeded"...57Test Succeeded5859So we don't want to match on the "# Executing ..." line, and they60both get written to stdout.61*/62output.stdoutShouldMatch("^" + msg); // match start of line only63System.out.println("PASSED");64}65}666768