Re: [PATCH bpf-next v7 7/7] selftests/bpf: add tests for verdict skmsg to closed socket

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Oct 28, 2023 at 06:05 PM +08, Liu Jian wrote:
> Add four tests for verdict skmsg to closed socket in sockmap_basic.c.
>
> Signed-off-by: Liu Jian <liujian56@xxxxxxxxxx>
> ---
>  .../selftests/bpf/prog_tests/sockmap_basic.c  | 42 +++++++++++++++----
>  1 file changed, 34 insertions(+), 8 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c b/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c
> index 75107762a86e..4d49129cdd6b 100644
> --- a/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c
> +++ b/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c

[...]

> @@ -651,15 +669,23 @@ void test_sockmap_basic(void)
>  	if (test__start_subtest("sockmap skb_verdict msg_f_peek"))
>  		test_sockmap_skb_verdict_peek();
>  	if (test__start_subtest("sockmap msg_verdict"))
> -		test_sockmap_msg_verdict(false, false, false);
> +		test_sockmap_msg_verdict(false, false, false, false);
>  	if (test__start_subtest("sockmap msg_verdict ingress"))
> -		test_sockmap_msg_verdict(true, false, false);
> +		test_sockmap_msg_verdict(true, false, false, false);
>  	if (test__start_subtest("sockmap msg_verdict permanent"))
> -		test_sockmap_msg_verdict(false, true, false);
> +		test_sockmap_msg_verdict(false, true, false, false);
>  	if (test__start_subtest("sockmap msg_verdict ingress permanent"))
> -		test_sockmap_msg_verdict(true, true, false);
> +		test_sockmap_msg_verdict(true, true, false, false);
>  	if (test__start_subtest("sockmap msg_verdict permanent self"))
> -		test_sockmap_msg_verdict(false, true, true);
> +		test_sockmap_msg_verdict(false, true, true, false);
>  	if (test__start_subtest("sockmap msg_verdict ingress permanent self"))
> -		test_sockmap_msg_verdict(true, true, true);
> +		test_sockmap_msg_verdict(true, true, true, false);
> +	if (test__start_subtest("sockmap msg_verdict permanent shutdown"))
> +		test_sockmap_msg_verdict(false, true, false, true);
> +	if (test__start_subtest("sockmap msg_verdict ingress permanent shutdown"))
> +		test_sockmap_msg_verdict(true, true, false, true);
> +	if (test__start_subtest("sockmap msg_verdict shutdown"))
> +		test_sockmap_msg_verdict(false, false, false, true);
> +	if (test__start_subtest("sockmap msg_verdict ingress shutdown"))
> +		test_sockmap_msg_verdict(true, false, false, true);
>  }

I appreciate the split up of test changes into commits. Thanks.

As you see, the args for test_sockmap_msg_verdict became quite cryptic.
I think having dedicated aliases for 'true' would make it more readable:

        const bool INGRESS = true;
        const bool PERMANENT = true;
        const bool TO_SELF = true;
        const bool TARGET_SHUTDOWN = true;

Then invocations as:

        test_sockmap_msg_verdict(true, false, false, true);

become:

        test_sockmap_msg_verdict(INGRESS, !PERMANENT, !TO_SELF, TARGET_SHUTDOWN);




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux