From 741444797fbfb3436cf3ced2e1cffaaa21c574d4 Mon Sep 17 00:00:00 2001 From: Yaping Li <202858510+YapingLi04@users.noreply.github.com> Date: Tue, 22 Jul 2025 17:30:35 -0700 Subject: [PATCH] test-unit-serialize.c: Migrate to new assertion macros We recently added a new set of assertion macros such as ASSERT_GE, ASSERT_OK, ASSERT_EQ, ... which show not only the expression that failed but also the values of the arguments of the expression. Let's use them. --- src/test/test-unit-serialize.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/test-unit-serialize.c b/src/test/test-unit-serialize.c index 60cc82373d..752698e8dc 100644 --- a/src/test/test-unit-serialize.c +++ b/src/test/test-unit-serialize.c @@ -18,11 +18,11 @@ static void test_deserialize_exec_command_one(Manager *m, const char *key, const _cleanup_(unit_freep) Unit *u = NULL; int r; - assert_se(unit_new_for_name(m, sizeof(Service), "test.service", &u) >= 0); + ASSERT_OK(unit_new_for_name(m, sizeof(Service), "test.service", &u)); r = service_deserialize_exec_command(u, key, line); log_debug("[%s] → %d (expected: %d)", line, r, expected); - assert_se(r == expected); + ASSERT_EQ(r, expected); /* Note that the command doesn't match any command in the empty list of commands in 's', so it is * always rejected with "Current command vanished from the unit file", and we don't leak anything. */ @@ -38,7 +38,7 @@ TEST(deserialize_exec_command) { return; } - assert_se(r >= 0); + ASSERT_OK(r); test_deserialize_exec_command_one(m, "main-command", EXEC_START_ABSOLUTE, 0); test_deserialize_exec_command_one(m, "main-command", EXEC_START_RELATIVE, 0); @@ -57,7 +57,7 @@ static int intro(void) { if (enter_cgroup_subroot(NULL) == -ENOMEDIUM) return log_tests_skipped("cgroupfs not available"); - assert_se(runtime_dir = setup_fake_runtime_dir()); + ASSERT_NOT_NULL(runtime_dir = setup_fake_runtime_dir()); return EXIT_SUCCESS; }