Re: [RFC PATCH v3 2/3] bpf: Add selftests

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

 



Hi,

On 11/2/2021 10:14 AM, Joe Burton wrote:
> From: Joe Burton <jevburton@xxxxxxxxxx>
>
> Add selftests verifying that each supported map type is traced.
>
> Signed-off-by: Joe Burton <jevburton@xxxxxxxxxx>
> ---
>  .../selftests/bpf/prog_tests/map_trace.c      | 166 ++++++++++++++++++
>  .../selftests/bpf/progs/bpf_map_trace.c       |  95 ++++++++++
>  .../bpf/progs/bpf_map_trace_common.h          |  12 ++
>  3 files changed, 273 insertions(+)
>  create mode 100644 tools/testing/selftests/bpf/prog_tests/map_trace.c
>  create mode 100644 tools/testing/selftests/bpf/progs/bpf_map_trace.c
>  create mode 100644 tools/testing/selftests/bpf/progs/bpf_map_trace_common.h
snip
> +	/*
> +	 * Invoke core BPF program.
> +	 */
> +	write_fd = open("/tmp/map_trace_test_file", O_CREAT | O_WRONLY);
> +	if (!ASSERT_GE(rc, 0, "open tmp file for writing"))
> +		goto out;
> +
> +	bytes_written = write(write_fd, &write_buf, sizeof(write_buf));
> +	if (!ASSERT_EQ(bytes_written, sizeof(write_buf), "write to tmp file"))
> +		return;
In fentry__x64_sys_write(), you just do trigger updates to maps, so for the
portability of the test
(e.g. run-able for arm64) and minimal dependency (e.g. don't depends on /tmp),
why do you
using nanosleep() and replacing fentry_x64_sys_write by
tp/syscalls/sys_enter_nanosleep instead.
Also it will be better if you can filter out other processes by pid.

Thanks,
Tao




[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