Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp5482206rwb; Tue, 17 Jan 2023 14:33:26 -0800 (PST) X-Google-Smtp-Source: AMrXdXuiSHtSoCuzq5d6chpZo4oeYONF2iV78JtCKucwI3s5V+wl2DpDKVEn2m5HCixdldCW+DZU X-Received: by 2002:a05:6a20:4a1f:b0:b8:cc1f:beef with SMTP id fr31-20020a056a204a1f00b000b8cc1fbeefmr3316137pzb.6.1673994805973; Tue, 17 Jan 2023 14:33:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673994805; cv=none; d=google.com; s=arc-20160816; b=l7Vtn+d3yN6WU05Glh1qEDOq49za1Do/sMKOMUCIit15XXyjM2UejrmRergYSX2P3Y Z0jXEMyY7rwv3Ka3D6NljrypH5l8/+jpPdUcNRIuqlmK/P8QkhiAajg/awQuesODdnOz BvSAAt6YCVUnfmivcFdBHKajH5g7Hfi9ThhA6kG+pqX205KsET72IQDtB2u5yTqbUD6u 8N+x3vh/cQ29oTWZPBcD0m0jA1nKqr86htpXshR6VcsjeqqwdhXvKXoJvRWPzqJHZxiK 3WEtzljVDDLHSYGHMSXubpZZiMYiNTnylLNX5Qo60z2VZWCMYUhmjCq0+Aln59f1eYwM 4BIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=0cr0RPJmvb7n5x8XTwTIrboLTYQTJE656e9XjHwFqpY=; b=D8gjo/ryUPC5J0qE6eJQZHraQvmAGswqa4qkIMjVVZtj1S7NDcvrsPAorXCXIgg0Sr oXcx9aO8HkDOu0mWxFf1Yx8zWOGZWDo08eoZMLlxzGZY8Wcw0cNKox8Wv87J0e8E9zBU CR30froc/hO4XsPZz0T7wc9Ls0eRC4BZ9k3He543piWZaYvbW0EtdU/42AllWFDMFxvy rcwBaOb8JIwH4vZJlCHFgA/b8xlhg14+OABPs5xDGK5GsIf4p2F+SELmbFmEE206L2tw fBn9DtX8U78We8g3UtngCLPnIA56/ypnHluDNCq/HNgb9Lzj14ylZSXte4vijdp/FLme 9mnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=G0rIt6F9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g2-20020a631102000000b004a1b205441dsi33614700pgl.121.2023.01.17.14.33.20; Tue, 17 Jan 2023 14:33:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=G0rIt6F9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S229960AbjAQWLt (ORCPT + 46 others); Tue, 17 Jan 2023 17:11:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230253AbjAQWK3 (ORCPT ); Tue, 17 Jan 2023 17:10:29 -0500 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C5681CF52 for ; Tue, 17 Jan 2023 13:56:11 -0800 (PST) Received: by mail-pf1-x436.google.com with SMTP id 127so7400582pfe.4 for ; Tue, 17 Jan 2023 13:56:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=0cr0RPJmvb7n5x8XTwTIrboLTYQTJE656e9XjHwFqpY=; b=G0rIt6F9KwPDQsFFiIGt4cbVtyXK3cjH3I/6w6TjsnFWU6bimnOonwGB/F3Ziyd4Jo CyhhE546Qe7O1iA7p9B8kKZlu/AWuV7CnU32Yw4k40hOcYDvqJhYBQ+nxz8Qc/cZkJGm C/JUyEfenjifeNDck9wpYBNhHfMbdFyMCvpcQi/taQef9Wb/G0r6Ev7Qb501lU08Z/T7 qiIcBaK3utVFfoZ19giKv7T5AzWW/hlMaiCleM8YGcEfHsMkrdnFPcQG43iDhM0+UgE/ +9ZnDQfh0eS25IiLuTdw1jR7ibasSX3wOpYn98VNTDn1wPE5WB1S0nln6hRKzAUjTaBm mPSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=0cr0RPJmvb7n5x8XTwTIrboLTYQTJE656e9XjHwFqpY=; b=HkzhNOjOO+0jU4WJyVHQ72FZ4ZT64JSMxKjxzKuO/06e9amBbvtcJE7iKX4GMEIg2z GrD4Qr7Wc+D4sVh37GGV+SrNR8cnwQktlemwDL7ePk9YhPtNVEb8tga3E2xXiO2bZUu2 XRACscT3aUTRvhl1cdtgh3Bwfr5Xc+tlCSvIbKh6teJQ2su7aUqsca7i1SlOSoFwD+br nPlvPRlPZlwANwNIZ6d2bFt/N0MDWSRbuWRKRObOtW5BnMfufBnSvbdIpI4VMNGMtaNE jCws+uaJvHlAkR6UwMFl3I4mcJWxOn7cJIb9wg9vXz85Hi7oaUOX8ihjz7ib2x5Ltajw Vsow== X-Gm-Message-State: AFqh2krAJjJlTfCQ9BU6AagYDQK2XB7CL3FnnoL7jdPdTYTjWoUzIUEi Z93MHs3YM/zsx5xk7M/jPsgH9eaG5K6IYQNh8dIb9g== X-Received: by 2002:a63:500e:0:b0:4d0:6ad7:e5a9 with SMTP id e14-20020a63500e000000b004d06ad7e5a9mr17902pgb.464.1673992570808; Tue, 17 Jan 2023 13:56:10 -0800 (PST) MIME-Version: 1.0 References: <20230115210535.4085-1-apantykhin@gmail.com> In-Reply-To: <20230115210535.4085-1-apantykhin@gmail.com> From: Daniel Latypov Date: Tue, 17 Jan 2023 13:55:59 -0800 Message-ID: Subject: Re: [PATCH] tools/testing/kunit/kunit.py: remove redundant double check To: Alexander Pantyukhin Cc: brendan.higgins@linux.dev, davidgow@google.com, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, akpm@linux-foundation.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jan 15, 2023 at 1:05 PM Alexander Pantyukhin wrote: > > The build_tests function contained the doulbe checking for not success very nit: if we're fixing the "doulbe" typo, can we also do "the doulbe" => "double" (drop the "the") > result. It is fixed in the current patch. Additional small > simplifications of code like useing ternary if were applied (avoid use > the same operation by calculation times differ in two places). > > Signed-off-by: Alexander Pantyukhin Reviewed-by: Daniel Latypov Thanks! I can't believe we never noticed the duplicate `if not success` blocks before now. Some minor suggestions below if we're already going to send a v2 out for typos. > --- > tools/testing/kunit/kunit.py | 17 +++++------------ > 1 file changed, 5 insertions(+), 12 deletions(-) > > diff --git a/tools/testing/kunit/kunit.py b/tools/testing/kunit/kunit.py > index 43fbe96318fe..481c213818bd 100755 > --- a/tools/testing/kunit/kunit.py > +++ b/tools/testing/kunit/kunit.py > @@ -77,10 +77,8 @@ def config_tests(linux: kunit_kernel.LinuxSourceTree, > config_start = time.time() > success = linux.build_reconfig(request.build_dir, request.make_options) > config_end = time.time() > - if not success: > - return KunitResult(KunitStatus.CONFIG_FAILURE, > - config_end - config_start) > - return KunitResult(KunitStatus.SUCCESS, > + status = KunitStatus.SUCCESS if success else KunitStatus.CONFIG_FAILURE > + return KunitResult(status, > config_end - config_start) nit: perhaps we can shorten this to one line, i.e. return KunitResult(status, config_end - config_start) > > def build_tests(linux: kunit_kernel.LinuxSourceTree, > @@ -92,13 +90,8 @@ def build_tests(linux: kunit_kernel.LinuxSourceTree, > request.build_dir, > request.make_options) > build_end = time.time() > - if not success: > - return KunitResult(KunitStatus.BUILD_FAILURE, > - build_end - build_start) > - if not success: > - return KunitResult(KunitStatus.BUILD_FAILURE, > - build_end - build_start) Oh huh, I guess this duplication comes from commit 45ba7a893ad8 ("kunit: kunit_tool: Separate out config/build/exec/parse") @@ -64,78 +84,167 @@ def run_tests(linux: kunit_kernel.LinuxSourceTree, build_end = time.time() if not success: return KunitResult(KunitStatus.BUILD_FAILURE, 'could not build kernel') + if not success: + return KunitResult(KunitStatus.BUILD_FAILURE, + 'could not build kernel', > - return KunitResult(KunitStatus.SUCCESS, > + status = KunitStatus.SUCCESS if success else KunitStatus.BUILD_FAILURE > + return KunitResult(status, > build_end - build_start) ditto here, return KunitResult(status, build_end - build_start) > > def config_and_build_tests(linux: kunit_kernel.LinuxSourceTree, > @@ -145,7 +138,7 @@ def exec_tests(linux: kunit_kernel.LinuxSourceTree, request: KunitExecRequest) - > tests = _list_tests(linux, request) > if request.run_isolated == 'test': > filter_globs = tests > - if request.run_isolated == 'suite': > + elif request.run_isolated == 'suite': This is better, thanks. Daniel