Re: [PATCH 08/24] tools: bpftool: update bpftool-prog.rst reference
From: Quentin Monnet
Date: Thu Sep 16 2021 - 08:13:03 EST
2021-09-16 13:30 UTC+0200 ~ Mauro Carvalho Chehab
<mchehab+huawei@xxxxxxxxxx>
> [PATCH] scripts: documentation-file-ref-check: fix bpf selftests path
>
> tools/testing/selftests/bpf/test_bpftool_synctypes.py use
> relative patches on the top of BPFTOOL_DIR:
>
> BPFTOOL_DIR = os.path.join(LINUX_ROOT, 'tools/bpf/bpftool')
>
> Change the script to automatically convert:
>
> testing/selftests/bpf -> bpf/bpftool
>
> In order to properly check the files used by such script.
>
> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@xxxxxxxxxx>
>
> diff --git a/scripts/documentation-file-ref-check b/scripts/documentation-file-ref-check
> index 7187ea5e5149..2d91cfe11cd2 100755
> --- a/scripts/documentation-file-ref-check
> +++ b/scripts/documentation-file-ref-check
> @@ -144,6 +144,7 @@ while (<IN>) {
> if ($f =~ m/tools/) {
> my $path = $f;
> $path =~ s,(.*)/.*,$1,;
> + $path =~ s,testing/selftests/bpf,bpf/bpftool,;
> next if (grep -e, glob("$path/$ref $path/../$ref $path/$fulref"));
> }
>
>
>
>
I tested the patch and it works well on my side.
However, this looks a bit fragile to me. There is no particular reason
to have testing/selftests/bpf point to bpf/bpftool other than to
accommodate the current case, we could imagine other selftest files
pointing to other parts of the documentation in the future. I would
instead make an exception for test_bpftool_synctypes.py specifically
(other selftest files don't usually parse documentation anyway).
Alternatively, I would look at excluding lines where the path is used in
code (tricky to detect), maybe at least when used with os.path.join():
next if ($ln =~ m,os\.path\.join\([^\,]*\,\s*['"]$fulref,);
But I'm not familiar with documentation-file-ref-check in the first
place, so these are just my two cents.
Thanks,
Quentin