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 2CFA24608F; Wed, 15 Jan 2025 11:10:19 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EAA704025F; Wed, 15 Jan 2025 11:10:18 +0100 (CET) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mails.dpdk.org (Postfix) with ESMTP id E62334003C for ; Wed, 15 Jan 2025 11:10:17 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8267912FC; Wed, 15 Jan 2025 02:10:45 -0800 (PST) Received: from [10.1.39.16] (JR4XG4HTQC.cambridge.arm.com [10.1.39.16]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DC4E43F51B; Wed, 15 Jan 2025 02:10:15 -0800 (PST) Message-ID: Date: Wed, 15 Jan 2025 10:10:14 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1] dts: fix pass rate edge case in results json To: Dean Marx , probb@iol.unh.edu, npratte@iol.unh.edu, yoan.picchi@foss.arm.com, Honnappa.Nagarahalli@arm.com, paul.szczepanek@arm.com Cc: dev@dpdk.org References: <20250113215230.13942-1-dmarx@iol.unh.edu> Content-Language: en-GB From: Luca Vizzarro In-Reply-To: <20250113215230.13942-1-dmarx@iol.unh.edu> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 Hi Dean, good timing! I actually noticed this issue last week and was going to tackle it soon. On 13/01/2025 21:52, Dean Marx wrote: > @@ -324,13 +324,15 @@ 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 > + ) > + if cases_not_skipped == 0: > + return {"PASS_RATE": 0.0} > + else: > + return { > + "PASS_RATE": (float(test_run_summary[Result.PASS.name]) * 100 / cases_not_skipped) > + } The solution feels a bit overcomplicated, you can just throw a max(sum(..), 1), so: ran_tests = 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(ran_tests, 1) } also while you are at it, changing the 100 to 100.0 will spare us from writing a longer float(..) expression.