Skip to contentSkip to conversation

testsuite: add tests for weak dependencies

PATCH In review Jose Ignacio Tornos Martinez 3 participants 5 messages May 30, 2024 – Jul 9, 2024 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 testsuite: add tests for weak dependencies

The following tests to verify weak dependencies have been implemented:
1) modprobe test to check that related weakdep modules are not loaded due to being a weakdep.
2) depmod test to check weakdep output.
3) user test to check that configuration files with weakdep are parsed correctly and related weakdep modules can be read correctly from user applications.

---
 Makefile.am                                   |   4 +-
 testsuite/.gitignore                          |   3 +
 testsuite/module-playground/Makefile          |   2 +
 testsuite/module-playground/mod-weakdep.c     |  15 +++
 .../lib/modules/4.4.4/correct-modules.weakdep |   2 +
 .../etc/modprobe.d/dumb-weakdep.conf          |   1 +
 .../lib/modules/4.4.4/modules.alias           |   1 +
 .../lib/modules/4.4.4/modules.alias.bin       | Bin 0 -> 12 bytes
 .../modules/4.4.4/modules.builtin.alias.bin   |   0
 .../lib/modules/4.4.4/modules.builtin.bin     |   0
 .../lib/modules/4.4.4/modules.dep             |   3 +
 .../lib/modules/4.4.4/modules.dep.bin         | Bin 0 -> 188 bytes
 .../lib/modules/4.4.4/modules.devname         |   1 +
 .../lib/modules/4.4.4/modules.softdep         |   1 +
 .../lib/modules/4.4.4/modules.symbols         |   3 +
 .../lib/modules/4.4.4/modules.symbols.bin     | Bin 0 -> 78 bytes
 .../lib/modules/4.4.4/modules.weakdep         |   1 +
 .../test-user/correct-weakdep.txt             |   2 +
 .../etc/modprobe.d/dumb-weakdep.conf          |   1 +
 .../test-user/lib/modules/4.4.4/modules.alias |   1 +
 .../lib/modules/4.4.4/modules.alias.bin       | Bin 0 -> 12 bytes
 .../modules/4.4.4/modules.builtin.alias.bin   |   0
 .../lib/modules/4.4.4/modules.builtin.bin     |   0
 .../test-user/lib/modules/4.4.4/modules.dep   |   4 +
 .../lib/modules/4.4.4/modules.dep.bin         | Bin 0 -> 242 bytes
 .../lib/modules/4.4.4/modules.devname         |   0
 .../lib/modules/4.4.4/modules.softdep         |   1 +
 .../lib/modules/4.4.4/modules.symbols         |   3 +
 .../lib/modules/4.4.4/modules.symbols.bin     | Bin 0 -> 78 bytes
 .../lib/modules/4.4.4/modules.weakdep         |   2 +
 testsuite/setup-rootfs.sh                     |   9 ++
 testsuite/test-depmod.c                       |  27 +++++
 testsuite/test-modprobe.c                     |  23 ++++
 testsuite/test-user.c                         | 110 ++++++++++++++++++
 testsuite/testsuite.c                         |  94 +++++++++++++--
 testsuite/testsuite.h                         |   1 +
 36 files changed, 305 insertions(+), 10 deletions(-)
 create mode 100644 testsuite/module-playground/mod-weakdep.c
 create mode 100644 testsuite/rootfs-pristine/test-depmod/check-weakdep/lib/modules/4.4.4/correct-modules.weakdep
 create mode 100644 testsuite/rootfs-pristine/test-modprobe/weakdep-loop/etc/modprobe.d/dumb-weakdep.conf
 create mode 100644 testsuite/rootfs-pristine/test-modprobe/weakdep-loop/lib/modules/4.4.4/modules.alias
 create mode 100644 testsuite/rootfs-pristine/test-modprobe/weakdep-loop/lib/modules/4.4.4/modules.alias.bin
 create mode 100644 testsuite/rootfs-pristine/test-modprobe/weakdep-loop/lib/modules/4.4.4/modules.builtin.alias.bin
 create mode 100644 testsuite/rootfs-pristine/test-modprobe/weakdep-loop/lib/modules/4.4.4/modules.builtin.bin
 create mode 100644 testsuite/rootfs-pristine/test-modprobe/weakdep-loop/lib/modules/4.4.4/modules.dep
 create mode 100644 testsuite/rootfs-pristine/test-modprobe/weakdep-loop/lib/modules/4.4.4/modules.dep.bin
 create mode 100644 testsuite/rootfs-pristine/test-modprobe/weakdep-loop/lib/modules/4.4.4/modules.devname
 create mode 100644 testsuite/rootfs-pristine/test-modprobe/weakdep-loop/lib/modules/4.4.4/modules.softdep
 create mode 100644 testsuite/rootfs-pristine/test-modprobe/weakdep-loop/lib/modules/4.4.4/modules.symbols
 create mode 100644 testsuite/rootfs-pristine/test-modprobe/weakdep-loop/lib/modules/4.4.4/modules.symbols.bin
 create mode 100644 testsuite/rootfs-pristine/test-modprobe/weakdep-loop/lib/modules/4.4.4/modules.weakdep
 create mode 100644 testsuite/rootfs-pristine/test-user/correct-weakdep.txt
 create mode 100644 testsuite/rootfs-pristine/test-user/etc/modprobe.d/dumb-weakdep.conf
 create mode 100644 testsuite/rootfs-pristine/test-user/lib/modules/4.4.4/modules.alias
 create mode 100644 testsuite/rootfs-pristine/test-user/lib/modules/4.4.4/modules.alias.bin
 create mode 100644 testsuite/rootfs-pristine/test-user/lib/modules/4.4.4/modules.builtin.alias.bin
 create mode 100644 testsuite/rootfs-pristine/test-user/lib/modules/4.4.4/modules.builtin.bin
 create mode 100644 testsuite/rootfs-pristine/test-user/lib/modules/4.4.4/modules.dep
 create mode 100644 testsuite/rootfs-pristine/test-user/lib/modules/4.4.4/modules.dep.bin
 create mode 100644 testsuite/rootfs-pristine/test-user/lib/modules/4.4.4/modules.devname
 create mode 100644 testsuite/rootfs-pristine/test-user/lib/modules/4.4.4/modules.softdep
 create mode 100644 testsuite/rootfs-pristine/test-user/lib/modules/4.4.4/modules.symbols
 create mode 100644 testsuite/rootfs-pristine/test-user/lib/modules/4.4.4/modules.symbols.bin
 create mode 100644 testsuite/rootfs-pristine/test-user/lib/modules/4.4.4/modules.weakdep
 create mode 100644 testsuite/test-user.c
