From andrew.iain.mcdermott at gmail.com Tue Jan 28 18:25:58 2014 From: andrew.iain.mcdermott at gmail.com (Andrew McDermott) Date: Tue, 28 Jan 2014 18:25:58 -0000 Subject: [PATCH] jtreg: handle StringIndexOutOfBoundsException when parsing summary.txt Message-ID: <87lhy0netq.fsf@spicy.frobware.com> # HG changeset patch # User Andrew McDermott # 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 --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); From andrew.iain.mcdermott at gmail.com Tue Jan 28 18:32:40 2014 From: andrew.iain.mcdermott at gmail.com (Andrew McDermott) Date: Tue, 28 Jan 2014 18:32:40 -0000 Subject: [PATCH] jtreg: handle StringIndexOutOfBoundsException when parsing summary.txt Message-ID: <878uu0neit.fsf@spicy.frobware.com> # HG changeset patch # User Andrew McDermott # 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 --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);