DPDK patches and discussions
 help / color / mirror / Atom feed
From: Dean Marx <dmarx@iol.unh.edu>
To: probb@iol.unh.edu, npratte@iol.unh.edu, luca.vizzarro@arm.com,
	yoan.picchi@foss.arm.com, Honnappa.Nagarahalli@arm.com,
	paul.szczepanek@arm.com
Cc: dev@dpdk.org, Dean Marx <dmarx@iol.unh.edu>
Subject: [PATCH v2] dts: fix pass rate edge case in results json
Date: Wed, 15 Jan 2025 10:43:45 -0500	[thread overview]
Message-ID: <20250115154345.23790-1-dmarx@iol.unh.edu> (raw)
In-Reply-To: <20250113215230.13942-1-dmarx@iol.unh.edu>

Add condition to results.json pass rate generation
method which returns 0 as the pass rate when the suite
is skipped, rather than causing a divide by 0 error.

Fixes: 9f8a257235ac ("dts: improve test run result statistics")

Signed-off-by: Dean Marx <dmarx@iol.unh.edu>
---
 dts/framework/test_result.py | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/dts/framework/test_result.py b/dts/framework/test_result.py
index ba7c1c9804..45fc2e8241 100644
--- a/dts/framework/test_result.py
+++ b/dts/framework/test_result.py
@@ -324,13 +324,10 @@ def generate_pass_rate_dict(self, test_run_summary) -> dict[str, float]:
         Returns:
             A dictionary with the PASS/FAIL ratio of all test cases.
         """
-        return {
-            "PASS_RATE": (
-                float(test_run_summary[Result.PASS.name])
-                * 100
-                / sum(test_run_summary[result.name] for result in Result if result != Result.SKIP)
-            )
-        }
+        cases_not_skipped = sum(
+            test_run_summary[result.name] for result in Result if result != Result.SKIP
+        )
+        return {"PASS_RATE": test_run_summary[Result.PASS.name] * 100.0 / max(cases_not_skipped, 1)}
 
 
 class DTSResult(BaseResult):
-- 
2.44.0


  parent reply	other threads:[~2025-01-15 15:43 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-13 21:52 [PATCH v1] " Dean Marx
2025-01-15 10:10 ` Luca Vizzarro
2025-01-15 15:23   ` Dean Marx
2025-01-15 15:31   ` Dean Marx
2025-01-15 15:41     ` Dean Marx
2025-01-15 16:28       ` Luca Vizzarro
2025-01-15 15:43 ` Dean Marx [this message]
2025-01-15 16:30   ` [PATCH v2] " Luca Vizzarro

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250115154345.23790-1-dmarx@iol.unh.edu \
    --to=dmarx@iol.unh.edu \
    --cc=Honnappa.Nagarahalli@arm.com \
    --cc=dev@dpdk.org \
    --cc=luca.vizzarro@arm.com \
    --cc=npratte@iol.unh.edu \
    --cc=paul.szczepanek@arm.com \
    --cc=probb@iol.unh.edu \
    --cc=yoan.picchi@foss.arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).