Makefile.am +3 -1
index e2e2411..4b67ee2 100644
@@ -262,7 +262,7 @@ TESTSUITE = \
 	testsuite/test-modinfo testsuite/test-util testsuite/test-new-module \
 	testsuite/test-modprobe testsuite/test-blacklist \
 	testsuite/test-dependencies testsuite/test-depmod \
-	testsuite/test-list
+	testsuite/test-list testsuite/test-user
 
 check_PROGRAMS = $(TESTSUITE)
 TESTS = $(TESTSUITE)
@@ -305,6 +305,8 @@ testsuite_test_depmod_LDADD = $(TESTSUITE_LDADD)
 testsuite_test_depmod_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
 testsuite_test_list_LDADD = $(TESTSUITE_LDADD)
 testsuite_test_list_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
+testsuite_test_user_LDADD = $(TESTSUITE_LDADD)
+testsuite_test_user_CPPFLAGS = $(TESTSUITE_CPPFLAGS)
 
 testsuite-distclean:
 	$(RM) -r $(ROOTFS)
testsuite/.gitignore +3 -0
index 5465b1a..56d628e 100644
@@ -18,6 +18,7 @@
 /test-modprobe
 /test-hash
 /test-list
+/test-user
 /rootfs
 /stamp-rootfs
 /test-scratchbuf.log
@@ -52,3 +53,5 @@
 /test-testsuite.trs
 /test-list.log
 /test-list.trs
+/test-user.log
+/test-user.trs
testsuite/module-playground/Makefile +2 -0
index a7ab09b..42c750b 100644
@@ -37,6 +37,8 @@ obj-m += mod-fake-hpsa.o
 obj-m += mod-fake-scsi-mod.o
 obj-m += mod-fake-cciss.o
 
