]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
ftests: Ignore all profiling errors by default
authorTom Hromatka <tom.hromatka@oracle.com>
Mon, 28 Mar 2022 15:32:04 +0000 (09:32 -0600)
committerTom Hromatka <tom.hromatka@oracle.com>
Fri, 1 Apr 2022 14:01:54 +0000 (08:01 -0600)
Move the ignoring of profiling errors in stderr to Run.run().
Previously only Cgroup.__get(), Cgroup.lssubsys(), and
Cgroup.lscgroup() were ignoring profiling errors.  But profiling
errors can be raised in other calls as well.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
ftests/cgroup.py
ftests/run.py

index 75d15b8b647ee259881a9995b5700cc429eea109..9c4fd5cd39f2ccb1e751535cffcf21dd9c4cca85 100644 (file)
@@ -343,13 +343,7 @@ class Cgroup(object):
         if config.args.container:
             ret = config.container.run(cmd)
         else:
-            try:
-                ret = Run.run(cmd)
-            except RunError as re:
-                if 'profiling' in re.stderr:
-                    ret = re.stdout
-                else:
-                    raise re
+            ret = Run.run(cmd)
 
         return ret
 
@@ -820,13 +814,7 @@ class Cgroup(object):
         if config.args.container:
             ret = config.container.run(cmd)
         else:
-            try:
-                ret = Run.run(cmd)
-            except RunError as re:
-                if 'profiling' in re.stderr:
-                    ret = re.stdout
-                else:
-                    raise re
+            ret = Run.run(cmd)
 
         return ret
 
@@ -881,13 +869,7 @@ class Cgroup(object):
         if config.args.container:
             ret = config.container.run(cmd)
         else:
-            try:
-                ret = Run.run(cmd)
-            except RunError as re:
-                if 'profiling' in re.stderr:
-                    ret = re.stdout
-                else:
-                    raise re
+            ret = Run.run(cmd)
 
         return ret
 
index 4ca7ee7bc95e65243774fdcba6cfe5645102e86b..d7e844319d89f9e1dcd764d2a33b8cbb3b8bf3e6 100644 (file)
@@ -12,7 +12,7 @@ import subprocess
 
 class Run(object):
     @staticmethod
-    def run(command, shell_bool=False):
+    def run(command, shell_bool=False, ignore_profiling_errors=True):
         if shell_bool:
             if isinstance(command, str):
                 # nothing to do.  command is already formatted as a string
@@ -48,10 +48,14 @@ class Run(object):
             raise RunError("Command '{}' failed".format(''.join(command)),
                            command, ret, out, err)
         if ret != 0 or len(err) > 0:
-            if err.find('WARNING: cgroup v2 is not fully supported yet') == -1:
+            if err.find('WARNING: cgroup v2 is not fully supported yet') >= 0:
                 # LXD throws the above warning on systems that are fully
                 # running cgroup v2.  Ignore this warning, but fail if any
                 # other warnings/errors are raised
+                pass
+            elif ignore_profiling_errors and err.find('profiling') >= 0:
+                pass
+            else:
                 raise RunError("Command '{}' failed".format(''.join(command)),
                                command, ret, out, err)