Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp135625pxa; Mon, 10 Aug 2020 21:32:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyGiLZ7h0Q5e6lMrpOzBOFL+ogb/gAcuDdeVR4eqIp7My4IA711ERzxxRdjbhbTiCkYcDXQ X-Received: by 2002:aa7:c544:: with SMTP id s4mr24253768edr.51.1597120366555; Mon, 10 Aug 2020 21:32:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597120366; cv=none; d=google.com; s=arc-20160816; b=wQ6JekYL5Qwz8ZBAV+NCNtBSpEJSunD5SNbadIWDqLC6zqzZb5jnMyDPO0YJkyXkev RIzBirmcepsJ9v/gepR7STjCeiTjdKLP0XHyMdLNo7vNSCA/rlTzK7gf7GxFBKlTXIf5 CANHrpITy93J0j9Xe2FAAI3Xislb9KBh900EdHFO9yz7bAh8WmkOdAjvb2W1BMzfa2cL uWHcA621hCR5lKCp53gj3K7S66JtaFCDVWhtWB7IHuLpQK9wMxBjqtaECz0ij5Eajqin k+WfgMO8sGFMJhp1ljiRj87ns/vx6r4nykqhU6yFmCKxnGy62oa0qyR4P6geDFXR6eNY mWvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=UTA/jlI4ZkjE+5vHGh7qBO6GyXxZqYMrHrBvLYqNA/8=; b=kNLCI9kNeg/K8Dk63GSNId7LKeO3xCjAHDTmNyFUX6hnT7QrE8vi0DcepB/BVEPGzk Cvc9QjSsKrE2PEnn5ebSi7UtspNif5PaljgCC5z7C+8PadaJOIqsbjuMdSJD92ueSOvy PAahedZ5lJmJSIlQjDUAtpsF8xUO3Idp1+WfJ/82QiXr/4xpOOCAnP5GiUJyc7kYimhv rhjdkWZDSV9J/DqPbdCmjqcAndNbYzuVGv7l5G+UvOej6RA1snKKFlnytIMVO1Nf2ytn +lRWjTRXIo0n2N9GdVsyAyhbW5dhzT8z5wVeHwT7uY2e4QgCtS/shAIO71JNzWi65VDB rVJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ecIE6H8P; 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 p6si11468387edx.443.2020.08.10.21.32.23; Mon, 10 Aug 2020 21:32:46 -0700 (PDT) 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=ecIE6H8P; 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 S1726512AbgHKEaO (ORCPT + 99 others); Tue, 11 Aug 2020 00:30:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726488AbgHKEaN (ORCPT ); Tue, 11 Aug 2020 00:30:13 -0400 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 737B3C061756 for ; Mon, 10 Aug 2020 21:30:12 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id c15so10133434wrs.11 for ; Mon, 10 Aug 2020 21:30:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=UTA/jlI4ZkjE+5vHGh7qBO6GyXxZqYMrHrBvLYqNA/8=; b=ecIE6H8POPKe2GmWnNT6j85kVXuCut+VRP5UWYxjZhFuR0utGUaTCLiyLZFEFaDGXA Nk/IlTphNYMbm49+EFFnIapGm8TEPL82eic3iPh2Rlf0lJA+8IhA3A3oHXIQu8w5MVug OvVkhDq+VZYnuiK6dN1Bu0HPFneZmrTPkI3nfzbMatTEZlaex8bGobr6YOJ7YoXcI07z DkFRr3Qa5XPbsrwvmjqdYC/0QkNHbwQzMak6Zf9z33kZSpuCDs0VGKCcRf8TGkbkT+vT dqycUjwh94zMZvgPC4Dchf6trndi28QLRRNPB7oCxwuYZkAjf/7FraDP6yUyEczB2yKe wI5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=UTA/jlI4ZkjE+5vHGh7qBO6GyXxZqYMrHrBvLYqNA/8=; b=qizLPUUjoUs9bv6iN03xfS2JsMAxiDzXU0XoIhqFeIz2SZiY/cW1sBYMH8oYMD43Kw KZ0TJpNutNU4j+gy7kFp5shNXCzzKPHeFQYdkOMMHmCW/HqNvouQBCW7HueoQw3azTfJ t2kK3ytHceoSwaRIiP6LBk5qh+bbmBn4iDTz2TY8IjRXloHkamWVuMfoYZhX2HWm3Epe 59yu4Qfi+bhSEVoAxm4BKIHP//bJnZONtRFOSVM032ehBalBcZUWM+mDfInUu6/d6ETx 85Vu1xXlyGvRj7KmMaXPQecLNA3sIF4KB3yG8d1fo6PaoPhbIgItliBgeEa4iluB1ABX mU4g== X-Gm-Message-State: AOAM532zYdITMKSZaPZP4Mbg1E75ncbRB2yc0oQXOB8TzVwNsm3bBzS/ dNs7uQTOdPlYmVV0Tgkc2FRPnvaArvDNrnmvG34QgQ== X-Received: by 2002:adf:f511:: with SMTP id q17mr4184981wro.414.1597120210798; Mon, 10 Aug 2020 21:30:10 -0700 (PDT) MIME-Version: 1.0 References: <20200808011651.2113930-1-brendanhiggins@google.com> In-Reply-To: From: David Gow Date: Tue, 11 Aug 2020 12:29:59 +0800 Message-ID: Subject: Re: [PATCH v1 1/2] kunit: tool: fix running kunit_tool from outside kernel tree To: Brendan Higgins Cc: Shuah Khan , "open list:KERNEL SELFTEST FRAMEWORK" , KUnit Development , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Aug 8, 2020 at 4:51 PM Brendan Higgins wrote: > > On Fri, Aug 7, 2020 at 10:45 PM David Gow wrote: > > > > On Sat, Aug 8, 2020 at 9:17 AM Brendan Higgins > > wrote: > > > > > > Currently kunit_tool does not work correctly when executed from a path > > > outside of the kernel tree, so make sure that the current working > > > directory is correct and the kunit_dir is properly initialized before > > > running. > > > > > > Signed-off-by: Brendan Higgins > > > --- > > > tools/testing/kunit/kunit.py | 8 ++++++++ > > > 1 file changed, 8 insertions(+) > > > > > > diff --git a/tools/testing/kunit/kunit.py b/tools/testing/kunit/kunit.py > > > index 425ef40067e7..96344a11ff1f 100755 > > > --- a/tools/testing/kunit/kunit.py > > > +++ b/tools/testing/kunit/kunit.py > > > @@ -237,9 +237,14 @@ def main(argv, linux=None): > > > > > > cli_args = parser.parse_args(argv) > > > > > > + if get_kernel_root_path(): > > > + print('cd ' + get_kernel_root_path()) > > Do we want to print this, or is it a leftover debug statement? > > Whoops, I was supposed to delete that. That's embarrassing... ^_^; > > > > + os.chdir(get_kernel_root_path()) > > > + > > > if cli_args.subcommand == 'run': > > > if not os.path.exists(cli_args.build_dir): > > > os.mkdir(cli_args.build_dir) > > > + create_default_kunitconfig() > > Why are we adding this everywhere when it's already in config_tests, > > which should already be called in all of the places where a > > kunitconfig is required? > > Ah yes, .kunitconfig needs to be created before config_tests() can be > called because the LinuxSourceTree constructor needs .kunitconfig to > exist. I see. I guess the ultimate solution will be for LinuxSourceTree not require a .kunitconfig unless it's actually being used. > > Is the goal to always copy the default kunitconfig when creating a new > > build_dir? While I can sort-of see why we might want to do that, if > > the build dir doesn't exist, most of the subcommands will fail anyway > > (maybe we should only create the build-dir for 'config' and 'run'?) > > I just did it because we were getting a failure in a constructor so we > couldn't do much. Ideally we would check that the current state allows > for the command that the user intended to run, but I think that's > beyond the scope of this change. > > So I guess the real question is: Is it okay for it to crash in the > constructor with a cryptic error message for now, or do we want to let > it fail with a slightly less cryptic message later? > I personally am leaning towards allowing it to crash in the build, exec, etc. subcommands for now, and tidying up the error messages later, rather than silently creating a blank build dir, only for it then to fail later. In the meantime, yeah, we can add this for the config and run tasks, and maybe remove the whole "if cli_args.build_dir" / mkdir branch from the other subcommands. If we weren't going to fix the LinuxSourceTree constructor, it'd make sense to get rid of the redundant code to create it in config_tests(), too, but I'm not sure it's worthwhile. In any case, now I know what's happening, I'm okay with anything moderately sensible which gets the 'config' and 'run' subcommands working on an empty build dir, and the code and error messages can be fixed when tidying up the LinuxSourceTree() constructor in a separate patch. Cheers, -- David > > > if not linux: > > > linux = kunit_kernel.LinuxSourceTree() > > > @@ -257,6 +262,7 @@ def main(argv, linux=None): > > > if cli_args.build_dir: > > > if not os.path.exists(cli_args.build_dir): > > > os.mkdir(cli_args.build_dir) > > > + create_default_kunitconfig() > > > > > > if not linux: > > > linux = kunit_kernel.LinuxSourceTree() > > > @@ -273,6 +279,7 @@ def main(argv, linux=None): > > > if cli_args.build_dir: > > > if not os.path.exists(cli_args.build_dir): > > > os.mkdir(cli_args.build_dir) > > > + create_default_kunitconfig() > > > > > > if not linux: > > > linux = kunit_kernel.LinuxSourceTree() > > > @@ -291,6 +298,7 @@ def main(argv, linux=None): > > > if cli_args.build_dir: > > > if not os.path.exists(cli_args.build_dir): > > > os.mkdir(cli_args.build_dir) > > > + create_default_kunitconfig() > > > > > > if not linux: > > > linux = kunit_kernel.LinuxSourceTree() > > > > > > base-commit: 30185b69a2d533c4ba6ca926b8390ce7de495e29 > > > -- > > > 2.28.0.236.gb10cc79966-goog > > >