Commit Graph

239 Commits

Author SHA1 Message Date
Lucas De Marchi 9b51e13b84 testsuite: test kmod_module_remove_module for failure 2015-01-14 14:32:09 -02:00
Lucas De Marchi af87874f9c testsuite: fix retcodes parsing
It was not saving _modules in modules and thus all check were falling in
the fallback "consider a success if module is not in the list". Also the
name check wasn't right: replace with streq().

The parsing could be better implemented, but this is left for later.
2015-01-14 14:25:02 -02:00
Lucas De Marchi c78066aef1 testsuite: add test for array_pop() 2015-01-08 17:10:18 -02:00
Lucas De Marchi 8ff7f008cd testsuite: do not overrid paths inside build
If we are accessing a file inside the build directory we should really
not trap the path. Right now this isn't important because we never do
such accesses. However it will be needed when gcov is integrated because
it dumps files to the same place where the binaries are located.
2015-01-07 19:14:20 -02:00
Lucas De Marchi f357866d97 Fix includes after change to build-sys
Make the includes be libkmod/libkmod.h for code outside of library. This
fixes the broken build after 1315123 ('build-sys: Don't add libkmod
subdirectory to include path').
2015-01-02 12:41:01 -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 1315123955 build-sys: Don't add libkmod subdirectory to include path
Like 05437b8 (Makefile.am: Don't add abc subdirectory to include path)
in libabc by Josh Triplett.
2014-12-25 23:41:34 -02:00
Lucas De Marchi 48e4d18191 testsuite: add tests for strbuf 2014-10-13 18:42:01 -03: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 c5798fea93 testsuite: use a section to put tests in instead of array
Intead of having to declare an array of tests, tweak the definition of
DEFINE_TEST and TESTSUITE_MAIN so they know the tests are put in a
particular section of the ELF file.

This avoids the mistake of adding a test and forgetting to add it to the
array. Now once a test is defined, it's ready to run, so one less step
to define new tests.

The removal of the arrays is left for another patch so not to clutter
the diff on this one.
2014-10-09 14:17:24 -03:00
Lucas De Marchi f1155c1574 Move static keyword to DEFINE_TEST macro 2014-10-09 13:00:30 -03:00
Lucas De Marchi f4e8c16291 Move remaining functions from libkmod-util to shared 2014-10-09 01:26:39 -03:00
Lucas De Marchi 2b0104fe3c Move alias_normalize() to shared 2014-10-09 01:26:39 -03:00
Lucas De Marchi fdafa6b655 testsuite: add tests for array implementation 2014-10-09 01:26:39 -03:00
Lucas De Marchi aafd38359a Rename getline_wrapped() to freadline_wrapped() 2014-10-03 03:25:06 -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 0db718edcf Move hash implementation to shared directory 2014-10-03 00:40:11 -03:00
Lucas De Marchi 96573a0220 Move generic util functions to shared directory 2014-10-03 00:33:25 -03:00
Lucas De Marchi 576dd4393d Move macro.h to shared directory
It's not really related to libkmod, so move it to a directory in which
we keep common stuff.
2014-10-02 22:03:19 -03:00
Lucas De Marchi a5a41f8dbb testsuite: Fix macro missing format string 2014-06-14 11:14:58 -03:00
Lucas De Marchi 5963c36da3 testsuite: Add basic tests for hash implementation
Far from complete, but already covers all internal APIs.
2014-06-06 02:24:39 -03:00
Lucas De Marchi 30471c80a4 testsuite: Add assert_return
Add assert_return to use in testcases instead of assert. The issues
with assert are:
	1) It's disabled when NDEBUG is defined
	2) Even if it's well supported by testsuite (the parent will
	   report the child died) it can't output any meaningful
	   error message