+obj-m += mod-weakdep.o
+
 else
 # only build ARCH-specific module
 ifeq ($(ARCH),)
testsuite/module-playground/mod-weakdep.c new file +15 -0
new file mode 100644
index 0000000..d8a9d48
@@ -0,0 +1,15 @@
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/init.h>
+#include <linux/module.h>
+
+static int __init weakdep_init(void)
+{
+	return 0;
+}
+
+module_init(weakdep_init);
+
+MODULE_AUTHOR("Jose Ignacio Tornos Martinez <[email protected]>");
+MODULE_LICENSE("LGPL");
+MODULE_WEAKDEP("mod-simple");
testsuite/rootfs-pristine/test-depmod/check-weakdep/lib/modules/4.4.4/correct-modules.weakdep new file +2 -0
new file mode 100644
index 0000000..00777b8
@@ -0,0 +1,2 @@
+# Weak dependencies extracted from modules themselves.
+weakdep mod_weakdep mod-simple
testsuite/rootfs-pristine/test-modprobe/weakdep-loop/etc/modprobe.d/dumb-weakdep.conf new file +1 -0
new file mode 100644
index 0000000..181714a
@@ -0,0 +1 @@
+weakdep mod-loop-b mod-loop-a mod-simple
testsuite/rootfs-pristine/test-modprobe/weakdep-loop/lib/modules/4.4.4/modules.alias new file +1 -0
new file mode 100644
index 0000000..ba76e18
@@ -0,0 +1 @@
+# Aliases extracted from modules themselves.
testsuite/rootfs-pristine/test-modprobe/weakdep-loop/lib/modules/4.4.4/modules.alias.bin new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..7075435f6268c4d815aec093d61e26647666ba76
GIT binary patch
testsuite/rootfs-pristine/test-modprobe/weakdep-loop/lib/modules/4.4.4/modules.builtin.alias.bin new file +0 -0
new file mode 100644
index 0000000..e69de29
testsuite/rootfs-pristine/test-modprobe/weakdep-loop/lib/modules/4.4.4/modules.builtin.bin new file +0 -0
new file mode 100644
index 0000000..e69de29
testsuite/rootfs-pristine/test-modprobe/weakdep-loop/lib/modules/4.4.4/modules.dep new file +3 -0
new file mode 100644
index 0000000..9207182
@@ -0,0 +1,3 @@
+kernel/mod-loop-b.ko:
+kernel/mod-loop-a.ko:
+kernel/mod-simple.ko:
testsuite/rootfs-pristine/test-modprobe/weakdep-loop/lib/modules/4.4.4/modules.dep.bin new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..418d5839a88c95cb08ed24e128ffdb8717ca1504
GIT binary patch
testsuite/rootfs-pristine/test-modprobe/weakdep-loop/lib/modules/4.4.4/modules.devname new file +1 -0
new file mode 100644
index 0000000..58f6d6d
@@ -0,0 +1 @@
+# Device nodes to trigger on-demand module loading.
testsuite/rootfs-pristine/test-modprobe/weakdep-loop/lib/modules/4.4.4/modules.softdep new file +1 -0
new file mode 100644
index 0000000..5554ccc
@@ -0,0 +1 @@
+# Soft dependencies extracted from modules themselves.
testsuite/rootfs-pristine/test-modprobe/weakdep-loop/lib/modules/4.4.4/modules.symbols new file +3 -0
new file mode 100644
index 0000000..6c53580
@@ -0,0 +1,3 @@
+# Aliases for symbols, used by symbol_request().
+alias symbol:printB mod_loop_b
+alias symbol:printA mod_loop_a
testsuite/rootfs-pristine/test-modprobe/weakdep-loop/lib/modules/4.4.4/modules.symbols.bin new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..27c5f4330c93722f6bab5c7a91601ab58fdda577
GIT binary patch
testsuite/rootfs-pristine/test-modprobe/weakdep-loop/lib/modules/4.4.4/modules.weakdep new file +1 -0
new file mode 100644
index 0000000..569696d
@@ -0,0 +1 @@
+# Weak dependencies extracted from modules themselves.
testsuite/rootfs-pristine/test-user/correct-weakdep.txt new file +2 -0
new file mode 100644
index 0000000..ac09f8d
@@ -0,0 +1,2 @@
+mod-loop-b: mod_loop_a mod_simple
+mod-weakdep: mod_simple
testsuite/rootfs-pristine/test-user/etc/modprobe.d/dumb-weakdep.conf new file +1 -0
new file mode 100644
index 0000000..181714a
@@ -0,0 +1 @@
+weakdep mod-loop-b mod-loop-a mod-simple
testsuite/rootfs-pristine/test-user/lib/modules/4.4.4/modules.alias new file +1 -0
new file mode 100644
index 0000000..ba76e18
@@ -0,0 +1 @@
+# Aliases extracted from modules themselves.
testsuite/rootfs-pristine/test-user/lib/modules/4.4.4/modules.alias.bin new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..7075435f6268c4d815aec093d61e26647666ba76
GIT binary patch
testsuite/rootfs-pristine/test-user/lib/modules/4.4.4/modules.builtin.alias.bin new file +0 -0
new file mode 100644
index 0000000..e69de29
testsuite/rootfs-pristine/test-user/lib/modules/4.4.4/modules.builtin.bin new file +0 -0
new file mode 100644
index 0000000..e69de29
testsuite/rootfs-pristine/test-user/lib/modules/4.4.4/modules.dep new file +4 -0
new file mode 100644
index 0000000..3ffbd6b
@@ -0,0 +1,4 @@
+kernel/mod-weakdep.ko:
+kernel/mod-simple.ko:
+kernel/mod-loop-b.ko:
+kernel/mod-loop-a.ko: kernel/mod-loop-b.ko
testsuite/rootfs-pristine/test-user/lib/modules/4.4.4/modules.dep.bin new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..70a6e76b79f9a74037dcb00b69fe2555cf022a51
GIT binary patch
testsuite/rootfs-pristine/test-user/lib/modules/4.4.4/modules.devname new file +0 -0
new file mode 100644
index 0000000..e69de29
testsuite/rootfs-pristine/test-user/lib/modules/4.4.4/modules.softdep new file +1 -0
new file mode 100644
index 0000000..5554ccc
@@ -0,0 +1 @@
+# Soft dependencies extracted from modules themselves.
testsuite/rootfs-pristine/test-user/lib/modules/4.4.4/modules.symbols new file +3 -0
new file mode 100644
index 0000000..6c53580
@@ -0,0 +1,3 @@
+# Aliases for symbols, used by symbol_request().
+alias symbol:printB mod_loop_b
+alias symbol:printA mod_loop_a
testsuite/rootfs-pristine/test-user/lib/modules/4.4.4/modules.symbols.bin new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..8683b6cb7f60e035be224d97cd560a822e269b1f
GIT binary patch
testsuite/rootfs-pristine/test-user/lib/modules/4.4.4/modules.weakdep new file +2 -0
new file mode 100644
index 0000000..00777b8
@@ -0,0 +1,2 @@
+# Weak dependencies extracted from modules themselves.
+weakdep mod_weakdep mod-simple
testsuite/setup-rootfs.sh +9 -0
index 5477c69..f57ef19 100755
@@ -68,6 +68,8 @@ map=(
     ["test-depmod/search-order-external-last/lib/modules/external/"]="mod-simple.ko"
     ["test-depmod/search-order-override$MODULE_DIRECTORY/4.4.4/foo/"]="mod-simple.ko"
     ["test-depmod/search-order-override$MODULE_DIRECTORY/4.4.4/override/"]="mod-simple.ko"
+    ["test-depmod/check-weakdep$MODULE_DIRECTORY/4.4.4/kernel/mod-weakdep.ko"]="mod-weakdep.ko"
+    ["test-depmod/check-weakdep$MODULE_DIRECTORY/4.4.4/kernel/mod-simple.ko"]="mod-simple.ko"
     ["test-dependencies$MODULE_DIRECTORY/4.0.20-kmod/kernel/fs/foo/"]="mod-foo-b.ko"
     ["test-dependencies$MODULE_DIRECTORY/4.0.20-kmod/kernel/"]="mod-foo-c.ko"
     ["test-dependencies$MODULE_DIRECTORY/4.0.20-kmod/kernel/lib/"]="mod-foo-a.ko"
@@ -80,6 +82,9 @@ map=(
     ["test-modprobe/show-exports/mod-loop-a.ko"]="mod-loop-a.ko"
     ["test-modprobe/softdep-loop$MODULE_DIRECTORY/4.4.4/kernel/mod-loop-a.ko"]="mod-loop-a.ko"
     ["test-modprobe/softdep-loop$MODULE_DIRECTORY/4.4.4/kernel/mod-loop-b.ko"]="mod-loop-b.ko"
+    ["test-modprobe/weakdep-loop$MODULE_DIRECTORY/4.4.4/kernel/mod-loop-a.ko"]="mod-loop-a.ko"
+    ["test-modprobe/weakdep-loop$MODULE_DIRECTORY/4.4.4/kernel/mod-loop-b.ko"]="mod-loop-b.ko"
+    ["test-modprobe/weakdep-loop$MODULE_DIRECTORY/4.4.4/kernel/mod-simple.ko"]="mod-simple.ko"
     ["test-modprobe/install-cmd-loop$MODULE_DIRECTORY/4.4.4/kernel/mod-loop-a.ko"]="mod-loop-a.ko"
     ["test-modprobe/install-cmd-loop$MODULE_DIRECTORY/4.4.4/kernel/mod-loop-b.ko"]="mod-loop-b.ko"
     ["test-modprobe/force$MODULE_DIRECTORY/4.4.4/kernel/"]="mod-simple.ko"
@@ -103,6 +108,10 @@ map=(
     ["test-modinfo/mod-simple-sha256.ko"]="mod-simple.ko"
     ["test-modinfo/mod-simple-pkcs7.ko"]="mod-simple.ko"
     ["test-modinfo/external/lib/modules/external/mod-simple.ko"]="mod-simple.ko"
+    ["test-user$MODULE_DIRECTORY/4.4.4/kernel/mod-loop-a.ko"]="mod-loop-a.ko"
+    ["test-user$MODULE_DIRECTORY/4.4.4/kernel/mod-loop-b.ko"]="mod-loop-b.ko"
+    ["test-user$MODULE_DIRECTORY/4.4.4/kernel/mod-simple.ko"]="mod-simple.ko"
+    ["test-user$MODULE_DIRECTORY/4.4.4/kernel/mod-weakdep.ko"]="mod-weakdep.ko"
 )
 
 gzip_array=(
testsuite/test-depmod.c +27 -0
index c96dbf0..eaa5b1a 100644
@@ -244,4 +244,31 @@ DEFINE_TEST(depmod_search_order_override,
 		},
 	});
 
+#define CHECK_WEAKDEP_ROOTFS TESTSUITE_ROOTFS "test-depmod/check-weakdep"
+#define CHECK_WEAKDEP_LIB_MODULES CHECK_WEAKDEP_ROOTFS MODULE_DIRECTORY "/" MODULES_UNAME
+static noreturn int depmod_check_weakdep(const struct test *t)
+{
+	const char *progname = ABS_TOP_BUILDDIR "/tools/depmod";
+	const char *const args[] = {
+		progname,
+		NULL,
+	};
+
+	test_spawn_prog(progname, args);
+	exit(EXIT_FAILURE);
+}
+DEFINE_TEST(depmod_check_weakdep,
+	.description = "check weakdep output",
+	.config = {
+		[TC_UNAME_R] = MODULES_UNAME,
+		[TC_ROOTFS] = CHECK_WEAKDEP_ROOTFS,
+	},
+	.output = {
+		.files = (const struct keyval[]) {
+			{ CHECK_WEAKDEP_LIB_MODULES "/correct-modules.weakdep",
+			  CHECK_WEAKDEP_LIB_MODULES "/modules.weakdep" },
+			{ }
+		},
+	});
+
 TESTSUITE_MAIN();
testsuite/test-modprobe.c +23 -0
index 309f3e3..6a824c9 100644
@@ -181,6 +181,29 @@ DEFINE_TEST(modprobe_softdep_loop,
 	.modules_loaded = "mod-loop-a,mod-loop-b",
 	);
 
+static noreturn int modprobe_weakdep_loop(const struct test *t)
+{
+	const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe";
+	const char *const args[] = {
+		progname,
+		"mod-loop-b",
+		NULL,
+	};
+
+	test_spawn_prog(progname, args);
+	exit(EXIT_FAILURE);
+}
+DEFINE_TEST(modprobe_weakdep_loop,
+	.description = "check if modprobe breaks weakdep loop",
+	.config = {
+		[TC_UNAME_R] = "4.4.4",
+		[TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/weakdep-loop",
+		[TC_INIT_MODULE_RETCODES] = "",
+	},
+	.modules_loaded = "mod-loop-b",
+	.modules_not_loaded = "mod-loop-a,mod-simple-c",
+	);
+
 static noreturn int modprobe_install_cmd_loop(const struct test *t)
 {
 	const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe";
testsuite/test-user.c new file +110 -0

110 lines not on this page · raw message

testsuite/testsuite.c +85 -9

125 lines not on this page · raw message

testsuite/testsuite.h +1 -0
index 44d1730..4b2565c 100644
@@ -103,6 +103,7 @@ struct test {
 	} output;
 	/* comma-separated list of loaded modules at the end of the test */
 	const char *modules_loaded;
+	const char *modules_not_loaded;
 	testfunc func;
 	const char *config[_TC_LAST];
 	const char *path;
Signature · 1 line
2.45.1
#1 lore raw
Quoted 9 lines · Jose Ignacio Tornos Martinez

The following tests to verify weak dependencies have been implemented:
1) modprobe test to check that related weakdep modules are not loaded due to being a weakdep.
2) depmod test to check weakdep output.
3) user test to check that configuration files with weakdep are parsed correctly and related weakdep modules can be read correctly from user applications.

