]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
ftests: Clean up a few exceptions
authorTom Hromatka <tom.hromatka@oracle.com>
Mon, 1 Mar 2021 16:37:38 +0000 (16:37 +0000)
committerTom Hromatka <tom.hromatka@oracle.com>
Mon, 1 Mar 2021 16:37:38 +0000 (16:37 +0000)
In the ftests and process files, two exceptions were
erroneously throwing ValueException rather than
ValueError.  Fix this.

In CgroupVersion.get_version(), it returned CGROUP_UNK
if it couldn't determine the version.  Make this method
more pythonic by raising a ValueError exception.

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

index b32bbbf0dd44ed903e28b3f64d169b6fecc63b0f..a5ceeb55b081ccf63b87702799dd1872dac1d45a 100644 (file)
@@ -51,7 +51,7 @@ class CgroupVersion(Enum):
                             if ctrl == controller:
                                 return CgroupVersion.CGROUP_V2
 
-        return CgroupVersion.CGROUP_UNK
+        raise IndexError("Unknown version for controller {}".format(controller))
 
 class Cgroup(object):
     # This class is analogous to libcgroup's struct cgroup
index e2efb7b52b3a1e79f19156d25062ee94cf7738c8..db18dc990663ecfcf58cfd00d5ddc84a9743715b 100755 (executable)
@@ -234,7 +234,7 @@ def run_tests(config):
                         elif ret == consts.TEST_SKIPPED:
                             skipped_tests.append([filename, run_time, failure_cause])
                         else:
-                            raise ValueException('Unexpected ret: {}'.format(ret))
+                            raise ValueError('Unexpected ret: {}'.format(ret))
 
     passed_cnt = len(passed_tests)
     failed_cnt = len(failed_tests)
index 9fa456e82ae0a20896b3cfdeff823ff4ec2ff46d..cfc4ccdc505b967c668d28f354a8bd28a35dc25d 100644 (file)
@@ -81,7 +81,7 @@ class Process(object):
                 pid = pid.splitlines()[1]
 
         if pid == "" or int(pid) <= 0:
-            raise ValueException('Failed to get the pid of the child process: {}'.format(pid))
+            raise ValueError('Failed to get the pid of the child process: {}'.format(pid))
 
         self.children.append(p)
         return pid