2014-06-06 02:19:28 -03:00
Lucas De Marchi f988e25c68 testsuite: separate testcases on log 2014-06-05 17:54:41 -03:00
Lucas De Marchi 7a2d0e6187 testsuite: check for correct error message in detect-loop 2014-05-30 10:26:17 -03:00
Lucas De Marchi d7293a1628 testsuite: Fix expected_fail parsing
If a test has expected_fail=true, it means the return code must be
different from 0 *and* the outputs must match. This way it's possible to
check if the error messages are printed as they should.
2014-05-30 10:23:05 -03:00
Lucas De Marchi f429113a47 testsuite: Add braces 2014-05-30 10:20:19 -03:00
Lucas De Marchi 8183cfa9da testsuite: add test to fail depmod on module loops 2014-05-30 09:36:56 -03:00
Lucas De Marchi b8b990f47d Add gitignore to module playground 2014-05-09 08:43:32 -03:00
Lucas De Marchi 3f8dd30a76 testsuite: Add module playground dir 2014-05-02 12:57:17 -03:00
Lucas De Marchi 3e68b2c455 testsuite: Remove duplicate test
This partially reverts ad7f175 ("Add test for depmod using search dirs
with same prefix"). Testing it twice in the inverted order doesn't
ensure we get the bug with wrong ordering.

As put by Anssi Hannula <anssi@mageia.org>:

	So the bug is triggered only if the shorter name is higher-prio _and_
	shorter name is traversed first. If the long name is traversed first,
	the bug don't trigger with either "search" directive order (and on my
	"make check" runs this is the case).
2014-04-06 17:46:45 -03:00
Michal Marek 81bf88d6c4 testsuite: Do not run tests with *.ko.gz if zlib is not enabled 2014-04-04 13:05:49 +02:00
Michal Marek 73476ec5cb testsuite: Uncompress most modules
Only keep test-depmod/modules-order-compressed to test compressed module
support.
2014-04-04 12:32:16 +02:00
Lucas De Marchi ad7f1757c0 Add test for depmod using search dirs with same prefix
Test depmod with search dirs "foo" and "foobar". Previously to 49b33c1
("depmod: do not allow partial matches with "search" directive") we were
failing this test due to matching the prefix without checking if
it's the full dir name.

We are adding 2 tests here in order to catch the case we only pass the
test due to processing the directories in a favourable order.
2014-03-19 09:22:20 -03:00
Lucas De Marchi aa0abec721 Add test for simple search order in depmod 2014-03-19 08:52:33 -03:00
Michal Marek 632fb7b463 testsuite: Fix uname() during glibc startup
In a specific configuration (chroot with the linux32 personality), the
modprobe_install_cmd_loop test failed, because the bash process handling
the install command segfaulted. The backtrace showed a uname() call
during libpthread initialization, at which point the environ pointer
hadn't been initialized yet:

	Program terminated with signal SIGSEGV, Segmentation fault.
	#0  0x080c1591 in getenv (name=<optimized out>,
	    name@entry=0xf775f850 "TESTSUITE_UNAME_R") at getenv.c:81
	81	      for (i = 0, len = strlen (name); environ[i]; i++)
	(gdb) bt
	#0  0x080c1591 in getenv (name=<optimized out>,
	    name@entry=0xf775f850 "TESTSUITE_UNAME_R") at getenv.c:81
	#1  0xf775f754 in uname (u=u@entry=0xff946350) at testsuite/uname.c:32
	#2  0xf74ffc6c in is_smp_system ()
	    at ../nptl/sysdeps/unix/sysv/linux/i386/smp.h:39
	#3  __pthread_initialize_minimal_internal () at nptl-init.c:460
	#4  0xf74fe32c in _init () at ../sysdeps/i386/crti.S:74
	#5  0x00000000 in ?? ()
	(gdb) p environ
	$1 = (char **) 0x0

I don't know why it only happend in the chroot, but glibc can call its
own functions and impose any restrictions before main() is started, so
we have to adapt.

