diff options
author | Jan Janssen <medhefgo@web.de> | 2021-11-24 12:00:02 +0100 |
---|---|---|
committer | Jan Janssen <medhefgo@web.de> | 2021-11-25 15:03:06 +0100 |
commit | 4f7452a8eb7a946efea927fae017d4d661097833 (patch) | |
tree | 413778cc0fb08fbbed0890130b5ba66c90581e61 /src/test/test-exec-util.c | |
parent | 4d5ad9d951299c905453ac8e3769dc82b0a09fb4 (diff) | |
download | systemd-4f7452a8eb7a946efea927fae017d4d661097833.tar.gz |
test: Use TEST macro
This converts to TEST macro where it is trivial.
Some additional notable changes:
- simplify HAVE_LIBIDN #ifdef in test-dns-domain.c
- use saved_argc/saved_argv in test-copy.c, test-path-util.c,
test-tmpfiles.c and test-unit-file.c
Diffstat (limited to 'src/test/test-exec-util.c')
-rw-r--r-- | src/test/test-exec-util.c | 40 |
1 files changed, 13 insertions, 27 deletions
diff --git a/src/test/test-exec-util.c b/src/test/test-exec-util.c index ae740218b2..94ef6e8bbf 100644 --- a/src/test/test-exec-util.c +++ b/src/test/test-exec-util.c @@ -53,7 +53,7 @@ static const gather_stdout_callback_t ignore_stdout[] = { ignore_stdout_func3, }; -static void test_execute_directory(bool gather_stdout) { +static void test_execute_directory_one(bool gather_stdout) { char template_lo[] = "/tmp/test-exec-util.lo.XXXXXXX"; char template_hi[] = "/tmp/test-exec-util.hi.XXXXXXX"; const char * dirs[] = {template_hi, template_lo, NULL}; @@ -135,7 +135,12 @@ static void test_execute_directory(bool gather_stdout) { (void) rm_rf(template_hi, REMOVE_ROOT|REMOVE_PHYSICAL); } -static void test_execution_order(void) { +TEST(execute_directory) { + test_execute_directory_one(true); + test_execute_directory_one(false); +} + +TEST(execution_order) { char template_lo[] = "/tmp/test-exec-util-lo.XXXXXXX"; char template_hi[] = "/tmp/test-exec-util-hi.XXXXXXX"; const char *dirs[] = {template_hi, template_lo, NULL}; @@ -237,7 +242,7 @@ const gather_stdout_callback_t gather_stdout[] = { gather_stdout_three, }; -static void test_stdout_gathering(void) { +TEST(stdout_gathering) { char template[] = "/tmp/test-exec-util.XXXXXXX"; const char *dirs[] = {template, NULL}; const char *name, *name2, *name3; @@ -250,8 +255,6 @@ static void test_stdout_gathering(void) { assert_se(mkdtemp(template)); - log_info("/* %s */", __func__); - /* write files */ name = strjoina(template, "/10-foo"); name2 = strjoina(template, "/20-bar"); @@ -282,7 +285,7 @@ static void test_stdout_gathering(void) { assert_se(streq(output, "a\nb\nc\nd\n")); } -static void test_environment_gathering(void) { +TEST(environment_gathering) { char template[] = "/tmp/test-exec-util.XXXXXXX", **p; const char *dirs[] = {template, NULL}; const char *name, *name2, *name3, *old; @@ -295,8 +298,6 @@ static void test_environment_gathering(void) { assert_se(mkdtemp(template)); - log_info("/* %s */", __func__); - /* write files */ name = strjoina(template, "/10-foo"); name2 = strjoina(template, "/20-bar"); @@ -375,7 +376,7 @@ static void test_environment_gathering(void) { assert_se(set_unset_env("PATH", old, true) == 0); } -static void test_error_catching(void) { +TEST(error_catching) { char template[] = "/tmp/test-exec-util.XXXXXXX"; const char *dirs[] = {template, NULL}; const char *name, *name2, *name3; @@ -383,8 +384,6 @@ static void test_error_catching(void) { assert_se(mkdtemp(template)); - log_info("/* %s */", __func__); - /* write files */ name = strjoina(template, "/10-foo"); name2 = strjoina(template, "/20-bar"); @@ -413,7 +412,7 @@ static void test_error_catching(void) { assert_se(r == 42); } -static void test_exec_command_flags_from_strv(void) { +TEST(exec_command_flags_from_strv) { ExecCommandFlags flags = 0; char **valid_strv = STRV_MAKE("no-env-expand", "no-setuid", "ignore-failure"); char **invalid_strv = STRV_MAKE("no-env-expand", "no-setuid", "nonexistent-option", "ignore-failure"); @@ -433,7 +432,7 @@ static void test_exec_command_flags_from_strv(void) { assert_se(r == -EINVAL); } -static void test_exec_command_flags_to_strv(void) { +TEST(exec_command_flags_to_strv) { _cleanup_strv_free_ char **opts = NULL, **empty_opts = NULL, **invalid_opts = NULL; ExecCommandFlags flags = 0; int r; @@ -457,17 +456,4 @@ static void test_exec_command_flags_to_strv(void) { assert_se(r == -EINVAL); } -int main(int argc, char *argv[]) { - test_setup_logging(LOG_DEBUG); - - test_execute_directory(true); - test_execute_directory(false); - test_execution_order(); - test_stdout_gathering(); - test_environment_gathering(); - test_error_catching(); - test_exec_command_flags_from_strv(); - test_exec_command_flags_to_strv(); - - return 0; -} +DEFINE_TEST_MAIN(LOG_DEBUG); |