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)
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 {} \;
+++ /dev/null
-#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;
-}
/.dirstamp
/test-alias
/test-blacklist
+/test-dependencies
/test-init
/test-loaded
/test-modinfo
--- /dev/null
+# Aliases extracted from modules themselves.
--- /dev/null
+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:
--- /dev/null
+# Device nodes to trigger on-demand module loading.
--- /dev/null
+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
--- /dev/null
+# Soft dependencies extracted from modules themselves.
+# Copy, with a .conf extension, to /etc/modprobe.d to use it with modprobe.
--- /dev/null
+# 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
--- /dev/null
+/*
+ * 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);