]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
ftests: Clean up handling of bytes vs string
authorTom Hromatka <tom.hromatka@oracle.com>
Wed, 10 Feb 2021 20:25:22 +0000 (20:25 +0000)
committerTom Hromatka <tom.hromatka@oracle.com>
Mon, 1 Mar 2021 17:16:50 +0000 (10:16 -0700)
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 <tom.hromatka@oracle.com>
ftests/cgroup.py
ftests/container.py
ftests/process.py
ftests/run.py

index a5ceeb55b081ccf63b87702799dd1872dac1d45a..e58fcc44fc1bd82b1b58c3119f0650f40ffc5028 100644 (file)
@@ -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)
index a944a5dc584389e04915bec6ef53e79380772f35..efd85d33ed15e737fe75956595b62ef2ff1b163d 100644 (file)
@@ -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()
index cfc4ccdc505b967c668d28f354a8bd28a35dc25d..74e77e6454ee7d60809712f03deebe97733ce7b6 100644 (file)
@@ -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:
index 419f38fce78116071c0c718c23f4b43b76deca4f..53b4f34c257d7cc815b23f0a260e008541f4787f 100644 (file)
@@ -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(