testsuite: add tests for external directory support
authorYauheni Kaliuta <yauheni.kaliuta@redhat.com>
Tue, 9 May 2017 19:09:24 +0000 (22:09 +0300)
committerLucas De Marchi <lucas.demarchi@intel.com>
Fri, 2 Jun 2017 03:31:37 +0000 (20:31 -0700)
The following tests added:

- depmod_search_order_external_first -- checks if external module
  is taken in use when it has higher priority;
- depmod_search_order_external_last -- checks if external module
  is skipped when it has lower priority;
- test_modinfo_external -- checks if modinfo is able to look up
  correct external module;
- modprobe_external -- checks if modprobe is able to look up
  correct external module and loads it.

Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
30 files changed:
testsuite/populate-modules.sh
testsuite/rootfs-pristine/test-depmod/search-order-external-first/etc/depmod.d/external.conf [new file with mode: 0644]
testsuite/rootfs-pristine/test-depmod/search-order-external-first/etc/depmod.d/search.conf [new file with mode: 0644]
testsuite/rootfs-pristine/test-depmod/search-order-external-first/lib/modules/4.4.4/correct-modules.dep [new file with mode: 0644]
testsuite/rootfs-pristine/test-depmod/search-order-external-last/etc/depmod.d/external.conf [new file with mode: 0644]
testsuite/rootfs-pristine/test-depmod/search-order-external-last/etc/depmod.d/search.conf [new file with mode: 0644]
testsuite/rootfs-pristine/test-depmod/search-order-external-last/lib/modules/4.4.4/correct-modules.dep [new file with mode: 0644]
testsuite/rootfs-pristine/test-modinfo/correct-external.txt [new file with mode: 0644]
testsuite/rootfs-pristine/test-modinfo/external/lib/modules/4.4.4/modules.alias [new file with mode: 0644]
testsuite/rootfs-pristine/test-modinfo/external/lib/modules/4.4.4/modules.alias.bin [new file with mode: 0644]
testsuite/rootfs-pristine/test-modinfo/external/lib/modules/4.4.4/modules.builtin.bin [new file with mode: 0644]
testsuite/rootfs-pristine/test-modinfo/external/lib/modules/4.4.4/modules.dep [new file with mode: 0644]
testsuite/rootfs-pristine/test-modinfo/external/lib/modules/4.4.4/modules.dep.bin [new file with mode: 0644]
testsuite/rootfs-pristine/test-modinfo/external/lib/modules/4.4.4/modules.devname [new file with mode: 0644]
testsuite/rootfs-pristine/test-modinfo/external/lib/modules/4.4.4/modules.softdep [new file with mode: 0644]
testsuite/rootfs-pristine/test-modinfo/external/lib/modules/4.4.4/modules.symbols [new file with mode: 0644]
testsuite/rootfs-pristine/test-modinfo/external/lib/modules/4.4.4/modules.symbols.bin [new file with mode: 0644]
testsuite/rootfs-pristine/test-modprobe/external/lib/modules/4.4.4/modules.alias [new file with mode: 0644]
testsuite/rootfs-pristine/test-modprobe/external/lib/modules/4.4.4/modules.alias.bin [new file with mode: 0644]
testsuite/rootfs-pristine/test-modprobe/external/lib/modules/4.4.4/modules.builtin.bin [new file with mode: 0644]
testsuite/rootfs-pristine/test-modprobe/external/lib/modules/4.4.4/modules.dep [new file with mode: 0644]
testsuite/rootfs-pristine/test-modprobe/external/lib/modules/4.4.4/modules.dep.bin [new file with mode: 0644]
testsuite/rootfs-pristine/test-modprobe/external/lib/modules/4.4.4/modules.devname [new file with mode: 0644]
testsuite/rootfs-pristine/test-modprobe/external/lib/modules/4.4.4/modules.softdep [new file with mode: 0644]
testsuite/rootfs-pristine/test-modprobe/external/lib/modules/4.4.4/modules.symbols [new file with mode: 0644]
testsuite/rootfs-pristine/test-modprobe/external/lib/modules/4.4.4/modules.symbols.bin [new file with mode: 0644]
testsuite/rootfs-pristine/test-modprobe/external/proc/modules [new file with mode: 0644]
testsuite/test-depmod.c
testsuite/test-modinfo.c
testsuite/test-modprobe.c

