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 60365A0567; Wed, 16 Nov 2022 14:58:02 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4310040E03; Wed, 16 Nov 2022 14:58:02 +0100 (CET) Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by mails.dpdk.org (Postfix) with ESMTP id C775240DFB for ; Wed, 16 Nov 2022 14:57:59 +0100 (CET) Received: by mail-pf1-f176.google.com with SMTP id y203so17557666pfb.4 for ; Wed, 16 Nov 2022 05:57:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=tpS+skc5iCQxLcTeZLvQhJZfW3Lx3xpjUCzgDP/WuCQ=; b=cWxCu2REdvX13pV6OXsGWAWEn2k67exP4+NHkXl9dqWeYm2IuXbTF84W5xMuC639yc kLFNDMGBPW9KEV5wALdY/nX+yc1ySNysRCX+fbsosBAC0LHjFrFMVNssQno780FFJ8cS b+zqj+fSvViUjcujsaj2Ce/3MphwclNFzGxU0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=tpS+skc5iCQxLcTeZLvQhJZfW3Lx3xpjUCzgDP/WuCQ=; b=WxplgvK9yty9Z+1XUDoDntPARc8Mg0ebdBHgmyTzE+0WL9TxAWfoc6mZRLFGATvkVL SflwtaGH4E+dvYhSgvjSQ2qm/V4uoDLQky5483iVJFCxcIaeNDkZ+KnWzFWc2VF86pJH cxRt56Q6WOPnXzmDzqSplOeMy1fqrjQm6SHn+d6N3VYAllwsp+PWPCLxIfSBd7JsN5PV 7fC67sOhH/d1/3/J8vLa8UC8NXpU+/d6rJJjFJ6+5vC2TbJB8/uY0brw0l1ISh/rbON2 0aerH/8x00fnj4pbaGiCJeRU9mj8CbvkARprh7MK/mPp2jppYAIlxKYr5tRHysdxFx6t S2cQ== X-Gm-Message-State: ANoB5pk5No9Q+17/cmMcI9m8ucczNRPSq7Pdmp9i7Wh2KmPcVjrOahk0 5Hu7HzVzrAU5I+X6D4CpIAg29gPC0OwcOm6zjiifQA== X-Google-Smtp-Source: AA0mqf6+Fur3WiRLEcc7sYU6X4ZbHDu5wXzDMHbkpVdeTouFfwBzD0g+37YYmvaTHVbX0nQRkg4beDUOGraHHumBZm0= X-Received: by 2002:a63:5808:0:b0:476:f6e2:69e5 with SMTP id m8-20020a635808000000b00476f6e269e5mr666561pgb.48.1668607078877; Wed, 16 Nov 2022 05:57:58 -0800 (PST) MIME-Version: 1.0 References: <20220824162454.394285-1-juraj.linkes@pantheon.tech> <20221114165438.1133783-1-juraj.linkes@pantheon.tech> <20221114165438.1133783-8-juraj.linkes@pantheon.tech> In-Reply-To: <20221114165438.1133783-8-juraj.linkes@pantheon.tech> From: Owen Hilyard Date: Wed, 16 Nov 2022 08:57:22 -0500 Message-ID: Subject: Re: [RFC PATCH v2 07/10] dts: add simple stats report To: =?UTF-8?Q?Juraj_Linke=C5=A1?= Cc: thomas@monjalon.net, Honnappa.Nagarahalli@arm.com, lijuan.tu@intel.com, bruce.richardson@intel.com, dev@dpdk.org Content-Type: multipart/alternative; boundary="00000000000035038705ed96dcff" 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 --00000000000035038705ed96dcff Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable You are missing type annotations throughout this. On Mon, Nov 14, 2022 at 11:54 AM Juraj Linke=C5=A1 wrote: > Provide a summary of testcase passed/failed/blocked counts. > > Signed-off-by: Juraj Linke=C5=A1 > --- > 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 =3D getLogger("dts") > result: Result =3D Result() > +test_stats: TestStats =3D TestStats(SETTINGS.output_dir + "/statistics.t= xt") > > > def run_all() -> None: > @@ -29,6 +31,7 @@ def run_all() -> None: > return_code =3D 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 inpu= t. > + """ > + > + def __init__(self, filename): > + self.filename =3D filename > + > + def __add_stat(self, test_result): I think that this should probably be an option of an enum that gets matched over. ex: match test_result: case None: pass case PASSED: self.passed +=3D 1 case FAILED: self.failed +=3D 1 case BLOCKED: self.blocked +=3D 1 case unknown: # log this and throw an error. > + if test_result is not None: > + if test_result[0] =3D=3D "PASSED": > + self.passed +=3D 1 > + if test_result[0] =3D=3D "FAILED": > + self.failed +=3D 1 > + if test_result[0] =3D=3D "BLOCKED": > + self.blocked +=3D 1 > + self.total +=3D 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 =3D self.result.result_for(sut, targ= et, > suite, case) > + if len(test_result): > + self.__add_stat(test_result) > + > + def __write_stats(self): > + sut_nodes =3D self.result.all_suts() > + if len(sut_nodes) =3D=3D 1: > + self.stats_file.write( > + f"dpdk_version =3D > {self.result.current_dpdk_version(sut_nodes[0])}\n" > + ) > + else: > + for sut in sut_nodes: > + dpdk_version =3D self.result.current_dpdk_version(sut) > + self.stats_file.write(f"{sut}.dpdk_version =3D > {dpdk_version}\n") > + self.__count_stats() > + self.stats_file.write(f"Passed =3D {self.passed}\n") > + self.stats_file.write(f"Failed =3D {self.failed}\n") > + self.stats_file.write(f"Blocked =3D {self.blocked}\n") > + rate =3D 0 > + if self.total > 0: > + rate =3D self.passed * 100.0 / self.total > + self.stats_file.write(f"Pass rate =3D {rate:.1f}\n") > + > + def save(self, result): > + self.passed =3D 0 > + self.failed =3D 0 > + self.blocked =3D 0 > + self.total =3D 0 > + self.stats_file =3D open(self.filename, "w+") > + self.result =3D result > + self.__write_stats() > + self.stats_file.close() > -- > 2.30.2 > > --00000000000035038705ed96dcff Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
You are missing type annotations througho= ut this.=C2=A0

On Mon, Nov 14, 2022 at 11:54 AM Juraj Linke=C5=A1 &l= t;juraj.linkes@pantheon.tech> wrote:
Provide a summary of tes= tcase passed/failed/blocked counts.

Signed-off-by: Juraj Linke=C5=A1 <juraj.linkes@pantheon.tech>
---
=C2=A0dts/framework/dts.py=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |=C2=A0= 3 ++
=C2=A0dts/framework/stats_reporter.py | 65 ++++++++++++++++++++++++++++++++= +
=C2=A02 files changed, 68 insertions(+)
=C2=A0create 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 @@
=C2=A0from .exception import DTSError, ReturnCode
=C2=A0from .logger import DTSLOG, getLogger
=C2=A0from .settings import SETTINGS
+from .stats_reporter import TestStats
=C2=A0from .test_result import Result
=C2=A0from .utils import check_dts_python_version

=C2=A0dts_logger: DTSLOG =3D getLogger("dts")
=C2=A0result: Result =3D Result()
+test_stats: TestStats =3D TestStats(SETTINGS.output_dir + "/statistic= s.txt")


=C2=A0def run_all() -> None:
@@ -29,6 +31,7 @@ def run_all() -> None:
=C2=A0 =C2=A0 =C2=A0return_code =3D ReturnCode.NO_ERR
=C2=A0 =C2=A0 =C2=A0global dts_logger
=C2=A0 =C2=A0 =C2=A0global result
+=C2=A0 =C2=A0 global test_stats

=C2=A0 =C2=A0 =C2=A0# check the python version of the server that run dts =C2=A0 =C2=A0 =C2=A0check_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):
+=C2=A0 =C2=A0 """
+=C2=A0 =C2=A0 Generates a small statistics file containing the number of p= assing,
+=C2=A0 =C2=A0 failing and blocked tests. It makes use of a Result instance= as input.
+=C2=A0 =C2=A0 """
+
+=C2=A0 =C2=A0 def __init__(self, filename):
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 self.filename =3D filename
+
+=C2=A0 =C2=A0 def __add_stat(self, test_result):=C2=A0
I think that this should probably be an option of an enum that gets match= ed over. ex:

match test_result:
=C2=A0 =C2=A0 case None:=C2=A0 =C2=A0 =C2=A0 =C2=A0 pass
=C2=A0 =C2=A0 case PASSED:
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 self.passed=C2=A0+=3D 1
=C2=A0 =C2=A0 case F= AILED:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 self.failed=C2=A0+=3D 1
=C2=A0 =C2= =A0 case BLOCKED:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 self.blocked=C2=A0+=3D 1
=C2=A0 =C2=A0 cas= e unknown:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 # log this and throw an error.=C2= =A0
=C2=A0
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 if test_result is not None:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if test_result[0] =3D=3D "P= ASSED":
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self.passed +=3D 1=
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if test_result[0] =3D=3D "F= AILED":
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self.failed +=3D 1=
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if test_result[0] =3D=3D "B= LOCKED":
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self.blocked +=3D = 1
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self.total +=3D 1
+
+=C2=A0 =C2=A0 def __count_stats(self):
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 for sut in self.result.all_suts():
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 for target in self.result.all_ta= rgets(sut):
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 for suite in self.= result.all_test_suites(sut, target):
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 for = case in self.result.all_test_cases(sut, target, suite):
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 test_result =3D self.result.result_for(sut, target, suite, case)=
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 if len(test_result):
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 self.__add_stat(test_result)
+
+=C2=A0 =C2=A0 def __write_stats(self):
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 sut_nodes =3D self.result.all_suts()
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 if len(sut_nodes) =3D=3D 1:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self.stats_file.write(
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 f"dpdk_versio= n =3D {self.result.current_dpdk_version(sut_nodes[0])}\n"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 )
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 else:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 for sut in sut_nodes:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 dpdk_version =3D s= elf.result.current_dpdk_version(sut)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self.stats_file.wr= ite(f"{sut}.dpdk_version =3D {dpdk_version}\n")
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 self.__count_stats()
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 self.stats_file.write(f"Passed=C2=A0 =C2= =A0 =C2=A0=3D {self.passed}\n")
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 self.stats_file.write(f"Failed=C2=A0 =C2= =A0 =C2=A0=3D {self.failed}\n")
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 self.stats_file.write(f"Blocked=C2=A0 =C2= =A0 =3D {self.blocked}\n")
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 rate =3D 0
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 if self.total > 0:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 rate =3D self.passed * 100.0 / s= elf.total
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 self.stats_file.write(f"Pass rate=C2=A0 = =3D {rate:.1f}\n")
+
+=C2=A0 =C2=A0 def save(self, result):
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 self.passed =3D 0
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 self.failed =3D 0
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 self.blocked =3D 0
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 self.total =3D 0
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 self.stats_file =3D open(self.filename, "= w+")
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 self.result =3D result
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 self.__write_stats()
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 self.stats_file.close()
--
2.30.2

--00000000000035038705ed96dcff--