selftests/bpf: add read_with_timeout() utility function
authorEduard Zingerman <eddyz87@gmail.com>
Tue, 12 Nov 2024 11:09:04 +0000 (03:09 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 12 Nov 2024 21:53:27 +0000 (13:53 -0800)
commit03066ed3105a71c2b0ad39ea44b6e5733ddd4a68
tree640cb16e8e6bdbdc9c4731bfdde84eeb67ac3600
parentd9d4d127e813427afb26ff7e0f0c58989501be84
selftests/bpf: add read_with_timeout() utility function

int read_with_timeout(int fd, char *buf, size_t count, long usec)

As a regular read(2), but allows to specify a timeout in
micro-seconds. Returns -EAGAIN on timeout.
Implemented using select().

Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
Link: https://lore.kernel.org/r/20241112110906.3045278-3-eddyz87@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/Makefile
tools/testing/selftests/bpf/io_helpers.c [new file with mode: 0644]
tools/testing/selftests/bpf/io_helpers.h [new file with mode: 0644]