diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-11-08 16:37:15 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-11-11 14:55:57 +0100 |
commit | 5eecb1030ffd55296112a3308beca7beca5903b6 (patch) | |
tree | fdc668d8aafce998c03cfe82b4ab6a048e4461fb | |
parent | 8b139557febfc1c62c37214378a911d4f515aac5 (diff) | |
download | systemd-5eecb1030ffd55296112a3308beca7beca5903b6.tar.gz |
tests: make manager_skip_test() not a macro and move to tests.h
There is nothing magic in it.
-rw-r--r-- | src/shared/tests.h | 13 | ||||
-rw-r--r-- | src/test/test-engine.c | 2 | ||||
-rw-r--r-- | src/test/test-execute.c | 2 | ||||
-rw-r--r-- | src/test/test-helper.h | 14 | ||||
-rw-r--r-- | src/test/test-load-fragment.c | 4 | ||||
-rw-r--r-- | src/test/test-path.c | 2 | ||||
-rw-r--r-- | src/test/test-sched-prio.c | 2 | ||||
-rw-r--r-- | src/test/test-unit-name.c | 2 |
8 files changed, 22 insertions, 19 deletions
diff --git a/src/shared/tests.h b/src/shared/tests.h index 8416b107f3..72f6f63651 100644 --- a/src/shared/tests.h +++ b/src/shared/tests.h @@ -3,6 +3,19 @@ #include <stdbool.h> +#include "macro.h" + +static inline bool manager_errno_skip_test(int r) { + return IN_SET(abs(r), + EPERM, + EACCES, + EADDRINUSE, + EHOSTDOWN, + ENOENT, + ENOMEDIUM /* cannot determine cgroup */ + ); +} + char* setup_fake_runtime_dir(void); const char* get_testdata_dir(void); const char* get_catalog_dir(void); diff --git a/src/test/test-engine.c b/src/test/test-engine.c index 265152fb76..c292ad1c7c 100644 --- a/src/test/test-engine.c +++ b/src/test/test-engine.c @@ -30,7 +30,7 @@ int main(int argc, char *argv[]) { assert_se(set_unit_path(get_testdata_dir()) >= 0); assert_se(runtime_dir = setup_fake_runtime_dir()); r = manager_new(UNIT_FILE_USER, MANAGER_TEST_RUN_BASIC, &m); - if (MANAGER_SKIP_TEST(r)) + if (manager_errno_skip_test(r)) return log_tests_skipped_errno(r, "manager_new"); assert_se(r >= 0); assert_se(manager_startup(m, NULL, NULL) >= 0); diff --git a/src/test/test-execute.c b/src/test/test-execute.c index 92fb35fd87..57a4b1c282 100644 --- a/src/test/test-execute.c +++ b/src/test/test-execute.c @@ -781,7 +781,7 @@ static int run_tests(UnitFileScope scope, const test_entry tests[], char **patte assert_se(tests); r = manager_new(scope, MANAGER_TEST_RUN_BASIC, &m); - if (MANAGER_SKIP_TEST(r)) + if (manager_errno_skip_test(r)) return log_tests_skipped_errno(r, "manager_new"); assert_se(r >= 0); assert_se(manager_startup(m, NULL, NULL) >= 0); diff --git a/src/test/test-helper.h b/src/test/test-helper.h index 77af40d555..81e19ee207 100644 --- a/src/test/test-helper.h +++ b/src/test/test-helper.h @@ -5,9 +5,9 @@ Copyright © 2013 Holger Hans Peter Freyther ***/ -#include "sd-daemon.h" +#include <stdbool.h> -#include "macro.h" +#include "sd-daemon.h" #define TEST_REQ_RUNNING_SYSTEMD(x) \ if (sd_booted() > 0) { \ @@ -16,16 +16,6 @@ printf("systemd not booted skipping '%s'\n", #x); \ } -#define MANAGER_SKIP_TEST(r) \ - IN_SET(r, \ - -EPERM, \ - -EACCES, \ - -EADDRINUSE, \ - -EHOSTDOWN, \ - -ENOENT, \ - -ENOMEDIUM /* cannot determine cgroup */ \ - ) - int enter_cgroup_subroot(void); bool is_run_on_travis_ci(void); diff --git a/src/test/test-load-fragment.c b/src/test/test-load-fragment.c index 216f0e4d94..cb808bfce0 100644 --- a/src/test/test-load-fragment.c +++ b/src/test/test-load-fragment.c @@ -97,7 +97,7 @@ static void test_config_parse_exec(void) { _cleanup_(unit_freep) Unit *u = NULL; r = manager_new(UNIT_FILE_USER, MANAGER_TEST_RUN_MINIMAL, &m); - if (MANAGER_SKIP_TEST(r)) { + if (manager_errno_skip_test(r)) { log_notice_errno(r, "Skipping test: manager_new: %m"); return; } @@ -442,7 +442,7 @@ static void test_config_parse_log_extra_fields(void) { ExecContext c = {}; r = manager_new(UNIT_FILE_USER, MANAGER_TEST_RUN_MINIMAL, &m); - if (MANAGER_SKIP_TEST(r)) { + if (manager_errno_skip_test(r)) { log_notice_errno(r, "Skipping test: manager_new: %m"); return; } diff --git a/src/test/test-path.c b/src/test/test-path.c index 07a0e413ee..9157c6a13b 100644 --- a/src/test/test-path.c +++ b/src/test/test-path.c @@ -37,7 +37,7 @@ static int setup_test(Manager **m) { return log_tests_skipped("cgroupfs not available"); r = manager_new(UNIT_FILE_USER, MANAGER_TEST_RUN_BASIC, &tmp); - if (MANAGER_SKIP_TEST(r)) + if (manager_errno_skip_test(r)) return log_tests_skipped_errno(r, "manager_new"); assert_se(r >= 0); assert_se(manager_startup(tmp, NULL, NULL) >= 0); diff --git a/src/test/test-sched-prio.c b/src/test/test-sched-prio.c index 1aa178182b..d179ae21a6 100644 --- a/src/test/test-sched-prio.c +++ b/src/test/test-sched-prio.c @@ -29,7 +29,7 @@ int main(int argc, char *argv[]) { assert_se(set_unit_path(get_testdata_dir()) >= 0); assert_se(runtime_dir = setup_fake_runtime_dir()); r = manager_new(UNIT_FILE_USER, MANAGER_TEST_RUN_BASIC, &m); - if (MANAGER_SKIP_TEST(r)) + if (manager_errno_skip_test(r)) return log_tests_skipped_errno(r, "manager_new"); assert_se(r >= 0); assert_se(manager_startup(m, NULL, NULL) >= 0); diff --git a/src/test/test-unit-name.c b/src/test/test-unit-name.c index c9bbce0d2e..52c75406ae 100644 --- a/src/test/test-unit-name.c +++ b/src/test/test-unit-name.c @@ -209,7 +209,7 @@ static int test_unit_printf(void) { assert_se(get_shell(&shell) >= 0); r = manager_new(UNIT_FILE_USER, MANAGER_TEST_RUN_MINIMAL, &m); - if (MANAGER_SKIP_TEST(r)) + if (manager_errno_skip_test(r)) return log_tests_skipped_errno(r, "manager_new"); assert_se(r == 0); |