Commit Graph

621 Commits

Author SHA1 Message Date
Lucas De Marchi 658e0471b3 testsuite: fix color of unexpected failure 2012-02-16 21:18:00 -02: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
Dave Reisner f31d49c8b3 testsuite: add .path member to test struct
This allows us to prepend an arbitrary item to the PATH environment
variable, meaning we can favor the binaries we just built, rather than
relying on those in the filesystem.
2012-02-16 16:52:38 -02:00
Wouter van Kesteren f6301b65bd Fix path.c's function pointer defenitions.
int isn't big enough to hold a FILE* / DIR* on some systems, this causes
segfaults in calls that try to use the resulting FILE* / DIR*:

  TESTSUITE: ERR: 'testsuite_rootfs_fopen' [1176160] terminated by signal 11 (Segmentation fault)
  TESTSUITE: ERR: FAILED: testsuite_rootfs_fopen
  FAIL: testsuite/test-testsuite
  ...
  TESTSUITE: ERR: 'loaded_1' [1176166] terminated by signal 11 (Segmentation fault)
  TESTSUITE: ERR: FAILED: loaded_1
  FAIL: testsuite/test-loaded
  ...
  TESTSUITE: ERR: 'from_alias' [1176181] terminated by signal 11 (Segmentation fault)
  TESTSUITE: ERR: FAILED: from_alias
  FAIL: testsuite/test-new-module

For reference on my system:

  sizeof(int) = 4
  sizeof(long) = 8
  sizeof(FILE*) = 8
  sizeof(DIR*) = 8
2012-02-16 14:37:32 -02:00
Lucas De Marchi 9207df753a TODO: add tasks and bug fixes 2012-02-14 21:57:35 -02:00
Lucas De Marchi 73298175ea libkmod-index: don't print an error if index doesn't exist
It's ok not to have the index files, so just print a DBG message instead
of an ERR.
2012-02-13 21:58:36 -02:00
Lucas De Marchi 8cd0f9e4f9 libkmod-module: probe: fix infinite loop with softdeps
If a softdep depends on a module in the dependency list of the module
being inserted, we would enter and infinite loop.

Move the "mod->visited = true" assignment to the proper place, hoping it
didn't break other use cases. This is a bug that comes and goes every
now and then. Since we have a testsuite now, a test for this should be
written.
2012-02-11 19:50:00 -02:00
Lucas De Marchi abb7e4706d test: remove test-state
This test is already covered by testsuite/test-loaded.
2012-02-09 01:44:09 -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 d005aeb752 Check if libc has __xstat
uClibc doesn't use __xstat. Check if it exists, otherwise don't export
the override function.
2012-02-08 20:29:52 -02:00
Lucas De Marchi 995627d04e build-sys: add rule to pack rootfs 2012-02-08 02:04:10 -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
Lucas De Marchi 4083b0997a testsuite: update README file
- Tell about TESTSUITE_MAIN and DEFINE_TEST macros
- Align item bodies and break on 80 chars
2012-02-07 11:00:41 -02:00
Lucas De Marchi c5d81989bc testsuite: macronify test definitions 2012-02-07 10:46:46 -02:00
Lucas De Marchi e9fa9de3c9 testsuite: macronify main function 2012-02-07 10:09:20 -02:00
Dan McGee d35e8832a6 testsuite: libtestsuite depends on individual components
Ensure this dependency is explicit in the Makefile so rebuilding just
one test works correctly. Also reduce some repetition in the test LDADD
bits by adding a new TESTSUITE_LDADD variable.
2012-02-07 10:08:58 -02:00
Lucas De Marchi 269de2e0bf libkmod-module: probe: Fix ignore-loaded flag not being applied 2012-02-07 09:48:59 -02:00
Lucas De Marchi e479598b7d kmod 5 2012-02-06 20:34:33 -02:00
Dan McGee a23f0c9c55 modinfo: handle arguments more carefully
A simple case of breakage before this commit:

    $ touch aes
    $ modinfo aes
    filename:       /tmp/aes
    ERROR: could not get modinfo from 'aes': Invalid argument

Add a new is_module_filename() function that attempts to do more than
just check if the passed argument is a regular file. We look at the name
for a '.ko' string, and if that is found, ensure it is either at the end
of the string or followed by another '.' (for .gz and .xz modules, for
instance). We don't make this second option conditional on the way the
tools are built with compression support; the file is a module file
regardless and should always be treated that way.

When doing this, and noticed in the test suite output, we open the
system modules index unconditionally, even if it is never going to be
used during the modinfo call, which is the case when passing module
filenames directly. For only one module there's not much advantage in
pre-loading the index, so just remove the call to kmod_load_resources().

With-help-from: Dave Reisner <dreisner@archlinux.org>
[lucas.demarchi@profusion.mobi: remove call to kmod_load_resources()]
2012-02-06 20:29:08 -02:00
Lucas De Marchi 54c43dff1b Add WARNING file for test dir and improve testsuite README 2012-02-06 19:52:58 -02:00
Lucas De Marchi 23e354bfdf testsuite: add README 2012-02-06 16:50:54 -02:00
Lucas De Marchi 08600ee579 libkmod-module: probe: return -EEXIST if told to do so
Commit "af9572c lib/module: check initstate before inserting module"
removed the check for "we should return -EEXIST" and moved it back to
the start of the function. The problem with this is the following
scenario:

- We check if module is in kernel -> no
- We insert the dependencies
					<-- External program loads
					the module
- We check if module is in kernel -> yes
- We return 0, when we should return -EEXIST
2012-02-06 12:54:42 -02:00
Lucas De Marchi 814a57babf libkmod-module: probe: rename flag to be more meaningful 2012-02-06 12:46:39 -02:00
Dan McGee 2efd5d4c1a test-conversion: remove test/test-{insmod,rmmod,rmmod2}
These are covered by the various test cases in testsuite/test-init.
2012-02-05 02:15:48 -02:00
Dan McGee 2af31a5dbb test-conversion: remove test/test-init
This was already converted to testsuite/test-init.
2012-02-05 02:15:44 -02:00
Dan McGee 6fc9458f58 test-conversion: remove test/test-loaded
This was already converted to testsuite/test-loaded.
2012-02-05 02:15:35 -02:00
Dan McGee 2ec79834a3 Update .gitignore files
Add kmod-* prefixed tool names, add 'tags' in root directory (for ctags,
matches cscope.out ignore already in there), and prefix tools/ entries
with '/' so they are absolute ignores and don't apply to subdirectories.
2012-02-05 02:15:20 -02:00
Dan McGee 9a252c218a Fix simple grammar issue 2012-02-05 02:15:15 -02:00
Ambroz Bizjak a2c7d3e8b0 Fix unaligned memory access in hash function
Use a function to properly get an unsigned short from memory that is
possibly unaligned.

Note that it implicitly fixes a small bug in the hash function that
was introduced when modifying the eina code: the line "hash ^= key[2]
<< 18;" is supposed to be accessing the 3rd byte of the remainder of
the input, but when 'it' was introduced, 'key' ('data' in eina code)
was no longer incremented, so this ended up accessing the 3rd byte of
the input from the beginning. This is fixed by iterating over 'key',
like the eina code does.

Before this patch depmod was failing on ARMv5 and possibly others that
don't have unaligned access. They do not calculate correctly the
dependencies as shown below:

[root@alarm ~]# modinfo bridge
filename: /lib/modules/2.6.39.4/kernel/net/bridge/bridge.ko
version: 2.3
license: GPL
srcversion: 6B583530AE2B39C7E2317BF
depends: stp,llc
vermagic: 2.6.39.4 preempt mod_unload ARMv5
[root@alarm ~]# depmod
[root@alarm ~]# cat /lib/modules/2.6.39.4/modules.dep |grep bridge
kernel/net/bridge/bridge.ko:
[root@alarm ~]#

See how modinfo properly lists the dependencies, but modules.dep which
depmod generates does not contain them. As a result, most kernel
modules fail to load because their dependencies are not loaded by
modprobe.
2012-02-03 18:15:01 -02:00
Lucas De Marchi c90fc61b6c TODO: add task to write testsuite/README 2012-02-03 18:11:53 -02:00
Lucas De Marchi 6923e95b66 man: insmod: we don't handle modules from stdin
- Gah, kmod insmod can't load from stdin anymore. :/
- What's the use case?
- zcat module.ko.gz | insmod - (but the new insmod apparently can load .gz fine)
- yes... just insmod module.ko.gz
- and actually insmod(8) says it works. :)

