Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp684762pxu; Thu, 7 Jan 2021 15:50:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJyYbf7OqS0RqO7RMFnb3N5qMSQij7K/vk+5l4zqZN3KQae4vFMM6yyH/VBv5vi0dbru156s X-Received: by 2002:a50:b742:: with SMTP id g60mr3312719ede.113.1610063427012; Thu, 07 Jan 2021 15:50:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610063427; cv=none; d=google.com; s=arc-20160816; b=NP/w+FGaRnHG7PUCyBo7m7cXinwyeQ9ZRbyiJ1illmS6aXVcFGeMRTXPpVvm8W+vsN V9lbS+wDoNwVJBLZe8ddNqGzTbfBDncsB/Ijept/6V01RHjcLSmfP6RRGUDQ0XdcaHgK 6iAPV9yN4szhgSwmYzPrXhzd7EBH+8Ff87KUwzg0AR5IO5U43LMdojn9UZhrecpX5/Nj cHUzhCx346KoCsjMyhHYf0uq1MUmsAFM8qz3P0tMvlvl/Lumk+tmFvd4wyHLPZIdg+CL hoA0wBvBLcvzkLmDcxsZCmWOI+koN5KMwJjhzfb1QfZbIC9W+HXbrQVDh2CqCaiwTh8+ w6oA== 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=dn3H8b+dEueAIyMb2RVGjQZHU+d9OmjIpuh9w4CGHNo=; b=bxyUhSBZx93+NYQnGC6AcCzomGHWPgRpG/+EF+xci0bJaEKDroEbuQVLjiYl0KUBkt wTMJhvGKNrn9e1gjMEvqJ+iWOgWB+HPYivUhY+LeRqx46CeczDFH4tlG1GutJ9iDKFao 6BCPiq6BquQe/Waoy9rYIQlsHrFCMoZqxfw6CdGTDiJA6nLXPyEz55O9p4gnmgkdJApu 9wDVH3dUf5XtxbdaG6T+H+A04L7+x1yi5xHQqRGVut3KU3h3aJDPLmvWuBNy6dIL0meM CPOxJVwXN4REq2Xna9gj+rwNgkZDMDkBIPHuKECoUiCMcEJ2s1Asm1kdqPWjfB+Ez0f6 b/Jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=CyG+eDb1; 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 ch18si2772983ejb.736.2021.01.07.15.50.03; Thu, 07 Jan 2021 15:50:26 -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=CyG+eDb1; 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 S1729197AbhAGXtK (ORCPT + 99 others); Thu, 7 Jan 2021 18:49:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727858AbhAGXtK (ORCPT ); Thu, 7 Jan 2021 18:49:10 -0500 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 148DBC0612F6 for ; Thu, 7 Jan 2021 15:48:30 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id b131so13141954ybc.3 for ; Thu, 07 Jan 2021 15:48:30 -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=dn3H8b+dEueAIyMb2RVGjQZHU+d9OmjIpuh9w4CGHNo=; b=CyG+eDb1tY9Es+lhDqZWXGA9iQGhjpfvNzCM7r9M8ragFYZSQVJyZtmCSrNBa8fjcb w0x0XPQ0L/KqCZdWvPzdnzZUdmJRwZ+Z88kxcaTFJKRBWlKD0a8raCsKEopqxSNlA3I3 nlalMrW6b1bP76Q7dI7YjLAQr7ka3jtH1Ei525um4yJc4Yl9vTKSAgQ7rIuc6R7iIQAX qy+qfTL7khu+3P5qy89nBSG+xiCx3HbXi/5+0DJl/jfGp0xNPAK7VT0l9prXQJ9U27hM sWsdmiDN91y/xHBWPdh2y1y4qVo05SCW0836qEcNapKZjFDWaGgnrz3eZqRDSZ7s4byA /vdQ== 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=dn3H8b+dEueAIyMb2RVGjQZHU+d9OmjIpuh9w4CGHNo=; b=nt1qYM4HEr0CqwNrFJ395NXbYu4e2mJ4h4NckMoSfWl60R8HggfJDRfU4Lt2N6G4Et kaWYTs8jbG/qcjXT3RApvV/z5lUT+e1Ass77+KIOf2+VDRBdpzwTUuo/Pxj6B4l2kvj4 +FHBEAfrclv6SpXqLgnDKxJvlpv7J/59ej1NWDlPgNbLj0mWYIlyUZ+fCtk01puByzTN SNbwZ5E/c2j+ShzJrd+a2MLAIab8Iru/2jXm5hhWUHn++wHp8zN24ej3ob+AHOGHRvhQ mXPQC0ACghVoj7gJv8+0y2/Ug7BOKrZquxFX+gSDyFeY4Ts196taSfKWxsXkjVIfDlg1 1xMw== X-Gm-Message-State: AOAM532rAZp3cBg7NhdREnauapspmUZrBc3fUx0sCEW/yVY9y/BaRfr5 iSxbrKR6ecuZ8H+So/55Ebrtw0lt0O+Pow== 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:a25:743:: with SMTP id 64mr1689790ybh.333.1610063309333; Thu, 07 Jan 2021 15:48:29 -0800 (PST) Date: Thu, 7 Jan 2021 15:48:02 -0800 In-Reply-To: <20210107234803.1096592-1-dlatypov@google.com> Message-Id: <20210107234803.1096592-2-dlatypov@google.com> Mime-Version: 1.0 References: <20210107234803.1096592-1-dlatypov@google.com> X-Mailer: git-send-email 2.29.2.729.g45daf8777d-goog Subject: [PATCH v3 2/3] kunit: tool: fix minor typing issue with None status From: Daniel Latypov To: davidgow@google.com, brendanhiggins@google.com Cc: 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 8b5eb9507765..2e4cb5206fa7 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] @@ -224,12 +224,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]: @@ -282,8 +281,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.729.g45daf8777d-goog