]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-unit-serialize.c: Migrate to new assertion macros
authorYaping Li <202858510+YapingLi04@users.noreply.github.com>
Wed, 23 Jul 2025 00:30:35 +0000 (17:30 -0700)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 23 Jul 2025 22:27:58 +0000 (07:27 +0900)
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

index 60cc82373d67ed6196306b295ec37903c1bba814..752698e8dc4098615b0565d29856f99cc4563ade 100644 (file)
@@ -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;
 }