Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7156183ybi; Mon, 8 Jul 2019 15:47:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqysAaiZa45DjzvXZPKSAXu2JKXfLMvzZ+foOA1YMI6GN6v8thpjoM8RqPiCHAnftYcI+3v9 X-Received: by 2002:a17:90a:3086:: with SMTP id h6mr29201041pjb.14.1562626028107; Mon, 08 Jul 2019 15:47:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562626028; cv=none; d=google.com; s=arc-20160816; b=JaFqlyrFkNocxlfzyj/7ycrOVi5DNND9peupkxD2dPqfbDnPIeTWCtKNqEVcXu0hwP vkQL8Ug8YfZkKeZ3F8/aiyOF/d40dV2+SjoroOjSgbj0LjUGlTFfQ14//Y1pGxz0hFEs vAYgbCFTv0/ODNDpT0v0fYfEfrLU0KU+pggnmGhrP3nO/xwyyF+4edPo+vv9y8f+oMk3 ZfNhcNQBT8Aigp0mlgwZzGHaiPSEeZHiyNUN/If9PFfmJIoyi4NAmq3I0HoX9jXB/phw C7w1RlmjvFY5D0jlnx89+UOil4Ixoc66TAyMJQ+HHufyQfs0H24a3a12jygu4Qw49+Lo FrFw== 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=pl4l3gaXCZ0Civm5i1pNfvFYe/9qjH5f6pxejgr6AT8=; b=Xb8FNMA4WUEJ3VAPL/mGyKJ9RfLe0t7ERuLfiIbIpXRaixMNZReo3ekWHND8tkWxqK e7sSczV8M5uJDBX/JiOnkI9njHUKcvgrXPsClb8HZBvoL9JIyfucMlPQozoowtng26MG LQBvFg8dkqlLGeIVmOO88y8in5PhwVDdP5xtl50nGCWKSpqNujo5hY5aFdeeiXDViKDF lvthifvtFlGVSgWPAcwmLDJOjFglZDo37eR25ewX7Nh8+19cqQ1aa/w3VkIsTsesgOqG p1qhIHfdDYdA2MT95dJJ0bVT3F2ytCTvZcmSOjVkWMFDxxcKkajeQ1ofcgHS3PcLRE5V hlig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=SmOjZWgQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id p13si19907822pgd.347.2019.07.08.15.46.53; Mon, 08 Jul 2019 15:47:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=SmOjZWgQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1731160AbfGHSIk (ORCPT + 99 others); Mon, 8 Jul 2019 14:08:40 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:41676 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730959AbfGHSIj (ORCPT ); Mon, 8 Jul 2019 14:08:39 -0400 Received: by mail-pf1-f196.google.com with SMTP id m30so7971800pff.8 for ; Mon, 08 Jul 2019 11:08:39 -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=pl4l3gaXCZ0Civm5i1pNfvFYe/9qjH5f6pxejgr6AT8=; b=SmOjZWgQtja4PiBSvkc/DsaRuuY8KuEdsMMIKFu//v+ppa1NV5GwqJ4JU08u4uuqXU KBGOdoVwwU+z3nPB5Yc7Nj2ei2N1Y2sszCQi7aydqX+v1bs0R5WVY9VfrLuAxD0X22yO et4/wVXqTEuA8XKb8I+GG2Cy0aB5wgbYiiI9zkmmG0P1bXmqCbs0GEYAywdf8m69uDNv i3LNyALK0qO5EHrEqLLK7h1Y4PRr0CfVpj56uFuOU19A9ib63eiTFseAJoBv3geF+XdI Ex1jzjCOgerKv5XAy3Zhbk2qyoHk/ecWgRcxMQ7auZjG3EZDzZIqKZ+9SL7kyLXtMMIf MRgA== 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=pl4l3gaXCZ0Civm5i1pNfvFYe/9qjH5f6pxejgr6AT8=; b=CTxlnzI3+Asy60DCFyLh856SHXpU1FZQr61XYigrItakUixZD7mB0EFN45D0Cm9DDo Fx4Ucq2nquIOHYjbi+HOekXKzsaeGEBGcmhBvkQsVuCf7f9sv07njnhfebJte5xtIqrc D1/ysjiegxoSJEz8wXfIZ9GsbVmybQaocOMJegU1T6njbBRgqZx476ycJ0f0w4A4wnQ9 guNeE20ZtGcphbcFger+lE5/5/zKaO4b/qCfFFUoc/D2gymvkaKErb8ZVwqGwXnuZzLw dXRPQdJkAfjy2DQK25oOZSFtAFyqPAhcpX5C5uViMKTFzu35Fm93litRkPS3ta/8fKpt ZrjA== X-Gm-Message-State: APjAAAXEMrcjtXG5zjXMczGmwH5dlxZcVAa+tK6YKk5vxlYKGOO1kcdJ nNu3tSiodqVYlmIUsjt392eW79Y6Tud2yvYptgWdmg== X-Received: by 2002:a63:b919:: with SMTP id z25mr25337810pge.201.1562609318390; Mon, 08 Jul 2019 11:08:38 -0700 (PDT) MIME-Version: 1.0 References: <20190704003615.204860-1-brendanhiggins@google.com> <20190704003615.204860-2-brendanhiggins@google.com> <20190705201505.GA19023@42.do-not-panic.com> In-Reply-To: <20190705201505.GA19023@42.do-not-panic.com> From: Brendan Higgins Date: Mon, 8 Jul 2019 11:08:27 -0700 Message-ID: Subject: Re: [PATCH v6 01/18] kunit: test: add KUnit test runner core To: Luis Chamberlain Cc: Frank Rowand , Greg KH , Josh Poimboeuf , Kees Cook , Kieran Bingham , Peter Zijlstra , Rob Herring , Stephen Boyd , shuah , "Theodore Ts'o" , Masahiro Yamada , devicetree , dri-devel , kunit-dev@googlegroups.com, "open list:DOCUMENTATION" , linux-fsdevel@vger.kernel.org, linux-kbuild , Linux Kernel Mailing List , "open list:KERNEL SELFTEST FRAMEWORK" , linux-nvdimm , linux-um@lists.infradead.org, Sasha Levin , "Bird, Timothy" , Amir Goldstein , Dan Carpenter , Daniel Vetter , Jeff Dike , Joel Stanley , Julia Lawall , Kevin Hilman , Knut Omang , Logan Gunthorpe , Michael Ellerman , Petr Mladek , Randy Dunlap , Richard Weinberger , David Rientjes , Steven Rostedt , wfg@linux.intel.com 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, Jul 5, 2019 at 1:15 PM Luis Chamberlain wrote: > > On Wed, Jul 03, 2019 at 05:35:58PM -0700, Brendan Higgins wrote: > > Add core facilities for defining unit tests; this provides a common way > > to define test cases, functions that execute code which is under test > > and determine whether the code under test behaves as expected; this also > > provides a way to group together related test cases in test suites (here > > we call them test_modules). > > > > Just define test cases and how to execute them for now; setting > > expectations on code will be defined later. > > > > Signed-off-by: Brendan Higgins > > Reviewed-by: Greg Kroah-Hartman > > Reviewed-by: Logan Gunthorpe > > Reviewed-by: Luis Chamberlain > > But a nitpick below, I think that can be fixed later with a follow up > patch. > > > +/** > > + * struct kunit - represents a running instance of a test. > > + * @priv: for user to store arbitrary data. Commonly used to pass data created > > + * in the init function (see &struct kunit_suite). > > + * > > + * Used to store information about the current context under which the test is > > + * running. Most of this data is private and should only be accessed indirectly > > + * via public functions; the one exception is @priv which can be used by the > > + * test writer to store arbitrary data. > > + * > > + * A brief note on locking: > > + * > > + * First off, we need to lock because in certain cases a user may want to use an > > + * expectation in a thread other than the thread that the test case is running > > + * in. > > This as a prefix to the struct without a lock seems odd. It would be > clearer I think if you'd explain here what locking mechanism we decided > to use and why it suffices today. Whoops, sorry this should have been in the next patch. Will fix. > > +/** > > + * suite_test() - used to register a &struct kunit_suite with KUnit. > > You mean kunit_test_suite()? Yep, sorry about that. Will fix. > > + * @suite: a statically allocated &struct kunit_suite. > > + * > > + * Registers @suite with the test framework. See &struct kunit_suite for more > > + * information. > > + * > > + * NOTE: Currently KUnit tests are all run as late_initcalls; this means that > > + * they cannot test anything where tests must run at a different init phase. One > > + * significant restriction resulting from this is that KUnit cannot reliably > > + * test anything that is initialize in the late_init phase. > initialize prior to the late init phase. > > > That is, this is useless to test things running early. Yeah, I can add that phrasing in. > > + * > > + * TODO(brendanhiggins@google.com): Don't run all KUnit tests as late_initcalls. > > + * I have some future work planned to dispatch all KUnit tests from the same > > + * place, and at the very least to do so after everything else is definitely > > + * initialized. > > TODOs are odd to be adding to documentation, this is just not common > place practice. The NOTE should suffice for you. Because it is a kernel doc? Would you usually make a separate non-kernel doc comment for a TODO? I guess that makes sense. Thanks!