From 354665bb5a417f3b233ee40a3989ce9cf2680373 Mon Sep 17 00:00:00 2001 From: Ayush Jain Date: Sat, 12 Apr 2025 11:23:21 +0000 Subject: [PATCH 1/3] Print final count summary after test run Adds a final count summary at the end of the test run, displaying the total number of tests and their statuses (e.g., PASS, FAILURES, SKIP). Example output: Final count summary for tests run: TOTAL 4 PASS 2 CANCEL 2 ERRORS 0 FAILURES 0 SKIP 0 WARN 0 INTERRUPT 0 Signed-off-by: Ayush Jain --- avocado-setup.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/avocado-setup.py b/avocado-setup.py index bde34a5c..1c930526 100644 --- a/avocado-setup.py +++ b/avocado-setup.py @@ -24,7 +24,7 @@ import argparse import configparser import binascii - +from enum import Enum from lib.logger import logger_init from lib import helper @@ -56,6 +56,17 @@ pipManager = None +class Result(Enum): + Testcount = "Total" + Pass = "pass" + Cancel = "cancel" + Error = "errors" + Failures = "failures" + Skip = "skip" + Warn = "warn" + Interrupt ="interrupt" + +count_result = { _.value : 0 for _ in Result} class TestSuite(): """ Class for Testsuite @@ -396,8 +407,10 @@ def run_test(testsuite, avocado_bin, nrunner): result_link += "/job.log\n" with open(result_json, encoding="utf-8") as filep: result_state = json.load(filep) - for state in ['pass', 'cancel', 'errors', 'failures', 'skip', 'warn', 'interrupt']: + for state in count_result: if state in result_state.keys(): + count_result[Result.Testcount.value] += int(result_state[state]) + count_result[state] += int(result_state[state]) result_link += "| %s %s |" % (state.upper(), str(result_state[state])) testsuite.runstatus("Run", "Successfully executed", result_link) @@ -782,6 +795,11 @@ def parse_test_config(test_config_file, avocado_bin, enable_kvm): 10), Testsuites[test_suite].runsummary)) summary_output.append(Testsuites[test_suite].runlink) + + summary_output.append("\nFinal count summary for tests run:\n") + for k, val in count_result.items(): + summary_output.append('%s %s' % (k.upper().ljust(20), val)) + logger.info("\n".join(summary_output)) if os.path.isdir("/tmp/mux/"): From 48076f4f134e814564075cc8c70565bc744f63a8 Mon Sep 17 00:00:00 2001 From: Ayush Jain Date: Sat, 12 Apr 2025 12:44:22 +0000 Subject: [PATCH 2/3] Add summary of testsuites ran There are following possible testsuite run status "Run" "Not_Run" "Cant_Run" Print summary of testsuites post completion Examples Output: TestSuite TestRun Summary host_sanity_test_linsched Run Successfully executed /home/Avocadotests/results/job-2025-04-12T13.29-b585cfe/job.log | PASS 1 || CANCEL 0 || ERRORS 0 || FAILURES 0 || SKIP 0 || WARN 0 || INTERRUPT 0 | host_sanity_test_numactl_Numactl_test_localalloc_numa_fc Run Successfully executed /home/Avocadotests/results/job-2025-04-12T13.29-6d7be4d/job.log | PASS 0 || CANCEL 1 || ERRORS 0 || FAILURES 0 || SKIP 0 || WARN 0 || INTERRUPT 0 | host_sanity_test2_sanity_test2 Not_Run Command execution failed host_sanity_test3 Cant_Run Config file not present Test suites status: TOTAL 4 RUN 2 NOT_RUN 1 CANT_RUN 1 Signed-off-by: Ayush Jain --- avocado-setup.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/avocado-setup.py b/avocado-setup.py index 1c930526..2824849e 100644 --- a/avocado-setup.py +++ b/avocado-setup.py @@ -66,7 +66,15 @@ class Result(Enum): Warn = "warn" Interrupt ="interrupt" +class Testsuite_status(Enum): + Total = "Total" + Run = "Run" + Not_Run = "Not_Run" + Cant_Run = "Cant_Run" + count_result = { _.value : 0 for _ in Result} +count_testsuites_status = { _.value : 0 for _ in Testsuite_status} + class TestSuite(): """ Class for Testsuite @@ -394,11 +402,13 @@ def run_test(testsuite, avocado_bin, nrunner): status = int(bin(int(status))[2:].zfill(16)[:-8], 2) if status >= 2: testsuite.runstatus("Not_Run", "Command execution failed") + count_testsuites_status[Testsuite_status.Not_Run.value] += 1 return except Exception as error: logger.error("Running testsuite %s failed with error\n%s", testsuite.name, error) testsuite.runstatus("Not_Run", "Command execution failed") + count_testsuites_status[Testsuite_status.Not_Run.value] += 1 return logger.info('') result_link = testsuite.jobdir() @@ -414,8 +424,10 @@ def run_test(testsuite, avocado_bin, nrunner): result_link += "| %s %s |" % (state.upper(), str(result_state[state])) testsuite.runstatus("Run", "Successfully executed", result_link) + count_testsuites_status[Testsuite_status.Run.value] += 1 else: testsuite.runstatus("Not_Run", "Unable to find job log file") + count_testsuites_status[Testsuite_status.Not_Run.value] += 1 return @@ -741,6 +753,8 @@ def parse_test_config(test_config_file, avocado_bin, enable_kvm): use_test_dir=args.testdir) Testsuites[test_suite].runstatus("Cant_Run", "Config file not present") + count_testsuites_status[Testsuite_status.Cant_Run.value] += 1 + Testsuites_list.append(test_suite) continue for test in test_list: for l_key in ['mux', 'args']: @@ -763,8 +777,10 @@ def parse_test_config(test_config_file, avocado_bin, enable_kvm): if not Testsuites[test_suite].config(): Testsuites[test_suite].runstatus("Cant_Run", "Config file not present") + count_testsuites_status[Testsuite_status.Cant_Run.value] += 1 continue # Run Tests + count_testsuites_status[Testsuite_status.Total.value] = len(Testsuites_list) for test_suite in Testsuites_list: if not Testsuites[test_suite].run == "Cant_Run": run_test(Testsuites[test_suite], avocado_bin, args.nrunner) @@ -796,6 +812,10 @@ def parse_test_config(test_config_file, avocado_bin, enable_kvm): Testsuites[test_suite].runsummary)) summary_output.append(Testsuites[test_suite].runlink) + summary_output.append("\nTest suites status:\n") + for k, val in count_testsuites_status.items(): + summary_output.append('%s %s' % (k.upper().ljust(20), val)) + summary_output.append("\nFinal count summary for tests run:\n") for k, val in count_result.items(): summary_output.append('%s %s' % (k.upper().ljust(20), val)) From 3e028bf3431fbb8e5da45e9b63866ee5cd9004b5 Mon Sep 17 00:00:00 2001 From: Ayush Jain Date: Sat, 12 Apr 2025 13:50:31 +0000 Subject: [PATCH 3/3] Use Testsuite_status enum instead of hardcoded status strings Replaced all direct string usages of test suite run statuses ("Run", "Not_Run", "Cant_Run") with their corresponding Testsuite_status enum values for consistency and improved type safety. Signed-off-by: Ayush Jain --- avocado-setup.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/avocado-setup.py b/avocado-setup.py index 2824849e..3b47aa04 100644 --- a/avocado-setup.py +++ b/avocado-setup.py @@ -94,7 +94,7 @@ def __init__(self, name, resultdir, vt_type, test=None, mux=None, args=None, self.test = test self.mux = mux self.args = args - self.run = "Not_Run" + self.run = Testsuite_status.Not_Run.value self.runsummary = None self.runlink = None if use_test_dir: @@ -401,13 +401,13 @@ def run_test(testsuite, avocado_bin, nrunner): status = os.system(cmd) status = int(bin(int(status))[2:].zfill(16)[:-8], 2) if status >= 2: - testsuite.runstatus("Not_Run", "Command execution failed") + testsuite.runstatus(Testsuite_status.Not_Run.value, "Command execution failed") count_testsuites_status[Testsuite_status.Not_Run.value] += 1 return except Exception as error: logger.error("Running testsuite %s failed with error\n%s", testsuite.name, error) - testsuite.runstatus("Not_Run", "Command execution failed") + testsuite.runstatus(Testsuite_status.Not_Run.value, "Command execution failed") count_testsuites_status[Testsuite_status.Not_Run.value] += 1 return logger.info('') @@ -423,10 +423,10 @@ def run_test(testsuite, avocado_bin, nrunner): count_result[state] += int(result_state[state]) result_link += "| %s %s |" % (state.upper(), str(result_state[state])) - testsuite.runstatus("Run", "Successfully executed", result_link) + testsuite.runstatus(Testsuite_status.Run.value, "Successfully executed", result_link) count_testsuites_status[Testsuite_status.Run.value] += 1 else: - testsuite.runstatus("Not_Run", "Unable to find job log file") + testsuite.runstatus(Testsuite_status.Not_Run.value, "Unable to find job log file") count_testsuites_status[Testsuite_status.Not_Run.value] += 1 return @@ -751,7 +751,7 @@ def parse_test_config(test_config_file, avocado_bin, enable_kvm): Testsuites[test_suite] = TestSuite(test_suite, outputdir, args.vt_type, use_test_dir=args.testdir) - Testsuites[test_suite].runstatus("Cant_Run", + Testsuites[test_suite].runstatus(Testsuite_status.Cant_Run.value, "Config file not present") count_testsuites_status[Testsuite_status.Cant_Run.value] += 1 Testsuites_list.append(test_suite) @@ -775,14 +775,14 @@ def parse_test_config(test_config_file, avocado_bin, enable_kvm): use_test_dir=args.testdir) Testsuites_list.append(str(test_suite)) if not Testsuites[test_suite].config(): - Testsuites[test_suite].runstatus("Cant_Run", + Testsuites[test_suite].runstatus(Testsuite_status.Cant_Run.value, "Config file not present") count_testsuites_status[Testsuite_status.Cant_Run.value] += 1 continue # Run Tests count_testsuites_status[Testsuite_status.Total.value] = len(Testsuites_list) for test_suite in Testsuites_list: - if not Testsuites[test_suite].run == "Cant_Run": + if not Testsuites[test_suite].run == Testsuite_status.Cant_Run.value: run_test(Testsuites[test_suite], avocado_bin, args.nrunner) if args.interval: time.sleep(int(args.interval))