From 460a6e5439c883d034c16c22e653c02abc4c0425 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Wed, 11 Jan 2017 16:03:09 -0800 Subject: [PATCH] Simplify the services test fix I forgot `script_run` actually returns the exit code. That makes it easier. --- tests/base_services_start.pm | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/base_services_start.pm b/tests/base_services_start.pm index bfc8134f..30daeb5c 100644 --- a/tests/base_services_start.pm +++ b/tests/base_services_start.pm @@ -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; } }