Skip to content

Commit 1770d39

Browse files
committed
firewire: test: add KUnit test for device attributes
The traverse over CSR space results in attributes of node and unit devices. Any test of the traverse is useful. This commit adds a skeleton of KUnit test for the purpose. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Sakamoto <[email protected]>
1 parent afa36da commit 1770d39

File tree

4 files changed

+40
-0
lines changed

4 files changed

+40
-0
lines changed

drivers/firewire/.kunitconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ CONFIG_KUNIT=y
22
CONFIG_PCI=y
33
CONFIG_FIREWIRE=y
44
CONFIG_FIREWIRE_KUNIT_UAPI_TEST=y
5+
CONFIG_FIREWIRE_KUNIT_DEVICE_ATTRIBUTE_TEST=y

drivers/firewire/Kconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,22 @@ config FIREWIRE_KUNIT_UAPI_TEST
3434
For more information on KUnit and unit tests in general, refer
3535
to the KUnit documentation in Documentation/dev-tools/kunit/.
3636

37+
config FIREWIRE_KUNIT_DEVICE_ATTRIBUTE_TEST
38+
tristate "KUnit tests for device attributes" if !KUNIT_ALL_TESTS
39+
depends on FIREWIRE && KUNIT
40+
default KUNIT_ALL_TESTS
41+
help
42+
This builds the KUnit tests for device attribute for node and
43+
unit.
44+
45+
KUnit tests run during boot and output the results to the debug
46+
log in TAP format (https://testanything.org/). Only useful for
47+
kernel devs running KUnit test harness and are not for inclusion
48+
into a production build.
49+
50+
For more information on KUnit and unit tests in general, refer
51+
to the KUnit documentation in Documentation/dev-tools/kunit/.
52+
3753
config FIREWIRE_OHCI
3854
tristate "OHCI-1394 controllers"
3955
depends on PCI && FIREWIRE && MMU

drivers/firewire/core-device.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,3 +1310,7 @@ void fw_node_event(struct fw_card *card, struct fw_node *node, int event)
13101310
break;
13111311
}
13121312
}
1313+
1314+
#ifdef CONFIG_FIREWIRE_KUNIT_DEVICE_ATTRIBUTE_TEST
1315+
#include "device-attribute-test.c"
1316+
#endif
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
//
3+
// device-attribute-test.c - An application of Kunit to test implementation for device attributes.
4+
//
5+
// Copyright (c) 2023 Takashi Sakamoto
6+
//
7+
// This file can not be built independently since it is intentionally included in core-device.c.
8+
9+
#include <kunit/test.h>
10+
11+
static struct kunit_case device_attr_test_cases[] = {
12+
{}
13+
};
14+
15+
static struct kunit_suite device_attr_test_suite = {
16+
.name = "firewire-device-attribute",
17+
.test_cases = device_attr_test_cases,
18+
};
19+
kunit_test_suite(device_attr_test_suite);

0 commit comments

Comments
 (0)