summaryrefslogtreecommitdiffstats
path: root/src/test/test-process-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2022-02-01 12:06:59 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2022-02-02 03:00:16 +0100
commit99839c7ebd4b83a5b0d5982d669cfe10d1252e1f (patch)
tree233ee8eda2a42e35af272157afddbc5c15fa3a4d /src/test/test-process-util.c
parentnetwork: dhcp-server: make empty string to DNS= or friends clear previously s... (diff)
downloadsystemd-99839c7ebd4b83a5b0d5982d669cfe10d1252e1f.tar.xz
systemd-99839c7ebd4b83a5b0d5982d669cfe10d1252e1f.zip
tests: rework test macros to not take code as parameters
C macros are nasty. We use them, but we try to be conservative with them. In particular passing literal, complex code blocks as argument is icky, because of "," handling of C, and also because it's quite a challange for most code highlighters and similar. Hence, let's avoid that. Using macros for genreating functions is OK but if so, the parameters should be simple words, not full code blocks. hence, rework DEFINE_CUSTOM_TEST_MAIN() to take a function name instead of code block as argument. As side-effect this also fixes a bunch of cases where we might end up returning a negative value from main(). Some uses of DEFINE_CUSTOM_TEST_MAIN() inserted local variables into the main() functions, these are replaced by static variables, and their destructors by the static destructor logic. This doesn't fix any bugs or so, it's just supposed to make the code easier to work with and improve it easthetically. Or in other words: let's use macros where it really makes sense, but let's not go overboard with it. (And yes, FOREACH_DIRENT() is another one of those macros that take code, and I dislike that too and regret I ever added that.)
Diffstat (limited to 'src/test/test-process-util.c')
-rw-r--r--src/test/test-process-util.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/test/test-process-util.c b/src/test/test-process-util.c
index 06a640b1cc..8661934929 100644
--- a/src/test/test-process-util.c
+++ b/src/test/test-process-util.c
@@ -895,4 +895,9 @@ TEST(set_oom_score_adjust) {
assert_se(b == a);
}
-DEFINE_CUSTOM_TEST_MAIN(LOG_INFO, log_show_color(true), /* no outro */);
+static int intro(void) {
+ log_show_color(true);
+ return EXIT_SUCCESS;
+}
+
+DEFINE_CUSTOM_TEST_MAIN(LOG_INFO, intro, test_nop);