]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
ftests/systemd: add method to check if systemd support
authorTom Hromatka <tom.hromatka@oracle.com>
Wed, 6 Dec 2023 15:37:44 +0000 (15:37 +0000)
committerTom Hromatka <tom.hromatka@oracle.com>
Thu, 7 Dec 2023 15:58:13 +0000 (08:58 -0700)
Add a method to check if libcgroup is compiled with --enable-systemd
support. The newly introduced is_systemd_enabled(), calls systemd C
function is_systemd_enabled(), that return true if configured with
--enable-systemd, false otherwise.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
tests/ftests/systemd.py

index 826f3c4032c9ed900bc83cf306b2374e9bee47b8..dd339fbf9b170e8f5b030633b164a283445adbf3 100644 (file)
@@ -6,8 +6,9 @@
 # Author: Tom Hromatka <tom.hromatka@oracle.com>
 #
 
+from cgroup import Cgroup as CgroupCli
 from run import Run, RunError
-from cgroup import Cgroup
+from libcgroup import Cgroup
 import os
 
 
@@ -70,7 +71,12 @@ class Systemd(object):
         # In case the error occurs before the creation of slice/scope and
         # we may very well be on the teardown path, ignore the exception
         try:
-            Cgroup.delete(config, controller, cgname=_slice, ignore_systemd=True)
+            CgroupCli.delete(config, controller, cgname=_slice, ignore_systemd=True)
         except RunError as re:
             if 'No such file or directory' not in re.stderr:
                 raise re
+
+    # Check if libcgroup is compiled with --enable-systemd
+    @staticmethod
+    def is_systemd_enabled():
+        return Cgroup.is_systemd_enabled()