]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: fix assertion failure with CONFIG_UNIX_DIAG disabled
authorLuca Boccassi <luca.boccassi@gmail.com>
Wed, 14 May 2025 19:02:34 +0000 (20:02 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Wed, 14 May 2025 20:24:48 +0000 (21:24 +0100)
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
src/test/test-socket-netlink.c

index 92138ec556ab44500d2f464e003ccd0d03ac4b6a..274719c29630555fc641d4eab7a10dd4329a09f9 100644 (file)
@@ -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);
index 45144a16ea2dfd58fbe01b44af352f438bdd9966..c2a92a754414702de791ba830729274a1527c139 100644 (file)
@@ -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));