From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 538CE212B0FD3 for ; Fri, 5 Jul 2019 13:15:08 -0700 (PDT) Received: by mail-pl1-f196.google.com with SMTP id b3so1745278plr.4 for ; Fri, 05 Jul 2019 13:15:08 -0700 (PDT) Date: Fri, 5 Jul 2019 20:15:05 +0000 From: Luis Chamberlain Subject: Re: [PATCH v6 01/18] kunit: test: add KUnit test runner core Message-ID: <20190705201505.GA19023@42.do-not-panic.com> References: <20190704003615.204860-1-brendanhiggins@google.com> <20190704003615.204860-2-brendanhiggins@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190704003615.204860-2-brendanhiggins@google.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" To: Brendan Higgins Cc: pmladek@suse.com, linux-doc@vger.kernel.org, peterz@infradead.org, amir73il@gmail.com, dri-devel@lists.freedesktop.org, Alexander.Levin@microsoft.com, yamada.masahiro@socionext.com, mpe@ellerman.id.au, linux-kselftest@vger.kernel.org, shuah@kernel.org, robh@kernel.org, linux-nvdimm@lists.01.org, frowand.list@gmail.com, knut.omang@oracle.com, kieran.bingham@ideasonboard.com, wfg@linux.intel.com, joel@jms.id.au, rientjes@google.com, jdike@addtoit.com, dan.carpenter@oracle.com, devicetree@vger.kernel.org, linux-kbuild@vger.kernel.org, Tim.Bird@sony.com, linux-um@lists.infradead.org, rostedt@goodmis.org, julia.lawall@lip6.fr, jpoimboe@redhat.com, kunit-dev@googlegroups.com, tytso@mit.edu, richard@nod.at, sboyd@kernel.org, gregkh@linuxfoundation.org, rdunlap@infradead.org, linux-kernel@vger.kernel.org, daniel@ffwll.ch, keescook@google.com, linux-fsdevel@vger.kernel.org, khilman@baylibre.com List-ID: 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. > +/** > + * suite_test() - used to register a &struct kunit_suite with KUnit. You mean kunit_test_suite()? > + * @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. > + * > + * 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. Luis _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm