Re: [PATCH bpf-next 04/14] selftests/bpf: add tests for ring_buffer__ring

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

 



On Thu, Sep 14, 2023 at 4:12 PM Martin Kelly
<martin.kelly@xxxxxxxxxxxxxxx> wrote:
>
> Add tests for the new API ring_buffer__ring.
>
> Signed-off-by: Martin Kelly <martin.kelly@xxxxxxxxxxxxxxx>
> ---
>  .../selftests/bpf/prog_tests/ringbuf_multi.c     | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/ringbuf_multi.c b/tools/testing/selftests/bpf/prog_tests/ringbuf_multi.c
> index 1455911d9fcb..f0729ffaf030 100644
> --- a/tools/testing/selftests/bpf/prog_tests/ringbuf_multi.c
> +++ b/tools/testing/selftests/bpf/prog_tests/ringbuf_multi.c
> @@ -42,6 +42,8 @@ void test_ringbuf_multi(void)
>  {
>         struct test_ringbuf_multi *skel;
>         struct ring_buffer *ringbuf = NULL;
> +       struct ring *ring_old;
> +       struct ring *ring;
>         int err;
>         int page_size = getpagesize();
>         int proto_fd = -1;
> @@ -84,11 +86,25 @@ void test_ringbuf_multi(void)
>         if (CHECK(!ringbuf, "ringbuf_create", "failed to create ringbuf\n"))
>                 goto cleanup;
>
> +       /* verify ring_buffer__ring returns expected results */
> +       ring = ring_buffer__ring(ringbuf, 0);
> +       if (CHECK(ring == NULL, "ringbuf_ring", "valid index returning NULL\n"))
> +               goto cleanup;
> +       ring_old = ring;
> +       ring = ring_buffer__ring(ringbuf, 1);
> +       if (CHECK(ring != NULL, "ringbuf_ring", "invalid index not rejected\n"))
> +               goto cleanup;
> +

we don't use CHECK() for new code, please use ASSERT_OK_PTR() and
ASSERT_ERR_PTR here

>         err = ring_buffer__add(ringbuf, bpf_map__fd(skel->maps.ringbuf2),
>                               process_sample, (void *)(long)2);
>         if (CHECK(err, "ringbuf_add", "failed to add another ring\n"))
>                 goto cleanup;
>
> +       /* verify adding a new ring didn't invalidate our older pointer */
> +       ring = ring_buffer__ring(ringbuf, 0);
> +       if (CHECK(ring != ring_old, "ringbuf_ring", "old ring invalidated\n"))

and ASSERT_EQ() here


> +               goto cleanup;
> +
>         err = test_ringbuf_multi__attach(skel);
>         if (CHECK(err, "skel_attach", "skeleton attachment failed: %d\n", err))
>                 goto cleanup;
> --
> 2.34.1
>





[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