Sorry for naive questions. I’m trying to write a simple unit test (using KUnit https://www.kernel.org/doc/html/latest/dev-tools/kunit/) for my kernel module but looks like KUnit is not “enabled” by default in openSUSE (TUMBLEWEED). By not “enabled” I mean that there is only a header file “kunit/test.h” but appropriate kunit.ko and kunit.symvers are absent, so it’s not possible to compile a module that uses this lib.
What I’ve already tried to do is:
Install linux sources
Run **make menuconfig**
Enable KUnit and specify SUSE_VERSION (5) and SUSE_PATCHLEVEL (12)
Run **make** **modules_install**
After that I’ve found that kunit.ko generated but when I tried to insert it, I’ve got an error: version magic '5.12.0 mod_unload ’ should be '5.12.0-2-default SMP mod_unload modversions '
Also, after make module_install/usr/src/linux-5.12.0-2/Module.symvers contains kunit’s methods but when I build my module with this symvers
**make -C /lib/modules/$(shell uname -r)/build M=$(PWD)/test modules KBUILD_EXTRA_SYMBOLS+=/usr/src/linux-5.12.0-2/Module.symvers
**I’ve got a lot of warnings that methods are exported twice
WARNING: modpost: vmlinux: ‘si_meminfo’ exported twice. Previous export was in vmlinux
WARNING: modpost: vmlinux: ‘poll_freewait’ exported twice. Previous export was in vmlinux
WARNING: modpost: vmlinux: ‘vfs_fsync’ exported twice. Previous export was in vmlinux
So, ideally I would prefer to have a symservs file that contains only kunit’s methods.
I would really appreciate any advice what else I can try (most probably I need to specify some special version in config file to have build exactly for my kernel version 5.12.0-2-default). May be it’s possible to enable KUnit without kernel re-compilation?
Thanks a lot!
P.S.
If it’s important, for my experiments I use Vagrant+VirtualBox.
Thank you very very much! You’ve really saved hours of my life And special thanks for pointing to “Open Build Service”, I didn’t know about this service!
If you don’t mind, one more question. I’ve installed your rpm and kunit.ko can be successfully inserted now but may be you know the right way how to generate a Module.symvers for kunit?
Yep, I’ve got the same errors when tried to compile it.
Now for compilation I use just
make -C /lib/modules/$(shell uname -r)/build M=$(PWD)/test modules
and looks like the system cannot identify kunit methods. Previously, when I built kunit locally, there was generated Module.symvers that contained all these __kunit_test_suites_init/__kunit_test_suites_exit, so adding