Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2859068pxa; Sat, 8 Aug 2020 01:53:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqLja6gapO3+2ewQKImmbXpR+Hd0IgrMwSzLRQ2RTNbFpqVZM9WqLgQjNYiVIxAqB1oRYH X-Received: by 2002:a50:af45:: with SMTP id g63mr13140264edd.52.1596876793194; Sat, 08 Aug 2020 01:53:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596876793; cv=none; d=google.com; s=arc-20160816; b=OkReeFw9EXRKBPUittOcdHKpbuqle3wKnDGm73UDMZCwwSiRDLmIGpr+Uz0XT5kpGa piWvr/qjm4+SskG+jExJRb//ruw+mqoMy4n2KpqW8PoEw9sOi5ZlCQfEOw4hz4qWeSVa MsLhu36EWy/1qxzQmdh0HBbTH41FI/4VuT6VCYxsJAdRsRfHLRqHPUOAaDHPxD2huvI5 iXqNteI2O6zD1oR33S7eS/paSTagPMmQkqkEsT80X7jfYP4v6V7Qu2XB9/3bOdykRsv+ CT1ou9uAxuT4HrgE7O6G5ifZ0SxJuwW17Y95yYKUQtcmfzMtl/0dK3AfMfePfFzb1qCc mayA== 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=iJ0NqtLhxMa8vy08p3okMi0ViGuJVupVz011S0TP8uw=; b=dyGSEvTBOtt0jnLKSOU6sZLXFxElIj4m3WSa0BCOVZhKAwJ8CfluFxQh+GHF0hOSzY VVgBPx7mNFWcN2RluGsAOyikXMK8RD8sLnXJiiDAt973KOHV/tPbtjC8sSBgPIPi0Q/V sTfw+lmVGjCqokATxS8hkTSdP2arXCPpO19Yoi7pEbbRauZUzAWGsI+tJ3QiDXEAqSFV cD9nEAQQFkp9yKds4li8/aJ9eYg/wLVr2Nx2vCOvvPlq01uiXz7v2FFFxCc0xZGapz/r 6zxswsHwcgPXGOkyePWqwn4CvasZ/SEFTNtcOz7I86InKm9Bc7U7odHkpu9Y0DLS0SFv yp9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=cImpvsWP; 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 g16si6604659edr.534.2020.08.08.01.52.49; Sat, 08 Aug 2020 01:53:13 -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=cImpvsWP; 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 S1726256AbgHHIvG (ORCPT + 99 others); Sat, 8 Aug 2020 04:51:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725853AbgHHIvF (ORCPT ); Sat, 8 Aug 2020 04:51:05 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2BCCC061756 for ; Sat, 8 Aug 2020 01:51:05 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id y206so2421693pfb.10 for ; Sat, 08 Aug 2020 01:51:05 -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=iJ0NqtLhxMa8vy08p3okMi0ViGuJVupVz011S0TP8uw=; b=cImpvsWPA0tuRi4FaCIuCkXN09crvNWiva4SxYghBRxe6QF2UvZhTPYZb15Kg/i6q4 U04UHFT/tSEwoIikSa9Sv9Ww6ahDFtp7AX/xoeCrjs09WdmOunuqUuQll8zvKiEI8xWl B5SS6ez59kzeNCmSP6eRF54eKARyzxYPJoGuqXxvfJ70QYV54PMxDCXnbPFnZd2eECBk bmMzFz8Q5U4eOEvqpx12T5+VfNpUNdTNemuIe3yul8DlBqCwiMSFO4FzonQLwBbiAD17 hyRba4cPe6q4owa2MM8Q//2W8lXY3zXmDtx5B9W/F+2EeHESKda7rDJvNkzrsIeEJGv+ a4EQ== 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=iJ0NqtLhxMa8vy08p3okMi0ViGuJVupVz011S0TP8uw=; b=CLbxKLwxxHaURHzPc2SeeZdhoKgRbfPRc3B/Xo1Lh96jk9wLpiV3Z/3nxHMt6VrH1U yrw6exHyHVcTVzz+SNzPHWjO0KwbCYWxEVtQdS7B4DHGJC3ko5ZXuINtGgaXDFyp4WJE LG5NPZIaH04x2IQ0vAkuWsDQCgEj5RpOLc64JtVlW3NTNUrpRafIEWxp1d4VrVDt1zNG KNtXAsQrFu5lVgFbu28gK4Wzo+OPaaPiqRThQrEk7cnnSH/Hrsq4+lGrUAn2noZ3nVwu K+VHUqfVmh11DHKiRuap1O+xI/7z7Ry1jD61ivaPINdF+3ulC0XxCQ+00J3PHu74mQDD JdLA== X-Gm-Message-State: AOAM533EYDWWe1OXTsADATl8n8uejymhbkURvRHf8pC51huOQcnrOvjm P+zjlYAjRkvqTRraoAwF940a+Z+qX1sgx0pLG0dlQg== X-Received: by 2002:a63:6e0e:: with SMTP id j14mr14337055pgc.384.1596876664643; Sat, 08 Aug 2020 01:51:04 -0700 (PDT) MIME-Version: 1.0 References: <20200808011651.2113930-1-brendanhiggins@google.com> In-Reply-To: From: Brendan Higgins Date: Sat, 8 Aug 2020 01:50:53 -0700 Message-ID: Subject: Re: [PATCH v1 1/2] kunit: tool: fix running kunit_tool from outside kernel tree To: David Gow 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 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. > 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? > > 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 > >