ceph: introduce Kunit based unit-tests for string operations
Subsystems (3)
Viacheslav Dubeyko
maintainerPATCH v2 1/1 ceph: introduce Kunit based unit-tests for string operations
From: Viacheslav Dubeyko <[email protected]>
This patch implements the Kunit based set of
unit tests for string operations. It checks
functionality of ceph_mds_state_name(),ceph_session_op_name(), ceph_mds_op_name(),ceph_cap_op_name(), ceph_lease_op_name(), andceph_snap_op_name().
./tools/testing/kunit/kunit.py run --kunitconfig ./fs/ceph/.kunitconfig [11:05:53] Configuring KUnit Kernel ...
[11:05:53] Building KUnit Kernel ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig Building with: $ make all compile_commands.json scripts_gdb ARCH=um O=.kunit --jobs=22 [11:06:01] Starting KUnit Kernel (1/1)... [11:06:01] ============================================================ Running tests with: $ .kunit/linux kunit.enable=1 mem=1G console=tty kunit_shutdown=halt [11:06:01] ================ ceph_strings (6 subtests) ================= [11:06:01] [PASSED] ceph_mds_state_name_test [11:06:01] [PASSED] ceph_session_op_name_test [11:06:01] [PASSED] ceph_mds_op_name_test [11:06:01] [PASSED] ceph_cap_op_name_test [11:06:01] [PASSED] ceph_lease_op_name_test [11:06:01] [PASSED] ceph_snap_op_name_test [11:06:01] ================== [PASSED] ceph_strings =================== [11:06:01] ============================================================ [11:06:01] Testing complete. Ran 6 tests: passed: 6 [11:06:01] Elapsed time: 8.286s total, 0.002s configuring, 8.117s building, 0.128s running
v2
Fix sparse warnings in strings_test.c
sparse warnings: (new ones prefixed by >>)
Quoted 3 lines
Quoted 3 lines
fs/ceph/strings_test.c:102:11: sparse: sparse: symbol 'ceph_str_idx_2_mds_state' was not declared. Should it be static?fs/ceph/strings_test.c:247:11: sparse: sparse: symbol 'ceph_str_idx_2_mds_op' was not declared. Should it be static?fs/ceph/strings_test.c:459:11: sparse: sparse: symbol 'ceph_str_idx_2_lease_op' was not declared. Should it be static?
--- fs/ceph/.kunitconfig | 16 + fs/ceph/Kconfig | 12 + fs/ceph/Makefile | 2 + fs/ceph/kunit_tests.h | 30 ++ fs/ceph/strings.c | 381 +++++++++++++++++------ fs/ceph/strings_test.c | 588 +++++++++++++++++++++++++++++++++++ include/linux/ceph/ceph_fs.h | 191 ++++++++---- 7 files changed, 1062 insertions(+), 158 deletions(-) create mode 100644 fs/ceph/.kunitconfig create mode 100644 fs/ceph/kunit_tests.h create mode 100644 fs/ceph/strings_test.c
fs/ceph/.kunitconfig new file +16 -0
@@ -0,0 +1,16 @@ +CONFIG_KUNIT=y +CONFIG_NET=y +CONFIG_INET=y +CONFIG_IPV6=y +CONFIG_CRYPTO=y +CONFIG_CRC32=y +CONFIG_CRYPTO_AES=y +CONFIG_CRYPTO_CBC=y +CONFIG_CRYPTO_GCM=y +CONFIG_CRYPTO_HMAC=y +CONFIG_CRYPTO_SHA256=y +CONFIG_KEYS=y +CONFIG_NETFS_SUPPORT=y +CONFIG_CEPH_LIB=y +CONFIG_CEPH_FS=y +CONFIG_CEPH_FS_KUNIT_TEST=y
fs/ceph/Kconfig +12 -0
@@ -50,3 +50,15 @@ config CEPH_FS_SECURITY_LABEL If you are not using a security module that requires using extended attributes for file security labels, say N. + +config CEPH_FS_KUNIT_TEST + tristate "KUnit tests for Ceph FS" if !KUNIT_ALL_TESTS + depends on CEPH_FS && KUNIT + default KUNIT_ALL_TESTS + help + This builds KUnit tests for Ceph file system functions. + + For more information on KUnit and unit tests in general, please refer + to the KUnit documentation in Documentation/dev-tools/kunit. + + If unsure, say N.
fs/ceph/Makefile +2 -0
@@ -13,3 +13,5 @@ ceph-y := super.o inode.o dir.o file.o locks.o addr.o ioctl.o \ ceph-$(CONFIG_CEPH_FSCACHE) += cache.o ceph-$(CONFIG_CEPH_FS_POSIX_ACL) += acl.o ceph-$(CONFIG_FS_ENCRYPTION) += crypto.o + +obj-$(CONFIG_CEPH_FS_KUNIT_TEST) += strings_test.o
fs/ceph/kunit_tests.h new file +30 -0
@@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* KUnit tests declarations +* +* Copyright (C) 2025, IBM Corporation +* +* Author: Viacheslav Dubeyko <[email protected]> +*/ + +#ifndef _CEPH_KUNIT_TESTS_H +#define _CEPH_KUNIT_TESTS_H + +#include <kunit/visibility.h> + +#if IS_ENABLED (CONFIG_KUNIT ) +int ceph_mds_state_2_str_idx (int mds_state); +extern const char *ceph_mds_state_name_strings[]; +int ceph_session_op_2_str_idx (int op); +extern const char *ceph_session_op_name_strings[]; +int ceph_mds_op_2_str_idx (int op); +extern const char *ceph_mds_op_name_strings[]; +int ceph_cap_op_2_str_idx (int op); +extern const char *ceph_cap_op_name_strings[]; +int ceph_lease_op_2_str_idx (int op); +extern const char *ceph_lease_op_name_strings[]; +int ceph_snap_op_2_str_idx (int op); +extern const char *ceph_snap_op_name_strings[]; +#endif + +#endif /* _CEPH_KUNIT_TESTS_H */
fs/ceph/strings.c +287 -94
413 lines not on this page · raw message
fs/ceph/strings_test.c new file +588 -0
588 lines not on this page · raw message
include/linux/ceph/ceph_fs.h +127 -64
233 lines not on this page · raw message
Signature · 1 line
2.51.0