Also, do not return error if there is an environment, but the
environment variable is not found. If uname() is called by kmod, then
the respective test will simply fail later. If it's something else
calling uname(), then we do not want to disturb the program.
2014-03-06 23:09:56 -03:00
Lucas De Marchi 06eb29e117 build-sys: add small redirecting Makefiles
These redirecting makefiles simplifies compiling from some editors and
when CWD is not the root of the source tree. This is similar to what was
introduced in systemd in 340d89e ("build-sys: add small redirecting
Makefiles to simplify compilation from within emacs")
2014-03-06 01:59:58 -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 063086e038 testsuite: Do not provide finit_module(2) on older kernels
If the test's uname -r is less that 3.8, return -ENOSYS from
finit_module(), so that the fallback is tested.
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
Lucas De Marchi 1dda626f6b testsuite: add basic test for getline_wrapped 2013-11-18 11:01:16 -02:00
Lucas De Marchi 807c601df2 testsuite: Move test-alias to test-util
Move file so we can use the same file to test other functions from
libkmod-util.c
2013-11-18 04:35:03 -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 c493b93750 util: Add len arg to mkdir_p() 2013-07-15 12:44:33 -03:00
Lucas De Marchi 85d02ebea3 util: Add mkdir_p implementation from testsuite 2013-07-15 12:44:33 -03:00
Lucas De Marchi 7980eaf0ec testsuite: Fix mkdir_p corner cases
- Fix infinite loop when path is relative
 - Fix not considering EEXIST as a success
 - General refactor to mkdir_p so it never calls mkdir for an existing
   dir (given no one creates it from outside)
2013-07-15 12:44:26 -03:00
Lucas De Marchi 83b855a6ed Use "-internal" suffix instead of "-private" 2013-07-04 16:13:11 -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 2ad09ccf0f testsuite: errno is a positive number 2013-04-12 01:24:30 -03:00
Lucas De Marchi 8e00db9537 testsuite: Fix checking __sysno
Use an if instead of a case statemente. If __NR_finit_module is not
defined in system headers we define it to -1, causing a "duplicate case
value" error. Yet, we don't want to actually call our finit_module()
function if -1 is passed.

This also fix errno being set with negative value.
2013-04-09 11:54:05 -03:00
Lucas De Marchi 0ae58609dc testsuite: Wrap syscall() to get calls to finit_module()
When we don't have finit_module() in libc (most likely because as of
today glibc didn't add it yet), we end up using
syscall(__NR_finit_module, ...). In this case we would not wrap the
function in the testsuite and thus having some tests failing:

TESTSUITE: ERR: could not insert module: Operation not permitted

This implementation relies on the fact that this is the only caller of
syscall(2), because we can't call libc's syscall(). There's an abort()
in place to be future safe: as soon as we need more calls to syscall(),
we can detect (and decide what to do).

Now we have all tests passing in the testsuite again.
2013-04-09 05:45:44 -03:00
Lucas De Marchi 55112d19f7 libkmod: Move finit_module() definition to missing.h
Check for finit_module() and don't use our own static inline function if
there's such function in libc (or another lib).

In testsuite we need to unconditionally define HAVE_FINIT_MODULE because
we want to override this function, and never use the static inline one
in missing.h
2013-04-09 04:38:27 -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 489c04ddec testsuite: Exit with success on signal if test has expected_fail=true 2013-03-21 02:22:15 -03:00
Kees Cook e87352d289 testsuite: handle finit_module
This adds the finit_module logic to the testsuite.
2013-02-19 19:19:51 -03:00
Michal Marek 709b86346e testsuite: Add modinfo test for module signatures 2013-01-17 23:48:43 -02:00
Lucas De Marchi e6b0e49b4e Update copyright notices 2013-01-16 11:27:45 -02:00
Lucas De Marchi 4111bc0fc7 gitignore: ignore files generated by Automake's testsuite
These files are generated by Automake 1.13 when running the testsuite.
2013-01-15 18:03:55 -02:00
Lucas De Marchi b0c9fc85a2 testsuite: add depmod test for modules.alias
Check if modules.alias is correctly generated from modules.order if we
have compressed modules.
2012-10-04 01:08:13 -03:00
Lucas De Marchi 3e451bfefb testsuite: allow to check generated files
This gives the test cases the ability to supply files that must be
checked after the test is run, rather than just checking stdout/stderr.

This is intended to be used with tools that generate files, like depmod.
It includes a poor's man implementation of a "check for differences in
files". Not really optimized, but it's simple enough and does what it
proposes to.
2012-10-04 01:04:52 -03:00
Lucas De Marchi d642341777 testsuite: Fix double definition of 64-bits variant
If _FILE_OFFSET_BITS is defined we should not be wrapping these 64
variants, since they are macros in libc.
2012-09-07 15:12:12 -03:00
Martin Pitt 123e8278ed testsuite preload: Factorize into macros, add more stat and open variants
Instead of replicating the same code several times, define and use macros for
the various types of wrapped functions in the testsuite's path.c LD_PRELOAD
wrapper.

Add various __xstat() variants and open64(), which are being used when enabling
large file support.
2012-08-01 20:44:27 -03:00
Lucas De Marchi e8fd8fec23 Use #pragma once instead of #ifndef
Only the public header maintains #ifndef in the header, together with
pragma. The other ones contain only pragma.

As reported by Shawn Landden on systemd mailing list this is compatible
with all major compilers and gcc has this since version 3.3.
2012-07-18 10:31:50 -03:00
Lucas De Marchi e1b1ab24ab testsuite: re-license under LGPL 2012-07-10 10:31:57 -03:00
Martin Pitt 4281cee076 testsuite: path wrapper: Fix open() with 3 arguments
Properly return the original libc return value in the case that open() is
called with 3 arguments.
2012-07-10 10:31:40 -03:00
Lucas De Marchi fca5b9bcd4 testsuite: use right offset for module name
We need to cope with the case in which a 32 bits machine is opening a 64
bits kernel module and vice-versa. The offset in `struct module' are
different and do not depend on the architecture we are running, but
rather on the architecture they were created for.

This fixes `make check' in 32 bits machines (since we are shipping 64
bits modules for testing)
2012-06-21 11:30:56 -03:00
Lucas De Marchi 33202e84f3 build-sys: Make dirs writable on rootfs creation
Autofoo make the dist dir as readonly. If we copy it, tools needing to
create sysfs entries will not be able to do so, because they can't
create the needed directories/files.

