diff mbox

jtreg: handle StringIndexOutOfBoundsException when parsing summary.txt

Message ID 87zjmgnfek.fsf@spicy.frobware.com
State New
Headers show

Commit Message

frobware Jan. 28, 2014, 6:13 p.m. UTC
# HG changeset patch
# User Andrew McDermott <andrew.mcdermott@linaro.org>
# Date 1390932496 0
# Node ID 2f0c51ac5a7313e2199c412e02e0532627409ea3
# Parent  e08a5e0b79ba57743222bbea19c0bdb142968769
jtreg: handle StringIndexOutOfBoundsException when parsing summary.txt

Handle a case where a badly formatted summary.txt causes a
StringIndexOutOfBoundsException to be generated. This can happen when
the format in the summary.txt file has additional lines of output from
a failed test.

A real-world example is as follows:

runtime/8026365/InvokeSpecialAnonTest.java                                   Passed. Execution successful
runtime/8026394/InterfaceObjectTest.java                                     Passed. Execution successful
runtime/CDSCompressedKPtrs/CDSCompressedKPtrsError.java                      Passed. Execution successful
runtime/ClassFile/JsrRewriting.java Failed. Execution failed: `main' [...elided...]
java.lang.LinkageError
java.lang.NoSuchMethodError
Main method not found in class OOMCrashClass4000_1
runtime/ClassFile/OomWhileParsingRepeatedJsr.java                            Failed. Execution failed: `main' threw exception: java.lang.RuntimeException: 'Cannot reserve enough memory' missing from stdout/stderr
runtime/ClassUnload/KeepAliveClass.java                                      Passed. Execution successful
runtime/ClassUnload/KeepAliveClassLoader.java                                Passed. Execution successful
diff mbox

Patch

diff --git a/src/share/classes/com/sun/javatest/diff/Diff.java b/src/share/classes/com/sun/javatest/diff/Diff.java
--- a/src/share/classes/com/sun/javatest/diff/Diff.java
+++ b/src/share/classes/com/sun/javatest/diff/Diff.java
@@ -75,7 +75,9 @@ 
                 int[] counts = new int[Status.NUM_STATES];
                 for (TestResult tr: r) {
                     table.addRow(index, tr.getTestName(), tr);
-                    counts[tr.getStatus().getType()]++;
+		    if (tr.getStatus() != null) {
+			    counts[tr.getStatus().getType()]++;
+		    }
                 }
                 testCounts.add(counts);
             }
diff --git a/src/share/classes/com/sun/javatest/diff/ReportReader.java b/src/share/classes/com/sun/javatest/diff/ReportReader.java
--- a/src/share/classes/com/sun/javatest/diff/ReportReader.java
+++ b/src/share/classes/com/sun/javatest/diff/ReportReader.java
@@ -105,8 +105,8 @@ 
             String line;
             while ((line = in.readLine()) != null) {
                 int sp = line.indexOf(' ');
-                String t = line.substring(0, sp);
-                Status s = Status.parse(line.substring(sp).trim());
+                String t = line.substring(0, sp == -1 ? line.length() : sp);
+                Status s = Status.parse(line.substring(sp == -1 ? line.length() : sp).trim());
                 TestDescription td = new TestDescription(root, new File(t), Collections.emptyMap());
                 TestResult tr = new TestResult(td, s);
                 list.add(tr);