From: Tom Hromatka Date: Wed, 10 Feb 2021 20:25:22 +0000 (+0000) Subject: ftests: Clean up handling of bytes vs string X-Git-Tag: v2.0.3~11^2^2~24^2~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=88ccbee8acc65e63ad0287451425f7d8c72703d6;p=thirdparty%2Flibcgroup.git ftests: Clean up handling of bytes vs string The conversion of bytes to string was being done piecemeal within the functional tests. Consolidate these conversions all into one location within the run() method. Signed-off-by: Tom Hromatka --- diff --git a/ftests/cgroup.py b/ftests/cgroup.py index a5ceeb55..e58fcc44 100644 --- a/ftests/cgroup.py +++ b/ftests/cgroup.py @@ -236,7 +236,7 @@ class Cgroup(object): if config.args.container: ret = config.container.run(cmd) else: - ret = Run.run(cmd).decode('ascii') + ret = Run.run(cmd) return ret @@ -372,7 +372,7 @@ class Cgroup(object): if config.args.container: res = config.container.run(cmd) else: - res = Run.run(cmd).decode('ascii') + res = Run.run(cmd) # convert the cgsnapshot stdout to a dict of cgroup objects return Cgroup.snapshot_to_dict(res) diff --git a/ftests/container.py b/ftests/container.py index a944a5dc..efd85d33 100644 --- a/ftests/container.py +++ b/ftests/container.py @@ -148,7 +148,7 @@ class Container(object): else: raise ContainerError('Unsupported command type') - return Run.run(cmd, shell_bool=shell_bool).decode('ascii') + return Run.run(cmd, shell_bool=shell_bool) def start(self): cmd = list() diff --git a/ftests/process.py b/ftests/process.py index cfc4ccdc..74e77e64 100644 --- a/ftests/process.py +++ b/ftests/process.py @@ -71,7 +71,7 @@ class Process(object): if config.args.container: pid = config.container.run(cmd, shell_bool=True) else: - pid = Run.run(cmd, shell_bool=True).decode('ascii') + pid = Run.run(cmd, shell_bool=True) for _pid in pid.splitlines(): self.children_pids.append(_pid) @@ -117,7 +117,7 @@ class Process(object): if config.args.container: ret = config.container.run(cmd) else: - ret = Run.run(cmd).decode('ascii') + ret = Run.run(cmd) for line in ret.splitlines(): # cgroup v1 appears in /proc/{pid}/cgroup like the following: @@ -157,7 +157,7 @@ class Process(object): if config.args.container: ret = config.container.run(cmd) else: - ret = Run.run(cmd).decode('ascii') + ret = Run.run(cmd) for line in ret.splitlines(): # cgroup v2 appears in /proc/{pid}/cgroup like the following: diff --git a/ftests/run.py b/ftests/run.py index 419f38fc..53b4f34c 100644 --- a/ftests/run.py +++ b/ftests/run.py @@ -41,8 +41,8 @@ class Run(object): out, err = subproc.communicate() ret = subproc.returncode - out = out.strip() - err = err.strip() + out = out.strip().decode('ascii') + err = err.strip().decode('ascii') if shell_bool: Log.log_debug(