From 188b903f13f642c928049d1fcdfefee6e3e070a1 Mon Sep 17 00:00:00 2001 From: Jeny Sadadia Date: Wed, 28 Aug 2024 13:00:44 +0530 Subject: [PATCH] kcidb/oo/__init__: methods for getting fluster tests stats Add `Node.sort_fluster_tests_by_platform` to create a sorted dictionary by platform with its associated passed and failed tests. Add `Node.get_fluster_stats` for getting number of passed and failed tests for all enabled fluster tests per platform. Signed-off-by: Jeny Sadadia --- kcidb/oo/__init__.py | 68 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/kcidb/oo/__init__.py b/kcidb/oo/__init__.py index bd234707..d22c864b 100644 --- a/kcidb/oo/__init__.py +++ b/kcidb/oo/__init__.py @@ -406,6 +406,74 @@ def waived_status_tests(self): waived_status_tests[test.waived][test.status].append(test) return waived_status_tests + def sort_fluster_tests_by_platform(self, passed_tests, failed_tests): + """ + Create a sorted dictionary by platform with its associated passed + and failed tests + + Arguments: + (passed_tests) A list with platform and passed tests for that + platform with the format: [, ] + (failed_tests) A list with platform and failed tests for that + platform with the format: [, ] + + Returns: (sorted_tests) A dictionary with key as a + platform and value as a list consists of passed and failed tests + in a format as the below: + {: [, ]} + """ + sorted_tests = {} + for platform, tests in passed_tests: + sorted_tests[platform] = tests + + for platform, tests in failed_tests: + if platform in sorted_tests.keys(): + sorted_tests[platform] = [sorted_tests[platform], tests] + else: + sorted_tests[platform] = [[], tests] + return sorted_tests + + def get_fluster_stats(self, sorted_tests_by_platform): + """ + Get number of passed and failed tests for all enabled fluster tests + + Argument: (sorted_tests_by_platform) A dictionary with key as a + platform and value as a list consists of passed and failed tests + in a format as the below: + {: [, ]} + + Returns: (final_stats) A dictionary with key as a platform and value + as a list consists of flutser tests stats in a format as the below: + {: [, , + ]} + """ + fluster_tests_mapping = { + "fluster.v4l2.gstreamer_av1": "v4l2-decoder-conformance-av1", + "fluster.v4l2.gstreamer_av1_chromium": + "v4l2-decoder-conformance-av1-chromium-10bit", + "fluster.v4l2.gstreamer_h264": "v4l2-decoder-conformance-h264", + "fluster.v4l2.gstreamer_h264_frext": + "v4l2-decoder-conformance-h264-frext", + "fluster.v4l2.gstreamer_h265": "v4l2-decoder-conformance-h265", + "fluster.v4l2.gstreamer_vp8": "v4l2-decoder-conformance-vp8", + "fluster.v4l2.gstreamer_vp9": "v4l2-decoder-conformance-vp9" + } + final_stats = {} + for platform, tests in sorted_tests_by_platform.items(): + stats = [] + passed = tests[0] + failed = tests[1] + for key, value in fluster_tests_mapping.items(): + matched_passed = [t.path for t in passed + if key in t.path and t.path != key and + t.path != f"{key}.validate-fluster-results"] + matched_failed = [t.path for t in failed + if key in t.path and t.path != key and + t.path != f"{key}.validate-fluster-results"] + stats.append([value, len(matched_passed), len(matched_failed)]) + final_stats[platform] = stats + return final_stats + def __getitem__(self, name): assert isinstance(name, (str, type(None))) return Node(self, name)