From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D7E87A00C4; Mon, 14 Nov 2022 17:55:42 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 50A5C42D47; Mon, 14 Nov 2022 17:54:54 +0100 (CET) Received: from lb.pantheon.sk (lb.pantheon.sk [46.229.239.20]) by mails.dpdk.org (Postfix) with ESMTP id 74E3F42D29 for ; Mon, 14 Nov 2022 17:54:51 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by lb.pantheon.sk (Postfix) with ESMTP id B8AED243083; Mon, 14 Nov 2022 17:54:50 +0100 (CET) X-Virus-Scanned: amavisd-new at siecit.sk Received: from lb.pantheon.sk ([127.0.0.1]) by localhost (lb.pantheon.sk [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9y5M1B_PaRHt; Mon, 14 Nov 2022 17:54:49 +0100 (CET) Received: from entguard.lab.pantheon.local (unknown [46.229.239.141]) by lb.pantheon.sk (Postfix) with ESMTP id 14B5F165617; Mon, 14 Nov 2022 17:54:43 +0100 (CET) From: =?UTF-8?q?Juraj=20Linke=C5=A1?= To: thomas@monjalon.net, Honnappa.Nagarahalli@arm.com, ohilyard@iol.unh.edu, lijuan.tu@intel.com, bruce.richardson@intel.com Cc: dev@dpdk.org, =?UTF-8?q?Juraj=20Linke=C5=A1?= Subject: [RFC PATCH v2 07/10] dts: add simple stats report Date: Mon, 14 Nov 2022 16:54:35 +0000 Message-Id: <20221114165438.1133783-8-juraj.linkes@pantheon.tech> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221114165438.1133783-1-juraj.linkes@pantheon.tech> References: <20220824162454.394285-1-juraj.linkes@pantheon.tech> <20221114165438.1133783-1-juraj.linkes@pantheon.tech> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Provide a summary of testcase passed/failed/blocked counts. Signed-off-by: Juraj Linkeš --- dts/framework/dts.py | 3 ++ dts/framework/stats_reporter.py | 65 +++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 dts/framework/stats_reporter.py diff --git a/dts/framework/dts.py b/dts/framework/dts.py index d606f8de2e..a7c243a5c3 100644 --- a/dts/framework/dts.py +++ b/dts/framework/dts.py @@ -14,11 +14,13 @@ from .exception import DTSError, ReturnCode from .logger import DTSLOG, getLogger from .settings import SETTINGS +from .stats_reporter import TestStats from .test_result import Result from .utils import check_dts_python_version dts_logger: DTSLOG = getLogger("dts") result: Result = Result() +test_stats: TestStats = TestStats(SETTINGS.output_dir + "/statistics.txt") def run_all() -> None: @@ -29,6 +31,7 @@ def run_all() -> None: return_code = ReturnCode.NO_ERR global dts_logger global result + global test_stats # check the python version of the server that run dts check_dts_python_version() diff --git a/dts/framework/stats_reporter.py b/dts/framework/stats_reporter.py new file mode 100644 index 0000000000..a2735d0a1d --- /dev/null +++ b/dts/framework/stats_reporter.py @@ -0,0 +1,65 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2010-2014 Intel Corporation +# Copyright(c) 2022 PANTHEON.tech s.r.o. + +""" +Simple text file statistics generator +""" + + +class TestStats(object): + """ + Generates a small statistics file containing the number of passing, + failing and blocked tests. It makes use of a Result instance as input. + """ + + def __init__(self, filename): + self.filename = filename + + def __add_stat(self, test_result): + if test_result is not None: + if test_result[0] == "PASSED": + self.passed += 1 + if test_result[0] == "FAILED": + self.failed += 1 + if test_result[0] == "BLOCKED": + self.blocked += 1 + self.total += 1 + + def __count_stats(self): + for sut in self.result.all_suts(): + for target in self.result.all_targets(sut): + for suite in self.result.all_test_suites(sut, target): + for case in self.result.all_test_cases(sut, target, suite): + test_result = self.result.result_for(sut, target, suite, case) + if len(test_result): + self.__add_stat(test_result) + + def __write_stats(self): + sut_nodes = self.result.all_suts() + if len(sut_nodes) == 1: + self.stats_file.write( + f"dpdk_version = {self.result.current_dpdk_version(sut_nodes[0])}\n" + ) + else: + for sut in sut_nodes: + dpdk_version = self.result.current_dpdk_version(sut) + self.stats_file.write(f"{sut}.dpdk_version = {dpdk_version}\n") + self.__count_stats() + self.stats_file.write(f"Passed = {self.passed}\n") + self.stats_file.write(f"Failed = {self.failed}\n") + self.stats_file.write(f"Blocked = {self.blocked}\n") + rate = 0 + if self.total > 0: + rate = self.passed * 100.0 / self.total + self.stats_file.write(f"Pass rate = {rate:.1f}\n") + + def save(self, result): + self.passed = 0 + self.failed = 0 + self.blocked = 0 + self.total = 0 + self.stats_file = open(self.filename, "w+") + self.result = result + self.__write_stats() + self.stats_file.close() -- 2.30.2