index a7e5036..3ac92ee 100755 (executable)
@@ -22,6 +22,12 @@ map=(
     ["test-depmod/detect-loop/lib/modules/4.4.4/kernel/mod-loop-i.ko"]="mod-loop-i.ko"
     ["test-depmod/detect-loop/lib/modules/4.4.4/kernel/mod-loop-j.ko"]="mod-loop-j.ko"
     ["test-depmod/detect-loop/lib/modules/4.4.4/kernel/mod-loop-k.ko"]="mod-loop-k.ko"
+    ["test-depmod/search-order-external-first/lib/modules/4.4.4/foo/"]="mod-simple.ko"
+    ["test-depmod/search-order-external-first/lib/modules/4.4.4/foobar/"]="mod-simple.ko"
+    ["test-depmod/search-order-external-first/lib/modules/external/"]="mod-simple.ko"
+    ["test-depmod/search-order-external-last/lib/modules/4.4.4/foo/"]="mod-simple.ko"
+    ["test-depmod/search-order-external-last/lib/modules/4.4.4/foobar/"]="mod-simple.ko"
+    ["test-depmod/search-order-external-last/lib/modules/external/"]="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"
@@ -40,6 +46,7 @@ map=(
     ["test-modprobe/oldkernel-force/lib/modules/3.3.3/kernel/"]="mod-simple.ko"
     ["test-modprobe/alias-to-none/lib/modules/4.4.4/kernel/"]="mod-simple.ko"
     ["test-modprobe/module-param-kcmdline/lib/modules/4.4.4/kernel/"]="mod-simple.ko"
+    ["test-modprobe/external/lib/modules/external/"]="mod-simple.ko"
     ["test-depmod/modules-order-compressed/lib/modules/4.4.4/kernel/drivers/block/cciss.ko"]="mod-fake-cciss.ko"
     ["test-depmod/modules-order-compressed/lib/modules/4.4.4/kernel/drivers/scsi/hpsa.ko"]="mod-fake-hpsa.ko"
     ["test-depmod/modules-order-compressed/lib/modules/4.4.4/kernel/drivers/scsi/scsi_mod.ko"]="mod-fake-scsi-mod.ko"
@@ -48,6 +55,7 @@ map=(
     ["test-modinfo/mod-simple-sparc64.ko"]="mod-simple-sparc64.ko"
     ["test-modinfo/mod-simple-sha1.ko"]="mod-simple.ko"
     ["test-modinfo/mod-simple-sha256.ko"]="mod-simple.ko"
+    ["test-modinfo/external/lib/modules/external/mod-simple.ko"]="mod-simple.ko"
     ["test-tools/insert/lib/modules/4.4.4/kernel/"]="mod-simple.ko"
     ["test-tools/remove/lib/modules/4.4.4/kernel/"]="mod-simple.ko"
 )
diff --git a/testsuite/rootfs-pristine/test-depmod/search-order-external-first/etc/depmod.d/external.conf b/testsuite/rootfs-pristine/test-depmod/search-order-external-first/etc/depmod.d/external.conf
new file mode 100644 (file)
index 0000000..59f46ae
--- /dev/null
@@ -0,0 +1 @@
+external 4\.4\..* /lib/modules/external
diff --git a/testsuite/rootfs-pristine/test-depmod/search-order-external-first/etc/depmod.d/search.conf b/testsuite/rootfs-pristine/test-depmod/search-order-external-first/etc/depmod.d/search.conf
new file mode 100644 (file)
index 0000000..642e497
--- /dev/null
@@ -0,0 +1 @@
+search external foobar foo built-in
diff --git a/testsuite/rootfs-pristine/test-depmod/search-order-external-first/lib/modules/4.4.4/correct-modules.dep b/testsuite/rootfs-pristine/test-depmod/search-order-external-first/lib/modules/4.4.4/correct-modules.dep
new file mode 100644 (file)
index 0000000..e612900
--- /dev/null
@@ -0,0 +1 @@
+/lib/modules/external/mod-simple.ko:
diff --git a/testsuite/rootfs-pristine/test-depmod/search-order-external-last/etc/depmod.d/external.conf b/testsuite/rootfs-pristine/test-depmod/search-order-external-last/etc/depmod.d/external.conf
new file mode 100644 (file)
index 0000000..59f46ae
--- /dev/null
@@ -0,0 +1 @@
+external 4\.4\..* /lib/modules/external
diff --git a/testsuite/rootfs-pristine/test-depmod/search-order-external-last/etc/depmod.d/search.conf b/testsuite/rootfs-pristine/test-depmod/search-order-external-last/etc/depmod.d/search.conf
new file mode 100644 (file)
index 0000000..5fdb812
--- /dev/null
@@ -0,0 +1 @@
+search foobar foo built-in external
diff --git a/testsuite/rootfs-pristine/test-depmod/search-order-external-last/lib/modules/4.4.4/correct-modules.dep b/testsuite/rootfs-pristine/test-depmod/search-order-external-last/lib/modules/4.4.4/correct-modules.dep
new file mode 100644 (file)
index 0000000..eab3bb0
--- /dev/null
@@ -0,0 +1 @@
+foobar/mod-simple.ko:
diff --git a/testsuite/rootfs-pristine/test-modinfo/correct-external.txt b/testsuite/rootfs-pristine/test-modinfo/correct-external.txt
new file mode 100644 (file)
index 0000000..a094abe
--- /dev/null
@@ -0,0 +1 @@
+/lib/modules/external/mod-simple.ko
diff --git a/testsuite/rootfs-pristine/test-modinfo/external/lib/modules/4.4.4/modules.alias b/testsuite/rootfs-pristine/test-modinfo/external/lib/modules/4.4.4/modules.alias
new file mode 100644 (file)
index 0000000..ba76e18
--- /dev/null
@@ -0,0 +1 @@
+# Aliases extracted from modules themselves.
diff --git a/testsuite/rootfs-pristine/test-modinfo/external/lib/modules/4.4.4/modules.alias.bin b/testsuite/rootfs-pristine/test-modinfo/external/lib/modules/4.4.4/modules.alias.bin
new file mode 100644 (file)
index 0000000..7075435
Binary files /dev/null and b/testsuite/rootfs-pristine/test-modinfo/external/lib/modules/4.4.4/modules.alias.bin differ
diff --git a/testsuite/rootfs-pristine/test-modinfo/external/lib/modules/4.4.4/modules.builtin.bin b/testsuite/rootfs-pristine/test-modinfo/external/lib/modules/4.4.4/modules.builtin.bin
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/testsuite/rootfs-pristine/test-modinfo/external/lib/modules/4.4.4/modules.dep b/testsuite/rootfs-pristine/test-modinfo/external/lib/modules/4.4.4/modules.dep
new file mode 100644 (file)
index 0000000..e612900
--- /dev/null
@@ -0,0 +1 @@
+/lib/modules/external/mod-simple.ko:
diff --git a/testsuite/rootfs-pristine/test-modinfo/external/lib/modules/4.4.4/modules.dep.bin b/testsuite/rootfs-pristine/test-modinfo/external/lib/modules/4.4.4/modules.dep.bin
new file mode 100644 (file)
index 0000000..556e3c8
Binary files /dev/null and b/testsuite/rootfs-pristine/test-modinfo/external/lib/modules/4.4.4/modules.dep.bin differ
diff --git a/testsuite/rootfs-pristine/test-modinfo/external/lib/modules/4.4.4/modules.devname b/testsuite/rootfs-pristine/test-modinfo/external/lib/modules/4.4.4/modules.devname
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/testsuite/rootfs-pristine/test-modinfo/external/lib/modules/4.4.4/modules.softdep b/testsuite/rootfs-pristine/test-modinfo/external/lib/modules/4.4.4/modules.softdep
new file mode 100644 (file)
index 0000000..5554ccc
--- /dev/null
@@ -0,0 +1 @@
+# Soft dependencies extracted from modules themselves.
diff --git a/testsuite/rootfs-pristine/test-modinfo/external/lib/modules/4.4.4/modules.symbols b/testsuite/rootfs-pristine/test-modinfo/external/lib/modules/4.4.4/modules.symbols
new file mode 100644 (file)
index 0000000..618c345
--- /dev/null
@@ -0,0 +1 @@
+# Aliases for symbols, used by symbol_request().
diff --git a/testsuite/rootfs-pristine/test-modinfo/external/lib/modules/4.4.4/modules.symbols.bin b/testsuite/rootfs-pristine/test-modinfo/external/lib/modules/4.4.4/modules.symbols.bin
new file mode 100644 (file)
index 0000000..7075435
Binary files /dev/null and b/testsuite/rootfs-pristine/test-modinfo/external/lib/modules/4.4.4/modules.symbols.bin differ
diff --git a/testsuite/rootfs-pristine/test-modprobe/external/lib/modules/4.4.4/modules.alias b/testsuite/rootfs-pristine/test-modprobe/external/lib/modules/4.4.4/modules.alias
new file mode 100644 (file)
index 0000000..ba76e18
--- /dev/null
@@ -0,0 +1 @@
+# Aliases extracted from modules themselves.
diff --git a/testsuite/rootfs-pristine/test-modprobe/external/lib/modules/4.4.4/modules.alias.bin b/testsuite/rootfs-pristine/test-modprobe/external/lib/modules/4.4.4/modules.alias.bin
new file mode 100644 (file)
index 0000000..7075435
Binary files /dev/null and b/testsuite/rootfs-pristine/test-modprobe/external/lib/modules/4.4.4/modules.alias.bin differ
diff --git a/testsuite/rootfs-pristine/test-modprobe/external/lib/modules/4.4.4/modules.builtin.bin b/testsuite/rootfs-pristine/test-modprobe/external/lib/modules/4.4.4/modules.builtin.bin
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/testsuite/rootfs-pristine/test-modprobe/external/lib/modules/4.4.4/modules.dep b/testsuite/rootfs-pristine/test-modprobe/external/lib/modules/4.4.4/modules.dep
new file mode 100644 (file)
index 0000000..e612900
--- /dev/null
@@ -0,0 +1 @@
+/lib/modules/external/mod-simple.ko:
diff --git a/testsuite/rootfs-pristine/test-modprobe/external/lib/modules/4.4.4/modules.dep.bin b/testsuite/rootfs-pristine/test-modprobe/external/lib/modules/4.4.4/modules.dep.bin
new file mode 100644 (file)
index 0000000..556e3c8
Binary files /dev/null and b/testsuite/rootfs-pristine/test-modprobe/external/lib/modules/4.4.4/modules.dep.bin differ
diff --git a/testsuite/rootfs-pristine/test-modprobe/external/lib/modules/4.4.4/modules.devname b/testsuite/rootfs-pristine/test-modprobe/external/lib/modules/4.4.4/modules.devname
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/testsuite/rootfs-pristine/test-modprobe/external/lib/modules/4.4.4/modules.softdep b/testsuite/rootfs-pristine/test-modprobe/external/lib/modules/4.4.4/modules.softdep
new file mode 100644 (file)
index 0000000..5554ccc
--- /dev/null
@@ -0,0 +1 @@
+# Soft dependencies extracted from modules themselves.
diff --git a/testsuite/rootfs-pristine/test-modprobe/external/lib/modules/4.4.4/modules.symbols b/testsuite/rootfs-pristine/test-modprobe/external/lib/modules/4.4.4/modules.symbols
new file mode 100644 (file)
index 0000000..618c345
--- /dev/null
@@ -0,0 +1 @@
+# Aliases for symbols, used by symbol_request().
diff --git a/testsuite/rootfs-pristine/test-modprobe/external/lib/modules/4.4.4/modules.symbols.bin b/testsuite/rootfs-pristine/test-modprobe/external/lib/modules/4.4.4/modules.symbols.bin
new file mode 100644 (file)
index 0000000..7075435
Binary files /dev/null and b/testsuite/rootfs-pristine/test-modprobe/external/lib/modules/4.4.4/modules.symbols.bin differ
diff --git a/testsuite/rootfs-pristine/test-modprobe/external/proc/modules b/testsuite/rootfs-pristine/test-modprobe/external/proc/modules
new file mode 100644 (file)
index 0000000..e69de29
index b9beb01..e249c61 100644 (file)
@@ -131,4 +131,56 @@ DEFINE_TEST(depmod_detect_loop,
                .err = DETECT_LOOP_ROOTFS "/correct.txt",
        });
 
+#define SEARCH_ORDER_EXTERNAL_FIRST_ROOTFS TESTSUITE_ROOTFS "test-depmod/search-order-external-first"
+static noreturn int depmod_search_order_external_first(const struct test *t)
+{
+       const char *progname = ABS_TOP_BUILDDIR "/tools/depmod";
+       const char *const args[] = {
+               progname,
+               NULL,
+       };
+
+       test_spawn_prog(progname, args);
+       exit(EXIT_FAILURE);
+}
+DEFINE_TEST(depmod_search_order_external_first,
+       .description = "check if depmod honor external keyword with higher priority",
+       .config = {
+               [TC_UNAME_R] = "4.4.4",
+               [TC_ROOTFS] = SEARCH_ORDER_EXTERNAL_FIRST_ROOTFS,
+       },
+       .output = {
+               .files = (const struct keyval[]) {
+                       { SEARCH_ORDER_EXTERNAL_FIRST_ROOTFS "/lib/modules/4.4.4/correct-modules.dep",
+                         SEARCH_ORDER_EXTERNAL_FIRST_ROOTFS "/lib/modules/4.4.4/modules.dep" },
+                       { }
+               },
+       });
+
+#define SEARCH_ORDER_EXTERNAL_LAST_ROOTFS TESTSUITE_ROOTFS "test-depmod/search-order-external-last"
+static noreturn int depmod_search_order_external_last(const struct test *t)
+{
+       const char *progname = ABS_TOP_BUILDDIR "/tools/depmod";
+       const char *const args[] = {
+               progname,
+               NULL,
+       };
+
+       test_spawn_prog(progname, args);
+       exit(EXIT_FAILURE);
+}
+DEFINE_TEST(depmod_search_order_external_last,
+       .description = "check if depmod honor external keyword with lower priority",
+       .config = {
+               [TC_UNAME_R] = "4.4.4",
+               [TC_ROOTFS] = SEARCH_ORDER_EXTERNAL_LAST_ROOTFS,
+       },
+       .output = {
+               .files = (const struct keyval[]) {
+                       { SEARCH_ORDER_EXTERNAL_LAST_ROOTFS "/lib/modules/4.4.4/correct-modules.dep",
+                         SEARCH_ORDER_EXTERNAL_LAST_ROOTFS "/lib/modules/4.4.4/modules.dep" },
+                       { }
+               },
+       });
+
 TESTSUITE_MAIN();
index 4877502..8fdfe35 100644 (file)
@@ -89,4 +89,25 @@ DEFINE_TEST(test_modinfo_signature,
                .out = TESTSUITE_ROOTFS "test-modinfo/correct.txt",
        });
 #endif
