mirror of
https://github.com/AuxXxilium/kmod.git
synced 2024-11-23 23:10:53 +07:00
testsuite: port test-dependencies to module-playground
This commit is contained in:
parent
d2db083ab6
commit
450c1f037b
@ -253,6 +253,10 @@ check-am: rootfs check-sysconfdir
|
||||
|
||||
|
||||
EXTRA_DIST += testsuite/module-playground/Makefile \
|
||||
testsuite/module-playground/mod-foo.c \
|
||||
testsuite/module-playground/mod-foo-a.c \
|
||||
testsuite/module-playground/mod-foo-b.c \
|
||||
testsuite/module-playground/mod-foo-c.c \
|
||||
testsuite/module-playground/mod-simple.c
|
||||
|
||||
|
||||
|
@ -1,6 +1,14 @@
|
||||
ifneq ($(KERNELRELEASE),)
|
||||
# kbuild part of makefile
|
||||
obj-m := mod-simple.o
|
||||
|
||||
# mod-foo depends on foo-x, and foo-x modules don't depend
|
||||
# on anyone
|
||||
obj-m += mod-foo-a.o
|
||||
obj-m += mod-foo-b.o
|
||||
obj-m += mod-foo-c.o
|
||||
obj-m += mod-foo.o
|
||||
|
||||
else
|
||||
# normal makefile
|
||||
KDIR ?= /lib/modules/`uname -r`/build
|
||||
|
20
testsuite/module-playground/mod-foo-a.c
Normal file
20
testsuite/module-playground/mod-foo-a.c
Normal file
@ -0,0 +1,20 @@
|
||||
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
||||
|
||||
#include <linux/init.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/printk.h>
|
||||
|
||||
static int __init foo_init(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
module_init(foo_init);
|
||||
|
||||
void print_fooA(void)
|
||||
{
|
||||
pr_warn("fooA\n");
|
||||
}
|
||||
EXPORT_SYMBOL(print_fooA);
|
||||
|
||||
MODULE_AUTHOR("Lucas De Marchi <lucas.demarchi@intel.com>");
|
||||
MODULE_LICENSE("LGPL");
|
20
testsuite/module-playground/mod-foo-b.c
Normal file
20
testsuite/module-playground/mod-foo-b.c
Normal file
@ -0,0 +1,20 @@
|
||||
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
||||
|
||||
#include <linux/init.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/printk.h>
|
||||
|
||||
static int __init foo_init(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
module_init(foo_init);
|
||||
|
||||
void print_fooB(void)
|
||||
{
|
||||
pr_warn("fooB\n");
|
||||
}
|
||||
EXPORT_SYMBOL(print_fooB);
|
||||
|
||||
MODULE_AUTHOR("Lucas De Marchi <lucas.demarchi@intel.com>");
|
||||
MODULE_LICENSE("LGPL");
|
20
testsuite/module-playground/mod-foo-c.c
Normal file
20
testsuite/module-playground/mod-foo-c.c
Normal file
@ -0,0 +1,20 @@
|
||||
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
||||
|
||||
#include <linux/init.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/printk.h>
|
||||
|
||||
static int __init foo_init(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
module_init(foo_init);
|
||||
|
||||
void print_fooC(void)
|
||||
{
|
||||
pr_warn("fooC\n");
|
||||
}
|
||||
EXPORT_SYMBOL(print_fooC);
|
||||
|
||||
MODULE_AUTHOR("Lucas De Marchi <lucas.demarchi@intel.com>");
|
||||
MODULE_LICENSE("LGPL");
|
23
testsuite/module-playground/mod-foo.c
Normal file
23
testsuite/module-playground/mod-foo.c
Normal file
@ -0,0 +1,23 @@
|
||||
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
||||
|
||||
#include <linux/init.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/printk.h>
|
||||
|
||||
void print_fooA(void);
|
||||
void print_fooB(void);
|
||||
void print_fooC(void);
|
||||
|
||||
static int __init foo_init(void)
|
||||
{
|
||||
print_fooA();
|
||||
print_fooB();
|
||||
print_fooC();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
module_init(foo_init);
|
||||
|
||||
MODULE_AUTHOR("Lucas De Marchi <lucas.demarchi@intel.com>");
|
||||
MODULE_LICENSE("LGPL");
|
@ -11,6 +11,10 @@ map=(
|
||||
["test-depmod/search-order-simple/lib/modules/4.4.4/updates/"]="mod-simple.ko"
|
||||
["test-depmod/search-order-same-prefix/lib/modules/4.4.4/foo/"]="mod-simple.ko"
|
||||
["test-depmod/search-order-same-prefix/lib/modules/4.4.4/foobar/"]="mod-simple.ko"
|
||||
["test-dependencies/lib/modules/4.0.20-kmod/kernel/fs/foo/"]="mod-foo-b.ko"
|
||||
["test-dependencies/lib/modules/4.0.20-kmod/kernel/"]="mod-foo-c.ko"
|
||||
["test-dependencies/lib/modules/4.0.20-kmod/kernel/lib/"]="mod-foo-a.ko"
|
||||
["test-dependencies/lib/modules/4.0.20-kmod/kernel/fs/"]="mod-foo.ko"
|
||||
)
|
||||
|
||||
for k in ${!map[@]}; do
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,4 +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:
|
||||
kernel/fs/foo/mod-foo-b.ko:
|
||||
kernel/mod-foo-c.ko:
|
||||
kernel/lib/mod-foo-a.ko:
|
||||
kernel/fs/mod-foo.ko: kernel/fs/foo/mod-foo-b.ko kernel/lib/mod-foo-a.ko kernel/mod-foo-c.ko
|
||||
|
Binary file not shown.
@ -1,2 +1 @@
|
||||
# Soft dependencies extracted from modules themselves.
|
||||
# Copy, with a .conf extension, to /etc/modprobe.d to use it with modprobe.
|
||||
|
@ -1,58 +1,4 @@
|
||||
# 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
|
||||
alias symbol:print_fooA mod_foo_a
|
||||
alias symbol:print_fooC mod_foo_c
|
||||
alias symbol:print_fooB mod_foo_b
|
||||
|
Binary file not shown.
@ -31,23 +31,23 @@
|
||||
|
||||
#define TEST_UNAME "4.0.20-kmod"
|
||||
|
||||
static int test_dependencies(const struct test *t)
|
||||
static noreturn int test_dependencies(const struct test *t)
|
||||
{
|
||||
struct kmod_ctx *ctx;
|
||||
struct kmod_module *mod = NULL;
|
||||
struct kmod_list *list, *l;
|
||||
int err;
|
||||
size_t len = 0;
|
||||
int crc16 = 0, mbcache = 0, jbd2 = 0;
|
||||
int fooa = 0, foob = 0, fooc = 0;
|
||||
|
||||
ctx = kmod_new(NULL, NULL);
|
||||
if (ctx == NULL)
|
||||
return EXIT_FAILURE;
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
err = kmod_module_new_from_name(ctx, "ext4", &mod);
|
||||
err = kmod_module_new_from_name(ctx, "mod-foo", &mod);
|
||||
if (err < 0 || mod == NULL) {
|
||||
kmod_unref(ctx);
|
||||
return EXIT_FAILURE;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
list = kmod_module_get_dependencies(mod);
|
||||
@ -56,32 +56,34 @@ static int test_dependencies(const struct test *t)
|
||||
struct kmod_module *m = kmod_module_get_module(l);
|
||||
const char *name = kmod_module_get_name(m);
|
||||
|
||||
if (streq(name, "crc16"))
|
||||
crc16 = 1;
|
||||
if (streq(name, "mbcache"))
|
||||
mbcache = 1;
|
||||
else if (streq(name, "jbd2"))
|
||||
jbd2 = 1;
|
||||
if (streq(name, "mod_foo_a"))
|
||||
fooa = 1;
|
||||
if (streq(name, "mod_foo_b"))
|
||||
foob = 1;
|
||||
else if (streq(name, "mod_foo_c"))
|
||||
fooc = 1;
|
||||
|
||||
fprintf(stderr, "name=%s", name);
|
||||
kmod_module_unref(m);
|
||||
len++;
|
||||
}
|
||||
|
||||
/* crc16, mbcache, jbd2 */
|
||||
if (len != 3 || !crc16 || !mbcache || !jbd2)
|
||||
return EXIT_FAILURE;
|
||||
/* fooa, foob, fooc */
|
||||
if (len != 3 || !fooa || !foob || !fooc)
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
kmod_module_unref_list(list);
|
||||
kmod_module_unref(mod);
|
||||
kmod_unref(ctx);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
DEFINE_TEST(test_dependencies,
|
||||
.description = "test if kmod_module_get_dependencies works",
|
||||
.config = {
|
||||
[TC_ROOTFS] = TESTSUITE_ROOTFS "test-dependencies/",
|
||||
[TC_UNAME_R] = TEST_UNAME,
|
||||
});
|
||||
[TC_ROOTFS] = TESTSUITE_ROOTFS "test-dependencies/",
|
||||
},
|
||||
.need_spawn = true);
|
||||
|
||||
TESTSUITE_MAIN();
|
||||
|
Loading…
Reference in New Issue
Block a user