From 017f9bc1d77d5026c3c009c7246d6c743197a41e Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 27 Mar 2025 03:56:46 +0900 Subject: [PATCH] test-watch-pid: move required test conditions to intro() Follow-up for 7bcd76513a61f8f16f2cc9b291895779c7c367fe. --- src/test/test-watch-pid.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/test/test-watch-pid.c b/src/test/test-watch-pid.c index 17dce056785..2769377c7f4 100644 --- a/src/test/test-watch-pid.c +++ b/src/test/test-watch-pid.c @@ -7,17 +7,10 @@ #include "service.h" #include "tests.h" -TEST_RET(watch_pid) { +TEST(watch_pid) { _cleanup_(rm_rf_physical_and_freep) char *runtime_dir = NULL; _cleanup_(manager_freep) Manager *m = NULL; Unit *a, *b, *c, *u; - int r; - - if (getuid() != 0) - return log_tests_skipped("not root"); - r = enter_cgroup_subroot(NULL); - if (r < 0) - return log_tests_skipped("cgroupfs not available"); _cleanup_free_ char *unit_dir = NULL; ASSERT_OK(get_testdata_dir("units/", &unit_dir)); @@ -95,12 +88,18 @@ TEST_RET(watch_pid) { unit_unwatch_pid(c, pid); ASSERT_NULL(manager_get_unit_by_pid(m, pid)); - - return EXIT_SUCCESS; } static int intro(void) { - log_show_color(true); + int r; + + if (getuid() != 0) + return log_tests_skipped("not root"); + + r = enter_cgroup_subroot(NULL); + if (r < 0) + return log_tests_skipped_errno(r, "cgroupfs not available"); + return EXIT_SUCCESS; } -- 2.47.3