Re: [PATCH bpf-next v4 6/6] selftests/bpf: add sleepable timer tests

From: Eduard Zingerman
Date: Mon Mar 18 2024 - 20:15:15 EST


On Fri, 2024-03-15 at 15:29 +0100, Benjamin Tissoires wrote:
> bpf_experimental.h and ../bpf_testmod/bpf_testmod_kfunc.h are both
> including vmlinux.h, which is not compatible with including time.h
> or bpf_tcp_helpers.h.
>
> So prevent vmlinux.h to be included, and override the few missing
> types.
>
> Signed-off-by: Benjamin Tissoires <bentiss@xxxxxxxxxx>

[...]

> @@ -6,6 +6,14 @@
> #include <bpf/bpf_helpers.h>
> #include "bpf_tcp_helpers.h"
>
> +#define __VMLINUX_H__
> +#define u32 __u32
> +#define u64 __u64
> +#include "bpf_experimental.h"
> +struct prog_test_member1;
> +#include "../bpf_testmod/bpf_testmod_kfunc.h"
> +#undef __VMLINUX_H__

Tbh, this looks very ugly.
Would it be possible to create a new tests file sleepable_timer.c
and include bpf_experimental.h there, skipping time.h?
It appears that for the new tests the only necessary definition from
time.h is CLOCK_MONOTONIC.