Simplify the services test fix

I forgot `script_run` actually returns the exit code. That makes
it easier.
This commit is contained in:
Adam Williamson 2017-01-11 16:03:09 -08:00
parent 641b30ac09
commit 460a6e5439
1 changed files with 7 additions and 6 deletions

View File

@ -9,15 +9,16 @@ sub run {
# dump the systemctl output
assert_script_run "systemctl --failed | tee /tmp/failed.txt";
# if we have 0 failed services, we're good
eval "assert_script_run 'grep \"0 loaded units\" /tmp/failed.txt';";
return unless $@;
my $ret = script_run "grep '0 loaded units' /tmp/failed.txt";
return if $ret == 0;
# if only mcelog failed, that's a soft fail
eval "assert_script_run 'grep \"1 loaded units\" /tmp/failed.txt';";
if ($@) {
die "More than one services failed to start";
$ret = script_run "grep '1 loaded units' /tmp/failed.txt";
if ($ret != 0) {
die "More than one services failed to start";
}
else {
assert_script_run "systemctl is-failed mcelog.service";
# fail if it's something other than mcelog
assert_script_run "systemctl is-failed mcelog.service";
record_soft_failure;
}
}