Commit Graph

46 Commits

Author SHA1 Message Date
Lucas De Marchi 3d38e322f9 testsuite: Handle different sysconfdir
Instead of skipping tests if sysconfdir isn't /etc, just handle it
during the rootfs setup logic.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
2023-02-10 14:29:28 -08:00
Gustavo Sousa 883d931d1b modprobe: Allow passing path to module
This is useful to kernel module developers for testing a just compiled
module: instead of using insmod, they can load the module from the path
while getting all the benefits of modprobe (e.g. module dependency
resolution).

v2:
  - Add test for relative path as well. (Lucas)
  - Add note warning about modules with dependencies not matching the
    installed depmod database. (Lucas)

Signed-off-by: Gustavo Sousa <gustavo.sousa@intel.com>
Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2023-01-13 16:48:02 -08:00
Lucas De Marchi d8b31c34a6 test-modprobe: share single function for kcmdline tests 2021-02-15 11:53:43 -08:00
Lucas De Marchi d3a1fe67b6 libkmod-config: re-quote option from kernel cmdline
It was reported that grub mangles the kernel cmdline. It turns

	acpi_cpufreq.dyndbg="file drivers/cpufreq/acpi-cpufreq.c +mpf"

	into

	"acpi_cpufreq.dyndbg=file drivers/cpufreq/acpi-cpufreq.c +mpf"

However, even though we could blame grub for doing that, the kernel
happily accepts and re-quotes it when the module is built-in.
So, it's better if kmod also understands it this way and does the same.

Here we basically add additional code to un-mangle it, moving the quote
in way that is acceptable to pass through init_module(). Note that the
interface [f]init_module() gives us mandates the quote to be part of the
value: the module name is not passed and the options are separated by
space.

Reported-by: Jiri Slaby <jirislaby@kernel.org>
Tested-by: Jessica Yu <jeyu@kernel.org>
Link: https://bugzilla.suse.com/show_bug.cgi?id=1181111#c10
2021-02-15 11:53:43 -08:00
Marius Bakke 847247a4a8 testsuite: Automatically skip tests that fail when sysconfdir != /etc. 2021-01-07 19:44:50 -08:00
Lucas De Marchi 3c1073e17a testsuite: check for ill-formed kcmdline
Commit ca3bf5d47cec ("iommu/amd: Introduces ivrs_acpihid kernel parameter")
in the kernel introduced an ill-formed kernel parameter, ivrs_acpihid.
The problem is that it may have a dot on the key side:
"ivrs_acpihid[00:14.5]=AMD0020:0". This could potentially trip our
parser of module options, but right now it's working as intended: the
only thing that happens is that after deciding "ivrs_acpihid[00:14" is a
module name, it will fail the underscores() routine and the option will
be ignored from the kmod pov (not kernel's pov since that driver parsers
the kernel command line by itself).
2020-03-13 09:23:58 -07:00
Lucas De Marchi eb862179c0 testsuite: move --show-exports test to use regex
This allows it to pass if the kernel is configured with
CONFIG_MODVERSIONS.
2019-01-03 12:43:18 -08:00
Lucas De Marchi 068729e368 testsuite: add simple test for --show-exports 2018-11-13 10:45:00 -08:00
Yauheni Kaliuta df492f5ca3 testsuite: add tests for external directory support
The following tests added:

- depmod_search_order_external_first -- checks if external module
  is taken in use when it has higher priority;
- depmod_search_order_external_last -- checks if external module
  is skipped when it has lower priority;
- test_modinfo_external -- checks if modinfo is able to look up
  correct external module;
- modprobe_external -- checks if modprobe is able to look up
  correct external module and loads it.

Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
2017-06-01 20:31:37 -07:00
Lucas De Marchi ded0bebca8 testsuite: add test for kernel cmdline with quotes
Add some tests in which we quotes in kernel cmdline and also spaces
inside quotes.  This doesn't yet cover the case in which quotes are used
for module name, wihch should be forbidden.
2017-01-23 11:59:31 -08:00
Lucas De Marchi 55f8286fcd testsuite: fix typo in description 2017-01-23 11:58:29 -08:00
Lucas De Marchi ade6b25c9a testsuite: add test for modprobe -R <builtin-module> 2015-02-28 14:18:54 -03:00
Lucas De Marchi 246d67d493 testsuite: port kcmdline test to module-playground 2015-02-11 02:59:08 -02:00
Lucas De Marchi 621ac887e7 testsuite: port install-cmd-loop test to module-playground 2015-02-11 02:50:06 -02:00
Lucas De Marchi bf0b87f4e6 testsuite: port alias-to-none test to module-playground 2015-02-10 22:19:53 -02:00
Lucas De Marchi 33c1185239 testsuite: port tests without finit_module() to module-playground 2015-02-10 22:11:25 -02:00
Lucas De Marchi a1a1369051 testsuite: port modprobe --force test to module-playground 2015-02-10 22:01:42 -02:00
Lucas De Marchi 1e128242ed testsuite: port softdep-loop test to module-playground 2015-02-10 21:45:09 -02:00
Lucas De Marchi eeb627004b testsuite: port show-depends tests to module-playground
Another test, modprobe_show_alias_to_none was wrongly checking the
output in the show-depends namespace so it needed changing as well.
2015-02-10 09:30:49 -02:00
Lucas De Marchi dea2dfee9b Remove FSF mailing address
It has changed in the past, and these days, anyone can get a copy of the
LGPL via the web rather than by post.