A few whitespace issues below in testsuite/test-user.c
Also we need to define MODULE_WEAKDEP for the mod-weakdep.ko otherwise we break the build without that defined by kernel-headers.

I fixed those, squashed, and pushed.

Thanks
Lucas De Marchi

#2 lore raw
In reply to Jose Ignacio Tornos Martinez

Hello Jose,

Quoted 10 lines · Jose Ignacio Tornos Martinez

The following tests to verify weak dependencies have been implemented:
1) modprobe test to check that related weakdep modules are not loaded due to being a weakdep.
2) depmod test to check weakdep output.
3) user test to check that configuration files with weakdep are parsed correctly and related weakdep modules can be read correctly from user applications.

---

Seems like this commit has regressed make distcheck on my end. Namely I'm running the following commands:

git clone ...
cd kmod
git clean -fxd
./autogen.sh c
make distcheck

Result in:

...
make[5]: *** No rule to make target '.../kmod-32/_build/sub/testsuite/module-playground/mod-weakdep.o', needed by '.../kmod-32/_build/sub/testsuite/module-playground/mod-weakdep.mod'. Stop. make[4]: *** [Makefile:1903: .../kmod-32/_build/sub/testsuite/module-playground] Error 2

Can you reproduce it on your end?

While in the area, a couple of question if I may:

