Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp157110pxk; Wed, 9 Sep 2020 01:38:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzXDqEXbWJnYkkbd4figXGvF35mpPd0a2uMW2rtkjnPNLqqzanVI0pqnbKtOpZOhiujNnu9 X-Received: by 2002:aa7:cb10:: with SMTP id s16mr3059134edt.72.1599640690465; Wed, 09 Sep 2020 01:38:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599640690; cv=none; d=google.com; s=arc-20160816; b=UbrecxNEt9iVcGjpKRsWAJFc57vUDRiO9a8CN+CCgs5OllSsYB9eBNCKCbBevjn3Rg BVIN+DARUcfyUjpCaIHqO75+LJraZh5C0IRyQ9fv+2VBLedCKrO6cjd7XnpFfNurLjLK V7QZcYiEQ25/T0YbUhngeF0s6xQ3DBnxYKvSQLTeQuSdUQXG+fYTk7saa8wWlFk3eqrj hqEKsFQPJjAlZU0NhYGNv3syUPBoblKZvYv4e729OImC+ZNzk0mYEW4//GVVvKfmqZlF pLWkqGIVaRJUl/sXHjElWejLEspBFt9u3SFz7p+jB14nuZGlwsFUSdEldmJlU9GX+773 SvMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=BhyBPgB9vs4GX0WG0TB0f4M/oPN9+cSShKiQ6+MBT10=; b=VkaTFegGhUIvAa3/3wfH5aFv0IqYPg3Q4PKoxYCG2txpLKP06hy1UeKF6jS/d/voYd 9TTrGTJu5Sd9pnZ1Su2ToU9aqpOoy8sF+qm22inkGjdW8kLmbWHlHykiX9ifUbkQ/m+Q PSWmWBUkiN6g4QnJ1JMlZfhLUTLaMEC0KqfM8ktgIRW/3/ciNskxzbIg4D3ZKkoWkeDD 0288RENAiOfis/oLmKeFbPZf4RrLuOVOP3j7cBvNm9J3Ih6cB9ydyF5AHan/UMfVmqvu P9imhZly+8Z2yybFLNT8fGLDPLxvouyY6eeVbyWp0NkR51hCw9JOIkd5aMmUxP3XjpuQ XLvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=OPN9vAK9; 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 v13si1111961edi.95.2020.09.09.01.37.47; Wed, 09 Sep 2020 01:38:10 -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=OPN9vAK9; 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 S1726811AbgIIIhK (ORCPT + 99 others); Wed, 9 Sep 2020 04:37:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726293AbgIIIhC (ORCPT ); Wed, 9 Sep 2020 04:37:02 -0400 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60865C061755 for ; Wed, 9 Sep 2020 01:37:01 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id q9so1436723wmj.2 for ; Wed, 09 Sep 2020 01:37:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=BhyBPgB9vs4GX0WG0TB0f4M/oPN9+cSShKiQ6+MBT10=; b=OPN9vAK9sNgPp5A/WCtYKZk4EXN1Xv0wFzNPosFQBrGLKCNlgDFMXSLTi1DzTXcVvQ U5mDF/rrsVKk3hj4upMkQ5Xu1yelPahQ3J3SjNu7gPE6TlyM5fwq1GNOiSRLh3WT2MN9 uJnP16gsogLc9kRrF/MY8ctXVS/nt59oIcTjh4apsEQcJAOa7fZ2I80LdFK8s6Zip30a qIaYdbcw8KjjcfPwWG7haVmyFwgYW7+J5eHtdcJEXIUqW05F7kRcUh0UyJ5mdkPcsrat IniktyEOHY3TTukZNwemyKmcTbIqc+D69GiOb5YjGOwN+EEg5iFhXdswjOAI5DcweYD0 Ornw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=BhyBPgB9vs4GX0WG0TB0f4M/oPN9+cSShKiQ6+MBT10=; b=j6yKjHEE7ViS2dpX2ReA5Ow3P2AYIMm8nXXJnYHa+mO+hrusSy/9Bvj6ivv5pUurF8 HD9PRkwcPCHeX6S6f0HOEyFOhKibjU0LzsnUSMv6+gEhqKmMJ6M0VPOkqb8T4YIhWwUs QO5/Y/s6C2fotAdLbFyzZN47jX/2cppIaOGZliEDWM9JW2rxoyQ/MaScL6hffAvm9/ox Xdqli7+53jW1hYbaeSS470/ESUNAPy8LDbTXfe+XZWzzlC/cMhT9yXJz9d88AoXRvNNy xPSi11gTQsBXzK6LXmUcEjDVZnBHq78uOE0J9q+Q8ToHm6z1qKIM5rcXv2/FI241Bo9Y qEpA== X-Gm-Message-State: AOAM5322X/xv5xd4iGha1iOLdmNyuitw28FSaVTv1JW8NDNMD+cR/ZRR Asrwr1j8XUTgm9oeReBk2GPozQ== X-Received: by 2002:a7b:ce86:: with SMTP id q6mr2557860wmj.163.1599640619750; Wed, 09 Sep 2020 01:36:59 -0700 (PDT) Received: from elver.google.com ([100.105.32.75]) by smtp.gmail.com with ESMTPSA id a127sm2812203wmh.34.2020.09.09.01.36.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 01:36:58 -0700 (PDT) Date: Wed, 9 Sep 2020 10:36:53 +0200 From: Marco Elver To: David Gow Cc: Brendan Higgins , Jonathan Corbet , Kees Cook , Alan Maguire , Randy Dunlap , Theodore Ts'o , Tim Bird , kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] Documentation: kunit: Add naming guidelines Message-ID: <20200909083653.GA620870@elver.google.com> References: <20200909051631.2960347-1-davidgow@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200909051631.2960347-1-davidgow@google.com> User-Agent: Mutt/1.14.4 (2020-06-18) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 08, 2020 at 10:16PM -0700, David Gow wrote: > As discussed in [1], KUnit tests have hitherto not had a particularly > consistent naming scheme. This adds documentation outlining how tests > and test suites should be named, including how those names should be > used in Kconfig entries and filenames. > > [1]: > https://lore.kernel.org/linux-kselftest/202006141005.BA19A9D3@keescook/t/#u > > Signed-off-by: David Gow > Reviewed-by: Kees Cook > Reviewed-by: Brendan Higgins > --- > > This is v2 of the KUnit test nomenclature guidelines. The guidelines have > changed a bit in response to the discussion on the v1 thread which came > about after plumbers. The major change is that the filename suffix is > now "_test", with "_kunit" permitted where it conflicts. There are also > some other exceptions carved out around existing tests, and very > non-unit-like tests. > > Changelog: > > v2: > - Rewrote the filename section to use "_test" as a suffix, and focus on > module names, not filenames. > - Add a motivating introduction, which also calls out existing tests and > tests which cause problems when run automatically (long running, > flaky tests) as reasons to avoid the guidelines. > - Talk about including the type of test in the suite name, but only if > theres an actual confict. (And update the example for this). > > v1: > https://lore.kernel.org/linux-kselftest/20200702071416.1780522-1-davidgow@google.com/ > - Fixed a bit of space/tab confusion in the index (Thanks, Randy) > - Added some more examples (and some test case examples). > - Added some examples of what not to call subsystems and suites. > - No longer explicitly require "If unsure, put N" in Kconfig entries. > - Minor formatting changes > > RFC: > https://lore.kernel.org/linux-kselftest/20200620054944.167330-1-davidgow@google.com/T/#u > - Initial version > > > The result is a little bit weaker than the previous versions, but > hopefully will let us get the areas we agree on down. > > -- David > > > Documentation/dev-tools/kunit/index.rst | 1 + > Documentation/dev-tools/kunit/style.rst | 207 ++++++++++++++++++++++++ > 2 files changed, 208 insertions(+) > create mode 100644 Documentation/dev-tools/kunit/style.rst > > diff --git a/Documentation/dev-tools/kunit/index.rst b/Documentation/dev-tools/kunit/index.rst > index e93606ecfb01..c234a3ab3c34 100644 > --- a/Documentation/dev-tools/kunit/index.rst > +++ b/Documentation/dev-tools/kunit/index.rst > @@ -11,6 +11,7 @@ KUnit - Unit Testing for the Linux Kernel > usage > kunit-tool > api/index > + style > faq > > What is KUnit? > diff --git a/Documentation/dev-tools/kunit/style.rst b/Documentation/dev-tools/kunit/style.rst > new file mode 100644 > index 000000000000..c001ea1cd87d > --- /dev/null > +++ b/Documentation/dev-tools/kunit/style.rst > @@ -0,0 +1,207 @@ > +.. SPDX-License-Identifier: GPL-2.0 > + > +=========================== > +Test Style and Nomenclature > +=========================== > + > +To make finding, writing, and using KUnit tests as simple as possible, it's > +strongly encouraged that they are named and written according to the guidelines > +below. While it's possible to write KUnit tests which do not follow these rules, > +they may break some tooling, may conflict with other tests, and may not be run > +automatically by testing systems. > + > +It's recommended that you only deviate from these guidelines when: > + > +1. Porting tests to KUnit which are already known with an existing name, or > +2. Writing tests which would cause serious problems if automatically run (e.g., > + nonderministically producing false positives or negatives, or taking an s/nonderministically/nondeterministically/ (or non-deterministically?) > + extremely long time to run). [...] > +Test File and Module Names > +========================== > + > +KUnit tests can often be compiled as a module. These modules should be named > +after the test suite, followed by ``_test``. If this is likely to conflict with > +non-KUnit tests, the suffic ``_kunit`` can also be used. s/suffic/suffix/ > +The easiest way of achieving this is to name the file containing the test suite > +``_test.c`` (or, as above, ``_kunit.c``). This file should be > +placed next to the code under test. > + > +If the suite name contains some or all of the name of the test's parent > +directory, it may make sense to modify the source filename to reduce redundancy. > +For example, a ``foo_firmware`` suite could be in the ``foo/firmware_test.c`` > +file. Reviewed-by: Marco Elver Thank you!