Not anymore...
2012-02-03 16:33:36 -02:00
Khem Raj 035cbdc763 depmod: Dont use errno unconditionally
fopen() will not reset errno if it succeeds so we should
make sure that we only use errno in error cases.

Also fix the diagnostic messages to not use strerror
when there is no error since strerror will not return
anything useful in this case
2012-02-03 14:52:59 -02:00
Dave Reisner 3e71e7e7ad fix building and cleaning of manpages
- add modules.dep as an explicit dependency of modules.dep.bin to ensure
  parallel builds don't fail
- add generated man pages to CLEANFILES
2012-02-03 09:10:13 -05:00
Dave Reisner 1505ee9793 modprobe: avoid breaking on insertion failure 2012-02-03 09:10:13 -05:00
Dave Reisner af9572c6d7 lib/module: check initstate before inserting module
This applies to both the high level probe_insert_module() and the
underlying insert_module() functions. By checking module initstate prior
to inserting a module, we can avoid a lot of needless work just to find
out that the init_module call fails with EEXIST.

This implements a helper function, module_is_inkernel, to return a
boolean value describing if a module is live, coming, or builtin.
2012-02-03 09:10:13 -05:00
Dave Reisner 7bede7b6a8 whitespace fix -- no logical code changes 2012-02-02 19:52:37 -02:00
Gustavo Sverzut Barbieri f4ac4a0b4e fix manpage build and install.
just build and install manpages if tools are enabled.

List stub modules.dep.bin in proper variable.
2012-02-02 17:04:29 -02:00
Gustavo Sverzut Barbieri dfa96f1545 improve logging to mention context.
Just printing the errno string such as "%m\n" is not enough to help
debug or users understand the problem.

Change to provide more context on the failing operation.
2012-01-31 22:01:00 -02:00
Gustavo Sverzut Barbieri e3cb0900dd improve log when debugging.
Some messages may happen more than once in the same function and
discovering the line is hard. Now we print the actual log priority
that exposed the message as well as filename and line.

NOTE: We should consider printing the log priority in the non-debug
version as well.
2012-01-31 22:01:00 -02:00
Lucas De Marchi 9226ddad2c libkmod: organize public header 2012-01-31 17:23:35 -02:00
Lucas De Marchi 4bc1895674 Prepare for API bump 2012-01-31 16:05:02 -02:00
Dave Reisner 297a3182e4 modprobe: properly handle errors from init_module
Effectively catch and the zero and non-zero cases and error out
appropriately. Note that -EEXIST will only ever be returned when
KMOD_PROBE_STOP_ON_ALREADY_LOADED is set as a probe_insert_module flag.
2012-01-31 14:08:57 -02:00
Lucas De Marchi 7aed46088e libkmod-module: probe: remove useless KMOD_PROBE_STOP_ON_COMMAND 2012-01-31 14:08:57 -02:00
Lucas De Marchi 3bc92e8949 libkmod-module: probe: return -EEXIST if told to stop on already loaded 2012-01-31 14:08:57 -02:00
Dave Reisner fa0046ba83 testsuite: allow for expected failure of tests
Adds a bool to the test struct called 'expected_fail' which can be set
to flip the logic used to determine success and failure. Messaging is
also changed to reflect an unexpected pass or expected fail. This can be
used to write tests which may represent functionality desirable for a
future release.
2012-01-31 14:08:57 -02:00
Dave Reisner 69a1974347 modprobe: post-remove module deps with 0 refcnt
This commit looks shockingly similar to 0e9bd2d1 because SOMEONE decided
to remove it in a872bba in a glorious frenzy of refactoring.
2012-01-31 14:08:57 -02:00
Lucas De Marchi 2e9dcd742e kmod-modprobe: migrate to kmod_module_probe_insert_module() 2012-01-31 14:08:57 -02:00
Lucas De Marchi 4c1ffb75d4 libkmod-module: probe: add flag to dry-run 2012-01-31 14:08:57 -02:00
Lucas De Marchi 7c10c69c72 libkmod-module: probe: add flag to ignore loaded modules
We need a way to tell libkmod to ignore loaded modules, so modprobe can
tell it to dry-run and show dependencies. However there's a conflict
with two flags. KMOD_PROBE_STOP_ON_ALREADY_LOADED prevails if passed
together with KMOD_PROBE_IGNORE_LOADED.
2012-01-31 14:08:57 -02:00