testsuite: port test-dependencies to module-playground
authorLucas De Marchi <lucas.demarchi@intel.com>
Tue, 3 Feb 2015 02:24:33 +0000 (00:24 -0200)
committerLucas De Marchi <lucas.demarchi@intel.com>
Tue, 3 Feb 2015 03:12:13 +0000 (01:12 -0200)
16 files changed:
Makefile.am
testsuite/module-playground/Makefile
testsuite/module-playground/mod-foo-a.c [new file with mode: 0644]
testsuite/module-playground/mod-foo-b.c [new file with mode: 0644]
testsuite/module-playground/mod-foo-c.c [new file with mode: 0644]
testsuite/module-playground/mod-foo.c [new file with mode: 0644]
testsuite/populate-modules.sh
testsuite/rootfs-pristine/test-dependencies/lib/modules/4.0.20-kmod/kernel/fs/jbd2/jbd2.ko [deleted file]
testsuite/rootfs-pristine/test-dependencies/lib/modules/4.0.20-kmod/kernel/fs/mbcache.ko [deleted file]
testsuite/rootfs-pristine/test-dependencies/lib/modules/4.0.20-kmod/kernel/lib/crc16.ko [deleted file]
testsuite/rootfs-pristine/test-dependencies/lib/modules/4.0.20-kmod/modules.dep
testsuite/rootfs-pristine/test-dependencies/lib/modules/4.0.20-kmod/modules.dep.bin
testsuite/rootfs-pristine/test-dependencies/lib/modules/4.0.20-kmod/modules.softdep
testsuite/rootfs-pristine/test-dependencies/lib/modules/4.0.20-kmod/modules.symbols
testsuite/rootfs-pristine/test-dependencies/lib/modules/4.0.20-kmod/modules.symbols.bin
testsuite/test-dependencies.c

index 97a9631..7774759 100644 (file)
@@ -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
 
 
index b8b465a..88367cf 100644 (file)
@@ -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
diff --git a/testsuite/module-playground/mod-foo-a.c b/testsuite/module-playground/mod-foo-a.c
new file mode 100644 (file)
index 0000000..bc65f66
--- /dev/null
@@ -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");
diff --git a/testsuite/module-playground/mod-foo-b.c b/testsuite/module-playground/mod-foo-b.c
new file mode 100644 (file)
index 0000000..09079f6
--- /dev/null
@@ -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");
diff --git a/testsuite/module-playground/mod-foo-c.c b/testsuite/module-playground/mod-foo-c.c
new file mode 100644 (file)
index 0000000..3afd35d
--- /dev/null
@@ -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");
diff --git a/testsuite/module-playground/mod-foo.c b/testsuite/module-playground/mod-foo.c
new file mode 100644 (file)
index 0000000..8105608
--- /dev/null
@@ -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");
index 25ce457..6a32f04 100755 (executable)
@@ -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
diff --git a/testsuite/rootfs-pristine/test-dependencies/lib/modules/4.0.20-kmod/kernel/fs/jbd2/jbd2.ko b/testsuite/rootfs-pristine/test-dependencies/lib/modules/4.0.20-kmod/kernel/fs/jbd2/jbd2.ko
deleted file mode 100644 (file)
index 521c214..0000000
Binary files a/testsuite/rootfs-pristine/test-dependencies/lib/modules/4.0.20-kmod/kernel/fs/jbd2/jbd2.ko and /dev/null differ
diff --git a/testsuite/rootfs-pristine/test-dependencies/lib/modules/4.0.20-kmod/kernel/fs/mbcache.ko b/testsuite/rootfs-pristine/test-dependencies/lib/modules/4.0.20-kmod/kernel/fs/mbcache.ko
deleted file mode 100644 (file)
index 5849fa7..0000000
Binary files a/testsuite/rootfs-pristine/test-dependencies/lib/modules/4.0.20-kmod/kernel/fs/mbcache.ko and /dev/null differ
diff --git a/testsuite/rootfs-pristine/test-dependencies/lib/modules/4.0.20-kmod/kernel/lib/crc16.ko b/testsuite/rootfs-pristine/test-dependencies/lib/modules/4.0.20-kmod/kernel/lib/crc16.ko
deleted file mode 100644 (file)
index 2fffdb7..0000000
Binary files a/testsuite/rootfs-pristine/test-dependencies/lib/modules/4.0.20-kmod/kernel/lib/crc16.ko and /dev/null differ
index c4e2516..d9ebfa3 100644 (file)
@@ -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
index 2e89d91..8874801 100644 (file)
Binary files a/testsuite/rootfs-pristine/test-dependencies/lib/modules/4.0.20-kmod/modules.dep.bin and b/testsuite/rootfs-pristine/test-dependencies/lib/modules/4.0.20-kmod/modules.dep.bin differ
index 0f0d88c..ddb6ab6 100644 (file)
@@ -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
index aa8cfc8..1add6e5 100644 (file)
Binary files a/testsuite/rootfs-pristine/test-dependencies/lib/modules/4.0.20-kmod/modules.symbols.bin and b/testsuite/rootfs-pristine/test-dependencies/lib/modules/4.0.20-kmod/modules.symbols.bin differ
index c2a4607..38f5fc1 100644 (file)
 
 #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();