Rather than assuming the existence of the 'service' command, use the
object variable holding the current state of the libvirtd service which
got populated right after we performed the tested action on the service.
---
 scripts/hooks/051-daemon-hook.t | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/scripts/hooks/051-daemon-hook.t b/scripts/hooks/051-daemon-hook.t
index 82cedee..b66dde0 100644
--- a/scripts/hooks/051-daemon-hook.t
+++ b/scripts/hooks/051-daemon-hook.t
@@ -85,7 +85,7 @@ SKIP: {
     ok($hook->compare_log(), "$hook->{name} is invoked correctly while 
$hook->{action} libvirtd");
 
     diag "check if libvirtd is stopped";
-    ok(`service libvirtd status` =~ /stopped|unused|inactive/, "libvirtd is 
stopped");
+    ok($hook->{libvirtd_status} =~ /stopped|unused|inactive/, "libvirtd is 
stopped");
 
     # start libvirtd
     $hook->action('start');
@@ -110,7 +110,7 @@ SKIP: {
     ok($hook->compare_log(), "$hook->{name} is invoked correctly while 
$hook->{action} libvirtd");
 
     diag "check if libvirtd is still running";
-    ok(`service libvirtd status` =~ /running/, "libvirtd is running");
+    ok($hook->{libvirtd_status} =~ /running/, "libvirtd is running");
 
     # restart libvirtd
     $hook->action('restart');
@@ -135,7 +135,7 @@ SKIP: {
     ok($hook->compare_log(), "$hook->{name} is invoked correctly while 
$hook->{action} libvirtd");
 
     diag "check if libvirtd is still running";
-    ok(`service libvirtd status` =~ /running/, "libvirtd is running");
+    ok($hook->{libvirtd_status} =~ /running/, "libvirtd is running");
 
     # reload libvirtd
     $hook->action('reload');
@@ -160,7 +160,7 @@ SKIP: {
     ok($hook->compare_log(), "$hook->{name} is invoked correctly while 
$hook->{action} libvirtd");
 
     diag "check if libvirtd is still running";
-    ok(`service libvirtd status` =~ /running/, "libvirtd is running");
+    ok($hook->{libvirtd_status} =~ /running/, "libvirtd is running");
 
     $hook->cleanup();
 
-- 
2.23.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to