From: Lucas De Marchi Date: Wed, 25 Jan 2012 22:32:48 +0000 (-0200) Subject: testsuite: add test for modinfo X-Git-Tag: v5~58 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=95daea07f44f6907859850e37d3468376759f66f;p=thirdparty%2Fkmod.git testsuite: add test for modinfo These ext4 modules were sent by Jon Master so we can test the result of modinfo with modules generated for different architectures. They are now added to testsuite and their output tested automatically. --- diff --git a/Makefile.am b/Makefile.am index 74d1b8c6..a6f6bcc3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -170,7 +170,8 @@ testsuite_libtestsuite_la_DEPENDENCIES = testsuite/uname.so \ testsuite/rootfs testsuite_libtestsuite_la_CPPFLAGS = $(TESTSUITE_CPPFLAGS) -TESTSUITE = testsuite/test-init testsuite/test-testsuite testsuite/test-loaded +TESTSUITE = testsuite/test-init testsuite/test-testsuite testsuite/test-loaded \ + testsuite/test-modinfo check_PROGRAMS = $(TESTSUITE) TESTS = $(TESTSUITE) @@ -180,6 +181,8 @@ testsuite_test_testsuite_LDADD = testsuite/libtestsuite.la testsuite_test_testsuite_CPPFLAGS = $(TESTSUITE_CPPFLAGS) testsuite_test_loaded_LDADD = testsuite/libtestsuite.la libkmod/libkmod-private.la testsuite_test_loaded_CPPFLAGS = $(TESTSUITE_CPPFLAGS) +testsuite_test_modinfo_LDADD = testsuite/libtestsuite.la +testsuite_test_modinfo_CPPFLAGS = $(TESTSUITE_CPPFLAGS) DISTCHECK_CONFIGURE_FLAGS=--enable-gtk-doc diff --git a/testsuite/.gitignore b/testsuite/.gitignore index 58cac86a..f2e833d5 100644 --- a/testsuite/.gitignore +++ b/testsuite/.gitignore @@ -6,3 +6,4 @@ rootfs/ test-init test-loaded test-testsuite +test-modinfo diff --git a/testsuite/rootfs.tar.xz b/testsuite/rootfs.tar.xz index 091b45a2..7445e807 100644 Binary files a/testsuite/rootfs.tar.xz and b/testsuite/rootfs.tar.xz differ diff --git a/testsuite/test-modinfo.c b/testsuite/test-modinfo.c new file mode 100644 index 00000000..3e3b1a38 --- /dev/null +++ b/testsuite/test-modinfo.c @@ -0,0 +1,67 @@ +#include +#include +#include +#include +#include +#include +#include + +#include "testsuite.h" + +static int modinfo_jonsmodules(const struct test *t) +{ + const char *progname = ABS_TOP_BUILDDIR "/tools/modinfo"; + const char *const args[] = { + progname, + "/ext4-i686.ko", "/ext4-ppc64.ko", "/ext4-s390x.ko", + "/ext4-x86_64.ko", + NULL, + }; + + test_spawn_prog(progname, args); + exit(EXIT_FAILURE); +} +static const struct test smodinfo_jonsmodules = { + .name = "modinfo_jonsmodules", + .description = "check if output for modinfo is correct for i686, ppc64, s390x and x86_64", + .func = modinfo_jonsmodules, + .config = { + [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modinfo/", + }, + .output = { + .stdout = TESTSUITE_ROOTFS "test-modinfo/correct.txt", + }, +}; + +static const struct test *tests[] = { + &smodinfo_jonsmodules, + NULL, +}; + +int main(int argc, char *argv[]) +{ + const struct test *t; + int arg; + size_t i; + + arg = test_init(argc, argv, tests); + if (arg == 0) + return 0; + + if (arg < argc) { + t = test_find(tests, argv[arg]); + if (t == NULL) { + fprintf(stderr, "could not find test %s\n", argv[arg]); + exit(EXIT_FAILURE); + } + + return test_run(t); + } + + for (i = 0; tests[i] != NULL; i++) { + if (test_run(tests[i]) != 0) + exit(EXIT_FAILURE); + } + + exit(EXIT_SUCCESS); +} diff --git a/testsuite/testsuite.h b/testsuite/testsuite.h index b2831d4d..4259b21b 100644 --- a/testsuite/testsuite.h +++ b/testsuite/testsuite.h @@ -32,7 +32,7 @@ struct test { const struct test *test_find(const struct test *tests[], const char *name); int test_init(int argc, char *const argv[], const struct test *tests[]); -int test_spawn_prog(const char *prog, const char *args[]); +int test_spawn_prog(const char *prog, const char *const args[]); int test_run(const struct test *t);