- Should we move the new weakdeps API in libkmod/libkmod.sym near the end in a separate LIBKMOD_XX section?

As-is, it looks like we're adding symbols to what should be a frozen set (aka LIBKMOD_5, which was released decade+ ago).

Admittedly there was a similar erroneous(?) change not loo long ago - 9becaae ("libkmod: Add lookup from module name").

@Lucas can/should we fix the kmod_module_new_from_name_lookup symbol in the version script?

- Is this work related to the weak-modules used in RHEL/Fedora [1]? Alternatively, would the RedHat team consider having the weak-modules solution in upstream kmod?

... assuming Lucas is OK with the idea. I'm approaching with with my dkms co-maintainer hat on, where the fewer "if distro == X" logic we have the better.

Thanks in advance,
Emil

[1] https://src.fedoraproject.org/rpms/kmod/blob/rawhide/f/weak-modules

#3 lore raw
Quoted 23 lines · Emil Velikov

Hello Jose,

Quoted 10 lines · Jose Ignacio Tornos Martinez

The following tests to verify weak dependencies have been implemented:
1) modprobe test to check that related weakdep modules are not loaded due to being a weakdep.
2) depmod test to check weakdep output.
3) user test to check that configuration files with weakdep are parsed correctly and related weakdep modules can be read correctly from user applications.

