From 672c1432ed0f725ce71c99df9b3791cbc6f28839 Mon Sep 17 00:00:00 2001 From: Timothy Day Date: Sun, 8 Oct 2023 22:50:41 +0000 Subject: [PATCH] LU-16763 kunit: consolidate kernel unit testing There are several kernel modules used for different types of unit testing. Unify them all in one place. This will make it easier to standardize them in the future. Also, ensure kinode.ko is in the right place on Ubuntu. Test-Parameters: trivial Test-Parameters: testlist=sanity env=ONLY=55,ONLY_REPEAT=10 clientdistro=ubuntu2204 Test-Parameters: testlist=sanity env=ONLY=55,ONLY_REPEAT=10 Test-Parameters: testlist=sanity env=ONLY=410,ONLY_REPEAT=10 Test-Parameters: testlist=sanity env=ONLY=60a,ONLY_REPEAT=10 Signed-off-by: Timothy Day Change-Id: I16e5fc3dfb570d88c7ed817eab74511a22e91ac6 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/52597 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Arshad Hussain Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- debian/lustre-tests.install.in | 1 + lustre/Makefile.in | 2 +- lustre/autoMakefile.am | 2 +- lustre/autoconf/lustre-core.m4 | 4 +-- lustre/kunit/Makefile.in | 15 +++++++++ lustre/kunit/autoMakefile.am | 17 ++++++++++ lustre/{tests/kernel => kunit}/kinode.c | 37 ++++++++-------------- lustre/{obdclass => kunit}/llog_test.c | 28 ++++------------ lustre/{obdclass => kunit}/obd_test.c | 2 +- lustre/obdclass/Makefile.in | 4 +-- lustre/obdclass/autoMakefile.am | 6 ---- lustre/tests/kernel/Makefile.in | 5 --- lustre/tests/kernel/autoMakefile.am | 33 ------------------- .../tests/lutf/python/tests-infra/utility_paths.py | 4 +-- lustre/tests/run-llog.sh | 2 +- lustre/tests/sanity.sh | 4 +-- lustre/utils/debug.c | 4 ++- 17 files changed, 67 insertions(+), 103 deletions(-) create mode 100644 lustre/kunit/Makefile.in create mode 100644 lustre/kunit/autoMakefile.am rename lustre/{tests/kernel => kunit}/kinode.c (78%) rename lustre/{obdclass => kunit}/llog_test.c (98%) rename lustre/{obdclass => kunit}/obd_test.c (98%) delete mode 100644 lustre/tests/kernel/Makefile.in delete mode 100644 lustre/tests/kernel/autoMakefile.am diff --git a/debian/lustre-tests.install.in b/debian/lustre-tests.install.in index ad47368..6ff8b57 100644 --- a/debian/lustre-tests.install.in +++ b/debian/lustre-tests.install.in @@ -1,4 +1,5 @@ debian/tmp/lib/modules/_KVERS_/updates/kernel/fs/lustre/*_test.ko usr/lib/modules/_KVERS_/updates/kernel/fs/lustre/ +debian/tmp/lib/modules/_KVERS_/updates/kernel/fs/lustre/kinode.ko usr/lib/modules/_KVERS_/updates/kernel/fs/lustre/ debian/tmp/usr/lib/lustre/tests/* usr/lib/lustre/tests debian/tmp/usr/bin/mcreate usr/bin debian/tmp/usr/bin/statx usr/bin diff --git a/lustre/Makefile.in b/lustre/Makefile.in index 1cde69a..ef05062 100644 --- a/lustre/Makefile.in +++ b/lustre/Makefile.in @@ -5,7 +5,7 @@ obj-m += ldlm/ obj-m += obdecho/ obj-m += mgc/ obj-m += ec/ -obj-m += tests/kernel/ +obj-m += kunit/ @SERVER_TRUE@obj-m += ost/ mgs/ mdt/ mdd/ ofd/ quota/ osp/ lod/ lfsck/ target/ @CLIENT_TRUE@obj-m += lov/ osc/ mdc/ lmv/ llite/ fld/ diff --git a/lustre/autoMakefile.am b/lustre/autoMakefile.am index 61f0e97..5d9ee36 100644 --- a/lustre/autoMakefile.am +++ b/lustre/autoMakefile.am @@ -35,7 +35,7 @@ AUTOMAKE_OPTIONS = foreign # also update lustre/autoconf/lustre-core.m4 AC_CONFIG_FILES ALWAYS_SUBDIRS = include obdclass ldlm ptlrpc obdecho ec \ - mgc fid fld doc utils tests tests/kernel scripts autoconf conf + mgc fid fld doc utils tests scripts autoconf conf kunit SERVER_SUBDIRS = ost mgs mdt mdd ofd osd-zfs osd-ldiskfs \ quota osp lod target lfsck diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index 9948735..af32b5f 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -5100,8 +5100,8 @@ lustre/tests/mpi/Makefile lustre/tests/iabf/Makefile lustre/tests/lutf/Makefile lustre/tests/lutf/src/Makefile -lustre/tests/kernel/Makefile -lustre/tests/kernel/autoMakefile +lustre/kunit/Makefile +lustre/kunit/autoMakefile lustre/utils/Makefile lustre/utils/gss/Makefile lustre/osp/Makefile diff --git a/lustre/kunit/Makefile.in b/lustre/kunit/Makefile.in new file mode 100644 index 0000000..37f1339 --- /dev/null +++ b/lustre/kunit/Makefile.in @@ -0,0 +1,15 @@ +# SPDX-License-Identifier: GPL-2.0 + +# +# This file is part of Lustre, http://www.lustre.org/ +# +# lustre/kunit/Makefile.in +# +# Makefile template for kunit +# + +MODULES := llog_test obd_test kinode + +EXTRA_DIST = llog_test.c obd_test.c kinode.c + +@INCLUDE_RULES@ diff --git a/lustre/kunit/autoMakefile.am b/lustre/kunit/autoMakefile.am new file mode 100644 index 0000000..a696544 --- /dev/null +++ b/lustre/kunit/autoMakefile.am @@ -0,0 +1,17 @@ +# SPDX-License-Identifier: GPL-2.0 + +# +# This file is part of Lustre, http://www.lustre.org/ +# +# lustre/kunit/autoMakefile.am +# +# autoMakefile for kunit +# + +if MODULES +modulefs_DATA = llog_test$(KMODEXT) +modulefs_DATA += obd_test$(KMODEXT) +modulefs_DATA += kinode$(KMODEXT) +endif # MODULES + +MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ diff --git a/lustre/tests/kernel/kinode.c b/lustre/kunit/kinode.c similarity index 78% rename from lustre/tests/kernel/kinode.c rename to lustre/kunit/kinode.c index 83c531f..2958482 100644 --- a/lustre/tests/kernel/kinode.c +++ b/lustre/kunit/kinode.c @@ -1,35 +1,24 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.gnu.org/licenses/gpl-2.0.html - * - * GPL HEADER END - */ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright 2017 Cray Inc. All rights reserved. - * Author: Frank Zago. + * */ -/* Check that the inode number is the same whether the call to +/* + * This file is part of Lustre, http://www.lustre.org/ + * + * lustre/kunit/kinode.c + * + * Check that the inode number is the same whether the call to * vfs_getattr is coming from a system call or from a kthread. When * CONFIG_X86_X32 was set, the result used to be different for * Lustre. In addition, a user can also check that the same inode - * number is also seen from the kernel and userspace. */ + * number is also seen from the kernel and userspace. + * + * Author: Frank Zago + * + */ #include #include diff --git a/lustre/obdclass/llog_test.c b/lustre/kunit/llog_test.c similarity index 98% rename from lustre/obdclass/llog_test.c rename to lustre/kunit/llog_test.c index e06ee0a..9936924 100644 --- a/lustre/obdclass/llog_test.c +++ b/lustre/kunit/llog_test.c @@ -1,37 +1,21 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.gnu.org/licenses/gpl-2.0.html - * - * GPL HEADER END - */ +// SPDX-License-Identifier: GPL-2.0 + /* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. * * Copyright (c) 2012, 2017, Intel Corporation. + * */ + /* * This file is part of Lustre, http://www.lustre.org/ * - * lustre/obdclass/llog_test.c + * lustre/kunit/llog_test.c * * Author: Phil Schwan * Author: Mikhail Pershin + * */ #define DEBUG_SUBSYSTEM S_CLASS diff --git a/lustre/obdclass/obd_test.c b/lustre/kunit/obd_test.c similarity index 98% rename from lustre/obdclass/obd_test.c rename to lustre/kunit/obd_test.c index 117b5e8..3f9b943 100644 --- a/lustre/obdclass/obd_test.c +++ b/lustre/kunit/obd_test.c @@ -9,7 +9,7 @@ /* * This file is part of Lustre, http://www.lustre.org/ * - * lustre/obdclass/obd_test.c + * lustre/kunit/obd_test.c * * Simple OBD device for: * 1) testing OBD device lifecycle management diff --git a/lustre/obdclass/Makefile.in b/lustre/obdclass/Makefile.in index 408db86..ba1ef4c 100644 --- a/lustre/obdclass/Makefile.in +++ b/lustre/obdclass/Makefile.in @@ -8,7 +8,7 @@ # Makefile template for obdclass # -MODULES := obdclass llog_test obd_test +MODULES := obdclass default: all @@ -37,7 +37,7 @@ obdclass-objs := $(obdclass-all-objs) EXTRA_PRE_CFLAGS := -I@LINUX@/fs -I@LDISKFS_DIR@ -I@LDISKFS_DIR@/ldiskfs -EXTRA_DIST = $(obdclass-all-objs:.o=.c) llog_test.c obd_test.c llog_internal.h +EXTRA_DIST = $(obdclass-all-objs:.o=.c) llog_internal.h EXTRA_DIST += cl_internal.h local_storage.h EXTRA_DIST += range_lock.c interval_tree.c diff --git a/lustre/obdclass/autoMakefile.am b/lustre/obdclass/autoMakefile.am index b566f4e..cc80950 100644 --- a/lustre/obdclass/autoMakefile.am +++ b/lustre/obdclass/autoMakefile.am @@ -9,15 +9,9 @@ # if MODULES - if LINUX modulefs_DATA = obdclass$(KMODEXT) -if TESTS -modulefs_DATA += llog_test$(KMODEXT) -modulefs_DATA += obd_test$(KMODEXT) -endif # TESTS endif # LINUX - endif # MODULES MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ diff --git a/lustre/tests/kernel/Makefile.in b/lustre/tests/kernel/Makefile.in deleted file mode 100644 index 9cba127..0000000 --- a/lustre/tests/kernel/Makefile.in +++ /dev/null @@ -1,5 +0,0 @@ -MODULES := kinode - -EXTRA_DIST = kinode.c - -@INCLUDE_RULES@ diff --git a/lustre/tests/kernel/autoMakefile.am b/lustre/tests/kernel/autoMakefile.am deleted file mode 100644 index 7cf533d..0000000 --- a/lustre/tests/kernel/autoMakefile.am +++ /dev/null @@ -1,33 +0,0 @@ -# -# GPL HEADER START -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 only, -# as published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License version 2 for more details (a copy is included -# in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU General Public License -# version 2 along with this program; If not, see -# http://www.gnu.org/licenses/gpl-2.0.html -# -# GPL HEADER END -# - -# -# This file is part of Lustre, http://www.lustre.org/ -# - -if MODULES -if TESTS -modulefs_DATA = kinode$(KMODEXT) -endif -endif - -MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ diff --git a/lustre/tests/lutf/python/tests-infra/utility_paths.py b/lustre/tests/lutf/python/tests-infra/utility_paths.py index 95db416..ae96cd5 100644 --- a/lustre/tests/lutf/python/tests-infra/utility_paths.py +++ b/lustre/tests/lutf/python/tests-infra/utility_paths.py @@ -66,12 +66,12 @@ lmodules=[ 'lustre/ptlrpc/ptlrpc.ko', 'lustre/fld/fld.ko', 'lustre/fid/fid.ko', -'lustre/obdclass/llog_test.ko', +'lustre/kunit/llog_test.ko', 'lustre/ptlrpc/gss/ptlrpc_gss.ko', 'lustre/obdecho/obdecho.ko', 'lustre/mgc/mgc.ko', 'lustre/red/red.ko', -'lustre/tests/kernel/kinode.ko', +'lustre/kunit/kinode.ko', 'lustre/ost/ost.ko', 'lustre/mgs/mgs.ko', 'lustre/lfsck/lfsck.ko', diff --git a/lustre/tests/run-llog.sh b/lustre/tests/run-llog.sh index 714002a..9178b26 100644 --- a/lustre/tests/run-llog.sh +++ b/lustre/tests/run-llog.sh @@ -19,7 +19,7 @@ set -x MGS=$($LCTL dl | awk '/mgs/ { print $4 }') [ -z "$MGS" ] && echo "$0: SKIP: no MGS available, skipping llog test" && exit 0 -load_module obdclass/llog_test || exit 1 +load_module kunit/llog_test || exit 1 $LCTL modules > "$TMP/ogdb-$(hostname)" echo "NOW reload debugging syms.." diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 21901a0..a9b6ad4 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -6441,7 +6441,7 @@ run_test 54e "console/tty device works in lustre ======================" test_55a() { local dev_path="/sys/kernel/debug/lustre/devices" - load_module obdclass/obd_test verbose=2 || error "load_module failed" + load_module kunit/obd_test verbose=2 || error "load_module failed" # This must be run in iteractive mode, since attach and setup # are stateful @@ -6473,7 +6473,7 @@ test_55b() { # testing). We don't want to run this test forever. local num_dev_to_create="$(( 24000 - $dev_count))" - load_module obdclass/obd_test || error "load_module failed" + load_module kunit/obd_test || error "load_module failed" local start=$SECONDS diff --git a/lustre/utils/debug.c b/lustre/utils/debug.c index 96bbf1d..bf3e161 100644 --- a/lustre/utils/debug.c +++ b/lustre/utils/debug.c @@ -806,7 +806,9 @@ static struct mod_paths { { .name = "kgnilnd", .path = "lnet/klnds/gnilnd"}, { .name = "ksocklnd", .path = "lnet/klnds/socklnd" }, { .name = "obdclass", .path = "lustre/obdclass" }, - { .name = "llog_test", .path = "lustre/obdclass" }, + { .name = "llog_test", .path = "lustre/kunit" }, + { .name = "obd_test", .path = "lustre/kunit" }, + { .name = "kinode", .path = "lustre/kunit" }, { .name = "ptlrpc_gss", .path = "lustre/ptlrpc/gss" }, { .name = "ptlrpc", .path = "lustre/ptlrpc" }, { .name = "gks", .path = "lustre/sec/gks" }, -- 1.8.3.1