Skip to content

Commit f1fbca0

Browse files
[CAS] Improve llvm-cas-test for error handling
Do not ignore the error if a subprocess crashed when filling the data.
1 parent be199bc commit f1fbca0

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

llvm/tools/llvm-cas-test/llvm-cas-test.cpp

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -225,17 +225,28 @@ static int runOneTest(const char *Argv0) {
225225
Subprocesses.push_back(SP);
226226
}
227227

228-
if (Conf.Settings & CheckTermination) {
229-
for_each(Subprocesses, [](auto &P) {
230-
// Wait 1 second and killed the process.
231-
auto WP = sys::Wait(P, 1);
232-
if (WP.ReturnCode && Verbose)
228+
std::optional<unsigned> Timeout;
229+
// Wait 1 second and killed the process if CheckTermination.
230+
if (Conf.Settings & CheckTermination)
231+
Timeout = 1;
232+
233+
auto HasError = any_of(Subprocesses, [&](auto &P) {
234+
auto WP = sys::Wait(P, Timeout);
235+
if (WP.ReturnCode == 0)
236+
return false;
237+
if ((Conf.Settings & CheckTermination) && WP.ReturnCode == -2) {
238+
if (Verbose)
233239
llvm::errs() << "subprocess killed successfully\n";
234-
});
235-
} else {
236-
for_each(Subprocesses, [](auto &P) { sys::Wait(P, std::nullopt); });
240+
return false;
241+
}
242+
llvm::errs() << "subprocess failed with error code (" << WP.ReturnCode
243+
<< ")\n";
244+
return true;
245+
});
246+
if (HasError) {
247+
llvm::errs() << "end of stress test due to an error in subprocess\n";
248+
return 1;
237249
}
238-
239250
} else {
240251
// in-process fill data.
241252
fillData(CAS, AC, Conf);

0 commit comments

Comments
 (0)