From: Tom Hromatka Date: Mon, 28 Mar 2022 15:32:04 +0000 (-0600) Subject: ftests: Ignore all profiling errors by default X-Git-Tag: v3.1.0~308^2~2^2~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3b1c8c054d31ded20414e6947961bfa7770449e5;p=thirdparty%2Flibcgroup.git ftests: Ignore all profiling errors by default 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 Reviewed-by: Kamalesh Babulal --- diff --git a/ftests/cgroup.py b/ftests/cgroup.py index 75d15b8b..9c4fd5cd 100644 --- a/ftests/cgroup.py +++ b/ftests/cgroup.py @@ -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 diff --git a/ftests/run.py b/ftests/run.py index 4ca7ee7b..d7e84431 100644 --- a/ftests/run.py +++ b/ftests/run.py @@ -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)