It would be much better if autofoo allowed to let the files as is
instead of converting them to read-only.
2012-06-19 13:27:56 -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 34db3f2d3e testsuite: allow to export custom env vars 2012-06-06 01:45:30 -03:00
Lucas De Marchi b8e344a6d2 testsuite: add timeout for each test
Each test must run under 2 seconds. Ideally they should run in much less
than this; just give an arbitrary number so we don't wait forever in
case we reached an infinite loop somewhere.
2012-06-06 01:45:30 -03:00
Lucas De Marchi ed8e93fd92 testsuite: create additional pipe to monitor child 2012-06-06 01:45:30 -03:00
Lucas De Marchi a6976f8b1d testsuite: add test for softdep loops 2012-06-05 00:57:47 -03:00
Lucas De Marchi a655370541 testsuite: check if module is in kernel for return code 2012-06-05 00:54:48 -03:00
Lucas De Marchi ddf1e7a617 testsuite: set default init_module behavior to mimic kernel's 2012-06-05 00:54:48 -03:00
Lucas De Marchi 5a2949cdf3 testsuite: create initstate file upon fake init_module() 2012-06-05 00:54:47 -03:00
Lucas De Marchi 44e5466795 testsuite: add mkdir_p implementation 2012-06-05 00:54:47 -03:00
Lucas De Marchi 113d0084d4 testsuite: trap calls to mkdir 2012-06-05 00:54:47 -03:00
Lucas De Marchi 0de690c96c testsuite: check if rootfs dir is dirty before running
Keep around a stamp-rootfs file that is generated together with the
rootfs. testsuite checks each test directory if its mtime is greater
than stamp's mtime, deciding if rootfs should be re-generated.
2012-06-05 00:54:47 -03:00
Lucas De Marchi ada9719942 testsuite: separate insert and delete rootfs from modinfo 2012-06-05 00:54:47 -03:00
Lucas De Marchi e2ee7d9b7a testsuite: rename rootfs dir 2012-06-05 00:54:47 -03:00
Lucas De Marchi 90fc410b32 testsuite: fix find_module() finding wrong module 2012-06-05 00:54:39 -03:00
Dan McGee c88aec70d1 test-conversion: convert test-get-dependencies to new infrastructure
The test uses the ext4 module dependencies as the testcase, checking
both the number and the names of the returned modules.
2012-05-11 08:44:55 -03:00
Dan McGee bcca1b95d2 test-conversion: convert test-blacklist to new infrastructure
Add a modprobe.conf with some blacklist entries in a test rootfs, and
then ensure our blacklist function actually cuts out the two listed
entries (and doesn't cut out the others).
2012-05-11 08:44:55 -03:00
Lucas De Marchi 452c1dde2f build-sys: copy rootfs to another directory
We can't use the rootfs directory because it breaks out-of-tree build
and in future we want to make modifications to the fake filesystem such
as adding and removing files.

We need to call "chmod -R +w" in the resulting directory because when we
distribute the source with make dist all files will be readonly.

Fix 'make distcheck'
2012-05-11 02:23:34 -03:00
Dan McGee cdbcc2481c testsuite: ship testsuite/rootfs unzipped
The current configuration is dumb in any number of ways:
1) If the rationale was for space savings, it works the opposite- the
   git repo gets more bloated because we are adding binary compressed
   blobs that share little in common with their parent, and anyone that
   wants to run the test suite has to unzip it anyway.
2) It is a pain in the butt to add new tests, and not accidentally lose
   any new rootfs you built in the directory.
3) `git status` won't help you if you are tweaking files in the rootfs
   and don't know they have been changed, or if some test did that and
   you couldn't detect it.
4) `git log` won't help you find out what is changing in the rootfs test
   directory itself when changes are made to the binary blob, such as
   new files being added or even existing files being tweaked.
5) The files just aren't that big anyway- 2.7MB unzipped.
2012-05-11 01:03:17 -03:00
Lucas De Marchi 050db08c57 Add missing newlines
Checked with following semantic patch for the library:

// smpl
@a@
identifier virtual.func;
expression E1;
expression fmt;
position p1;
@@

func(E1, fmt@p1, ...)

@script:python b@
fmt << a.fmt;
p1 << a.p1;
@@

s = str(fmt)
if s.find("\\n") < 0:
	print p1[0].file + ":" + p1[0].line

// smpl

For tools, just remove E1
2012-02-18 03:56:21 -02:00
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 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
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
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
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
Lucas De Marchi dfdfb962d3 testsuite: check if dots are allowed in aliases 2012-01-30 20:05:34 -02:00
Lucas De Marchi a9474303a4 testsuite: add test for kmod_module_new_from_name()
Check if module names are being correctly normalized.
2012-01-30 20:05:34 -02:00
Lucas De Marchi 9901cfe242 Partially fix parsing of alias with dots
Alias names may contain dots. However since kmod_module_from_alias()
still calls kmod_module_new_from_name(), the bug is not entirely fixed,
and will be completely corrected in a later patch.
2012-01-30 20:05:33 -02:00
Lucas De Marchi 81e8b8042a testsuite: let stat.h take care of stat64
This fixes testsuite build in 32 bits machines.
2012-01-30 13:51:58 -02:00
Lucas De Marchi d3f159bbdd Use %zu for size_t
Remove warning on 32 bits systems.
2012-01-30 13:49:40 -02:00
Lucas De Marchi c41143ad45 testsuite: remove unneeded call to memset() 2012-01-28 21:30:57 -02:00
Pedro Pedruzzi 760b8968d4 testsuite: add test for function alias_normalize 2012-01-28 12:18:58 -02:00
Lucas De Marchi e701e381fa testsuite: add GPL license 2012-01-26 17:02:05 -02:00
Lucas De Marchi f6ef5d6b5f testsuite: trap calls to delete_module() including simple test 2012-01-26 16:14:18 -02:00
Lucas De Marchi d2c2b8b500 build-sys: autotoolify build of check libraries
Many thanks to Iván Briano (sachieru@gmail.com) for pointing out this
thread in libtool mailing list:
	http://www.mail-archive.com/libtool@gnu.org/msg09627.html