---

Seems like this commit has regressed make distcheck on my end. Namely I'm running the following commands:

git clone ...
cd kmod
git clean -fxd
./autogen.sh c
make distcheck

Quoted 5 lines

Result in:

...
make[5]: *** No rule to make target '.../kmod-32/_build/sub/testsuite/module-playground/mod-weakdep.o', needed by '.../kmod-32/_build/sub/testsuite/module-playground/mod-weakdep.mod'. Stop. make[4]: *** [Makefile:1903: .../kmod-32/_build/sub/testsuite/module-playground] Error 2

I added a fix in
https://lore.kernel.org/linux-modules/[email protected]/T/#t

and also sketched the new CI hooks using github.

Quoted 9 lines

Can you reproduce it on your end?

While in the area, a couple of question if I may:

- Should we move the new weakdeps API in libkmod/libkmod.sym near the end in a separate LIBKMOD_XX section?

yes

Quoted 6 lines

As-is, it looks like we're adding symbols to what should be a frozen set (aka LIBKMOD_5, which was released decade+ ago).

Admittedly there was a similar erroneous(?) change not loo long ago - 9becaae ("libkmod: Add lookup from module name").

yes, my bad

Quoted 3 lines

@Lucas can/should we fix the kmod_module_new_from_name_lookup symbol in the version script?

