test-watch-pid: move required test conditions to intro()

Follow-up for 7bcd76513a.
This commit is contained in:
Yu Watanabe
2025-03-27 03:57:02 +09:00
parent 3d9f3420b5
commit 017f9bc1d7
+10 -11
View 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;
}