Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests: nl_netdev: add a trivial Netlink netdev test

Add a trivial test using YNL.

$ ./tools/testing/selftests/net/nl_netdev.py
KTAP version 1
1..2
ok 1 nl_netdev.empty_check
ok 2 nl_netdev.lo_check

Instantiate the family once, it takes longer than the test itself.

Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Jakub Kicinski and committed by
David S. Miller
796c8c7f b86761ff

+25
+1
tools/testing/selftests/net/Makefile
··· 34 34 TEST_PROGS += cmsg_so_mark.sh 35 35 TEST_PROGS += cmsg_time.sh cmsg_ipv6.sh 36 36 TEST_PROGS += netns-name.sh 37 + TEST_PROGS += nl_netdev.py 37 38 TEST_PROGS += srv6_end_dt46_l3vpn_test.sh 38 39 TEST_PROGS += srv6_end_dt4_l3vpn_test.sh 39 40 TEST_PROGS += srv6_end_dt6_l3vpn_test.sh
+24
tools/testing/selftests/net/nl_netdev.py
··· 1 + #!/usr/bin/env python3 2 + # SPDX-License-Identifier: GPL-2.0 3 + 4 + from lib.py import ksft_run, ksft_pr, ksft_eq, ksft_ge, NetdevFamily 5 + 6 + 7 + def empty_check(nf) -> None: 8 + devs = nf.dev_get({}, dump=True) 9 + ksft_ge(len(devs), 1) 10 + 11 + 12 + def lo_check(nf) -> None: 13 + lo_info = nf.dev_get({"ifindex": 1}) 14 + ksft_eq(len(lo_info['xdp-features']), 0) 15 + ksft_eq(len(lo_info['xdp-rx-metadata-features']), 0) 16 + 17 + 18 + def main() -> None: 19 + nf = NetdevFamily() 20 + ksft_run([empty_check, lo_check], args=(nf, )) 21 + 22 + 23 + if __name__ == "__main__": 24 + main()