Message ID | 0e5f68ab045965292fee1748254bf9b91db9039a.1689171160.git.mchehab@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1199989vqm; Wed, 12 Jul 2023 07:44:54 -0700 (PDT) X-Google-Smtp-Source: APBJJlELKH18jizJKSsgO62/kyHPBbf2opS2SPSB2c0p0P4mAdRDAF7QFH9f/7NmQPIKGVHfyMhL X-Received: by 2002:a17:902:ecc2:b0:1b9:d439:c009 with SMTP id a2-20020a170902ecc200b001b9d439c009mr16020715plh.57.1689173094292; Wed, 12 Jul 2023 07:44:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689173094; cv=none; d=google.com; s=arc-20160816; b=P+RFWQkwdvacEbQ03kR7FR1VANMfedX4BO3BILvePnwoq/kS371n0ZW1FNjPryBK6U PcYcgUE50FxSXCZqz1SbMKhv54kkuo6lniCP2biPp446aKPzLj2Ksq2gLVFrg+uvCAav HGi8xmwoMz9SB0S49qQJZHov6rIi9vafWhvRZUi/KlbbeKzG2vj4uzVHklpZ75dXk1p1 wcx3WrDFlGnzjSk+57xgM4eKvjs3lkqPBZzI7Ggd9mkzoc592lA1e6RGOJT63ba0iT5G 2c9L3yeZ3DJ5t/nxOozlWlDq7bRNzaYNcccqZLfKf3KSat+yC3UsQQEhaRoTwgmViQtQ Ju7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from :dkim-signature; bh=QPqrIY3bJTDOy24nqukLq5X34Hg8mqKbx6P3JnRNGHU=; fh=kkJ8YW9XAgSAkn4Q2fk/JSfpoU7DtFd+2Zn5d0StDwE=; b=Vq0hYMkJpsLQqrvvKWWe3uenO3uI1QkMWDHJnhw1xdyyWlxIaxfe5sg9MK3y2U8yUc eENKNvJkvZ19PDZJWatn5RfEKzgHAysSqm5aFEsnn9HHFsPfxzzOfz4OZcvjwVp0DrsO 51Onj+tavSMWvQI4k1mv36DXzxJIYJX4lg1EgYZhrCDIRaHGbfJAwywM1eorORmXhbaJ NPAvPE1xiyhysf6FOMhdypbbeJaa9i3dtAXqQ3qpKdmb4V94ZcMiClYvyhfjJBDrYxmT ouvQ2E1fq6T3FbPsC+oq2poXgQVjrBH9Muc8x/KGa2fWkAVeDf+2Bei5E0lVn/LWskLL VNWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@kernel.org header.s=k20201202 header.b="S0R/RaIU"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y17-20020a1709027c9100b001b89eefc9fbsi3319697pll.262.2023.07.12.07.44.41; Wed, 12 Jul 2023 07:44:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@kernel.org header.s=k20201202 header.b="S0R/RaIU"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232198AbjGLO3J (ORCPT <rfc822;gnulinuxfreebsd@gmail.com> + 99 others); Wed, 12 Jul 2023 10:29:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232330AbjGLO3D (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 12 Jul 2023 10:29:03 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D765B1BDF; Wed, 12 Jul 2023 07:29:01 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6764861805; Wed, 12 Jul 2023 14:29:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C456FC433C8; Wed, 12 Jul 2023 14:29:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689172140; bh=ymDSmyQE+1VjD+F72bagnnqt4nfj752WMEBt5dK+Lf8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S0R/RaIUJMVH5qRd3pz5jBpfJ9HajmRwajHprZjx4FJo8VuMyk11Gzoauc+8Oi1r5 RQ2UbSV+xn9cGThw1Vao2W57lLkhyQA5D+CQOCbVK84AW8FxOjF2XPMX6RQ0DgjwZ/ jKV5Jm9v78U1GUyTpweDIgXj88SVHlVaARwtMzRBsVrVADMtIDU84GljlX7E+QlKD/ M8WW1BFb9+TmxctYDtMpsQodux4nSlCGfhhv0AErc+zZALvp5htxNuE03oT0aU6OeS PVEQdEhyiFBTAhYwcqHTsaMtAwz1NTuh8Jq+BpovEjAZnyOVOFAeo/LbbU5M+QGL+p e1LeC3DzwOAhA== Received: from mchehab by mail.kernel.org with local (Exim 4.96) (envelope-from <mchehab@kernel.org>) id 1qJapt-003beq-1r; Wed, 12 Jul 2023 16:28:57 +0200 From: Mauro Carvalho Chehab <mchehab@kernel.org> Cc: Mauro Carvalho Chehab <mchehab@kernel.org>, "Brendan Higgins" <brendanhiggins@google.com>, =?utf-8?q?Christian_K=C3=B6n?= =?utf-8?q?ig?= <christian.koenig@amd.com>, "Darrick J. Wong" <djwong@kernel.org>, "David Gow" <davidgow@google.com>, "Jason A. Donenfeld" <Jason@zx2c4.com>, "Jonathan Corbet" <corbet@lwn.net>, =?utf-8?q?Ma=C3=ADra_Canal?= <mairacanal@riseup.net>, "Nikolai Kondrashov" <spbnick@gmail.com>, "Rae Moar" <rmoar@google.com>, "Shuah Khan" <skhan@linuxfoundation.org>, Arthur Grillo <arthurgrillo@riseup.net>, Kees Cook <keescook@chromium.org>, dri-devel@lists.freedesktop.org, kunit-dev@googlegroups.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, mauro.chehab@intel.com Subject: [PATCH RFC 2/2] drm: add documentation for drm_buddy_test kUnit test Date: Wed, 12 Jul 2023 16:28:55 +0200 Message-Id: <0e5f68ab045965292fee1748254bf9b91db9039a.1689171160.git.mchehab@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <cover.1689171160.git.mchehab@kernel.org> References: <cover.1689171160.git.mchehab@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771226366295975321 X-GMAIL-MSGID: 1771226366295975321 |
Series |
Add support for inlined documentation for kunit and kselftests
|
|
Commit Message
Mauro Carvalho Chehab
July 12, 2023, 2:28 p.m. UTC
As an example for the new documentation tool, add a documentation
for drm_buddy_test.
I opted to place this on a completely different directory, in order
to make easier to test the feature with:
$ make SPHINXDIRS="tests" htmldocs
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
---
To avoid mailbombing on a large number of people, only mailing lists were C/C on the cover.
See [PATCH RFC 0/2] at: https://lore.kernel.org/all/cover.1689171160.git.mchehab@kernel.org/
Documentation/index.rst | 2 +-
Documentation/tests/index.rst | 6 ++++++
Documentation/tests/kunit.rst | 5 +++++
drivers/gpu/drm/tests/drm_buddy_test.c | 12 ++++++++++++
4 files changed, 24 insertions(+), 1 deletion(-)
create mode 100644 Documentation/tests/index.rst
create mode 100644 Documentation/tests/kunit.rst
Comments
On Wed, 12 Jul 2023, Mauro Carvalho Chehab <mchehab@kernel.org> wrote: > diff --git a/drivers/gpu/drm/tests/drm_buddy_test.c b/drivers/gpu/drm/tests/drm_buddy_test.c > index 09ee6f6af896..dd6c5afd6cd6 100644 > --- a/drivers/gpu/drm/tests/drm_buddy_test.c > +++ b/drivers/gpu/drm/tests/drm_buddy_test.c > @@ -737,6 +737,18 @@ static int drm_buddy_suite_init(struct kunit_suite *suite) > return 0; > } > > +/** > + * KTEST_SUITE: set of tests for drm buddy alloc > + * Scope: drm subsystem > + * Mega feature: drm > + * Feature: buddy_alloc > + * > + * KTEST_TEST: drm_test_buddy_alloc_%s > + * Description: Run DRM buddy allocation %arg[1] test > + * > + * arg[1].values: limit, range, optimistic, smoke, pathological > + */ > + "/**" indicates a kernel-doc comment, and this is not a kernel-doc comment. $ scripts/kernel-doc -none drivers/gpu/drm/tests/drm_buddy_test.c drivers/gpu/drm/tests/drm_buddy_test.c:752: warning: cannot understand function prototype: 'struct kunit_case drm_buddy_tests[] = ' Nowadays kernel-doc is part of W=1 builds. BR, Jani. > static struct kunit_case drm_buddy_tests[] = { > KUNIT_CASE(drm_test_buddy_alloc_limit), > KUNIT_CASE(drm_test_buddy_alloc_range),
Em Wed, 12 Jul 2023 18:03:00 +0300 Jani Nikula <jani.nikula@linux.intel.com> escreveu: > On Wed, 12 Jul 2023, Mauro Carvalho Chehab <mchehab@kernel.org> wrote: > > diff --git a/drivers/gpu/drm/tests/drm_buddy_test.c b/drivers/gpu/drm/tests/drm_buddy_test.c > > index 09ee6f6af896..dd6c5afd6cd6 100644 > > --- a/drivers/gpu/drm/tests/drm_buddy_test.c > > +++ b/drivers/gpu/drm/tests/drm_buddy_test.c > > @@ -737,6 +737,18 @@ static int drm_buddy_suite_init(struct kunit_suite *suite) > > return 0; > > } > > > > +/** > > + * KTEST_SUITE: set of tests for drm buddy alloc > > + * Scope: drm subsystem > > + * Mega feature: drm > > + * Feature: buddy_alloc > > + * > > + * KTEST_TEST: drm_test_buddy_alloc_%s > > + * Description: Run DRM buddy allocation %arg[1] test > > + * > > + * arg[1].values: limit, range, optimistic, smoke, pathological > > + */ > > + > > "/**" indicates a kernel-doc comment, and this is not a kernel-doc > comment. > > $ scripts/kernel-doc -none drivers/gpu/drm/tests/drm_buddy_test.c > drivers/gpu/drm/tests/drm_buddy_test.c:752: warning: cannot understand > function prototype: 'struct kunit_case drm_buddy_tests[] = ' > > Nowadays kernel-doc is part of W=1 builds. True. I already told it at patch 0. I opted to not add a patch for it on this RFC series, to make it simpler. A simple logic at kernel-doc is enough to tell its state machine to ignore blocks that contain the KTEST_\w+: pattern: diff --git a/scripts/kernel-doc b/scripts/kernel-doc index d0116c6939dc..bf386460691f 100755 --- a/scripts/kernel-doc +++ b/scripts/kernel-doc @@ -259,6 +259,7 @@ my $doc_sect = $doc_com . '\s*(\@[.\w]+|\@\.\.\.|description|context|returns?|notes?|examples?)\s*:([^:].*)?$'; my $doc_content = $doc_com_body . '(.*)'; my $doc_block = $doc_com . 'DOC:\s*(.*)?'; +my $ktest_block = $doc_com . 'KTEST_\w+:\s*(.*)?'; my $doc_inline_start = '^\s*/\*\*\s*$'; my $doc_inline_sect = '\s*\*\s*(@\s*[\w][\w\.]*\s*):(.*)'; my $doc_inline_end = '^\s*\*/\s*$'; @@ -2015,6 +2016,10 @@ sub process_name($$) { my $file = shift; my $descr; + if (/$ktest_block/o) { + $state = STATE_NORMAL; + return; + } if (/$doc_block/o) { $state = STATE_DOCBLOCK; $contents = ""; Thanks, Mauro
[Adding Arun] Am 12.07.23 um 16:28 schrieb Mauro Carvalho Chehab: > As an example for the new documentation tool, add a documentation > for drm_buddy_test. > > I opted to place this on a completely different directory, in order > to make easier to test the feature with: > > $ make SPHINXDIRS="tests" htmldocs > > Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org> Acked-by: Christian König <christian.koenig@amd.com> Arun please take a look as well. Thanks, Christian. > --- > > To avoid mailbombing on a large number of people, only mailing lists were C/C on the cover. > See [PATCH RFC 0/2] at: https://lore.kernel.org/all/cover.1689171160.git.mchehab@kernel.org/ > > Documentation/index.rst | 2 +- > Documentation/tests/index.rst | 6 ++++++ > Documentation/tests/kunit.rst | 5 +++++ > drivers/gpu/drm/tests/drm_buddy_test.c | 12 ++++++++++++ > 4 files changed, 24 insertions(+), 1 deletion(-) > create mode 100644 Documentation/tests/index.rst > create mode 100644 Documentation/tests/kunit.rst > > diff --git a/Documentation/index.rst b/Documentation/index.rst > index 9dfdc826618c..80a6ce14a61a 100644 > --- a/Documentation/index.rst > +++ b/Documentation/index.rst > @@ -60,7 +60,7 @@ Various other manuals with useful information for all kernel developers. > fault-injection/index > livepatch/index > rust/index > - > + test/index > > User-oriented documentation > =========================== > diff --git a/Documentation/tests/index.rst b/Documentation/tests/index.rst > new file mode 100644 > index 000000000000..bfc39eb5c0aa > --- /dev/null > +++ b/Documentation/tests/index.rst > @@ -0,0 +1,6 @@ > +======================== > +Kunit documentation test > +======================== > + > +.. toctree:: > + kunit > diff --git a/Documentation/tests/kunit.rst b/Documentation/tests/kunit.rst > new file mode 100644 > index 000000000000..6ffc151988a0 > --- /dev/null > +++ b/Documentation/tests/kunit.rst > @@ -0,0 +1,5 @@ > +Kunit tests > +----------- > + > +.. include-test:: drivers/gpu/drm/tests/drm_buddy_test.c > + > diff --git a/drivers/gpu/drm/tests/drm_buddy_test.c b/drivers/gpu/drm/tests/drm_buddy_test.c > index 09ee6f6af896..dd6c5afd6cd6 100644 > --- a/drivers/gpu/drm/tests/drm_buddy_test.c > +++ b/drivers/gpu/drm/tests/drm_buddy_test.c > @@ -737,6 +737,18 @@ static int drm_buddy_suite_init(struct kunit_suite *suite) > return 0; > } > > +/** > + * KTEST_SUITE: set of tests for drm buddy alloc > + * Scope: drm subsystem > + * Mega feature: drm > + * Feature: buddy_alloc > + * > + * KTEST_TEST: drm_test_buddy_alloc_%s > + * Description: Run DRM buddy allocation %arg[1] test > + * > + * arg[1].values: limit, range, optimistic, smoke, pathological > + */ > + > static struct kunit_case drm_buddy_tests[] = { > KUNIT_CASE(drm_test_buddy_alloc_limit), > KUNIT_CASE(drm_test_buddy_alloc_range),
On Wed, Jul 12, 2023 at 10:29 AM Mauro Carvalho Chehab <mchehab@kernel.org> wrote: > > As an example for the new documentation tool, add a documentation > for drm_buddy_test. > > I opted to place this on a completely different directory, in order > to make easier to test the feature with: > > $ make SPHINXDIRS="tests" htmldocs > > Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org> > --- > > To avoid mailbombing on a large number of people, only mailing lists were C/C on the cover. > See [PATCH RFC 0/2] at: https://lore.kernel.org/all/cover.1689171160.git.mchehab@kernel.org/ > > Documentation/index.rst | 2 +- > Documentation/tests/index.rst | 6 ++++++ > Documentation/tests/kunit.rst | 5 +++++ > drivers/gpu/drm/tests/drm_buddy_test.c | 12 ++++++++++++ > 4 files changed, 24 insertions(+), 1 deletion(-) > create mode 100644 Documentation/tests/index.rst > create mode 100644 Documentation/tests/kunit.rst > > diff --git a/Documentation/index.rst b/Documentation/index.rst > index 9dfdc826618c..80a6ce14a61a 100644 > --- a/Documentation/index.rst > +++ b/Documentation/index.rst > @@ -60,7 +60,7 @@ Various other manuals with useful information for all kernel developers. > fault-injection/index > livepatch/index > rust/index > - > + test/index > > User-oriented documentation > =========================== > diff --git a/Documentation/tests/index.rst b/Documentation/tests/index.rst > new file mode 100644 > index 000000000000..bfc39eb5c0aa > --- /dev/null > +++ b/Documentation/tests/index.rst > @@ -0,0 +1,6 @@ > +======================== > +Kunit documentation test > +======================== > + > +.. toctree:: > + kunit > diff --git a/Documentation/tests/kunit.rst b/Documentation/tests/kunit.rst > new file mode 100644 > index 000000000000..6ffc151988a0 > --- /dev/null > +++ b/Documentation/tests/kunit.rst > @@ -0,0 +1,5 @@ > +Kunit tests > +----------- > + > +.. include-test:: drivers/gpu/drm/tests/drm_buddy_test.c > + > diff --git a/drivers/gpu/drm/tests/drm_buddy_test.c b/drivers/gpu/drm/tests/drm_buddy_test.c > index 09ee6f6af896..dd6c5afd6cd6 100644 > --- a/drivers/gpu/drm/tests/drm_buddy_test.c > +++ b/drivers/gpu/drm/tests/drm_buddy_test.c > @@ -737,6 +737,18 @@ static int drm_buddy_suite_init(struct kunit_suite *suite) > return 0; > } > > +/** > + * KTEST_SUITE: set of tests for drm buddy alloc > + * Scope: drm subsystem > + * Mega feature: drm > + * Feature: buddy_alloc > + * > + * KTEST_TEST: drm_test_buddy_alloc_%s > + * Description: Run DRM buddy allocation %arg[1] test > + * > + * arg[1].values: limit, range, optimistic, smoke, pathological > + */ > + I apologize that the last email included a HTML attachment of the message. Just in case anyone was unable to receive the last email here is a copy of the message: Hi! This is such a cool patch series. I just have a few comments related to the output. In the html output the tests are listed as: ktest@drm_buddy_test@... I wonder if instead of using the file name of "drm_buddy_test" this could possibly be the suite name, "drm_buddy", as this is what users will call when using kunit.py to run the tests. Although "drm_buddy_test" is also the module name so I don't mind it too much. But in the future the file name and module name are not guaranteed to be the same for other tests. Most preferably, there would be a reference to the kunit suite name, file name, and the module name. This may be difficult to implement as these can all differ. I am currently working on the KUnit Attribute framework which saves the module name and I am thinking about also saving the file path as a future attribute. This could be a helpful framework for the KUnit tests specifically. I am not sure how easy it would be to access c objects/functions using this system. Finally, I was wondering if it is the intention to put a list of all KUnit tests that use this new feature into tests/kunit.rst or would this be broken up in some way. Thanks! -Rae > static struct kunit_case drm_buddy_tests[] = { > KUNIT_CASE(drm_test_buddy_alloc_limit), > KUNIT_CASE(drm_test_buddy_alloc_range), > -- > 2.40.1 >
Hi Rae, Em Thu, 13 Jul 2023 17:31:19 -0400 Rae Moar <rmoar@google.com> escreveu: > On Wed, Jul 12, 2023 at 10:29 AM Mauro Carvalho Chehab <mchehab@kernel.org> > wrote: > > > As an example for the new documentation tool, add a documentation > > for drm_buddy_test. > > > > I opted to place this on a completely different directory, in order > > to make easier to test the feature with: > > > > $ make SPHINXDIRS="tests" htmldocs > > > > Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org> > > --- > > > > To avoid mailbombing on a large number of people, only mailing lists were > > C/C on the cover. > > See [PATCH RFC 0/2] at: > > https://lore.kernel.org/all/cover.1689171160.git.mchehab@kernel.org/ > > > > Documentation/index.rst | 2 +- > > Documentation/tests/index.rst | 6 ++++++ > > Documentation/tests/kunit.rst | 5 +++++ > > drivers/gpu/drm/tests/drm_buddy_test.c | 12 ++++++++++++ > > 4 files changed, 24 insertions(+), 1 deletion(-) > > create mode 100644 Documentation/tests/index.rst > > create mode 100644 Documentation/tests/kunit.rst > > > > diff --git a/Documentation/index.rst b/Documentation/index.rst > > index 9dfdc826618c..80a6ce14a61a 100644 > > --- a/Documentation/index.rst > > +++ b/Documentation/index.rst > > @@ -60,7 +60,7 @@ Various other manuals with useful information for all > > kernel developers. > > fault-injection/index > > livepatch/index > > rust/index > > - > > + test/index > > > > User-oriented documentation > > =========================== > > diff --git a/Documentation/tests/index.rst b/Documentation/tests/index.rst > > new file mode 100644 > > index 000000000000..bfc39eb5c0aa > > --- /dev/null > > +++ b/Documentation/tests/index.rst > > @@ -0,0 +1,6 @@ > > +======================== > > +Kunit documentation test > > +======================== > > + > > +.. toctree:: > > + kunit > > diff --git a/Documentation/tests/kunit.rst b/Documentation/tests/kunit.rst > > new file mode 100644 > > index 000000000000..6ffc151988a0 > > --- /dev/null > > +++ b/Documentation/tests/kunit.rst > > @@ -0,0 +1,5 @@ > > +Kunit tests > > +----------- > > + > > +.. include-test:: drivers/gpu/drm/tests/drm_buddy_test.c > > + > > diff --git a/drivers/gpu/drm/tests/drm_buddy_test.c > > b/drivers/gpu/drm/tests/drm_buddy_test.c > > index 09ee6f6af896..dd6c5afd6cd6 100644 > > --- a/drivers/gpu/drm/tests/drm_buddy_test.c > > +++ b/drivers/gpu/drm/tests/drm_buddy_test.c > > @@ -737,6 +737,18 @@ static int drm_buddy_suite_init(struct kunit_suite > > *suite) > > return 0; > > } > > > > +/** > > + * KTEST_SUITE: set of tests for drm buddy alloc > > + * Scope: drm subsystem > > + * Mega feature: drm > > + * Feature: buddy_alloc > > + * > > + * KTEST_TEST: drm_test_buddy_alloc_%s > > + * Description: Run DRM buddy allocation %arg[1] test > > + * > > + * arg[1].values: limit, range, optimistic, smoke, pathological > > + */ > > > Hi! > > This is such a cool patch series. I just have a few comments related to the > output. Thank you for your comments! Sorry for not answering earlier. I took some vacations and this series ended sleeping over other tasks on my todo list. Also, before sending another version, I wanted to have the test_list.py changes to make it generic enough to be merged on IGT, to avoid having a fork of it. Those got merged today. > In the html output the tests are listed as: > ktest@drm_buddy_test@… > > I wonder if instead of using the file name of “drm_buddy_test” this could > possibly be the suite name, “drm_buddy”, as this is what users will call > when using kunit.py to run the tests. Although "drm_buddy_test" is also the > module name so I don't mind it too much. But in the future the file name > and module name are not guaranteed to be the same for other tests. > > Most preferably, there would be a reference to the kunit suite name, file > name, and the module name. I guess it shouldn't be hard to do such change in a way that it won't affect its usage on IGT. We need to define what would be the best pattern. As this can be used for both kunit and selftests, I would place kunit at the beginning. Currently, we're using: kunit@<base file name without .c>@<test_name> Some possible patterns would be: kunit@<base file name without .c>@<suite name>@<test_name> kunit@<subsystem>@<base file name without .c>@<suite name>@<test_name> kunit@<subsystem>@<suite name>@<test_name> Would do you think it would work best? > This may be difficult to implement as these can all differ. I am currently > working on the KUnit Attribute framework which saves the module name and I > am thinking about also saving the file path as a future attribute. This > could be a helpful framework for the KUnit tests specifically. > > I am not sure how easy it would be to access c objects/functions using this > system. I would prefer not. C language allows lots of flexibility with macros, making it hard to write a parser to read those C objects from the source. We have this at kernel-doc. As one of the people that did some work there, I can say that that several tricks are needed to keep this working. On the other hand, it should be easy to use the TestList class from test_list.py at kunit.py. So, kunit.py could use the data that came from the documentation directly. > Finally, I was wondering if it is the intention to put a list of all kunit > tests that use this new feature into tests/kunit.rst or would this be > broken up in some way IMO, it makes sense to break this per subsystem, and have an auto-generated index.rst pointing to the entire set of documents. We're already storing the subsystem at the documentation macros, so, IMO, it should shouldn't be hard to implement it. Regards, Mauro
diff --git a/Documentation/index.rst b/Documentation/index.rst index 9dfdc826618c..80a6ce14a61a 100644 --- a/Documentation/index.rst +++ b/Documentation/index.rst @@ -60,7 +60,7 @@ Various other manuals with useful information for all kernel developers. fault-injection/index livepatch/index rust/index - + test/index User-oriented documentation =========================== diff --git a/Documentation/tests/index.rst b/Documentation/tests/index.rst new file mode 100644 index 000000000000..bfc39eb5c0aa --- /dev/null +++ b/Documentation/tests/index.rst @@ -0,0 +1,6 @@ +======================== +Kunit documentation test +======================== + +.. toctree:: + kunit diff --git a/Documentation/tests/kunit.rst b/Documentation/tests/kunit.rst new file mode 100644 index 000000000000..6ffc151988a0 --- /dev/null +++ b/Documentation/tests/kunit.rst @@ -0,0 +1,5 @@ +Kunit tests +----------- + +.. include-test:: drivers/gpu/drm/tests/drm_buddy_test.c + diff --git a/drivers/gpu/drm/tests/drm_buddy_test.c b/drivers/gpu/drm/tests/drm_buddy_test.c index 09ee6f6af896..dd6c5afd6cd6 100644 --- a/drivers/gpu/drm/tests/drm_buddy_test.c +++ b/drivers/gpu/drm/tests/drm_buddy_test.c @@ -737,6 +737,18 @@ static int drm_buddy_suite_init(struct kunit_suite *suite) return 0; } +/** + * KTEST_SUITE: set of tests for drm buddy alloc + * Scope: drm subsystem + * Mega feature: drm + * Feature: buddy_alloc + * + * KTEST_TEST: drm_test_buddy_alloc_%s + * Description: Run DRM buddy allocation %arg[1] test + * + * arg[1].values: limit, range, optimistic, smoke, pathological + */ + static struct kunit_case drm_buddy_tests[] = { KUNIT_CASE(drm_test_buddy_alloc_limit), KUNIT_CASE(drm_test_buddy_alloc_range),