changeset 56:49d5be2f6189

Absorb the VM failure in the logs.
author shade
date Thu, 03 Oct 2013 15:00:30 +0400
parents c4ebc9b5ea9d
children 69bc1543d446
files harness/src/main/java/org/openjdk/jcstress/JCStress.java harness/src/main/java/org/openjdk/jcstress/infra/collectors/TestResult.java harness/src/main/java/org/openjdk/jcstress/infra/grading/ConsoleReportPrinter.java
diffstat 3 files changed, 30 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/harness/src/main/java/org/openjdk/jcstress/JCStress.java	Thu Oct 03 14:56:19 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/JCStress.java	Thu Oct 03 15:00:30 2013 +0400
@@ -54,6 +54,7 @@
 import org.openjdk.jcstress.util.InputStreamDrainer;
 import org.openjdk.jcstress.util.Reflections;
 
+import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.IOException;
 import java.io.PrintStream;
@@ -183,22 +184,27 @@
             Collection<String> commandString = getSeparateExecutionCommand(opts, test.getName());
             Process p = Runtime.getRuntime().exec(commandString.toArray(new String[commandString.size()]));
 
-            InputStreamDrainer errDrainer = new InputStreamDrainer(p.getErrorStream(), out);
-            InputStreamDrainer outDrainer = new InputStreamDrainer(p.getInputStream(), out);
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+            InputStreamDrainer errDrainer = new InputStreamDrainer(p.getErrorStream(), baos);
+            InputStreamDrainer outDrainer = new InputStreamDrainer(p.getInputStream(), baos);
 
             errDrainer.start();
             outDrainer.start();
 
             int ecode = p.waitFor();
 
+            errDrainer.join();
+            outDrainer.join();
+
             if (ecode != 0) {
                 // Test had failed, record this.
-                collector.add(new TestResult(test.getName(), Status.VM_ERROR));
+                TestResult result = new TestResult(test.getName(), Status.VM_ERROR);
+                String s = new String(baos.toByteArray()).trim();
+                result.addAuxData(s);
+                collector.add(result);
             }
 
-            errDrainer.join();
-            outDrainer.join();
-
         } catch (IOException ex) {
             ex.printStackTrace();
         } catch (InterruptedException ex) {
--- a/harness/src/main/java/org/openjdk/jcstress/infra/collectors/TestResult.java	Thu Oct 03 14:56:19 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/collectors/TestResult.java	Thu Oct 03 15:00:30 2013 +0400
@@ -29,8 +29,10 @@
 import org.openjdk.jcstress.util.Environment;
 
 import java.io.Serializable;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 
@@ -46,12 +48,14 @@
     private final Map<State, State> states;
     private volatile Environment env;
     private final Status status;
+    private final List<String> auxData;
 
     public TestResult(String name, Status status) {
         this.vmID = VM_ID;
         this.name = name;
         this.status = status;
         this.states = new HashMap<State, State>();
+        this.auxData = new ArrayList<String>();
     }
 
     public void addState(Object result, long count) {
@@ -63,6 +67,10 @@
         states.put(ns, ns);
     }
 
+    public void addAuxData(String data) {
+        auxData.add(data);
+    }
+
     public void setEnv(Environment e) {
         env = e;
     }
@@ -86,4 +94,8 @@
     public String getVmID() {
         return vmID;
     }
+
+    public List<String> getAuxData() {
+        return auxData;
+    }
 }
--- a/harness/src/main/java/org/openjdk/jcstress/infra/grading/ConsoleReportPrinter.java	Thu Oct 03 14:56:19 2013 +0400
+++ b/harness/src/main/java/org/openjdk/jcstress/infra/grading/ConsoleReportPrinter.java	Thu Oct 03 15:00:30 2013 +0400
@@ -124,7 +124,13 @@
                 printLine(output, "CHECK ERROR", r);
                 return;
             case VM_ERROR:
+                output.println();
                 printLine(output, "VM ERROR", r);
+                List<String> auxData = r.getAuxData();
+                for (String data : auxData) {
+                    output.println(data);
+                }
+                output.println();
                 return;
             case API_MISMATCH:
                 printLine(output, "SKIPPED", r);