From c5d81989bc09cf735e3d7bd4e74381b4fe65ffad Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Tue, 7 Feb 2012 10:46:46 -0200 Subject: [PATCH] testsuite: macronify test definitions --- testsuite/test-alias.c | 7 ++----- testsuite/test-init.c | 21 ++++++--------------- testsuite/test-loaded.c | 7 ++----- testsuite/test-modinfo.c | 7 ++----- testsuite/test-new-module.c | 15 ++++----------- testsuite/test-testsuite.c | 35 ++++++++++------------------------- testsuite/testsuite.h | 5 +++-- 7 files changed, 29 insertions(+), 68 deletions(-) diff --git a/testsuite/test-alias.c b/testsuite/test-alias.c index 2e84e6b3..567d6762 100644 --- a/testsuite/test-alias.c +++ b/testsuite/test-alias.c @@ -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, diff --git a/testsuite/test-init.c b/testsuite/test-init.c index d6e1e5c8..c807a16b 100644 --- a/testsuite/test-init.c +++ b/testsuite/test-init.c @@ -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, diff --git a/testsuite/test-loaded.c b/testsuite/test-loaded.c index cfeb1b49..81c9e5ae 100644 --- a/testsuite/test-loaded.c +++ b/testsuite/test-loaded.c @@ -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, diff --git a/testsuite/test-modinfo.c b/testsuite/test-modinfo.c index 3047d269..007cc0a3 100644 --- a/testsuite/test-modinfo.c +++ b/testsuite/test-modinfo.c @@ -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, diff --git a/testsuite/test-new-module.c b/testsuite/test-new-module.c index 117d9788..9a0cc378 100644 --- a/testsuite/test-new-module.c +++ b/testsuite/test-new-module.c @@ -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, diff --git a/testsuite/test-testsuite.c b/testsuite/test-testsuite.c index 6967b748..1c128305 100644 --- a/testsuite/test-testsuite.c +++ b/testsuite/test-testsuite.c @@ -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, diff --git a/testsuite/testsuite.h b/testsuite/testsuite.h index 8bb0fa7a..01512064 100644 --- a/testsuite/testsuite.h +++ b/testsuite/testsuite.h @@ -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) \ -- 2.47.2