+
+static noreturn int test_modinfo_external(const struct test *t)
+{
+       const char *const args[] = {
+               progname, "-F", "filename",
+               "mod-simple",
+               NULL,
+       };
+       test_spawn_prog(progname, args);
+       exit(EXIT_FAILURE);
+}
+DEFINE_TEST(test_modinfo_external,
+       .description = "check if modinfo finds external module",
+       .config = {
+               [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modinfo/external",
+               [TC_UNAME_R] = "4.4.4",
+       },
+       .output = {
+               .out = TESTSUITE_ROOTFS "test-modinfo/correct-external.txt",
+       })
+
 TESTSUITE_MAIN();
index e0dd199..ee9d82d 100644 (file)
@@ -371,4 +371,26 @@ DEFINE_TEST(modprobe_oldkernel_force,
        .modules_loaded = "mod-simple",
        );
 
+static noreturn int modprobe_external(const struct test *t)
+{
+       const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe";
+       const char *const args[] = {
+               progname,
+               "mod-simple",
+               NULL,
+       };
+
+       test_spawn_prog(progname, args);
+       exit(EXIT_FAILURE);
+}
+DEFINE_TEST(modprobe_external,
+       .description = "check modprobe able to load external module",
+       .config = {
+               [TC_UNAME_R] = "4.4.4",
+               [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/external",
+               [TC_INIT_MODULE_RETCODES] = "",
+       },
+       .modules_loaded = "mod-simple",
+       );
+
 TESTSUITE_MAIN();