:p
atchew
Login
From: Geliang Tang <tanggeliang@kylinos.cn> Add pm_nl_ctl. Use SYS_NOFAIL in _ss_search(). Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn> --- tools/testing/selftests/bpf/Makefile | 2 +- tools/testing/selftests/bpf/pm_nl_ctl.c | 1 + tools/testing/selftests/bpf/prog_tests/mptcp.c | 15 ++++----------- 3 files changed, 6 insertions(+), 12 deletions(-) create mode 120000 tools/testing/selftests/bpf/pm_nl_ctl.c diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile index XXXXXXX..XXXXXXX 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -XXX,XX +XXX,XX @@ TEST_GEN_PROGS_EXTENDED = test_sock_addr test_skb_cgroup_id_user \ flow_dissector_load test_flow_dissector test_tcp_check_syncookie_user \ test_lirc_mode2_user xdping test_cpp runqslower bench bpf_testmod.ko \ xskxceiver xdp_redirect_multi xdp_synproxy veristat xdp_hw_metadata \ - xdp_features bpf_test_no_cfi.ko + xdp_features bpf_test_no_cfi.ko pm_nl_ctl TEST_GEN_FILES += liburandom_read.so urandom_read sign-file uprobe_multi diff --git a/tools/testing/selftests/bpf/pm_nl_ctl.c b/tools/testing/selftests/bpf/pm_nl_ctl.c new file mode 120000 index XXXXXXX..XXXXXXX --- /dev/null +++ b/tools/testing/selftests/bpf/pm_nl_ctl.c @@ -0,0 +1 @@ +../net/mptcp/pm_nl_ctl.c \ No newline at end of file diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing/selftests/bpf/prog_tests/mptcp.c index XXXXXXX..XXXXXXX 100644 --- a/tools/testing/selftests/bpf/prog_tests/mptcp.c +++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c @@ -XXX,XX +XXX,XX @@ static int endpoint_init(char *flags) SYS(fail, "ip -net %s link set dev veth1 up", NS_TEST); SYS(fail, "ip -net %s addr add %s/24 dev veth2", NS_TEST, ADDR_2); SYS(fail, "ip -net %s link set dev veth2 up", NS_TEST); - SYS(fail, "ip -net %s mptcp endpoint add %s %s", NS_TEST, ADDR_2, flags); + if (SYS_NOFAIL("ip -net %s mptcp endpoint add %s %s", NS_TEST, ADDR_2, flags)) + SYS(fail, "ip netns exec %s ./pm_nl_ctl add %s flags %s", NS_TEST, ADDR_2, flags); return 0; fail: @@ -XXX,XX +XXX,XX @@ static int endpoint_init(char *flags) static int _ss_search(char *src, char *dst, char *port, char *keyword) { - char cmd[128]; - int n; - - n = snprintf(cmd, sizeof(cmd), - "ip netns exec %s ss -Menita src %s dst %s %s %d | grep -q '%s'", - NS_TEST, src, dst, port, PORT_1, keyword); - if (n < 0 || n >= sizeof(cmd)) - return -1; - - return system(cmd); + return SYS_NOFAIL("ip netns exec %s ss -Menita src %s dst %s %s %d | grep -q '%s'", + NS_TEST, src, dst, port, PORT_1, keyword); } static int ss_search(char *src, char *keyword) -- 2.43.0
From: Geliang Tang <tanggeliang@kylinos.cn> Skip the test with test__skip() for systems that do not support "ip mptcp", so that CI can also pass. Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn> --- tools/testing/selftests/bpf/prog_tests/mptcp.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing/selftests/bpf/prog_tests/mptcp.c index XXXXXXX..XXXXXXX 100644 --- a/tools/testing/selftests/bpf/prog_tests/mptcp.c +++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c @@ -XXX,XX +XXX,XX @@ static int endpoint_init(char *flags) SYS(fail, "ip -net %s link set dev veth1 up", NS_TEST); SYS(fail, "ip -net %s addr add %s/24 dev veth2", NS_TEST, ADDR_2); SYS(fail, "ip -net %s link set dev veth2 up", NS_TEST); - /* It would be better to use "ip -net %s mptcp endpoint add %s %s", - * but the BPF CI is using an old version of IPRoute (5.5.0). - */ - SYS(fail, "ip netns exec %s ./mptcp_pm_nl_ctl add %s flags %s", NS_TEST, ADDR_2, flags); + if (SYS_NOFAIL("ip -net %s mptcp endpoint add %s %s", NS_TEST, ADDR_2, flags)) { + /* "ip mptcp" not support, skip this test. */ + test__skip(); + goto fail; + } return 0; fail: @@ -XXX,XX +XXX,XX @@ static void test_subflow(void) if (!ASSERT_OK_PTR(nstoken, "create_netns: mptcp_subflow")) goto skel_destroy; - if (!ASSERT_OK(endpoint_init("subflow"), "endpoint_init")) + if (endpoint_init("subflow")) goto close_netns; run_subflow(skel->data->cc); -- 2.43.0