From 55c5c57d1ef3a8d403a8e84fcbf56bdd18e97f4a Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 14 Jan 2021 18:22:15 +0100 Subject: [PATCH] devices/tests: improve assert for ioctl() in _test_recv_fixture_setup() This assert sometimes fails during copr builds. But the way the assert was, it was hard to see what the actual problem was. Restructure the assert (again) to get the errno in the test logs. --- src/devices/tests/test-lldp.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/devices/tests/test-lldp.c b/src/devices/tests/test-lldp.c index 7762ce93d7..04c3b5b6fe 100644 --- a/src/devices/tests/test-lldp.c +++ b/src/devices/tests/test-lldp.c @@ -819,13 +819,22 @@ _test_recv_fixture_setup(TestRecvFixture *fixture, gconstpointer user_data) nm_utils_ifname_cpy(ifr.ifr_name, TEST_IFNAME); r = ioctl(fd, TUNSETIFF, &ifr); - g_assert_cmpint(r, >=, 0); + if (r != 0) { + g_assert_cmpint(errno, ==, 0); + g_assert_cmpint(r, ==, 0); + } /* Bring the interface up */ s = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0); g_assert(s >= 0); + ifr.ifr_flags |= IFF_UP; - g_assert(ioctl(s, SIOCSIFFLAGS, &ifr) >= 0); + r = ioctl(s, SIOCSIFFLAGS, &ifr); + if (r != 0) { + g_assert_cmpint(errno, ==, 0); + g_assert_cmpint(r, ==, 0); + } + nm_close(s); link = nmtstp_assert_wait_for_link(NM_PLATFORM_GET, TEST_IFNAME, NM_LINK_TYPE_TUN, 100);