From 74acb358c54ea2d5006e5f1bd1448e7340e525e0 Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Wed, 14 May 2025 20:02:34 +0100 Subject: [PATCH] test: fix assertion failure with CONFIG_UNIX_DIAG disabled On OBS the build VM is heavily locked down, with network disabled in various ways in the custom kernel, to isolate the build, including disabling CONFIG_UNIX_DIAG. [ 456s] /* test_af_unix_get_qlen */ [ 456s] src/test/test-socket-netlink.c:393: Assertion failed: Expected "af_unix_get_qlen(unix_fd, &q)" to succeed, but got error: No such file or directory [ 454s] /* test_sock_diag_unix */ [ 454s] src/libsystemd/sd-netlink/test-netlink.c:727: Assertion failed: Expected "sd_netlink_call(nl, message, 0, &reply)" to succeed, but got error: No such file or directory Follow-up for 89e546e927b8d1fb6b7d44d689586f949109f144 Follow-up for 4a3bf440f26c0577808c16da84a57f731c48eaeb --- src/libsystemd/sd-netlink/test-netlink.c | 6 +++++- src/test/test-socket-netlink.c | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/libsystemd/sd-netlink/test-netlink.c b/src/libsystemd/sd-netlink/test-netlink.c index 92138ec556a..274719c2963 100644 --- a/src/libsystemd/sd-netlink/test-netlink.c +++ b/src/libsystemd/sd-netlink/test-netlink.c @@ -705,6 +705,7 @@ TEST(rtnl_set_link_name) { TEST(sock_diag_unix) { _cleanup_(sd_netlink_unrefp) sd_netlink *nl = NULL; + int r; ASSERT_OK(sd_sock_diag_socket_open(&nl)); @@ -724,7 +725,10 @@ TEST(sock_diag_unix) { ASSERT_OK(sd_sock_diag_message_new_unix(nl, &message, st.st_ino, cookie, UDIAG_SHOW_RQLEN)); _cleanup_(sd_netlink_message_unrefp) sd_netlink_message *reply = NULL; - ASSERT_OK(sd_netlink_call(nl, message, /* usec= */ 0, &reply)); + r = sd_netlink_call(nl, message, /* usec= */ 0, &reply); + if (r == -ENOENT) + return (void) log_tests_skipped("CONFIG_UNIX_DIAG disabled"); + ASSERT_OK(r); } DEFINE_TEST_MAIN(LOG_DEBUG); diff --git a/src/test/test-socket-netlink.c b/src/test/test-socket-netlink.c index 45144a16ea2..c2a92a75441 100644 --- a/src/test/test-socket-netlink.c +++ b/src/test/test-socket-netlink.c @@ -385,12 +385,16 @@ TEST(netns_get_nsid) { } TEST(af_unix_get_qlen) { + int r; _cleanup_close_ int unix_fd = ASSERT_FD(socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0)); ASSERT_OK(socket_autobind(unix_fd, /* ret_name= */ NULL)); ASSERT_OK_ERRNO(listen(unix_fd, 123)); uint32_t q; - ASSERT_OK(af_unix_get_qlen(unix_fd, &q)); + r = af_unix_get_qlen(unix_fd, &q); + if (r == -ENOENT) + return (void) log_tests_skipped("CONFIG_UNIX_DIAG disabled"); + ASSERT_OK(r); ASSERT_EQ(q, 0U); _cleanup_close_ int conn_fd = ASSERT_FD(socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0)); -- 2.47.3