]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
ftests/utils: Add helper to check if output matches
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Fri, 5 Jul 2024 09:58:01 +0000 (15:28 +0530)
committerTom Hromatka <tom.hromatka@oracle.com>
Wed, 17 Jul 2024 21:26:47 +0000 (15:26 -0600)
Add a helper to check if the output from the controller(s), matches the
expected controller(s) output. It returns True/False and None in case
of matching output, a line that doesn't match in differing output.

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

index 67fdd80e771dbd9e82b9a9d83c50760eb93ceae6..6dedfd9091de6f4691f4e5e76383e4757722e12d 100644 (file)
@@ -87,4 +87,21 @@ def get_kernel_version(config):
     kernel_version = kernel_version_str.split('.')[0:3]
     return kernel_version
 
+
+# match if both outputs are same
+def is_output_same(config, out, expected_out):
+    result = True
+    cause = None
+
+    for line_num, line in enumerate(out.splitlines()):
+        if line.strip() != expected_out.splitlines()[line_num].strip():
+            cause = (
+                    'Expected line:\n\t{}\nbut received line:\n\t{}'
+                    ''.format(expected_out.splitlines()[line_num].strip(), line.strip())
+                    )
+            result = False
+
+    return result, cause
+
+
 # vim: set et ts=4 sw=4: