diff options
author | Dan McGee <dan@archlinux.org> | 2012-02-22 23:56:59 -0600 |
---|---|---|
committer | Lucas De Marchi <lucas.demarchi@profusion.mobi> | 2012-05-11 08:44:55 -0300 |
commit | c88aec70d1b74ea71cd3ec538b3f43ad8c6783b3 (patch) | |
tree | 4c1f791449dd42c7faecfaff19aa570a7a7d80b0 | |
parent | bcca1b95d274d98681556119383c14c3ed91acdf (diff) | |
download | kmod-c88aec70d1b74ea71cd3ec538b3f43ad8c6783b3.tar.gz |
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.
18 files changed, 169 insertions, 53 deletions
diff --git a/Makefile.am b/Makefile.am index 416672e..e04e7f7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -161,7 +161,7 @@ testsuite_libtestsuite_la_CPPFLAGS = $(TESTSUITE_CPPFLAGS) TESTSUITE = testsuite/test-init testsuite/test-testsuite testsuite/test-loaded \ testsuite/test-modinfo testsuite/test-alias testsuite/test-new-module \ - testsuite/test-modprobe testsuite/test-blacklist + testsuite/test-modprobe testsuite/test-blacklist testsuite/test-dependencies check_PROGRAMS = $(TESTSUITE) TESTS = $(TESTSUITE) @@ -181,6 +181,8 @@ testsuite_test_modprobe_LDADD = $(TESTSUITE_LDADD) testsuite_test_modprobe_CPPFLAGS = $(TESTSUITE_CPPFLAGS) testsuite_test_blacklist_LDADD = $(TESTSUITE_LDADD) testsuite_test_blacklist_CPPFLAGS = $(TESTSUITE_CPPFLAGS) +testsuite_test_dependencies_LDADD = $(TESTSUITE_LDADD) +testsuite_test_dependencies_CPPFLAGS = $(TESTSUITE_CPPFLAGS) testsuite-distclean: -find testsuite/rootfs-dirty -type d -exec chmod +w {} \; diff --git a/test/test-get-dependencies.c b/test/test-get-dependencies.c deleted file mode 100644 index 3a7bbf2..0000000 --- a/test/test-get-dependencies.c +++ /dev/null @@ -1,52 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <stddef.h> -#include <errno.h> -#include <unistd.h> -#include <inttypes.h> -#include <string.h> -#include <libkmod.h> - - -int main(int argc, char *argv[]) -{ - const char *name; - struct kmod_ctx *ctx; - struct kmod_module *mod; - struct kmod_list *list, *l; - int err; - - printf("libkmod version %s\n", VERSION); - - if (argc < 2) { - fprintf(stderr, "ERR: Provide a module name\n"); - return EXIT_FAILURE; - } - - name = argv[1]; - - ctx = kmod_new(NULL, NULL); - if (ctx == NULL) - exit(EXIT_FAILURE); - - err = kmod_module_new_from_name(ctx, name, &mod); - if (err < 0) { - kmod_unref(ctx); - exit(EXIT_FAILURE); - } - - list = kmod_module_get_dependencies(mod); - printf("Module: %s\nDependency list:\n", name); - - kmod_list_foreach(l, list) { - struct kmod_module *m = kmod_module_get_module(l); - printf("\t%s\n", kmod_module_get_name(m)); - kmod_module_unref(m); - } - - kmod_module_unref_list(list); - kmod_module_unref(mod); - kmod_unref(ctx); - - return EXIT_SUCCESS; -} diff --git a/testsuite/.gitignore b/testsuite/.gitignore index 0c620aa..21fe518 100644 --- a/testsuite/.gitignore +++ b/testsuite/.gitignore @@ -4,6 +4,7 @@ /.dirstamp /test-alias /test-blacklist +/test-dependencies /test-init /test-loaded /test-modinfo diff --git a/testsuite/rootfs/test-dependencies/lib/modules/4.0.20-kmod/kernel/fs/jbd2/jbd2.ko b/testsuite/rootfs/test-dependencies/lib/modules/4.0.20-kmod/kernel/fs/jbd2/jbd2.ko Binary files differnew file mode 100644 index 0000000..521c214 --- /dev/null +++ b/testsuite/rootfs/test-dependencies/lib/modules/4.0.20-kmod/kernel/fs/jbd2/jbd2.ko diff --git a/testsuite/rootfs/test-dependencies/lib/modules/4.0.20-kmod/kernel/fs/mbcache.ko b/testsuite/rootfs/test-dependencies/lib/modules/4.0.20-kmod/kernel/fs/mbcache.ko Binary files differnew file mode 100644 index 0000000..5849fa7 --- /dev/null +++ b/testsuite/rootfs/test-dependencies/lib/modules/4.0.20-kmod/kernel/fs/mbcache.ko diff --git a/testsuite/rootfs/test-dependencies/lib/modules/4.0.20-kmod/kernel/lib/crc16.ko b/testsuite/rootfs/test-dependencies/lib/modules/4.0.20-kmod/kernel/lib/crc16.ko Binary files differnew file mode 100644 index 0000000..2fffdb7 --- /dev/null +++ b/testsuite/rootfs/test-dependencies/lib/modules/4.0.20-kmod/kernel/lib/crc16.ko diff --git a/testsuite/rootfs/test-dependencies/lib/modules/4.0.20-kmod/modules.alias b/testsuite/rootfs/test-dependencies/lib/modules/4.0.20-kmod/modules.alias new file mode 100644 index 0000000..ba76e18 --- /dev/null +++ b/testsuite/rootfs/test-dependencies/lib/modules/4.0.20-kmod/modules.alias @@ -0,0 +1 @@ +# Aliases extracted from modules themselves. diff --git a/testsuite/rootfs/test-dependencies/lib/modules/4.0.20-kmod/modules.alias.bin b/testsuite/rootfs/test-dependencies/lib/modules/4.0.20-kmod/modules.alias.bin Binary files differnew file mode 100644 index 0000000..7075435 --- /dev/null +++ b/testsuite/rootfs/test-dependencies/lib/modules/4.0.20-kmod/modules.alias.bin diff --git a/testsuite/rootfs/test-dependencies/lib/modules/4.0.20-kmod/modules.builtin b/testsuite/rootfs/test-dependencies/lib/modules/4.0.20-kmod/modules.builtin new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/testsuite/rootfs/test-dependencies/lib/modules/4.0.20-kmod/modules.builtin diff --git a/testsuite/rootfs/test-dependencies/lib/modules/4.0.20-kmod/modules.builtin.bin b/testsuite/rootfs/test-dependencies/lib/modules/4.0.20-kmod/modules.builtin.bin Binary files differnew file mode 100644 index 0000000..7075435 --- /dev/null +++ b/testsuite/rootfs/test-dependencies/lib/modules/4.0.20-kmod/modules.builtin.bin diff --git a/testsuite/rootfs/test-dependencies/lib/modules/4.0.20-kmod/modules.dep b/testsuite/rootfs/test-dependencies/lib/modules/4.0.20-kmod/modules.dep new file mode 100644 index 0000000..c4e2516 --- /dev/null +++ b/testsuite/rootfs/test-dependencies/lib/modules/4.0.20-kmod/modules.dep @@ -0,0 +1,4 @@ +kernel/fs/mbcache.ko: +kernel/fs/ext4/ext4.ko: kernel/lib/crc16.ko kernel/fs/jbd2/jbd2.ko kernel/fs/mbcache.ko +kernel/fs/jbd2/jbd2.ko: +kernel/lib/crc16.ko: diff --git a/testsuite/rootfs/test-dependencies/lib/modules/4.0.20-kmod/modules.dep.bin b/testsuite/rootfs/test-dependencies/lib/modules/4.0.20-kmod/modules.dep.bin Binary files differnew file mode 100644 index 0000000..2e89d91 --- /dev/null +++ b/testsuite/rootfs/test-dependencies/lib/modules/4.0.20-kmod/modules.dep.bin diff --git a/testsuite/rootfs/test-dependencies/lib/modules/4.0.20-kmod/modules.devname b/testsuite/rootfs/test-dependencies/lib/modules/4.0.20-kmod/modules.devname new file mode 100644 index 0000000..58f6d6d --- /dev/null +++ b/testsuite/rootfs/test-dependencies/lib/modules/4.0.20-kmod/modules.devname @@ -0,0 +1 @@ +# Device nodes to trigger on-demand module loading. diff --git a/testsuite/rootfs/test-dependencies/lib/modules/4.0.20-kmod/modules.order b/testsuite/rootfs/test-dependencies/lib/modules/4.0.20-kmod/modules.order new file mode 100644 index 0000000..85f2778 --- /dev/null +++ b/testsuite/rootfs/test-dependencies/lib/modules/4.0.20-kmod/modules.order @@ -0,0 +1,7 @@ +kernel/fs/mbcache.ko +kernel/fs/ext3/ext3.ko +kernel/fs/ext2/ext2.ko +kernel/fs/ext4/ext4.ko +kernel/fs/jbd/jbd.ko +kernel/fs/jbd2/jbd2.ko +kernel/lib/crc16.ko diff --git a/testsuite/rootfs/test-dependencies/lib/modules/4.0.20-kmod/modules.softdep b/testsuite/rootfs/test-dependencies/lib/modules/4.0.20-kmod/modules.softdep new file mode 100644 index 0000000..3cc0512 --- /dev/null +++ b/testsuite/rootfs/test-dependencies/lib/modules/4.0.20-kmod/modules.softdep @@ -0,0 +1,2 @@ +# Soft dependencies extracted from modules themselves. +# Copy, with a .conf extension, to /etc/modprobe.d to use it with modprobe. diff --git a/testsuite/rootfs/test-dependencies/lib/modules/4.0.20-kmod/modules.symbols b/testsuite/rootfs/test-dependencies/lib/modules/4.0.20-kmod/modules.symbols new file mode 100644 index 0000000..0f0d88c --- /dev/null +++ b/testsuite/rootfs/test-dependencies/lib/modules/4.0.20-kmod/modules.symbols @@ -0,0 +1,58 @@ +# Aliases for symbols, used by symbol_request(). +alias symbol:jbd2_journal_invalidatepage jbd2 +alias symbol:jbd2_journal_release_buffer jbd2 +alias symbol:jbd2_journal_init_inode jbd2 +alias symbol:jbd2__journal_restart jbd2 +alias symbol:mb_cache_entry_find_next mbcache +alias symbol:crc16 crc16 +alias symbol:mb_cache_entry_insert mbcache +alias symbol:jbd2_journal_destroy jbd2 +alias symbol:jbd2_journal_lock_updates jbd2 +alias symbol:mb_cache_entry_free mbcache +alias symbol:jbd2_log_start_commit jbd2 +alias symbol:mb_cache_entry_find_first mbcache +alias symbol:mb_cache_destroy mbcache +alias symbol:jbd2_journal_extend jbd2 +alias symbol:jbd2_journal_begin_ordered_truncate jbd2 +alias symbol:jbd2_journal_revoke jbd2 +alias symbol:jbd2_journal_get_write_access jbd2 +alias symbol:jbd2_inode_cache jbd2 +alias symbol:jbd2_journal_ack_err jbd2 +alias symbol:mb_cache_create mbcache +alias symbol:jbd2_journal_flush jbd2 +alias symbol:jbd2_journal_init_jbd_inode jbd2 +alias symbol:mb_cache_entry_alloc mbcache +alias symbol:jbd2_journal_get_undo_access jbd2 +alias symbol:jbd2_journal_get_create_access jbd2 +alias symbol:jbd2_journal_update_format jbd2 +alias symbol:crc16_table crc16 +alias symbol:jbd2_journal_wipe jbd2 +alias symbol:jbd2_journal_check_used_features jbd2 +alias symbol:mb_cache_entry_get mbcache +alias symbol:jbd2_journal_force_commit_nested jbd2 +alias symbol:jbd2_log_wait_commit jbd2 +alias symbol:jbd2_journal_stop jbd2 +alias symbol:jbd2_journal_set_triggers jbd2 +alias symbol:jbd2_journal_release_jbd_inode jbd2 +alias symbol:jbd2_journal_unlock_updates jbd2 +alias symbol:jbd2_journal_start_commit jbd2 +alias symbol:jbd2_journal_dirty_metadata jbd2 +alias symbol:jbd2_journal_force_commit jbd2 +alias symbol:mb_cache_entry_release mbcache +alias symbol:jbd2_journal_init_dev jbd2 +alias symbol:jbd2_journal_forget jbd2 +alias symbol:jbd2_journal_set_features jbd2 +alias symbol:jbd2_journal_start jbd2 +alias symbol:jbd2_journal_clear_features jbd2 +alias symbol:jbd2__journal_start jbd2 +alias symbol:mb_cache_shrink mbcache +alias symbol:jbd2_journal_clear_err jbd2 +alias symbol:jbd2_journal_file_inode jbd2 +alias symbol:jbd2_journal_restart jbd2 +alias symbol:jbd2_journal_load jbd2 +alias symbol:jbd2_journal_check_available_features jbd2 +alias symbol:jbd2_journal_abort jbd2 +alias symbol:jbd2_journal_blocks_per_page jbd2 +alias symbol:jbd2_journal_try_to_free_buffers jbd2 +alias symbol:jbd2_trans_will_send_data_barrier jbd2 +alias symbol:jbd2_journal_errno jbd2 diff --git a/testsuite/rootfs/test-dependencies/lib/modules/4.0.20-kmod/modules.symbols.bin b/testsuite/rootfs/test-dependencies/lib/modules/4.0.20-kmod/modules.symbols.bin Binary files differnew file mode 100644 index 0000000..aa8cfc8 --- /dev/null +++ b/testsuite/rootfs/test-dependencies/lib/modules/4.0.20-kmod/modules.symbols.bin diff --git a/testsuite/test-dependencies.c b/testsuite/test-dependencies.c new file mode 100644 index 0000000..a4a1d40 --- /dev/null +++ b/testsuite/test-dependencies.c @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2011-2012 ProFUSION embedded systems + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <stddef.h> +#include <errno.h> +#include <unistd.h> +#include <inttypes.h> +#include <string.h> +#include <libkmod.h> + +#include "testsuite.h" +#define TEST_UNAME "4.0.20-kmod" + +static int test_dependencies(const struct test *t) +{ + struct kmod_ctx *ctx; + struct kmod_module *mod; + struct kmod_list *list, *l; + int err; + size_t len = 0; + int crc16 = 0, mbcache = 0, jbd2 = 0; + + ctx = kmod_new(NULL, NULL); + if (ctx == NULL) + return EXIT_FAILURE; + + err = kmod_module_new_from_name(ctx, "ext4", &mod); + if (err < 0) { + kmod_unref(ctx); + return EXIT_FAILURE; + } + + list = kmod_module_get_dependencies(mod); + + kmod_list_foreach(l, list) { + struct kmod_module *m = kmod_module_get_module(l); + const char *name = kmod_module_get_name(m); + + if (strcmp(name, "crc16") == 0) + crc16 = 1; + if (strcmp(name, "mbcache") == 0) + mbcache = 1; + else if (strcmp(name, "jbd2") == 0) + jbd2 = 1; + + kmod_module_unref(m); + len++; + } + + /* crc16, mbcache, jbd2 */ + if (len != 3 || !crc16 || !mbcache || !jbd2) + return EXIT_FAILURE; + + kmod_module_unref_list(list); + kmod_module_unref(mod); + kmod_unref(ctx); + + return EXIT_SUCCESS; +} +static const struct test stest_dependencies = { + .name = "test_dependencies", + .description = "test if kmod_module_get_dependencies works", + .func = test_dependencies, + .config = { + [TC_ROOTFS] = TESTSUITE_ROOTFS "test-dependencies/", + [TC_UNAME_R] = TEST_UNAME, + }, + .need_spawn = true, +}; + +static const struct test *tests[] = { + &stest_dependencies, + NULL, +}; + +TESTSUITE_MAIN(tests); |