From: Zbigniew Jędrzejewski-Szmek Date: Thu, 3 Jul 2025 15:22:45 +0000 (+0200) Subject: tests: use log_tests_skipped more, use shorter form X-Git-Tag: v258-rc1~173^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eb5b854150ec1d7b5613cc2ae470239c58345a68;p=thirdparty%2Fsystemd.git tests: use log_tests_skipped more, use shorter form Also change order to handle errors before 0 in one case. --- diff --git a/src/test/test-cgroup.c b/src/test/test-cgroup.c index 31f2d87800a..80c332efacf 100644 --- a/src/test/test-cgroup.c +++ b/src/test/test-cgroup.c @@ -44,10 +44,8 @@ TEST(cg_create) { int r; r = cg_unified_cached(false); - if (IN_SET(r, -ENOMEDIUM, -ENOENT)) { - log_tests_skipped("cgroupfs is not mounted"); - return; - } + if (IN_SET(r, -ENOMEDIUM, -ENOENT)) + return (void) log_tests_skipped("cgroupfs is not mounted"); ASSERT_OK(r); _cleanup_free_ char *here = NULL; @@ -122,14 +120,10 @@ TEST(id) { int r; r = cg_all_unified(); - if (r == 0) { - log_tests_skipped("skipping cgroupid test, not running in unified mode"); - return; - } - if (IN_SET(r, -ENOMEDIUM, -ENOENT)) { - log_tests_skipped("cgroupfs is not mounted"); - return; - } + if (IN_SET(r, -ENOMEDIUM, -ENOENT)) + return (void) log_tests_skipped("cgroupfs is not mounted"); + if (r == 0) + return (void) log_tests_skipped("skipping cgroupid test, not running in unified mode"); ASSERT_OK_POSITIVE(r); fd = cg_path_open(SYSTEMD_CGROUP_CONTROLLER, "/"); diff --git a/src/test/test-fs-util.c b/src/test/test-fs-util.c index 32f7c3c6af7..723cc8d0a10 100644 --- a/src/test/test-fs-util.c +++ b/src/test/test-fs-util.c @@ -184,8 +184,7 @@ TEST(touch_file) { r = touch_file(a, false, test_mtime, test_uid, test_gid, 0640); if (r < 0) { assert_se(IN_SET(r, -EINVAL, -ENOSYS, -ENOTTY, -EPERM)); - log_tests_skipped_errno(errno, "touch_file() not possible"); - return; + return (void) log_tests_skipped_errno(errno, "touch_file() not possible"); } assert_se(lstat(a, &st) >= 0); diff --git a/src/test/test-mempress.c b/src/test/test-mempress.c index b33ba740c61..98db7f0e028 100644 --- a/src/test/test-mempress.c +++ b/src/test/test-mempress.c @@ -201,10 +201,8 @@ TEST(real_pressure) { pid_t pid; r = sd_bus_open_system(&bus); - if (r < 0) { - log_notice_errno(r, "Can't connect to system bus, skipping test: %m"); - return; - } + if (r < 0) + return (void) log_tests_skipped_errno(r, "can't connect to system bus"); assert_se(bus_wait_for_jobs_new(bus, &w) >= 0); @@ -218,10 +216,8 @@ TEST(real_pressure) { assert_se(sd_bus_message_append(m, "a(sa(sv))", 0) >= 0); r = sd_bus_call(bus, m, 0, &error, &reply); - if (r < 0) { - log_notice_errno(r, "Can't issue transient unit call, skipping test: %m"); - return; - } + if (r < 0) + return (void) log_tests_skipped_errno(r, "can't issue transient unit call"); assert_se(sd_bus_message_read(reply, "o", &object) >= 0); @@ -250,10 +246,8 @@ TEST(real_pressure) { }; r = sd_event_add_memory_pressure(e, &es, real_pressure_callback, &context); - if (r < 0) { - log_notice_errno(r, "Can't allocate memory pressure fd, skipping test: %m"); - return; - } + if (r < 0) + return (void) log_tests_skipped_errno(r, "can't allocate memory pressure fd"); assert_se(sd_event_source_set_description(es, "real pressure event source") >= 0); assert_se(sd_event_source_set_memory_pressure_type(es, "some") == 0); @@ -272,10 +266,8 @@ TEST(real_pressure) { assert_se(sd_bus_get_property_trivial(bus, "org.freedesktop.systemd1", uo, "org.freedesktop.systemd1.Scope", "MemoryCurrent", &error, 't', &mcurrent) >= 0); printf("current: %" PRIu64 "\n", mcurrent); - if (mcurrent == UINT64_MAX) { - log_notice_errno(r, "Memory accounting not available, skipping test: %m"); - return; - } + if (mcurrent == UINT64_MAX) + return (void) log_tests_skipped_errno(r, "memory accounting not available"); m = sd_bus_message_unref(m);