]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
testsuite: macronify test definitions
authorLucas De Marchi <lucas.demarchi@profusion.mobi>
Tue, 7 Feb 2012 12:46:46 +0000 (10:46 -0200)
committerLucas De Marchi <lucas.demarchi@profusion.mobi>
Tue, 7 Feb 2012 12:46:46 +0000 (10:46 -0200)
testsuite/test-alias.c
testsuite/test-init.c
testsuite/test-loaded.c
testsuite/test-modinfo.c
testsuite/test-new-module.c
testsuite/test-testsuite.c
testsuite/testsuite.h

index 2e84e6b325d2aef3c39636c1b390b673c5a526a3..567d67623fe188fc9e6595c6457d174eb98afc88 100644 (file)
@@ -56,18 +56,15 @@ static int alias_1(const struct test *t)
 
        return EXIT_SUCCESS;
 }
-static const struct test salias_1 = {
-       .name = "alias_1",
+static DEFINE_TEST(alias_1,
        .description = "check if alias_normalize does the right thing",
-       .func = alias_1,
        .config = {
                [TC_ROOTFS] = TESTSUITE_ROOTFS "test-alias/",
        },
        .need_spawn = true,
        .output = {
                .stdout = TESTSUITE_ROOTFS "test-alias/correct.txt",
-       },
-};
+       });
 
 static const struct test *tests[] = {
        &salias_1,
index d6e1e5c8bb62fc0bd4bdd1de26624964d0737313..c807a16b73ae685b2fc05ef9cdfb957284b35eef 100644 (file)
@@ -38,11 +38,8 @@ static int test_initlib(const struct test *t)
 
        exit(EXIT_SUCCESS);
 }
-static const struct test stest_initlib = {
-       .name = "test_initlib",
-       .description = "test if libkmod's init function work",
-       .func = test_initlib,
-};
+static DEFINE_TEST(test_initlib,
+               .description = "test if libkmod's init function work");
 
 static int test_insert(const struct test *t)
 {
@@ -70,16 +67,13 @@ static int test_insert(const struct test *t)
 
        exit(EXIT_SUCCESS);
 }
-static const struct test stest_insert = {
-       .name = "test_insert",
+static DEFINE_TEST(test_insert,
        .description = "test if libkmod's insert_module returns ok",
-       .func = test_insert,
        .config = {
                [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modinfo/",
                [TC_INIT_MODULE_RETCODES] = "bla:1:20",
        },
-       .need_spawn = true,
-};
+       .need_spawn = true);
 
 static int test_remove(const struct test *t)
 {
@@ -107,16 +101,13 @@ static int test_remove(const struct test *t)
 
        exit(EXIT_SUCCESS);
 }
-static const struct test stest_remove = {
-       .name = "test_remove",
+static DEFINE_TEST(test_remove,
        .description = "test if libkmod's remove_module returns ok",
-       .func = test_remove,
        .config = {
                [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modinfo/",
                [TC_DELETE_MODULE_RETCODES] = "bla:1:20",
        },
-       .need_spawn = true,
-};
+       .need_spawn = true);
 
 static const struct test *tests[] = {
        &stest_initlib,
index cfeb1b49f5778e3103d39503c395150f540533b3..81c9e5ae9f18f08c9af68d6560c7e961449cc515 100644 (file)
@@ -77,18 +77,15 @@ static int loaded_1(const struct test *t)
 
        return EXIT_SUCCESS;
 }
-static const struct test sloaded_1 = {
-       .name = "sloaded_1",
+static DEFINE_TEST(loaded_1,
        .description = "check if list of module is created",
-       .func = loaded_1,
        .config = {
                [TC_ROOTFS] = TESTSUITE_ROOTFS "test-loaded/",
        },
        .need_spawn = true,
        .output = {
                .stdout = TESTSUITE_ROOTFS "test-loaded/correct.txt",
-       },
-};
+       });
 
 static const struct test *tests[] = {
        &sloaded_1,
index 3047d269d671b1ecb2e85439e053ce22dfd10ff0..007cc0a3737b7f860a8f0b8b7d9c72152d45a0e1 100644 (file)
@@ -38,17 +38,14 @@ static int modinfo_jonsmodules(const struct test *t)
        test_spawn_prog(progname, args);
        exit(EXIT_FAILURE);
 }
-static const struct test smodinfo_jonsmodules = {
-       .name = "modinfo_jonsmodules",
+static DEFINE_TEST(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,
index 117d978845fa0778c2b841aa2bb6c9c98e37b386..9a0cc3789d039860603c36e6ba8e6af5fd3f5e2f 100644 (file)
@@ -59,19 +59,15 @@ static int from_name(const struct test *t)
 
        return EXIT_SUCCESS;
 }
-static const struct test sfrom_name = {
-       .name = "sfrom_name",
+static DEFINE_TEST(from_name,
        .description = "check if module names are parsed correctly",
-       .func = from_name,
        .config = {
                [TC_ROOTFS] = TESTSUITE_ROOTFS "test-new-module/from_name/",
        },
        .need_spawn = true,
        .output = {
                .stdout = TESTSUITE_ROOTFS "test-new-module/from_name/correct.txt",
-       },
-};
-
+       });
 
 static int from_alias(const struct test *t)
 {
@@ -108,18 +104,15 @@ static int from_alias(const struct test *t)
 
        return EXIT_SUCCESS;
 }
-static const struct test sfrom_alias = {
-       .name = "sfrom_alias",
+static DEFINE_TEST(from_alias,
        .description = "check if aliases are parsed correctly",
-       .func = from_alias,
        .config = {
                [TC_ROOTFS] = TESTSUITE_ROOTFS "test-new-module/from_alias/",
        },
        .need_spawn = true,
        .output = {
                .stdout = TESTSUITE_ROOTFS "test-new-module/from_alias/correct.txt",
-       },
-};
+       });
 
 static const struct test *tests[] = {
        &sfrom_name,
index 6967b74841209f14d8d8b8a39eb11af12dcf8552..1c12830572d46e97997650472a5a23dad4fa49c4 100644 (file)
@@ -48,15 +48,12 @@ static int testsuite_uname(const struct test *t)
 
        exit(EXIT_SUCCESS);
 }
