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 89e546e927
Follow-up for 4a3bf440f2
This commit is contained in:
Luca Boccassi
2025-05-14 21:24:48 +01:00
parent 9ebbb785b0
commit 74acb358c5
2 changed files with 10 additions and 2 deletions
+5 -1
View 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);
+5 -1
View 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));