Like 657a122 (Remove FSF mailing address) in libabc by Josh Tripplet,
but let the FSF website in which the license can be found.
2014-12-25 23:41:34 -02:00
Lucas De Marchi 4328982058 testsuite: remove now unused array of tests
Remove the arrays and let each test with a guaranteed unique name.
2014-10-09 14:29:04 -03:00
Lucas De Marchi f1155c1574 Move static keyword to DEFINE_TEST macro 2014-10-09 13:00:30 -03:00
Lucas De Marchi c2e4286bb9 Reorder and reorganize header files
Let the includes in the following order:

< system headers >
< libkmod >
< tool >
< local headers >
2014-10-03 01:43:15 -03:00
Lucas De Marchi 49776627e6 testsuite: add test for '.' correctly parsed in param's value
In kcmdline it's possible to have a dot in the param's value. The
support for this was added in 66f3228 ("libkmod: Add support for '.' in
module parameter on kcmdline") and is needed to correctly support some
modules that depend on it.

This test was added in order to make sure the commit  aa87854
("libkmod-config: Only match dot before '=' in /proc/cmdline") didn't
break it. Although that commit  message says it's allowing to match a
dot before '=' it's actually enforcing the first part of the string to
be always in the format "<module-name>.param". Dots after '=' are still
correctly allowed.
2014-03-06 01:36:02 -03:00
Lucas De Marchi 4214902482 testsuite: add test to ignore unrelated strings in kcmdline
Strings unrelated to modules and modprobe should be ignored and not
appear in the output of "modprobe -c".

This adds a test for the fix provided in aa87854 ("libkmod-config: Only
match dot before '=' in /proc/cmdline").
2014-03-06 01:30:56 -03:00
Lucas De Marchi bad84a9e6e testsuite: give a more suitable description to test
We are not only checking if those options are correctly parsed from
kcmdline, but if in fact they are being passed to the final
(f)init_module call. This is why we use 'modprobe --show-depends'
instead of the simpler 'modprobe -c'.
2014-03-06 01:30:08 -03:00
Lucas De Marchi 55bcc4a5bd testsuite: add test for kcmdline params with no value
Use "modprobe -c" to dump the configuration. Since we configure our
rootfs to have only a /proc/cmdline file, this should dump the knowledge
we have from its parsed content.

Test if <module>.option, without any value is correctly parsed, as fixed
in commit 493dc65 ("libkmod: Fix getting param with no value from kcmdline")
2014-03-06 01:29:41 -03:00
Michal Marek be29c40e25 Add some tests for kernels without finit_module(2) 2014-03-05 12:22:37 -03:00
Michal Marek 2ce5de0ae6 testsuite: Add test for modprobe --force
There is no check if the correct flags are passed to finit_module, but
at least we cover the respective code path in kmod.
2014-03-05 12:22:37 -03:00
Michal Marek 88ac40840f testsuite: Check the list of loaded modules after a test
Add a ->modules_loaded member to struct test, which is a comma-separated
list of modules that should be present after the test finishes. Both
missing and excess modules cause an error.
2014-03-05 12:22:37 -03:00
Lucas De Marchi d96ca9c429 Use C11's noreturn
Also define noreturn w/o <stdnoreturn.h> and move it to macro.h instead
of in the testsuite.

Based on similar commit on systemd by Shawn Landden
<shawn@churchofgit.com>.
2013-12-17 19:10:16 -02:00
John Spencer bd4e7340bc testsuite: fix usage of reserved names
stdout and stderr are names reserved for the implementation
and musl uses them rightfully as macro - and the expansion
causes (of course) unexpected results.

rename the struct members stdout to out and stderr
to err, to be 1) compliant 2) cause compilation to
succeed.