-static const struct test stestsuite_uname = {
-       .name = "testsuite_uname",
+static DEFINE_TEST(testsuite_uname,
        .description = "test if trap to uname() works",
-       .func = testsuite_uname,
        .config = {
                [TC_UNAME_R] = TEST_UNAME,
        },
-       .need_spawn = true,
-};
+       .need_spawn = true);
 
 static int testsuite_rootfs_fopen(const struct test *t)
 {
@@ -77,15 +74,12 @@ static int testsuite_rootfs_fopen(const struct test *t)
 
        return EXIT_SUCCESS;
 }
-static const struct test stestsuite_rootfs_fopen = {
-       .name = "testsuite_rootfs_fopen",
+static DEFINE_TEST(testsuite_rootfs_fopen,
        .description = "test if rootfs works - fopen()",
-       .func = testsuite_rootfs_fopen,
        .config = {
                [TC_ROOTFS] = TESTSUITE_ROOTFS "test-rootfs/",
        },
-       .need_spawn = true,
-};
+       .need_spawn = true);
 
 static int testsuite_rootfs_open(const struct test *t)
 {
@@ -113,15 +107,12 @@ static int testsuite_rootfs_open(const struct test *t)
 
        return EXIT_SUCCESS;
 }
-static const struct test stestsuite_rootfs_open = {
-       .name = "testsuite_rootfs_open",
+static DEFINE_TEST(testsuite_rootfs_open,
        .description = "test if rootfs works - open()",
-       .func = testsuite_rootfs_open,
        .config = {
                [TC_ROOTFS] = TESTSUITE_ROOTFS "test-rootfs/",
        },
-       .need_spawn = true,
-};
+       .need_spawn = true);
 
 static int testsuite_rootfs_stat_access(const struct test *t)
 {
@@ -139,15 +130,12 @@ static int testsuite_rootfs_stat_access(const struct test *t)
 
        return EXIT_SUCCESS;
 }
-static const struct test stestsuite_rootfs_stat_access = {
-       .name = "testsuite_rootfs_stat_access",
+static DEFINE_TEST(testsuite_rootfs_stat_access,
        .description = "test if rootfs works - stat() and access()",
-       .func = testsuite_rootfs_stat_access,
        .config = {
                [TC_ROOTFS] = TESTSUITE_ROOTFS "test-rootfs/",
        },
-       .need_spawn = true,
-};
+       .need_spawn = true);
 
 static int testsuite_rootfs_opendir(const struct test *t)
 {
@@ -162,15 +150,12 @@ static int testsuite_rootfs_opendir(const struct test *t)
        closedir(d);
        return EXIT_SUCCESS;
 }
-static const struct test stestsuite_rootfs_opendir = {
-       .name = "testsuite_rootfs_opendir",
+static DEFINE_TEST(testsuite_rootfs_opendir,
        .description = "test if rootfs works - opendir()",
-       .func = testsuite_rootfs_opendir,
        .config = {
                [TC_ROOTFS] = TESTSUITE_ROOTFS "test-rootfs/",
        },
-       .need_spawn = true,
-};
+       .need_spawn = true);
 
 static const struct test *tests[] = {
        &stestsuite_uname,
index 8bb0fa7ab36cd66375af0d98aa8e3bdf9bb28a84..015120645326408756048876873133dbf7d73ad9 100644 (file)
@@ -101,10 +101,11 @@ int test_run(const struct test *t);
 #define ERR(fmt, ...) _LOG("ERR: ", fmt, ## __VA_ARGS__)
 
 /* Test definitions */
-#define DEFINE_TEST(_name) \
-       struct test s_name = { \
+#define DEFINE_TEST(_name, ...) \
+       const struct test s##_name = { \
                .name = #_name, \
                .func = _name, \
+               ## __VA_ARGS__ \
        }
 
 #define TESTSUITE_MAIN(_tests) \