@@ -136,11 +136,12 @@ private void addValgrindOutput() throws FileNotFoundException {
136
136
outputs [i ] = "" ;
137
137
}
138
138
139
- Pattern errorPattern = Pattern .compile ("ERROR SUMMARY: ([0-9]+)" );
139
+ Pattern errorPattern = Pattern .compile ("==[0-9]+== ERROR SUMMARY: ([0-9]+)" );
140
140
141
141
String line = scanner .nextLine ();
142
142
int firstPID = parsePID (line );
143
143
parentOutput += "\n " + line ;
144
+ boolean warningLogged = false ;
144
145
while (scanner .hasNextLine ()) {
145
146
line = scanner .nextLine ();
146
147
int pid = parsePID (line );
@@ -150,10 +151,18 @@ private void addValgrindOutput() throws FileNotFoundException {
150
151
if (pid == firstPID ) {
151
152
parentOutput += "\n " + line ;
152
153
} else {
153
- outputs [findIndex (pid , pids )] += "\n " + line ;
154
+ int outputIndex = findIndex (pid , pids );
155
+ if (outputIndex == -1 ) {
156
+ if (!warningLogged ) {
157
+ log .warning ("Valgrind output has more PIDs than the expected (# of test cases + 1)." );
158
+ warningLogged = true ;
159
+ }
160
+ continue ;
161
+ }
162
+ outputs [outputIndex ] += "\n " + line ;
154
163
Matcher m = errorPattern .matcher (line );
155
164
if (m .find ()) {
156
- errors [findIndex ( pid , pids ) ] = Integer .parseInt (m .group (1 ));
165
+ errors [outputIndex ] = Integer .parseInt (m .group (1 ));
157
166
}
158
167
}
159
168
}
@@ -162,7 +171,7 @@ private void addValgrindOutput() throws FileNotFoundException {
162
171
for (int i = 0 ; i < outputs .length ; i ++) {
163
172
if (errors [i ] == 0 ) {
164
173
// Workaround for a bug where any valgrind output is considered a potential error.
165
- outputs [i ] = "" ;
174
+ outputs [i ] = null ;
166
175
}
167
176
tests .get (i ).setValgrindTrace (outputs [i ]);
168
177
}
@@ -178,7 +187,7 @@ private int findIndex(int pid, int[] pids) {
178
187
return i ;
179
188
}
180
189
}
181
- return 0 ;
190
+ return - 1 ;
182
191
}
183
192
184
193
private int parsePID (String line ) {
0 commit comments