lldp/tests: try workaround failure with ioctl(TUNSETIFF)

On copr build, it seems possible that the ioctl fails with

  ERROR: src/core/devices/tests/test-lldp - Bail out! NetworkManager:ERROR:src/core/devices/tests/test-lldp.c:823:_test_recv_fixture_setup: assertion failed (errno == 0): (1 == 0)

(1 is EPERM). Unclear why this happens. But as it only affects the
test setup, retry a few times.
This commit is contained in:
Thomas Haller 2021-02-11 16:02:12 +01:00
parent a21fdd4237
commit 5ca018c0db
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -812,14 +812,21 @@ _test_recv_fixture_setup(TestRecvFixture *fixture, gconstpointer user_data)
link = nmtstp_assert_wait_for_link(NM_PLATFORM_GET, TEST_IFNAME, NM_LINK_TYPE_TUN, 0);
} else {
int s;
struct ifreq ifr = {};
struct ifreq ifr;
int r;
int try_cnt = 0;
again:
memset(&ifr, 0, sizeof(ifr));
ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
nm_utils_ifname_cpy(ifr.ifr_name, TEST_IFNAME);
r = ioctl(fd, TUNSETIFF, &ifr);
if (r != 0) {
if (errno == EPERM && try_cnt++ < 10) {
g_usleep(2);
goto again;
}
g_assert_cmpint(errno, ==, 0);
g_assert_cmpint(r, ==, 0);
}