changeset 914:0304b5947dcc

jmh-core-it: test different benchmark failure modes, make sure the useful info is printed.
author shade
date Thu, 17 Jul 2014 23:00:23 +0400
parents 3a2a1b06219b
children 99d0e66b7cf4
files jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/EmbeddedThrowExceptionTest.java jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/EmbeddedThrowRuntimeExceptionTest.java jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedExit0Test.java jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedExit1Test.java jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedExit42Test.java jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedHalt1Test.java jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedHalt42Test.java jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedThrowExceptionTest.java jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedThrowRuntimeExceptionTest.java jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/Shared.java jmh-core/src/main/java/org/openjdk/jmh/runner/ForkedMain.java jmh-core/src/main/java/org/openjdk/jmh/util/FileUtils.java
diffstat 12 files changed, 681 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/EmbeddedThrowExceptionTest.java	Thu Jul 17 23:00:23 2014 +0400
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.jmh.it.errors;
+
+import junit.framework.Assert;
+import org.junit.Test;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Warmup;
+import org.openjdk.jmh.it.Fixtures;
+import org.openjdk.jmh.runner.RunnerException;
+import org.openjdk.jmh.util.FileUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.concurrent.TimeUnit;
+
+@Measurement(iterations = 1, time = 10, timeUnit = TimeUnit.MILLISECONDS)
+@Warmup(iterations = 1, time = 10, timeUnit = TimeUnit.MILLISECONDS)
+public class EmbeddedThrowExceptionTest {
+
+    @Benchmark
+    public void bench() throws MyException {
+        throw new MyException("Something wicked");
+    }
+
+    @Test
+    public void test() throws RunnerException, IOException {
+        File output = FileUtils.tempFile("output");
+
+        Shared.doRun(Fixtures.getTestMask(this.getClass()), false, output);
+
+        Collection<String> lines = FileUtils.readAllLines(output);
+        Shared.print(lines);
+
+        Assert.assertTrue(Shared.contains(lines, "MyException"));
+        Assert.assertTrue(Shared.contains(lines, "Something wicked"));
+    }
+
+    public static class MyException extends Exception {
+        public MyException(String s) {
+            super(s);
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/EmbeddedThrowRuntimeExceptionTest.java	Thu Jul 17 23:00:23 2014 +0400
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.jmh.it.errors;
+
+import junit.framework.Assert;
+import org.junit.Test;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Warmup;
+import org.openjdk.jmh.it.Fixtures;
+import org.openjdk.jmh.runner.RunnerException;
+import org.openjdk.jmh.util.FileUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.concurrent.TimeUnit;
+
+@Measurement(iterations = 1, time = 10, timeUnit = TimeUnit.MILLISECONDS)
+@Warmup(iterations = 1, time = 10, timeUnit = TimeUnit.MILLISECONDS)
+public class EmbeddedThrowRuntimeExceptionTest {
+
+    @Benchmark
+    public void bench() {
+        throw new MyException("Something wicked");
+    }
+
+    @Test
+    public void test() throws RunnerException, IOException {
+        File output = FileUtils.tempFile("output");
+
+        Shared.doRun(Fixtures.getTestMask(this.getClass()), false, output);
+
+        Collection<String> lines = FileUtils.readAllLines(output);
+        Shared.print(lines);
+
+        Assert.assertTrue(Shared.contains(lines, "MyException"));
+        Assert.assertTrue(Shared.contains(lines, "Something wicked"));
+    }
+
+    public static class MyException extends RuntimeException {
+        public MyException(String s) {
+            super(s);
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedExit0Test.java	Thu Jul 17 23:00:23 2014 +0400
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.jmh.it.errors;
+
+import junit.framework.Assert;
+import org.junit.Test;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Warmup;
+import org.openjdk.jmh.it.Fixtures;
+import org.openjdk.jmh.runner.RunnerException;
+import org.openjdk.jmh.util.FileUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.concurrent.TimeUnit;
+
+@Measurement(iterations = 1, time = 10, timeUnit = TimeUnit.MILLISECONDS)
+@Warmup(iterations = 1, time = 10, timeUnit = TimeUnit.MILLISECONDS)
+public class ForkedExit0Test {
+
+    @Benchmark
+    public void bench() throws InterruptedException {
+        System.exit(0);
+    }
+
+    @Test
+    public void test() throws RunnerException, IOException {
+        File output = FileUtils.tempFile("output");
+
+        Shared.doRun(Fixtures.getTestMask(this.getClass()), true, output);
+
+        Collection<String> lines = FileUtils.readAllLines(output);
+        Shared.print(lines);
+
+        Assert.assertTrue(Shared.contains(lines, "VM prematurely exited before JMH had finished with it"));
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedExit1Test.java	Thu Jul 17 23:00:23 2014 +0400
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.jmh.it.errors;
+
+import junit.framework.Assert;
+import org.junit.Test;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Warmup;
+import org.openjdk.jmh.it.Fixtures;
+import org.openjdk.jmh.runner.RunnerException;
+import org.openjdk.jmh.util.FileUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.concurrent.TimeUnit;
+
+@Measurement(iterations = 1, time = 10, timeUnit = TimeUnit.MILLISECONDS)
+@Warmup(iterations = 1, time = 10, timeUnit = TimeUnit.MILLISECONDS)
+public class ForkedExit1Test {
+
+    @Benchmark
+    public void bench() throws InterruptedException {
+        System.exit(1);
+    }
+
+    @Test
+    public void test() throws RunnerException, IOException {
+        File output = FileUtils.tempFile("output");
+
+        Shared.doRun(Fixtures.getTestMask(this.getClass()), true, output);
+
+        Collection<String> lines = FileUtils.readAllLines(output);
+        Shared.print(lines);
+
+        Assert.assertTrue(Shared.contains(lines, "forked VM failed with exit code 1"));
+        Assert.assertTrue(Shared.contains(lines, "VM prematurely exited before JMH had finished with it"));
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedExit42Test.java	Thu Jul 17 23:00:23 2014 +0400
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.jmh.it.errors;
+
+import junit.framework.Assert;
+import org.junit.Test;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Warmup;
+import org.openjdk.jmh.it.Fixtures;
+import org.openjdk.jmh.runner.RunnerException;
+import org.openjdk.jmh.util.FileUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.concurrent.TimeUnit;
+
+@Measurement(iterations = 1, time = 10, timeUnit = TimeUnit.MILLISECONDS)
+@Warmup(iterations = 1, time = 10, timeUnit = TimeUnit.MILLISECONDS)
+public class ForkedExit42Test {
+
+    @Benchmark
+    public void bench() throws InterruptedException {
+        System.exit(42);
+    }
+
+    @Test
+    public void test() throws RunnerException, IOException {
+        File output = FileUtils.tempFile("output");
+
+        Shared.doRun(Fixtures.getTestMask(this.getClass()), true, output);
+
+        Collection<String> lines = FileUtils.readAllLines(output);
+        Shared.print(lines);
+
+        Assert.assertTrue(Shared.contains(lines, "forked VM failed with exit code 42"));
+        Assert.assertTrue(Shared.contains(lines, "VM prematurely exited before JMH had finished with it"));
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedHalt1Test.java	Thu Jul 17 23:00:23 2014 +0400
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.jmh.it.errors;
+
+import junit.framework.Assert;
+import org.junit.Test;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Warmup;
+import org.openjdk.jmh.it.Fixtures;
+import org.openjdk.jmh.runner.RunnerException;
+import org.openjdk.jmh.util.FileUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.concurrent.TimeUnit;
+
+@Measurement(iterations = 1, time = 10, timeUnit = TimeUnit.MILLISECONDS)
+@Warmup(iterations = 1, time = 10, timeUnit = TimeUnit.MILLISECONDS)
+public class ForkedHalt1Test {
+
+    @Benchmark
+    public void bench() throws InterruptedException {
+        Runtime.getRuntime().halt(1);
+    }
+
+    @Test
+    public void test() throws RunnerException, IOException {
+        File output = FileUtils.tempFile("output");
+
+        Shared.doRun(Fixtures.getTestMask(this.getClass()), true, output);
+
+        Collection<String> lines = FileUtils.readAllLines(output);
+        Shared.print(lines);
+
+        Assert.assertTrue(Shared.contains(lines, "forked VM failed with exit code 1"));
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedHalt42Test.java	Thu Jul 17 23:00:23 2014 +0400
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.jmh.it.errors;
+
+import junit.framework.Assert;
+import org.junit.Test;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Warmup;
+import org.openjdk.jmh.it.Fixtures;
+import org.openjdk.jmh.runner.RunnerException;
+import org.openjdk.jmh.util.FileUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.concurrent.TimeUnit;
+
+@Measurement(iterations = 1, time = 10, timeUnit = TimeUnit.MILLISECONDS)
+@Warmup(iterations = 1, time = 10, timeUnit = TimeUnit.MILLISECONDS)
+public class ForkedHalt42Test {
+
+    @Benchmark
+    public void bench() throws InterruptedException {
+        Runtime.getRuntime().halt(42);
+    }
+
+    @Test
+    public void test() throws RunnerException, IOException {
+        File output = FileUtils.tempFile("output");
+
+        Shared.doRun(Fixtures.getTestMask(this.getClass()), true, output);
+
+        Collection<String> lines = FileUtils.readAllLines(output);
+        Shared.print(lines);
+
+        Assert.assertTrue(Shared.contains(lines, "forked VM failed with exit code 42"));
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedThrowExceptionTest.java	Thu Jul 17 23:00:23 2014 +0400
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.jmh.it.errors;
+
+import junit.framework.Assert;
+import org.junit.Test;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Warmup;
+import org.openjdk.jmh.it.Fixtures;
+import org.openjdk.jmh.runner.RunnerException;
+import org.openjdk.jmh.util.FileUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.concurrent.TimeUnit;
+
+@Measurement(iterations = 1, time = 10, timeUnit = TimeUnit.MILLISECONDS)
+@Warmup(iterations = 1, time = 10, timeUnit = TimeUnit.MILLISECONDS)
+public class ForkedThrowExceptionTest {
+
+    @Benchmark
+    public void bench() throws MyException {
+        throw new MyException("Something wicked");
+    }
+
+    @Test
+    public void test() throws RunnerException, IOException {
+        File output = FileUtils.tempFile("output");
+
+        Shared.doRun(Fixtures.getTestMask(this.getClass()), true, output);
+
+        Collection<String> lines = FileUtils.readAllLines(output);
+        Shared.print(lines);
+
+        Assert.assertTrue(Shared.contains(lines, "MyException"));
+        Assert.assertTrue(Shared.contains(lines, "Something wicked"));
+    }
+
+    public static class MyException extends Exception {
+        public MyException(String s) {
+            super(s);
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/ForkedThrowRuntimeExceptionTest.java	Thu Jul 17 23:00:23 2014 +0400
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.jmh.it.errors;
+
+import junit.framework.Assert;
+import org.junit.Test;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Warmup;
+import org.openjdk.jmh.it.Fixtures;
+import org.openjdk.jmh.runner.RunnerException;
+import org.openjdk.jmh.util.FileUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.concurrent.TimeUnit;
+
+@Measurement(iterations = 1, time = 10, timeUnit = TimeUnit.MILLISECONDS)
+@Warmup(iterations = 1, time = 10, timeUnit = TimeUnit.MILLISECONDS)
+public class ForkedThrowRuntimeExceptionTest {
+
+    @Benchmark
+    public void bench() {
+        throw new MyException("Something wicked");
+    }
+
+    @Test
+    public void test() throws RunnerException, IOException {
+        File output = FileUtils.tempFile("output");
+
+        Shared.doRun(Fixtures.getTestMask(this.getClass()), true, output);
+
+        Collection<String> lines = FileUtils.readAllLines(output);
+        Shared.print(lines);
+
+        Assert.assertTrue(Shared.contains(lines, "MyException"));
+        Assert.assertTrue(Shared.contains(lines, "Something wicked"));
+    }
+
+    public static class MyException extends RuntimeException {
+        public MyException(String s) {
+            super(s);
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/errors/Shared.java	Thu Jul 17 23:00:23 2014 +0400
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.jmh.it.errors;
+
+import org.openjdk.jmh.runner.Runner;
+import org.openjdk.jmh.runner.RunnerException;
+import org.openjdk.jmh.runner.options.Options;
+import org.openjdk.jmh.runner.options.OptionsBuilder;
+
+import java.io.File;
+import java.util.Collection;
+
+public class Shared {
+
+    static void doRun(String include, boolean forked, File output) throws RunnerException {Options opt = new OptionsBuilder()
+            .include(include)
+            .forks(forked ? 1 : 0)
+            .shouldFailOnError(false)
+            .output(output.getAbsolutePath())
+            .build();
+
+        new Runner(opt).run();
+    }
+
+    static void print(Collection<String> lines) {
+        for (String line : lines) {
+            System.err.println(line);
+        }
+    }
+
+    static boolean contains(Collection<String> lines, String s) {
+        for (String line : lines) {
+            if (line.contains(s)) return true;
+        }
+        return false;
+    }
+
+
+}
--- a/jmh-core/src/main/java/org/openjdk/jmh/runner/ForkedMain.java	Thu Jul 17 21:24:47 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/ForkedMain.java	Thu Jul 17 23:00:23 2014 +0400
@@ -82,8 +82,19 @@
                     @Override
                     public void run() {
                         if (!gracefullyFinished) {
-                            System.err.println("<failure: VM prematurely exited before JMH had finished with it, " +
-                                    "explicit System.exit was called?>");
+                            String msg = "<failure: VM prematurely exited before JMH had finished with it, " +
+                                    "explicit System.exit was called?>";
+                            if (link != null) {
+                                link.getOutStream().println(msg);
+                                try {
+                                    link.pushException(new BenchmarkException(new IllegalStateException(msg)));
+                                } catch (IOException e) {
+                                    // do nothing
+                                }
+                            } else {
+                                // last resort
+                                System.err.println(msg);
+                            }
                         }
 
                         if (link != null) {
@@ -98,7 +109,7 @@
                         // to let host VM know we encountered a problem. This should be done
                         // after the link is flushed and down.
                         if (!gracefullyFinished) {
-                            Runtime.getRuntime().halt(1);
+//                            Runtime.getRuntime().halt(1);
                         }
                     }
                 }
--- a/jmh-core/src/main/java/org/openjdk/jmh/util/FileUtils.java	Thu Jul 17 21:24:47 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/util/FileUtils.java	Thu Jul 17 23:00:23 2014 +0400
@@ -136,6 +136,24 @@
         }
     }
 
+    public static Collection<String> readAllLines(File file) throws IOException {
+        FileInputStream fis = null;
+        try {
+            fis = new FileInputStream(file);
+            BufferedReader reader = new BufferedReader(new InputStreamReader(fis));
+            List<String> lines = new ArrayList<String>();
+            String line;
+            while ((line = reader.readLine()) != null) {
+                lines.add(line);
+            }
+            return lines;
+        } finally {
+            FileUtils.safelyClose(fis);
+        }
+
+    }
+
+
     public static Collection<File> getClasses(File root) {
         Collection<File> result = new ArrayList<File>();