Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp547329pxb; Thu, 20 Jan 2022 19:59:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJyQt+eY9H5bTjcdY1yYUaJ3P8gd8a2Rm4Txp6TK/Q0PlelCc/n6KVzA5aE2ozxZe3ZUbwRo X-Received: by 2002:a17:902:d4c3:b0:14a:f56f:be3d with SMTP id o3-20020a170902d4c300b0014af56fbe3dmr2064655plg.6.1642737556522; Thu, 20 Jan 2022 19:59:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642737556; cv=none; d=google.com; s=arc-20160816; b=04vgOvEbW79Jrd/aVPgwGiuUR27ejBPJ9y81uaJ4vvZUsfWFNaxE+495MCSkQAEyxx c5uVD/smYStywzdIgKBnpbzneq+KorBJd+24UMr390B2HmeQr8xRlpc7z2C/Ka57REPB pAxtxuOlHiBoa6WHJxpnrWYWvOZfblnSmJBTuTRgzkRQjraBEp7d62I8j/DA2wHTwVV5 8gxlsGf+fh7FpeLoiyFXViH1mEC+F8GsDOB3M5imVGq0lWTNsi4bbx1vSaSgJ0wQz2F3 2W7+Rq0kGo3l3T8E8wuyvNhbfQHp1NcSIkn/h8M88eh0aUF0eaOwzsfK1TLjRKt0X+yk K9Ng== 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:mime-version:message-id:date :dkim-signature; bh=Y+WNm4SRT+v0/a8Imp7LUvwXVPmkF4Imu0eAPnXyHIY=; b=YOjwUd8NyoAvhMiFcfuRLyf/y+lbK8/tkrR1ObPKsw7NKXAxK+96fRh2Vswr1SmQMd 2oqiRs3D66+UeZHWGdAcNTfInneCQszUP28B9LgLm6fEX2+p7BjRNORkXEsnUDk03kjp Fn441bvG2ARUKfeWFpd173O71hrAsdlhwm7yOtXjMsfGU5e3hX+lf6kmSA2iW3E8B19k gC3KKQWS1UPAYToqcadmf8M5TTi31Y6nXGC+Iyug+ZqkCHGVJ1h2mFq9sWvwrvKyTCL7 rdgSBK2vwDcb+uFfsUBljW/SeRAz/LzeI5pI+SPh7Fw+rvKSPhiKYifj6ZEp4gF/v2rM VnYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=ZZORa00G; 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 v16si4749572pjr.41.2022.01.20.19.58.35; Thu, 20 Jan 2022 19:59:16 -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=20210112 header.b=ZZORa00G; 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 S1348332AbiARTJg (ORCPT + 99 others); Tue, 18 Jan 2022 14:09:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348385AbiARTJb (ORCPT ); Tue, 18 Jan 2022 14:09:31 -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 E4D91C06161C for ; Tue, 18 Jan 2022 11:09:30 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id s7-20020a5b0447000000b005fb83901511so40362433ybp.11 for ; Tue, 18 Jan 2022 11:09:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=Y+WNm4SRT+v0/a8Imp7LUvwXVPmkF4Imu0eAPnXyHIY=; b=ZZORa00GlA7CoqqZHJqUgUHTShPxXbCBwfNgu8zSTsbERei9c7ruuWMpi1znaJeEEB 6BWxI2LQ6ChJswk93WjpKcBno2GG9Svvk1JysMxHyX78mjVuLNP7P0L3AXxc2l4wBgh9 UgCLYWICx9RYPeiWwE9kDVQLjuSPMjczPBD8uOtnTcQkXa0XsLBD+AO7HJZj+ZjesdLc GHqTANmCBJEon4tL04fPHFFFRLpgvEogeuozSsudbWXLZrh9SBNwqAcqDPqnyGrmiymW VdRadFd0xZ5hETSF0aIEOHd/cyY2AtCH5klS30UGMXPrHt1edGdR1B5LKi1+gGtMQPhc lIQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=Y+WNm4SRT+v0/a8Imp7LUvwXVPmkF4Imu0eAPnXyHIY=; b=jotpHCeWLryCYFxVdpKnIsbDwAwrZTUhllN4GGQcKb+tPjINJ/Uc2gWs/UTESWMOH4 ENABP2bd60HnhVEjY/08BZqmj3dKjXtd4AQAb6w4PebgqxgfzG+JHrGRt83TVb+ts3gK 739F8CJzaMvXUCINASomQLVw5xCmZVlBle/xM1nKwVTFuqnpt2tPl6LSKv2u/dsCSDli BitXvsvmo+Vda4dkL4YsxmZNVz+pfceiofli3plPPIh3pfwk0gEezDtEhuKH7Qm8brDY vwSA3vfTLYWXBVyMkTacdLceC6CsEjjmFBxe6CYATWVwPtBG8FyjIgg69Y8zPCrpvjg/ gblg== X-Gm-Message-State: AOAM5324vpaJ61JvQJ4hUCXcLICjGJXkbGuLFNIVch3WhP5KD37sLTuh Z5LcIKEt9FbRIgBdGzh6PhkfS1ERFUDtfQ== X-Received: from dlatypov.svl.corp.google.com ([2620:15c:2cd:202:7fc9:5977:ab73:1d36]) (user=dlatypov job=sendgmr) by 2002:a5b:590:: with SMTP id l16mr32787350ybp.629.1642532970016; Tue, 18 Jan 2022 11:09:30 -0800 (PST) Date: Tue, 18 Jan 2022 11:09:18 -0800 Message-Id: <20220118190922.1557074-1-dlatypov@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.34.1.703.g22d0c6ccf7-goog Subject: [PATCH 1/5] kunit: tool: drop mostly unused KunitResult.result field From: Daniel Latypov To: brendanhiggins@google.com, davidgow@google.com Cc: linux-kernel@vger.kernel.org, kunit-dev@googlegroups.com, 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 This field is only used to pass along the parsed Test object from parse_tests(). Everywhere else the `result` field is ignored. Instead make parse_tests() explicitly return a KunitResult and Test so we can retire the `result` field. Signed-off-by: Daniel Latypov --- tools/testing/kunit/kunit.py | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/tools/testing/kunit/kunit.py b/tools/testing/kunit/kunit.py index 7a706f96f68d..9274c6355809 100755 --- a/tools/testing/kunit/kunit.py +++ b/tools/testing/kunit/kunit.py @@ -17,7 +17,7 @@ assert sys.version_info >= (3, 7), "Python version is too old" from dataclasses import dataclass from enum import Enum, auto -from typing import Any, Iterable, Sequence, List, Optional +from typing import Iterable, List, Optional, Sequence, Tuple import kunit_json import kunit_kernel @@ -32,7 +32,6 @@ class KunitStatus(Enum): @dataclass class KunitResult: status: KunitStatus - result: Any elapsed_time: float @dataclass @@ -82,10 +81,8 @@ def config_tests(linux: kunit_kernel.LinuxSourceTree, config_end = time.time() if not success: return KunitResult(KunitStatus.CONFIG_FAILURE, - 'could not configure kernel', config_end - config_start) return KunitResult(KunitStatus.SUCCESS, - 'configured kernel successfully', config_end - config_start) def build_tests(linux: kunit_kernel.LinuxSourceTree, @@ -100,14 +97,11 @@ def build_tests(linux: kunit_kernel.LinuxSourceTree, build_end = time.time() if not success: return KunitResult(KunitStatus.BUILD_FAILURE, - 'could not build kernel', build_end - build_start) if not success: return KunitResult(KunitStatus.BUILD_FAILURE, - 'could not build kernel', build_end - build_start) return KunitResult(KunitStatus.SUCCESS, - 'built kernel successfully', build_end - build_start) def config_and_build_tests(linux: kunit_kernel.LinuxSourceTree, @@ -173,14 +167,14 @@ def exec_tests(linux: kunit_kernel.LinuxSourceTree, request: KunitExecRequest) - filter_glob=filter_glob, build_dir=request.build_dir) - result = parse_tests(request, run_result) + _, test_result = parse_tests(request, run_result) # run_kernel() doesn't block on the kernel exiting. # That only happens after we get the last line of output from `run_result`. # So exec_time here actually contains parsing + execution time, which is fine. test_end = time.time() exec_time += test_end - test_start - test_counts.add_subtest_counts(result.result.counts) + test_counts.add_subtest_counts(test_result.counts) if len(filter_globs) == 1 and test_counts.crashed > 0: bd = request.build_dir @@ -189,7 +183,7 @@ def exec_tests(linux: kunit_kernel.LinuxSourceTree, request: KunitExecRequest) - bd, bd, kunit_kernel.get_outfile_path(bd), bd, sys.argv[0])) kunit_status = _map_to_overall_status(test_counts.get_status()) - return KunitResult(status=kunit_status, result=result, elapsed_time=exec_time) + return KunitResult(status=kunit_status, elapsed_time=exec_time) def _map_to_overall_status(test_status: kunit_parser.TestStatus) -> KunitStatus: if test_status in (kunit_parser.TestStatus.SUCCESS, kunit_parser.TestStatus.SKIPPED): @@ -197,7 +191,7 @@ def _map_to_overall_status(test_status: kunit_parser.TestStatus) -> KunitStatus: else: return KunitStatus.TEST_FAILURE -def parse_tests(request: KunitParseRequest, input_data: Iterable[str]) -> KunitResult: +def parse_tests(request: KunitParseRequest, input_data: Iterable[str]) -> Tuple[KunitResult, kunit_parser.Test]: parse_start = time.time() test_result = kunit_parser.Test() @@ -231,11 +225,9 @@ def parse_tests(request: KunitParseRequest, input_data: Iterable[str]) -> KunitR print(json_obj) if test_result.status != kunit_parser.TestStatus.SUCCESS: - return KunitResult(KunitStatus.TEST_FAILURE, test_result, - parse_end - parse_start) + return KunitResult(KunitStatus.TEST_FAILURE, parse_end - parse_start), test_result - return KunitResult(KunitStatus.SUCCESS, test_result, - parse_end - parse_start) + return KunitResult(KunitStatus.SUCCESS, parse_end - parse_start), test_result def run_tests(linux: kunit_kernel.LinuxSourceTree, request: KunitRequest) -> KunitResult: @@ -513,7 +505,7 @@ def main(argv, linux=None): request = KunitParseRequest(raw_output=cli_args.raw_output, build_dir='', json=cli_args.json) - result = parse_tests(request, kunit_output) + result, _ = parse_tests(request, kunit_output) if result.status != KunitStatus.SUCCESS: sys.exit(1) else: base-commit: f079ab01b5609fb0c9acc52c88168bf1eed82373 -- 2.34.1.703.g22d0c6ccf7-goog