[PATCH 0/3] lib/crc: Fix crc_kunit dependency and add kunitconfig

1 view
Skip to first unread message

Eric Biggers

unread,
Mar 5, 2026, 10:38:18 PMMar 5
to linux-...@vger.kernel.org, linux-...@vger.kernel.org, Ard Biesheuvel, kuni...@googlegroups.com, Eric Biggers
This series fixes crc_kunit to follow the standard KUnit convention of
depending on the code it tests rather than selecting it, adds a kconfig
option that enables all the CRC variants for KUnit testing, and adds a
kunitconfig file for lib/crc/.

This follows similar changes to lib/crypto/ (except lib/crypto/ doesn't
have an equivalent to CRC_ENABLE_ALL_FOR_KUNIT yet, but we could
consider adding one).

This series applies to v7.0-rc2 and is targeting crc-next.

Eric Biggers (3):
lib/crc: tests: Make crc_kunit test only the enabled CRC variants
lib/crc: tests: Add CRC_ENABLE_ALL_FOR_KUNIT
lib/crc: tests: Add a .kunitconfig file

lib/crc/.kunitconfig | 3 +++
lib/crc/Kconfig | 17 +++++++++++++----
lib/crc/tests/crc_kunit.c | 28 ++++++++++++++++++++++------
3 files changed, 38 insertions(+), 10 deletions(-)
create mode 100644 lib/crc/.kunitconfig


base-commit: 11439c4635edd669ae435eec308f4ab8a0804808
--
2.53.0

Eric Biggers

unread,
Mar 5, 2026, 10:38:18 PMMar 5
to linux-...@vger.kernel.org, linux-...@vger.kernel.org, Ard Biesheuvel, kuni...@googlegroups.com, Eric Biggers
Now that crc_kunit uses the standard "depends on" pattern, enabling the
full set of CRC tests is a bit difficult, mainly due to CRC7 being
rarely used. Add a kconfig option to make it easier. It is visible
only when KUNIT, so hopefully the extra prompt won't be too annoying.

Signed-off-by: Eric Biggers <ebig...@kernel.org>
---
lib/crc/Kconfig | 14 ++++++++++++++
1 file changed, 14 insertions(+)

diff --git a/lib/crc/Kconfig b/lib/crc/Kconfig
index 9ddfd1a29757..cca228879bb5 100644
--- a/lib/crc/Kconfig
+++ b/lib/crc/Kconfig
@@ -105,10 +105,24 @@ config CRC_KUNIT_TEST
Unit tests for the CRC library functions.

This is intended to help people writing architecture-specific
optimized versions. If unsure, say N.

+config CRC_ENABLE_ALL_FOR_KUNIT
+ tristate "Enable all CRC functions for KUnit test"
+ depends on KUNIT
+ select CRC7
+ select CRC16
+ select CRC_T10DIF
+ select CRC32
+ select CRC64
+ help
+ Enable all CRC functions that have test code in CRC_KUNIT_TEST.
+
+ Enable this only if you'd like the CRC KUnit test suite to test all
+ the CRC variants, even ones that wouldn't otherwise need to be built.
+
config CRC_BENCHMARK
bool "Benchmark for the CRC functions"
depends on CRC_KUNIT_TEST
help
Include benchmarks in the KUnit test suite for the CRC functions.
--
2.53.0

Eric Biggers

unread,
Mar 13, 2026, 8:03:33 PM (7 days ago) Mar 13
to linux-...@vger.kernel.org, linux-...@vger.kernel.org, Ard Biesheuvel, kuni...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages