Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2065899pxu; Sun, 13 Dec 2020 12:26:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJx66Vi1lafx2Cy/TlvVF9FP78LdYOcFmzBxdolG+rHyYKkCSQ4JLslZsR/o/CBOcGWOkwdc X-Received: by 2002:a05:6402:312b:: with SMTP id dd11mr22436723edb.308.1607891188354; Sun, 13 Dec 2020 12:26:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607891188; cv=none; d=google.com; s=arc-20160816; b=AyhH9bYWYZCqBTqvNTEyGyrdKdc2oz3pljhHAhlXjuoGMQ4f3n+U075pqDFLLoXMKV t+IIr1XylBX/Kt1Gq497tdKIPEIxiZ90k6NvgcaHcxR7dGvPCo2eitOiYbBmuBBopx2i 5GY17Wz51ZeKP4GR5bCjqMr+18wIp17pgY9n4Y5FD/7+9zGfoYQRsaKgxQA4Ml52PUTv 6Bhm769E+EePC++/ygTJ6SWTOQ4nrI79+WCt6VKb4yuBqPa1mBJIHPKncM47wOk+KP9k aXZLKwAFmYjcjjKExADSFFaS6rjWJtfMvDv+ENCeFspf9dE+iZ9zWEPeg1IDQ3UARQgG ajfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:sender:dkim-signature; bh=7RMa+XpTrdaOo6hcubARisrgZhZH4+hqcPEO5nMuS64=; b=NzlF10Gqplv4X80y9SSSqH1aQFVjlYzMRUhz7KVdMb648q9NztoB3b4ojr0JVnJIE4 9d7sMM8wum/z/jwABPlZscqVkkwDnfxZgmDVLuT75kJJjThvD5+2virCIb9rSzCz7F6N g2dDRI95t5lNvsr9Rr6sEDBgUupAJe9MlPwiap8OgDzJQHmjGIooR9QtJyAum5j6GoMi nz5lkxtVQyFtsYfMaLNb15J86lLa35m/M5eDZ4DlqtXg49KSJBzMB769ayBY+SoV+7NT goWCrExgTH0MrZ0okOMvsdxZIwBJ3Jdk0L4+iRN1eqnFkeKJ6GHSyaav1/yFrpCKZIDH r29A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Fubqybu4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dj1si8944561edb.346.2020.12.13.12.26.05; Sun, 13 Dec 2020 12:26:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Fubqybu4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437213AbgLKXQs (ORCPT + 99 others); Fri, 11 Dec 2020 18:16:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2407105AbgLKXQS (ORCPT ); Fri, 11 Dec 2020 18:16:18 -0500 Received: from mail-pf1-x449.google.com (mail-pf1-x449.google.com [IPv6:2607:f8b0:4864:20::449]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35561C061793 for ; Fri, 11 Dec 2020 15:15:38 -0800 (PST) Received: by mail-pf1-x449.google.com with SMTP id r15so7230836pfg.5 for ; Fri, 11 Dec 2020 15:15:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=7RMa+XpTrdaOo6hcubARisrgZhZH4+hqcPEO5nMuS64=; b=Fubqybu4uTAPoAwaU2QIHcZOlw3DCHKAG7C9OJUMD6xTX/1dZaqQDro8a5Mq8KrOV0 SqAVbEGTniMITbL4yyzyGFgkNv9rHMrvbKOUN5npZuIGtuo3uBu2z4HwJc26/EkyGVml E3QpzVR1ga9iVkRgQda9H1r9mxXo6DlNwVxjRNoH5RmBOcx/45IrNJvlubWwoVEhMpi6 LbTUOWYZUCUA9VhzYvol9qn3Gsga20i+7ZMnsuyD+6viITQAxJm54Lb5UIp7vCweuwnx ADNQungzo4RXugKKZssmxO4i32pdCO+GlRDyChfHjK7Oi1YxYWnBLkbcFhRFidMMO223 10kA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=7RMa+XpTrdaOo6hcubARisrgZhZH4+hqcPEO5nMuS64=; b=a4+aE5t8keB0wExHTuJEcD7gNBackcOymAWhGhVwkTOMdjrBJfBpuwD7XyDB1U0Xd5 0PTOIJwlBF7/j29dVfXfGs136JTUmGRIuVuwRa3AzsvZAIPknZbWrdDxe1ctIBtLi0QL O1xCDLVEWVawZSZD0F1dNtl8XwVpOp0y9iqIYehhLo4cQlEBP8tA0i25Kzw1HXGJ24x+ JouXYRdxOG1a/CvCdlVwC8s5pWYVTkHpvunuDJ/jGiac8IgFAU9IwtnQi13KSnxhFmS9 LuczdeF5AzNckExRaMsrfJ7C+ED81Z8F1kNv/87dJCW5/BxUCunEVBcVZiddo8pA8HXW Hicg== X-Gm-Message-State: AOAM532G7waUjnumF48+x2x3FzjwjgpS4w30JJhIBwugBPVkYVuPn7xy L5wDIgTK0rVh9sXxZnAhwHSIAUG/srZlXg== Sender: "dlatypov via sendgmr" X-Received: from dlatypov.svl.corp.google.com ([2620:15c:2cd:202:a28c:fdff:fee3:28c6]) (user=dlatypov job=sendgmr) by 2002:a17:90b:fd5:: with SMTP id gd21mr5228649pjb.139.1607728537607; Fri, 11 Dec 2020 15:15:37 -0800 (PST) Date: Fri, 11 Dec 2020 15:15:19 -0800 In-Reply-To: <20201211231520.1654036-1-dlatypov@google.com> Message-Id: <20201211231520.1654036-2-dlatypov@google.com> Mime-Version: 1.0 References: <20201211231520.1654036-1-dlatypov@google.com> X-Mailer: git-send-email 2.29.2.684.gfbc64c5ab5-goog Subject: [PATCH v2 2/3] kunit: tool: fix minor typing issue with None status From: Daniel Latypov To: davidgow@google.com Cc: brendanhiggins@google.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, skhan@linuxfoundation.org, Daniel Latypov Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The code to handle aggregating statuses didn't check that the status actually got set to some non-None value. Default the value to SUCCESS instead of adding a bunch of `is None` checks. This sorta follows the precedent in commit 3fc48259d525 ("kunit: Don't fail test suites if one of them is empty"). Also slightly simplify the code and add type annotations. Signed-off-by: Daniel Latypov Reviewed-by: David Gow --- tools/testing/kunit/kunit_parser.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/tools/testing/kunit/kunit_parser.py b/tools/testing/kunit/kunit_parser.py index 24954bbc9baf..97e070506c31 100644 --- a/tools/testing/kunit/kunit_parser.py +++ b/tools/testing/kunit/kunit_parser.py @@ -12,13 +12,13 @@ from collections import namedtuple from datetime import datetime from enum import Enum, auto from functools import reduce -from typing import Iterator, List, Optional, Tuple +from typing import Iterable, Iterator, List, Optional, Tuple TestResult = namedtuple('TestResult', ['status','suites','log']) class TestSuite(object): def __init__(self) -> None: - self.status = None # type: Optional[TestStatus] + self.status = TestStatus.SUCCESS self.name = '' self.cases = [] # type: List[TestCase] @@ -30,7 +30,7 @@ class TestSuite(object): class TestCase(object): def __init__(self) -> None: - self.status = None # type: Optional[TestStatus] + self.status = TestStatus.SUCCESS self.name = '' self.log = [] # type: List[str] @@ -223,12 +223,11 @@ def parse_ok_not_ok_test_suite(lines: List[str], else: return False -def bubble_up_errors(to_status, status_container_list) -> TestStatus: - status_list = map(to_status, status_container_list) - return reduce(max_status, status_list, TestStatus.SUCCESS) +def bubble_up_errors(statuses: Iterable[TestStatus]) -> TestStatus: + return reduce(max_status, statuses, TestStatus.SUCCESS) def bubble_up_test_case_errors(test_suite: TestSuite) -> TestStatus: - max_test_case_status = bubble_up_errors(lambda x: x.status, test_suite.cases) + max_test_case_status = bubble_up_errors(x.status for x in test_suite.cases) return max_status(max_test_case_status, test_suite.status) def parse_test_suite(lines: List[str], expected_suite_index: int) -> Optional[TestSuite]: @@ -281,8 +280,8 @@ def parse_test_plan(lines: List[str]) -> Optional[int]: else: return None -def bubble_up_suite_errors(test_suite_list: List[TestSuite]) -> TestStatus: - return bubble_up_errors(lambda x: x.status, test_suite_list) +def bubble_up_suite_errors(test_suites: Iterable[TestSuite]) -> TestStatus: + return bubble_up_errors(x.status for x in test_suites) def parse_test_result(lines: List[str]) -> TestResult: consume_non_diagnositic(lines) -- 2.29.2.684.gfbc64c5ab5-goog