testsuite: macronify test definitions
diff --git a/testsuite/test-alias.c b/testsuite/test-alias.c
index 2e84e6b..567d676 100644
--- a/testsuite/test-alias.c
+++ b/testsuite/test-alias.c
@@ -56,18 +56,15 @@
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 d6e1e5c..c807a16 100644
--- a/testsuite/test-init.c
+++ b/testsuite/test-init.c
@@ -38,11 +38,8 @@
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 @@
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 @@
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 cfeb1b4..81c9e5a 100644
--- a/testsuite/test-loaded.c
+++ b/testsuite/test-loaded.c
@@ -77,18 +77,15 @@
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 3047d26..007cc0a 100644
--- a/testsuite/test-modinfo.c
+++ b/testsuite/test-modinfo.c
@@ -38,17 +38,14 @@
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 117d978..9a0cc37 100644
--- a/testsuite/test-new-module.c
+++ b/testsuite/test-new-module.c
@@ -59,19 +59,15 @@
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 @@
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 6967b74..1c12830 100644
--- a/testsuite/test-testsuite.c
+++ b/testsuite/test-testsuite.c
@@ -48,15 +48,12 @@
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 @@
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 @@
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 @@
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 @@
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 8bb0fa7..0151206 100644
--- a/testsuite/testsuite.h
+++ b/testsuite/testsuite.h
@@ -101,10 +101,11 @@
#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) \