[<prev] [next>] [day] [month] [year] [list]
Message-ID: <CAEf4BzbfiAx1QuNaDxcV0zX4wxOAOLUres61B7wf6SgZKa-E7w@mail.gmail.com>
Date: Mon, 11 Jan 2021 23:06:38 -0800
From: Andrii Nakryiko <andrii.nakryiko@...il.com>
To: Song Liu <songliubraving@...com>
Cc: bpf <bpf@...r.kernel.org>, Networking <netdev@...r.kernel.org>,
open list <linux-kernel@...r.kernel.org>,
Ingo Molnar <mingo@...hat.com>,
Peter Ziljstra <peterz@...radead.org>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>,
john fastabend <john.fastabend@...il.com>,
KP Singh <kpsingh@...omium.org>,
Kernel Team <kernel-team@...com>, Hao Luo <haoluo@...gle.com>
Subject: Re: [PATCH bpf-next 2/4] selftests/bpf: add non-BPF_LSM test for task
local storage
On Fri, Jan 8, 2021 at 3:30 PM Song Liu <songliubraving@...com> wrote:
>
> Task local storage is enabled for tracing programs. Add a test for it
> without CONFIG_BPF_LSM.
>
> Signed-off-by: Song Liu <songliubraving@...com>
> ---
> .../bpf/prog_tests/test_task_local_storage.c | 34 +++++++++++++++++
> .../selftests/bpf/progs/task_local_storage.c | 37 +++++++++++++++++++
> 2 files changed, 71 insertions(+)
> create mode 100644 tools/testing/selftests/bpf/prog_tests/test_task_local_storage.c
> create mode 100644 tools/testing/selftests/bpf/progs/task_local_storage.c
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/test_task_local_storage.c b/tools/testing/selftests/bpf/prog_tests/test_task_local_storage.c
> new file mode 100644
> index 0000000000000..7de7a154ebbe6
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/prog_tests/test_task_local_storage.c
> @@ -0,0 +1,34 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/* Copyright (c) 2020 Facebook */
> +
> +#include <sys/types.h>
> +#include <unistd.h>
> +#include <test_progs.h>
> +#include "task_local_storage.skel.h"
> +
> +static unsigned int duration;
> +
> +void test_test_task_local_storage(void)
nit: let's not use "test_test_" tautology. It can be simply
test_task_local_storage() and this file itself should be called
task_local_storage.c.
> +{
> + struct task_local_storage *skel;
> + const int count = 10;
> + int i, err;
> +
> + skel = task_local_storage__open_and_load();
> +
> + if (CHECK(!skel, "skel_open_and_load", "skeleton open and load failed\n"))
btw, can you ASSERT_OK_PTR(skel, "skel_open_and_load"); and save
yourself a bunch of typing
> + return;
> +
> + err = task_local_storage__attach(skel);
> +
> + if (CHECK(err, "skel_attach", "skeleton attach failed\n"))
> + goto out;
similarly, ASSERT_OK(err, "skel_attach")
> +
> + for (i = 0; i < count; i++)
> + usleep(1000);
> + CHECK(skel->bss->value < count, "task_local_storage_value",
> + "task local value too small\n");
> +
> +out:
> + task_local_storage__destroy(skel);
> +}
[...]
Powered by blists - more mailing lists