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

selftests: drv-net: xdp: use variants for qstat tests

Use just-added ksft variants for XDP qstat tests.

While at it correct the number of packets, we're sending
1000 packets now.

Reviewed-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Link: https://patch.msgid.link/20251120021024.2944527-5-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+14 -28
+14 -28
tools/testing/selftests/drivers/net/xdp.py
··· 12 12 from enum import Enum 13 13 14 14 from lib.py import ksft_run, ksft_exit, ksft_eq, ksft_ge, ksft_ne, ksft_pr 15 + from lib.py import KsftNamedVariant, ksft_variants 15 16 from lib.py import KsftFailEx, NetDrvEpEnv 16 17 from lib.py import EthtoolFamily, NetdevFamily, NlError 17 18 from lib.py import bkg, cmd, rand_port, wait_port_listen ··· 673 672 _validate_res(res, offset_lst, pkt_sz_lst) 674 673 675 674 676 - def _test_xdp_native_ifc_stats(cfg, act): 675 + @ksft_variants([ 676 + KsftNamedVariant("pass", XDPAction.PASS), 677 + KsftNamedVariant("drop", XDPAction.DROP), 678 + KsftNamedVariant("tx", XDPAction.TX), 679 + ]) 680 + def test_xdp_native_qstats(cfg, act): 681 + """ 682 + Send 1000 messages. Expect XDP action specified in @act. 683 + Make sure the packets were counted to interface level qstats 684 + (Rx, and Tx if act is TX). 685 + """ 686 + 677 687 cfg.require_cmd("socat") 678 688 679 689 bpf_info = BPFProgInfo("xdp_prog", "xdp_native.bpf.o", "xdp", 1500) ··· 745 733 ksft_ge(after['tx-packets'], before['tx-packets']) 746 734 747 735 748 - def test_xdp_native_qstats_pass(cfg): 749 - """ 750 - Send 2000 messages, expect XDP_PASS, make sure the packets were counted 751 - to interface level qstats (Rx). 752 - """ 753 - _test_xdp_native_ifc_stats(cfg, XDPAction.PASS) 754 - 755 - 756 - def test_xdp_native_qstats_drop(cfg): 757 - """ 758 - Send 2000 messages, expect XDP_DROP, make sure the packets were counted 759 - to interface level qstats (Rx). 760 - """ 761 - _test_xdp_native_ifc_stats(cfg, XDPAction.DROP) 762 - 763 - 764 - def test_xdp_native_qstats_tx(cfg): 765 - """ 766 - Send 2000 messages, expect XDP_TX, make sure the packets were counted 767 - to interface level qstats (Rx and Tx) 768 - """ 769 - _test_xdp_native_ifc_stats(cfg, XDPAction.TX) 770 - 771 - 772 736 def main(): 773 737 """ 774 738 Main function to execute the XDP tests. ··· 769 781 test_xdp_native_adjst_tail_shrnk_data, 770 782 test_xdp_native_adjst_head_grow_data, 771 783 test_xdp_native_adjst_head_shrnk_data, 772 - test_xdp_native_qstats_pass, 773 - test_xdp_native_qstats_drop, 774 - test_xdp_native_qstats_tx, 784 + test_xdp_native_qstats, 775 785 ], 776 786 args=(cfg,)) 777 787 ksft_exit()