summaryrefslogtreecommitdiff
path: root/jtreg.patch
blob: 5133a27622de5e041bac1bcadf353bbdb6e3acd6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# 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 --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);