Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3062838pxk; Mon, 7 Sep 2020 01:58:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyCj0AHGXTYf5tKtANH3vbs6/hysE4ngtFq45CvBsEFv6n+BrjeraC2TIIBIFyHhPL2nr2S X-Received: by 2002:a05:6402:17da:: with SMTP id s26mr20551528edy.221.1599469111047; Mon, 07 Sep 2020 01:58:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599469111; cv=none; d=google.com; s=arc-20160816; b=fTTRNO7R+yqu1RotnwLloFkxgy+8+CSzlM9JobLyANw34lEZreRBZuZ41vv5+7C3Zp fojwFBHQhodB12mZEEh68CBRAtkSUW4z5VtnKWFzX4FrPkdZO9eGhKP3ccz4KF798ZCY oNwgCf7tOUvGPBVOlNV6Sp6BDhm0p5mFnpihqEGsGace83nsS32BChacxejV3mwZ35BG BY5q0VEeYx7zFc47LMjEpHi3g0VadyAXpz8gQuvgUDJKyaB16cmx2PeCfZBDSfisxN6S ZTlrQz/xEgkUsxP3qiEp5Wj6Gbo+hjojfziJjfXlN0RsRq4ku7oINMxVKjKJS23O/6B1 et2A== 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=6Yl9hPW8Oci7ALl4vX8u8AUkDDmAA1DXOMq94Yc3e+E=; b=G1jVIxKYt54rBdhobp+HkrGGqKEN6hMOTYDUj6PngiYzv2kBWez4uZKI+u8Ek4fD+d 4jgXn9RQ9i0Jgs5w0kngA46qFGmd6NalGAWg8mYkYRdD4LjsqOHIzz2rMbYG+QYI+1a0 2izB71eImvoaQ3BccedVmu7fe2aWn+2te2G1s3+vllJ0nydkS5y7WMZv4iPvOVKZyWpT 5scuhbuIs+iR5yr3RNUqN4hzRBFVZakxk9hIPADTegtq/cixjkkWYAkHpIB+Jh6cj2y5 Luf+NqpNUW4jsuZhSKQvGXAYvWtw7Tnu1I1/Fyutpz6/hUzNpOtKshgHVDOzF7+qnEBl fWiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=sLjNZsZ9; 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 j5si3610210edc.28.2020.09.07.01.58.08; Mon, 07 Sep 2020 01:58:31 -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=sLjNZsZ9; 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 S1728111AbgIGI5M (ORCPT + 99 others); Mon, 7 Sep 2020 04:57:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728135AbgIGI5L (ORCPT ); Mon, 7 Sep 2020 04:57:11 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BB6CC061575 for ; Mon, 7 Sep 2020 01:57:11 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id b79so13389795wmb.4 for ; Mon, 07 Sep 2020 01:57:11 -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=6Yl9hPW8Oci7ALl4vX8u8AUkDDmAA1DXOMq94Yc3e+E=; b=sLjNZsZ9pVZFtfzH9TOmoRPxwqyh0H8Lftc9PoCx20A+dD+EhuV+c81AEkVHI2WeTg NbWu6HW5nwkllDPvUn5cgX/dIjBUyFAKwhwWxEtoAAa2JH+O8DBAtFhxdXiILhWbkbvf M5HqJmebzEehUkk2g8V2tuZ8AoNSgsqeECzXyuFb2+fbSe8ezt9wyO8dpr0RMmOO6mHQ sIAHFBz7k2xvBjqH91w2r16uxZCKQk2wqsowKrIeOUFzzxCr+YHzyj5fJJgvuqXNGOFi BrBEYVbNQ/9G8EvxfO07HFOpSwAfQP2JbsIRRBw59a3abecJmTmbLdsomy8NAHFYN3FW kEjw== 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=6Yl9hPW8Oci7ALl4vX8u8AUkDDmAA1DXOMq94Yc3e+E=; b=Qxm+1WhUcfM64ZQE4puvMT0Kb0zMzEJeYiHAmNeGgaOgVh8a2R0Zq6TGeJ+Ff9cjX0 /maUWcE6lOAH9UcYfk4NO2W4FcXLbulhtt1SOeLxrRg3z5umS9sp80T5xUEaExU/TvuV nl/jkkkt8mRifNnZi/tUrpH/0sfFahGLclvEgGfETAnn9AlLtO6qXCXOdTfv/ShKLZE9 5dlCiVp88k5MqBHm245ZXUdGc9Ho75MmaDH13ea2HR2XKC3doa+xLsFS0Ip+tAZVN9sR zJMo7cN++Dl2rWuW6G9LXR2kMdCfo0OVUPPj08YzX7SNEPkOqJb+JA7U0fLwyyVQPraQ +YCg== X-Gm-Message-State: AOAM5302bkFVr34samCMAB9lwo60u6eVk/7C0aoRVptNyqtzmvBlmA8J UMudzNrco7Udba8hKKNzUQut6A== X-Received: by 2002:a1c:2781:: with SMTP id n123mr19471333wmn.27.1599469029372; Mon, 07 Sep 2020 01:57:09 -0700 (PDT) Received: from elver.google.com ([100.105.32.75]) by smtp.gmail.com with ESMTPSA id q20sm24926205wmj.5.2020.09.07.01.57.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2020 01:57:08 -0700 (PDT) Date: Mon, 7 Sep 2020 10:57:03 +0200 From: Marco Elver To: David Gow Cc: Kees Cook , Brendan Higgins , Jonathan Corbet , Alan Maguire , Randy Dunlap , Theodore Ts'o , Tim Bird , KUnit Development , "open list:KERNEL SELFTEST FRAMEWORK" , "open list:DOCUMENTATION" , Linux Kernel Mailing List Subject: Re: [PATCH] Documentation: kunit: Add naming guidelines Message-ID: <20200907085703.GA1653285@elver.google.com> References: <20200702071416.1780522-1-davidgow@google.com> <20200827131438.GA3597431@elver.google.com> <202008311641.D10607D43@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Fri, Sep 04, 2020 at 12:22PM +0800, David Gow wrote: [...] > > This is a good point -- renaming files is definitely a pain. It's > obviously my hope that KUnit sticks around long enough that it's not > being added/removed as a dependency too often, particularly for the > unit tests, so "_kunit" as a name doesn't worry me that much > otherwise. Make sense. And I do also hope that once a test is a KUnit test, there is no need to change it. :-) [...] > I'm not personally convinced that "kunit" isn't something people could > associate with tests, particularly as it becomes more popular, but if > people really dislike it, we could have"_unittest.c" or similar. > There's a balancing act between being generic (and not distinguishing > between unit/integration/etc tests) and being consistent or avoiding > renames. Take the case where there's a set of unit tests in a > "-test.c" file, and an integration test is written as well: it > probably should go in a speparate file, so now you'd either have a > "-test.c" and a separate "-integration-test.c" (or the other way > around if the integration test was written first), or the "-test.c" > file would be renamed. Makes sense, too. Yeah, if we have both we'd need to distinguish one way or another. What might be particularly annoying is the case if an integration test exists first, and it had been named "_kunit.c", followed by addition of a unit test. I think the only sane thing at that point would be to do a rename of the integration test; whereas if it had been named "_test.c", I could live with there simply being a "_unit_test.c" (or similar) file for the new unit test. [...] > > 1. Clear, intuitive, descriptive filenames ("[...] something that says > > more strongly that this is a test [...]"). > > > > 2. Avoid renames if any of the following changes: test framework, test > > type or scope. I worry the most about this point, because it affects > > our workflows. We need to avoid unnecessary patch conflicts, keep > > cherry-picks simple, etc. > > > > 3. Strive for consistently named tests, regardless of type (because > > it's hard to get right). > > > > 4. Want to distinguish KUnit tests from non-KUnit tests. (Also > > consider that tooling can assist with this.) > > > > I think that these are somewhat in conflict with each other, which is > what makes this complicated. Particularly, it's going to be difficult > to both avoid renames if the test framework changes and to distinguish > between KUnit and non-KUnit tests by filename. > > I personally think that of these requirements, 2 is probably the one > that would cause people the most real-world pain. I'm not sure how > often test type or scope changes enough to be worth the rename, and I > hope KUnit survives long enough and is useful enough that test > framework changes are kept to a minimum, but this has already > irritated enough people porting tests to KUnit to be a noticeable > issue. One possibility is to focus on module names, which are probably > more important and can be renamed without changing the filename, > though that's pretty ugly. > > I actually think "_kunit.c" probably is descriptive/intuitive enough > to meet (1) -- or at least will be once KUnit is more widely used -- > but it does conflict a bit with 2. > > It'd be nice to have consistently named tests, but we're not there at > the moment, so fixing it will require a lot of renaming things. It's > looking increasingly unlikely that we'll be able to do that for > everything, so making this a recommendation for new test suites is > probably the best we're likely to get. > > > These are the 2 options under closer consideration: > > > > A. Original choice of "*-test.c": Satisfies 1,2,3. It seems to fail 4, > > per Kees's original concern. > > > > Kees also brings up that using hyphens instead of underscores causes > some inconsistency with module names, which is a bit of a pain. > > > B. "*_kunit.c": Satisfies 4, maybe 3. > > - Fails 1, because !strstr("_kunit.c", "test") and the resulting > > indirection. It hints at "unit test", but this may be a problem for > > (2). > > - Fails 2, because if the test for some reason decides to stop using > > KUnit (or a unit test morphs into an integration test), the file needs > > to be renamed. > > > > And based on all this, why not: > > > > C. "*-ktest.c" (or "*_ktest.c"): > > - Satisfies 1, because it's descriptive and clearly says it's a > > test; the 'k' can suggest it's an "[in-]kernel test" vs. some other > > hybrid test that requires a userspace component. > > - Satisfies 2, because neither test framework or test type need to > > be encoded in the filename. > > - Satisfies 3, because every test (that wants to use KUnit) can just > > use this without thinking too much about it. > > - Satisfies 4, because "git grep -- '[-_]ktest\.[co]'" returns nothing. > > > > My concern with this is that we're introducing new jargon either way: > does having "test" in the name outweigh the potential confusion from > having "ktest" be in the filename only for "KUnit tests". So my > feeling is that this would've been really useful if we'd named KUnit > KTest (which, ironically, I think Brendan had considered) instead, but > as-is is probably more confusing. Make sense, too. > At the risk of just chickening out at calling this "too hard", I'm > leaning towards a variant of (A) here, and going for _test, but making > it a weaker recommendation: > - Specifying that the module name should end in _test, rather than the > source filename. Module names are easier to change without causing > merge conflicts (though they're a pain to change for the user). > - Only applies to new test suites, and another suffix may be used if > it conflicts with an existing non-kunit test (if it conflicts with a > kunit test, they should be disambiguated in the suite name). > - Test types (unit, integration, some subsystem-specific thing, etc) > may be disambiguated in the suite name, at the discretion of the test > author. (e.g., "driver_integration" as a suite name, with > "driver_integration_test" as the module name, and either > "driver_integration_test.c" or "integration_test.c" as recommended > test filenames, depending on if "driver" is in its own directory.) > > This should satisfy 1 & 2, and go some way towards satisfying 3. We > can try to come up with some other technical solution to 4 if we need > to. > > Unless the objections are particularly earth-shattering, I'll do a new > version of the patch that matches this next week. The other option is > to drop the filename stuff from the document altogether, and sort it > out in another patch, so we at least get some of the consistency in > suite and Kconfig names. Thanks for the detailed answer. Your plan sounds good to me. I'm fine either way, as long as requirement (2) is somehow addressed, and we do not end up with unnecessary renames. Thanks, -- Marco