Skip to content

Commit f680f27

Browse files
committed
tests: add and use _nltst_skip_eopnotsupp() helper
1 parent 3cc413f commit f680f27

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

tests/cksuite-all-netns.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,7 @@ START_TEST(test_create_iface)
273273
}
274274

275275
r = rtnl_link_add(sk, link, NLM_F_CREATE);
276-
if (r == -NLE_OPNOTSUPP) {
277-
/* Hm, no kernel module? Skip the test. */
276+
if (_nltst_skip_eopnotsupp(r)) {
278277
_nltst_assert_link_not_exists(IFNAME);
279278
IFNAME = NULL;
280279
return;

tests/cksuite-route-nh.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,10 +1054,8 @@ START_TEST(test_kernel_roundtrip_encap_ila)
10541054
ck_assert_int_eq(rtnl_nh_set_oif(nh, (uint32_t)ifindex_dummy), 0);
10551055
ck_assert_int_eq(rtnl_nh_set_family(nh, AF_INET6), 0);
10561056
ret = rtnl_nh_add(sk, nh, NLM_F_CREATE);
1057-
if (ret == -NLE_OPNOTSUPP) {
1058-
/* ila module is not loaded - skipping */
1057+
if (_nltst_skip_eopnotsupp(ret))
10591058
return;
1060-
}
10611059
ck_assert_int_eq(ret, 0);
10621060

10631061
ck_assert_int_eq(rtnl_nh_alloc_cache(sk, AF_UNSPEC, &cache), 0);

tests/nl-test-util.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,17 @@ bool _nltst_skip_no_iproute2(const char *msg)
838838

839839
/*****************************************************************************/
840840

841+
bool _nltst_skip_eopnotsupp(int err)
842+
{
843+
if (err != -NLE_OPNOTSUPP)
844+
return false;
845+
846+
printf("skip test after operation failed with NLE_OPNOTSUPP. This indicates missing kernel support");
847+
return true;
848+
}
849+
850+
/*****************************************************************************/
851+
841852
void _nltst_add_dummy_and_up(struct nl_sock *sk, const char *ifname,
842853
int *out_ifindex)
843854
{

tests/nl-test-util.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,10 @@ bool _nltst_skip_no_iproute2(const char *msg);
449449

450450
/*****************************************************************************/
451451

452+
bool _nltst_skip_eopnotsupp(int err);
453+
454+
/*****************************************************************************/
455+
452456
typedef struct {
453457
int addr_family;
454458
int ifindex;

0 commit comments

Comments
 (0)