]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-watch-pid: move required test conditions to intro()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 26 Mar 2025 18:56:46 +0000 (03:56 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 26 Mar 2025 18:57:02 +0000 (03:57 +0900)
Follow-up for 7bcd76513a61f8f16f2cc9b291895779c7c367fe.

src/test/test-watch-pid.c

index 17dce05678540d2f629d089a6d85ab73d9326a8d..2769377c7f405ae6dd9a9655a8884a1c390f66ba 100644 (file)
@@ -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;
 }