Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2117816pxb; Mon, 22 Feb 2021 21:40:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJxhI/XnUk7jijGG/O6bxFZv6uQzOFF6TFBSM0VCLIwqiADlzQo9sQr58Q0S3APqobd00RfY X-Received: by 2002:a17:906:398c:: with SMTP id h12mr24725425eje.469.1614058824423; Mon, 22 Feb 2021 21:40:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614058824; cv=none; d=google.com; s=arc-20160816; b=UtTqyrDdHiRpSHLrYSHzkNExYoRVgYZBSJiWTJ2+j7ON0cnHBTPi8lZn897Lg3b1zw hCBYmMEkvcAwGoRwJ0EyJtmPGO0EA6OvjaYi7dZeeUthu/qzsewTjcc+lQDNyyKZaKdb qIuDGJx8/tc1X+gPsuz8n2kjoEqNZ8vfOmxL8EtkdmULrkSXlt/jmkz5qvkLfQLV0V7Q 47O6veOR3X1gqg88Jr7SswGe6/lOH6TW6b1IKwFZ1kYzj9q4bniAmk4m1tyaZZvXHOcn hXBk+zRDJo3aLWp98TXO9hecW8Oh/KMEcXwdHfOe2MU947ERCO0K4R3txyaHMPEKPNk/ zibw== 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=xoz9ruMyGlyHp0Dux5TOabse5pDK13RiWfyTntkpE9k=; b=MKWtNlTxtPDbTvoOPRJhhCuD+TLV1Cw+/D9R3CcIdvERklLHrfJalkr3J8K8i7c/5i HKOKCo8wxWlIjOVlT6YB+28gYA1xL1okDndrvVwUyufjlMZHGY99zH83v685NTEtFMI4 +NJk70mVTwu1KRDzDsjsuHsyUlKUqfouA9p9AZ9PD3XDCiIy+wthZYqRO173Pj0mUWx4 1hRIy78cBOS4QLlteCiZK2oUNdcK339Me2GVLPWwH1S5CjtsaE5Dtb7fJMXDQEyxVlDM +32b1N1aylk7uwejKRCS4RngnqI289u2QzWzDLUUNhfbCsdGcaWQ0FoWay826etGjgmx Qc4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=nRWf8ohT; 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 p31si15724577edb.298.2021.02.22.21.40.00; Mon, 22 Feb 2021 21:40:24 -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=nRWf8ohT; 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 S230073AbhBWFjZ (ORCPT + 99 others); Tue, 23 Feb 2021 00:39:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229967AbhBWFjU (ORCPT ); Tue, 23 Feb 2021 00:39:20 -0500 Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F0E3C061574 for ; Mon, 22 Feb 2021 21:38:40 -0800 (PST) Received: by mail-lj1-x234.google.com with SMTP id c17so61802384ljn.0 for ; Mon, 22 Feb 2021 21:38:40 -0800 (PST) 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=xoz9ruMyGlyHp0Dux5TOabse5pDK13RiWfyTntkpE9k=; b=nRWf8ohTY81ID4OOn/y0ijqzLx+G+HyUob9gT0Bzn3SmJxgY8uQk8RljshQadg1i+Z yFX7ZnEpsQ21+T1glSTVqoTLXFXVH9m8WXGbzaX92tIUcXO2J93mktG4/TFSj2l5JUwg v2+vweeSa0ceTIdPmchWgHY1Yp22+ZrwO2Gf9eeyV9w89ZLm+WYTW6XJAUa+ZGtp6Omj PnS+m/9KgtwXll2AQK390ka6b0RZi+QLrwOe9+PaKMlivFQurZelN5s2w65iF2mAxCAR 6/QqQZgTonNpGUohBPcs9eJTKCuYjP3DJ/fQBDyKmCsC65feKSy6/dcX1bnNObO1VmWn 8iCA== 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=xoz9ruMyGlyHp0Dux5TOabse5pDK13RiWfyTntkpE9k=; b=FU4hrhyle/KE6tIBLxR/CDlV0Ytr5DJALgG1bVq9xapKT9fyW2ceaOvtmgZj61rhHL K+CjkluJIipcS2rnZgEvei/mH5yQ4SEkEc5P7k5mDFUIgvPkWUqVW54XcFaYSp9U6VCq cpaUZR54xJFG2o9ayWf3weqd6de8hxju+CPLXC9JxlROhnPkIaKCiGhbgvoW9iKmqnmd r1Y44d5AGAxvDVSz6lYoyB7Kht0qUqnxZKD7URpFtGpuCLEaxWTMHyUW/0Fp+sVgw1oM 4PJiXvRsRrB7kr3dJ/soNpzikHBBRJBe52N7Kri1h5qLQL36bH3ad3MYlARj6ehMi9TY IjFA== X-Gm-Message-State: AOAM533tIgJv/HPmbuB0Q84vVBWY00+LL57jv41ufa51dAqbJYm8Ti4l ecUqJP5LlAj9scS8mySoYr+AA+6ibAhI0aw2+aJ4Lw== X-Received: by 2002:a2e:8656:: with SMTP id i22mr10243200ljj.245.1614058718700; Mon, 22 Feb 2021 21:38:38 -0800 (PST) MIME-Version: 1.0 References: <20210222225241.201145-1-dlatypov@google.com> In-Reply-To: <20210222225241.201145-1-dlatypov@google.com> From: David Gow Date: Tue, 23 Feb 2021 13:38:27 +0800 Message-ID: Subject: Re: [PATCH] kunit: tool: make --kunitconfig accept dirs, add lib/kunit fragment To: Daniel Latypov Cc: Brendan Higgins , Linux Kernel Mailing List , KUnit Development , "open list:KERNEL SELFTEST FRAMEWORK" , Shuah Khan , "Theodore Ts'o" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 23, 2021 at 6:52 AM Daniel Latypov wrote: > > TL;DR > $ ./tools/testing/kunit/kunit.py run --kunitconfig=lib/kunit > > Per suggestion from Ted [1], we can reduce the amount of typing by > assuming a convention that these files are named '.kunitconfig'. > > In the case of [1], we now have > $ ./tools/testing/kunit/kunit.py run --kunitconfig=fs/ext4 > > Also add in such a fragment for kunit itself so we can give that as an > example more close to home (and thus less likely to be accidentally > broken). > > [1] https://lore.kernel.org/linux-ext4/YCNF4yP1dB97zzwD@mit.edu/ > > Signed-off-by: Daniel Latypov > --- Thanks! I really like this. I'd assumed we'd check if the path exists, and fall back to appending ".kunitconfig", but checking if it's a directory is better. I tried this out with all the different combinations I could think of, and it works well. Reviewed-by: David Gow Cheers, -- David > lib/kunit/.kunitconfig | 3 +++ > tools/testing/kunit/kunit.py | 4 +++- > tools/testing/kunit/kunit_kernel.py | 2 ++ > tools/testing/kunit/kunit_tool_test.py | 6 ++++++ > 4 files changed, 14 insertions(+), 1 deletion(-) > create mode 100644 lib/kunit/.kunitconfig > > diff --git a/lib/kunit/.kunitconfig b/lib/kunit/.kunitconfig > new file mode 100644 > index 000000000000..9235b7d42d38 > --- /dev/null > +++ b/lib/kunit/.kunitconfig > @@ -0,0 +1,3 @@ > +CONFIG_KUNIT=y > +CONFIG_KUNIT_TEST=y > +CONFIG_KUNIT_EXAMPLE_TEST=y > diff --git a/tools/testing/kunit/kunit.py b/tools/testing/kunit/kunit.py > index d5144fcb03ac..5da8fb3762f9 100755 > --- a/tools/testing/kunit/kunit.py > +++ b/tools/testing/kunit/kunit.py > @@ -184,7 +184,9 @@ def add_common_opts(parser) -> None: > help='Run all KUnit tests through allyesconfig', > action='store_true') > parser.add_argument('--kunitconfig', > - help='Path to Kconfig fragment that enables KUnit tests', > + help='Path to Kconfig fragment that enables KUnit tests.' > + ' If given a directory, (e.g. lib/kunit), "/.kunitconfig" ' > + 'will get automatically appended.', > metavar='kunitconfig') > > def add_build_opts(parser) -> None: > diff --git a/tools/testing/kunit/kunit_kernel.py b/tools/testing/kunit/kunit_kernel.py > index f309a33256cd..89a7d4024e87 100644 > --- a/tools/testing/kunit/kunit_kernel.py > +++ b/tools/testing/kunit/kunit_kernel.py > @@ -132,6 +132,8 @@ class LinuxSourceTree(object): > return > > if kunitconfig_path: > + if os.path.isdir(kunitconfig_path): > + kunitconfig_path = os.path.join(kunitconfig_path, KUNITCONFIG_PATH) > if not os.path.exists(kunitconfig_path): > raise ConfigError(f'Specified kunitconfig ({kunitconfig_path}) does not exist') > else: > diff --git a/tools/testing/kunit/kunit_tool_test.py b/tools/testing/kunit/kunit_tool_test.py > index 1ad3049e9069..2e809dd956a7 100755 > --- a/tools/testing/kunit/kunit_tool_test.py > +++ b/tools/testing/kunit/kunit_tool_test.py > @@ -251,6 +251,12 @@ class LinuxSourceTreeTest(unittest.TestCase): > with tempfile.NamedTemporaryFile('wt') as kunitconfig: > tree = kunit_kernel.LinuxSourceTree('', kunitconfig_path=kunitconfig.name) > > + def test_dir_kunitconfig(self): > + with tempfile.TemporaryDirectory('') as dir: > + with open(os.path.join(dir, '.kunitconfig'), 'w') as f: > + pass > + tree = kunit_kernel.LinuxSourceTree('', kunitconfig_path=dir) > + > # TODO: add more test cases. > > > > base-commit: b12b47249688915e987a9a2a393b522f86f6b7ab > -- > 2.30.0.617.g56c4b15f3c-goog >