linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Latypov <dlatypov@google.com>
To: mika.westerberg@linux.intel.com
Cc: brendanhiggins@google.com, davidgow@google.com,
	linux-kernel@vger.kernel.org, kunit-dev@googlegroups.com,
	linux-usb@vger.kernel.org, Daniel Latypov <dlatypov@google.com>
Subject: [PATCH] thunderbolt: test: get running under UML, add kunitconfig
Date: Mon, 14 Feb 2022 10:41:04 -0800	[thread overview]
Message-ID: <20220214184104.1710107-1-dlatypov@google.com> (raw)

These tests didn't work under the normal `kunit.py run` command since
they require CONFIG_PCI=y, which could not be set on ARCH=um.

Commit 68f5d3f3b654 ("um: add PCI over virtio emulation driver") lets us
do so. To make it so people don't have to figure out how to do so, we
add a drivers/thunderbolt/.kunitconfig.

Can now run these tests using
$ ./tools/testing/kunit/kunit.py run --kunitconfig=drivers/thunderbolt

Potentially controversial bits:
1. this .kunitconfig is UML-specific, can't do this for example
$ ./tools/testing/kunit/kunit.py run --arch=x86_64 --kunitconfig=drivers/thunderbolt
2. this removes the manual call to __kunit_test_suites_init(), which
   allowed us to control exactly when the tests got run.

The main motivation for both is convenience.

For #1, we could drop the UML specific options, but then users would
always have to set --arch. Since UML is a bit faster and there's less to
type when running it with kunit.py, let's make it work by default.
Users can manually edit the .kunitconfig to run under x86_64.

For #2, running our suite separately prevents kunit.py from picking up
results properly as it only parses one set of KUnit results. I.e.
there's an assumption that __kunit_test_suites_init() only gets called
once. Since the tests seem to run fine when kunit runs them, giving up
this control seems fine.

Signed-off-by: Daniel Latypov <dlatypov@google.com>
---
 drivers/thunderbolt/.kunitconfig |  7 +++++++
 drivers/thunderbolt/domain.c     |  3 ---
 drivers/thunderbolt/tb.h         |  8 --------
 drivers/thunderbolt/test.c       | 12 +-----------
 4 files changed, 8 insertions(+), 22 deletions(-)
 create mode 100644 drivers/thunderbolt/.kunitconfig

diff --git a/drivers/thunderbolt/.kunitconfig b/drivers/thunderbolt/.kunitconfig
new file mode 100644
index 000000000000..c8c9467bc144
--- /dev/null
+++ b/drivers/thunderbolt/.kunitconfig
@@ -0,0 +1,7 @@
+CONFIG_PCI=y
+CONFIG_VIRTIO_UML=y
+CONFIG_UML_PCI_OVER_VIRTIO=y
+
+CONFIG_KUNIT=y
+CONFIG_USB4=y
+CONFIG_USB4_KUNIT_TEST=y
diff --git a/drivers/thunderbolt/domain.c b/drivers/thunderbolt/domain.c
index 7018d959f775..dedc2866f51b 100644
--- a/drivers/thunderbolt/domain.c
+++ b/drivers/thunderbolt/domain.c
@@ -878,7 +878,6 @@ int tb_domain_init(void)
 {
 	int ret;
 
-	tb_test_init();
 	tb_debugfs_init();
 	tb_acpi_init();
 
@@ -896,7 +895,6 @@ int tb_domain_init(void)
 err_acpi:
 	tb_acpi_exit();
 	tb_debugfs_exit();
-	tb_test_exit();
 
 	return ret;
 }
@@ -909,5 +907,4 @@ void tb_domain_exit(void)
 	tb_xdomain_exit();
 	tb_acpi_exit();
 	tb_debugfs_exit();
-	tb_test_exit();
 }
diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h
index 74d3b14f004e..db54f8a27ba8 100644
--- a/drivers/thunderbolt/tb.h
+++ b/drivers/thunderbolt/tb.h
@@ -1261,12 +1261,4 @@ static inline void tb_service_debugfs_init(struct tb_service *svc) { }
 static inline void tb_service_debugfs_remove(struct tb_service *svc) { }
 #endif
 
-#ifdef CONFIG_USB4_KUNIT_TEST
-int tb_test_init(void);
-void tb_test_exit(void);
-#else
-static inline int tb_test_init(void) { return 0; }
-static inline void tb_test_exit(void) { }
-#endif
-
 #endif
diff --git a/drivers/thunderbolt/test.c b/drivers/thunderbolt/test.c
index 1f69bab236ee..601c04aaa7d9 100644
--- a/drivers/thunderbolt/test.c
+++ b/drivers/thunderbolt/test.c
@@ -2725,14 +2725,4 @@ static struct kunit_suite tb_test_suite = {
 	.test_cases = tb_test_cases,
 };
 
-static struct kunit_suite *tb_test_suites[] = { &tb_test_suite, NULL };
-
-int tb_test_init(void)
-{
-	return __kunit_test_suites_init(tb_test_suites);
-}
-
-void tb_test_exit(void)
-{
-	return __kunit_test_suites_exit(tb_test_suites);
-}
+kunit_test_suites(&tb_test_suite);

base-commit: 754e0b0e35608ed5206d6a67a791563c631cec07
-- 
2.35.1.265.g69c8d7142f-goog


             reply	other threads:[~2022-02-14 18:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-14 18:41 Daniel Latypov [this message]
2022-02-15  2:39 ` [PATCH] thunderbolt: test: get running under UML, add kunitconfig Daniel Latypov
2022-02-15  6:35   ` David Gow
2022-02-15  6:41   ` Mika Westerberg
2022-02-15 18:03     ` Daniel Latypov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220214184104.1710107-1-dlatypov@google.com \
    --to=dlatypov@google.com \
    --cc=brendanhiggins@google.com \
    --cc=davidgow@google.com \
    --cc=kunit-dev@googlegroups.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).