fixes build with musl libc.
2013-08-29 01:22:20 -03:00
Lucas De Marchi ea225b982c testsuite: Add test for parameter with no value in kcmdline
Currently we fail to add the module option if the parameter doesn't have
a value.
2013-08-13 22:03:26 -03:00
Lucas De Marchi b6adccd6ff tools: Do not link dynamically with libkmod
Instead of linking dynamically with libkmod, use libkmod-private.la. We
disallow creating a static libkmod because we can't hide symbols there
and it cause problems with external programs. However this should not
prevent users that are only interested in the tools we provide not being
able to ship only them keeping the library alone.

Other projects also do this to allow our tools to use certain functions
that should not be used outside of the project.
2013-07-04 16:08:10 -03:00
Lucas De Marchi 9de9e07da6 tools: Use test/kmod instead of kmod-nolib
The reason to have a kmod-nolib binary is that we need to call kmod on
test cases (or a symlink to it) and for testing things in tree. Since
we are using libtool if we are dinamically linking to libkmod what we
end up having is a shell script that (depending on the version *)
changes argv[0] to contain an "lt-" prefix. Since this screws with our
compat stuff, we had a kmod-nolib that links statically.

This all workaround works fine iff we are using one of the compat
commands, i.e. we are using the symlinks insmod, rmmod, modprobe, etc.
However if we are actually trying the kmod binary, this doesn't work
because we can't create a kmod symlink since there's already a kmod
binary.

So, completely give up on libtool fixing their mess. Now we create a
tool/test/ directory and the symlinks and kmod is put there.

* http://lists.gnu.org/archive/html/bug-libtool/2011-12/msg00023.html
2013-07-02 21:15:54 -03:00
Lucas De Marchi ace742fa9a modprobe: Fix assertion on --show-depends with bogus config file
Putting something like "alias psmouse deadbeef" is a hackish way to
blacklist a module. While I don't encourage doing so, let's not explode
if we fiund such config files.

A small difference from the behavior of module-init-tools: we exit with
0 instead of 1.
2013-03-21 02:33:25 -03:00
Lucas De Marchi 5278396d98 testsuite: Add test to check if modprobe explodes on bogus config
Put this one /etc/modprobe.d/bougs.conf:

alias psmouse deaddood

`modprobe --show-depends --quiet psmouse` explodes in an assertion
(unless you have a module named deaddood). Some people and initrd's use
"alias psmouse off" to disable a module instead of blacklisting it or
adding a install rule.

Add a test with expected_fail == true before fixing this.
2013-03-21 02:31:16 -03:00
Lucas De Marchi e6b0e49b4e Update copyright notices 2013-01-16 11:27:45 -02:00
Lucas De Marchi e1b1ab24ab testsuite: re-license under LGPL 2012-07-10 10:31:57 -03:00
Lucas De Marchi 9b01fd2edd testsuite: Fix test description 2012-06-11 11:57:55 -03:00
Lucas De Marchi 01d9ee642d testsuite: add test for install-commands loop
This loop is similar to the one that comes with install rules of
alsa-utils package. It can be easily verified by reverting commit
abd5557 and running the testsuite.
2012-06-06 01:57:33 -03:00
Lucas De Marchi a6976f8b1d testsuite: add test for softdep loops 2012-06-05 00:57:47 -03:00
Lucas De Marchi 3805274bf5 kmod-module: lookup: search modules.builtin file too
Search modules.builtin file before saying the module was not found.
Note: these "modules" should not appear as dependencies of other modules
(in modules.dep) even if they appear in modinfo. This fixes the return
code of modprobe with builtin modules.

Also fixes a small coding style issue in module_is_inkernel().
2012-02-16 21:18:00 -02:00
Lucas De Marchi a7f5300d50 testsuite: add test for builtins with modprobe
When user tries to load a module that is builtin in kernel, modprobe
should just return 0. This is not happening right now, so mark test as
expected_fail until it gets fixed.
2012-02-16 21:18:00 -02:00
Lucas De Marchi 32d29b3523 Mark functions with attribute noreturn
Functions that always call exit() should be marked with attribute
noreturn. With glibc this is not necessary, but it fails to compile with
uClibc otherwise.
2012-02-08 20:32:31 -02:00
Lucas De Marchi 976ea8c3ae testsuite: add tests to modprobe --show-depends
test 1 - check whether modprobe outputs the right thing when
using --show-depends is used with already loaded modules.

test 2 - check whether modprobe outputs the right thing when
using --show-depends with modules not loaded yet
2012-02-08 02:04:10 -02:00