From: Kamalesh Babulal Date: Fri, 5 Jul 2024 09:58:01 +0000 (+0530) Subject: ftests/utils: Add helper to check if output matches X-Git-Tag: v3.2.0~93 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=55720e9b40347c74974ca1b9448414abdd1c575d;p=thirdparty%2Flibcgroup.git ftests/utils: Add helper to check if output matches 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 Signed-off-by: Tom Hromatka --- diff --git a/tests/ftests/utils.py b/tests/ftests/utils.py index 67fdd80e..6dedfd90 100644 --- a/tests/ftests/utils.py +++ b/tests/ftests/utils.py @@ -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: