mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 08:25:20 +09:00
test: update to use the new ASSERT_OK() macro and friends
This commit is contained in:
@@ -25,22 +25,22 @@ int main(int argc, char *argv[]) {
|
||||
ASSERT_OK(get_testdata_dir("units/", &unit_dir));
|
||||
ASSERT_OK(setenv_unit_path(unit_dir));
|
||||
|
||||
assert_se(runtime_dir = setup_fake_runtime_dir());
|
||||
ASSERT_NOT_NULL(runtime_dir = setup_fake_runtime_dir());
|
||||
|
||||
assert_se(manager_new(RUNTIME_SCOPE_USER, MANAGER_TEST_RUN_BASIC, &m) >= 0);
|
||||
assert_se(manager_startup(m, NULL, NULL, NULL) >= 0);
|
||||
ASSERT_OK(manager_new(RUNTIME_SCOPE_USER, MANAGER_TEST_RUN_BASIC, &m));
|
||||
ASSERT_OK(manager_startup(m, NULL, NULL, NULL));
|
||||
|
||||
assert_se(a = unit_new(m, sizeof(Service)));
|
||||
assert_se(unit_add_name(a, "a.service") >= 0);
|
||||
assert_se(set_isempty(a->pids));
|
||||
ASSERT_NOT_NULL(a = unit_new(m, sizeof(Service)));
|
||||
ASSERT_OK(unit_add_name(a, "a.service"));
|
||||
ASSERT_TRUE(set_isempty(a->pids));
|
||||
|
||||
assert_se(b = unit_new(m, sizeof(Service)));
|
||||
assert_se(unit_add_name(b, "b.service") >= 0);
|
||||
assert_se(set_isempty(b->pids));
|
||||
ASSERT_NOT_NULL(b = unit_new(m, sizeof(Service)));
|
||||
ASSERT_OK(unit_add_name(b, "b.service"));
|
||||
ASSERT_TRUE(set_isempty(b->pids));
|
||||
|
||||
assert_se(c = unit_new(m, sizeof(Service)));
|
||||
assert_se(unit_add_name(c, "c.service") >= 0);
|
||||
assert_se(set_isempty(c->pids));
|
||||
ASSERT_NOT_NULL(c = unit_new(m, sizeof(Service)));
|
||||
ASSERT_OK(unit_add_name(c, "c.service"));
|
||||
ASSERT_TRUE(set_isempty(c->pids));
|
||||
|
||||
/* Fork off a child so that we have a PID to watch */
|
||||
_cleanup_(sigkill_waitp) pid_t pid = 0;
|
||||
@@ -51,46 +51,46 @@ int main(int argc, char *argv[]) {
|
||||
_exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
assert_se(pid >= 0);
|
||||
ASSERT_OK(pid);
|
||||
|
||||
assert_se(hashmap_isempty(m->watch_pids));
|
||||
ASSERT_TRUE(hashmap_isempty(m->watch_pids));
|
||||
ASSERT_NULL(manager_get_unit_by_pid(m, pid));
|
||||
|
||||
assert_se(unit_watch_pid(a, pid, false) >= 0);
|
||||
assert_se(manager_get_unit_by_pid(m, pid) == a);
|
||||
ASSERT_OK(unit_watch_pid(a, pid, false));
|
||||
ASSERT_PTR_EQ(manager_get_unit_by_pid(m, pid), a);
|
||||
|
||||
assert_se(unit_watch_pid(a, pid, false) >= 0);
|
||||
assert_se(manager_get_unit_by_pid(m, pid) == a);
|
||||
ASSERT_OK(unit_watch_pid(a, pid, false));
|
||||
ASSERT_PTR_EQ(manager_get_unit_by_pid(m, pid), a);
|
||||
|
||||
assert_se(unit_watch_pid(b, pid, false) >= 0);
|
||||
ASSERT_OK(unit_watch_pid(b, pid, false));
|
||||
u = manager_get_unit_by_pid(m, pid);
|
||||
assert_se(u == a || u == b);
|
||||
ASSERT_TRUE(u == a || u == b);
|
||||
|
||||
assert_se(unit_watch_pid(b, pid, false) >= 0);
|
||||
ASSERT_OK(unit_watch_pid(b, pid, false));
|
||||
u = manager_get_unit_by_pid(m, pid);
|
||||
assert_se(u == a || u == b);
|
||||
ASSERT_TRUE(u == a || u == b);
|
||||
|
||||
assert_se(unit_watch_pid(c, pid, false) >= 0);
|
||||
ASSERT_OK(unit_watch_pid(c, pid, false));
|
||||
u = manager_get_unit_by_pid(m, pid);
|
||||
assert_se(u == a || u == b || u == c);
|
||||
ASSERT_TRUE(u == a || u == b || u == c);
|
||||
|
||||
assert_se(unit_watch_pid(c, pid, false) >= 0);
|
||||
ASSERT_OK(unit_watch_pid(c, pid, false));
|
||||
u = manager_get_unit_by_pid(m, pid);
|
||||
assert_se(u == a || u == b || u == c);
|
||||
ASSERT_TRUE(u == a || u == b || u == c);
|
||||
|
||||
unit_unwatch_pid(b, pid);
|
||||
u = manager_get_unit_by_pid(m, pid);
|
||||
assert_se(u == a || u == c);
|
||||
ASSERT_TRUE(u == a || u == c);
|
||||
|
||||
unit_unwatch_pid(b, pid);
|
||||
u = manager_get_unit_by_pid(m, pid);
|
||||
assert_se(u == a || u == c);
|
||||
ASSERT_TRUE(u == a || u == c);
|
||||
|
||||
unit_unwatch_pid(a, pid);
|
||||
assert_se(manager_get_unit_by_pid(m, pid) == c);
|
||||
ASSERT_PTR_EQ(manager_get_unit_by_pid(m, pid), c);
|
||||
|
||||
unit_unwatch_pid(a, pid);
|
||||
assert_se(manager_get_unit_by_pid(m, pid) == c);
|
||||
ASSERT_PTR_EQ(manager_get_unit_by_pid(m, pid), c);
|
||||
|
||||
unit_unwatch_pid(c, pid);
|
||||
ASSERT_NULL(manager_get_unit_by_pid(m, pid));
|
||||
|
||||
Reference in New Issue
Block a user