Passing '-rpath /nowhere' in LDFLAGS we are able to create shared libs
that are not installed.
2012-01-26 16:05:05 -02:00
Lucas De Marchi 53646fc56f testsuite: add trap to init_module() including simple test 2012-01-26 16:05:05 -02:00
Lucas De Marchi 95daea07f4 testsuite: add test for modinfo
These ext4 modules were sent by Jon Master so we can test the result of
modinfo with modules generated for different architectures.

They are now added to testsuite and their output tested automatically.
2012-01-26 16:05:05 -02:00
Lucas De Marchi 9e3b9d2e8c testsuite: remind users to build tools 2012-01-26 16:05:05 -02:00
Lucas De Marchi 51b1d1ab28 testsuite: add colors to test output 2012-01-26 16:05:05 -02:00
Lucas De Marchi 61e9433f7c testsuite: add simple test for list of loaded modules 2012-01-26 16:05:05 -02:00
Lucas De Marchi 3dbb8dea5f testsuite: match outputs of test with a known correct one
Tests may put the correct output in a file and tell testsuite to check
if it matches the output from the test running.

Testsuite compares the outputs while running the test: it creates a pipe
between parent and child; parent reads both stdout and stderr from child
and compares with the correct output.
2012-01-26 16:05:05 -02:00
Lucas De Marchi 45481ee28c testsuite: separate child from parent 2012-01-26 16:05:04 -02:00
Lucas De Marchi 6b88ef3e97 testsuite: allow to run tests outside of top_buildir
In order to locate where the shared libs to be preloaded are we need to
reference them using abs_top_buildir. Otherwise we are limited to
running tests from there.
2012-01-26 16:05:04 -02:00
Lucas De Marchi 4e36cb18e1 testsuite: add trap to opendir() including tests 2012-01-26 16:05:04 -02:00
Lucas De Marchi 1426a613fa testsuite: add trap to stat() and friends including tests
Add trap to stat(): we need to trap other functions too, depending on
stat.h, the function from glibc that is actually called may be stat64 or
__xstat() too.
2012-01-26 16:05:04 -02:00
Lucas De Marchi 7fa8c2d2df testsuite: add trap to open() including tests 2012-01-26 16:05:04 -02:00
Lucas De Marchi 6afc9cd616 testsuite: add trap to fopen() including tests 2012-01-26 16:05:04 -02:00
Lucas De Marchi ab25311072 testsuite: fake kernel 4.0.20-kmod is out
Go get it while it's fresh :-). Test fake results of "uname -r" by
LD_PRELOAD'ing uname.so.
2012-01-26 16:05:04 -02:00
Lucas De Marchi 395478cbbb testsuite: export environment with flags and LD_PRELOAD
A certain config can add flags and each flag may be associated with a
lib to LD_PRELOAD. It's now done for uname(2), which requires uname.so
in order to trap the calls.

Other trap will be added in later commits.
2012-01-26 16:05:04 -02:00
Lucas De Marchi ed2df4e984 testsuite: move oneshot to inside the test struct 2012-01-26 16:05:04 -02:00
Lucas De Marchi 68cc449376 testsuite: trap calls to uname 2012-01-26 16:05:04 -02:00
Lucas De Marchi eebca81e94 testsuite: test libkmod initialization 2012-01-26 16:05:04 -02:00
Lucas De Marchi 80f9e02382 testsuite: add skeleton 2012-01-26 16:05:04 -02:00