[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231217103012.41273-4-o-takashi@sakamocchi.jp>
Date: Sun, 17 Dec 2023 19:30:06 +0900
From: Takashi Sakamoto <o-takashi@...amocchi.jp>
To: linux1394-devel@...ts.sourceforge.net,
linux-kernel@...r.kernel.org
Cc: adamg@...ox.com
Subject: [RFC PATCH 3/8] firewire: test: add KUnit test for internal CSR API
The operation over CSR space is important since it is related to detection
of nodes and units, addition of system devices. Any test of the operation
is enough useful.
This commit adds a skeleton of KUnit test for the purpose.
Signed-off-by: Takashi Sakamoto <o-takashi@...amocchi.jp>
---
drivers/firewire/.kunitconfig | 1 +
drivers/firewire/Kconfig | 16 ++++++++++++++++
drivers/firewire/core-device.c | 4 ++++
drivers/firewire/csr-api-test.c | 19 +++++++++++++++++++
4 files changed, 40 insertions(+)
create mode 100644 drivers/firewire/csr-api-test.c
diff --git a/drivers/firewire/.kunitconfig b/drivers/firewire/.kunitconfig
index 1599e069395f..03104cdd06eb 100644
--- a/drivers/firewire/.kunitconfig
+++ b/drivers/firewire/.kunitconfig
@@ -2,3 +2,4 @@ CONFIG_KUNIT=y
CONFIG_PCI=y
CONFIG_FIREWIRE=y
CONFIG_FIREWIRE_KUNIT_UAPI_TEST=y
+CONFIG_FIREWIRE_KUNIT_CSR_API_TEST=y
diff --git a/drivers/firewire/Kconfig b/drivers/firewire/Kconfig
index 0a6596b027db..184906fdb77a 100644
--- a/drivers/firewire/Kconfig
+++ b/drivers/firewire/Kconfig
@@ -34,6 +34,22 @@ config FIREWIRE_KUNIT_UAPI_TEST
For more information on KUnit and unit tests in general, refer
to the KUnit documentation in Documentation/dev-tools/kunit/.
+config FIREWIRE_KUNIT_CSR_API_TEST
+ tristate "KUnit tests for internal CSR API" if !KUNIT_ALL_TESTS
+ depends on FIREWIRE && KUNIT
+ default KUNIT_ALL_TESTS
+ help
+ This builds the KUnit tests for internal API for Control and
+ Status Registers.
+
+ KUnit tests run during boot and output the results to the debug
+ log in TAP format (https://testanything.org/). Only useful for
+ kernel devs running KUnit test harness and are not for inclusion
+ into a production build.
+
+ For more information on KUnit and unit tests in general, refer
+ to the KUnit documentation in Documentation/dev-tools/kunit/.
+
config FIREWIRE_OHCI
tristate "OHCI-1394 controllers"
depends on PCI && FIREWIRE && MMU
diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
index 137001f8a695..14c7461c05f6 100644
--- a/drivers/firewire/core-device.c
+++ b/drivers/firewire/core-device.c
@@ -1313,3 +1313,7 @@ void fw_node_event(struct fw_card *card, struct fw_node *node, int event)
break;
}
}
+
+#ifdef CONFIG_FIREWIRE_KUNIT_CSR_API_TEST
+#include "csr-api-test.c"
+#endif
diff --git a/drivers/firewire/csr-api-test.c b/drivers/firewire/csr-api-test.c
new file mode 100644
index 000000000000..a76d767373e9
--- /dev/null
+++ b/drivers/firewire/csr-api-test.c
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// csr-api-test.c - An application of Kunit to test implementation for CSR operation.
+//
+// Copyright (c) 2023 Takashi Sakamoto
+//
+// This file can not be built independently since it is intentionally included in core-device.c.
+
+#include <kunit/test.h>
+
+static struct kunit_case csr_api_test_cases[] = {
+ {}
+};
+
+static struct kunit_suite csr_api_test_suite = {
+ .name = "firewire-csr-api",
+ .test_cases = csr_api_test_cases,
+};
+kunit_test_suite(csr_api_test_suite);
--
2.39.2
Powered by blists - more mailing lists