yes and this should be something for distros to backport.

Quoted 7 lines

- Is this work related to the weak-modules used in RHEL/Fedora [1]? Alternatively, would the RedHat team consider having the weak-modules solution in upstream kmod?

... assuming Lucas is OK with the idea. I'm approaching with with my

I was not familiar with that weak-modules and will wait for Jose to clarify.

thanks
Lucas De Marchi

Quoted 7 lines

dkms co-maintainer hat on, where the fewer "if distro == X" logic we have the better.

Thanks in advance,
Emil

[1] https://src.fedoraproject.org/rpms/kmod/blob/rawhide/f/weak-modules

#4 lore raw

Hello,

Quoted 11 lines
Quoted 11 lines

Seems like this commit has regressed make distcheck on my end. Namely I'm running the following commands:

git clone ...
cd kmod
git clean -fxd
./autogen.sh c
make distcheck

Result in:

Quoted 10 lines
Quoted 3 lines

...
make[5]: *** No rule to make target '.../kmod-32/_build/sub/testsuite/module-playground/mod-weakdep.o', needed by '.../kmod-32/_build/sub/testsuite/module-playground/mod-weakdep.mod'. Stop. make[4]: *** [Makefile:1903: .../kmod-32/_build/sub/testsuite/module-playground] Error 2

I added a fix in
https://lore.kernel.org/linux-modules/[email protected]/T/#t

and also sketched the new CI hooks using github.

Quoted 1 line

Can you reproduce it on your end?

Sorry Emil, I only tested with 'make check' and I didn't try 'make distcheck' (really I didn't know it).
Yes, it was failing for me too, and I have verified that with the solution from Lucas ([PATCH 2/3] build: Add mod-weakdep.c to EXTRA_DIST) is working. Thanks Lucas for fixing it.

Quoted 6 lines
Quoted 6 lines

- Is this work related to the weak-modules used in RHEL/Fedora [1]? Alternatively, would the RedHat team consider having the weak-modules solution in upstream kmod?

Quoted 6 lines
Quoted 3 lines

... assuming Lucas is OK with the idea. I'm approaching with with my dkms co-maintainer hat on, where the fewer "if distro == X" logic we have the better.

I was not familiar with that weak-modules and will wait for Jose to clarify.

weak modules concept is very different from weak dependencies and not related. Let me try to explain:

weak modules is about keeping KABI compatibility between kernels with the same version, in order to reuse modules (internal or external ones), so it is mainly for RHEL and the update process.
For Fedora, that is the upstream distro, and with no guarantee for KABI, is not necessary.

weak dependencies is to be used by upstream (and everywhere) to allow user applications to be aware of internal dependencies that are not declared as softdep because they are dynamically loaded.
dracut has approved this feature from yesterday and I am waiting to have the kernel declaration in linux master branch to apply some weak dependencies (i.e. lan78xx).

Best regards
José Ignacio