Re: [PATCH 08/24] tools: bpftool: update bpftool-prog.rst reference

From: Mauro Carvalho Chehab
Date: Thu Sep 16 2021 - 07:30:50 EST


Em Thu, 16 Sep 2021 11:57:51 +0100
Quentin Monnet <quentin@xxxxxxxxxxxxx> escreveu:

> 2021-09-16 12:49 UTC+0200 ~ Mauro Carvalho Chehab
> <mchehab+huawei@xxxxxxxxxx>
> > Hi Quentin,
> >
> > Em Thu, 16 Sep 2021 10:43:45 +0100
> > Quentin Monnet <quentin@xxxxxxxxxxxxx> escreveu:
> >
> >> 2021-09-16 11:14 UTC+0200 ~ Mauro Carvalho Chehab
> >> <mchehab+huawei@xxxxxxxxxx>
> >>> The file name: Documentation/bpftool-prog.rst
> >>> should be, instead: tools/bpf/bpftool/Documentation/bpftool-prog.rst.
> >>>
> >>> Update its cross-reference accordingly.
> >>>
> >>> Fixes: a2b5944fb4e0 ("selftests/bpf: Check consistency between bpftool source, doc, completion")
> >>> Fixes: ff69c21a85a4 ("tools: bpftool: add documentation")
> >>
> >> Hi,
> >> How is this a fix for the commit that added the documentation in bpftool?
> >>
> >>> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@xxxxxxxxxx>
> >>> ---
> >>> tools/testing/selftests/bpf/test_bpftool_synctypes.py | 2 +-
> >>> 1 file changed, 1 insertion(+), 1 deletion(-)
> >>>
> >>> diff --git a/tools/testing/selftests/bpf/test_bpftool_synctypes.py b/tools/testing/selftests/bpf/test_bpftool_synctypes.py
> >>> index be54b7335a76..27a2c369a798 100755
> >>> --- a/tools/testing/selftests/bpf/test_bpftool_synctypes.py
> >>> +++ b/tools/testing/selftests/bpf/test_bpftool_synctypes.py
> >>> @@ -374,7 +374,7 @@ class ManProgExtractor(ManPageExtractor):
> >>> """
> >>> An extractor for bpftool-prog.rst.
> >>> """
> >>> - filename = os.path.join(BPFTOOL_DIR, 'Documentation/bpftool-prog.rst')
> >>> + filename = os.path.join(BPFTOOL_DIR, 'tools/bpf/bpftool/Documentation/bpftool-prog.rst')
> >>>
> >>> def get_attach_types(self):
> >>> return self.get_rst_list('ATTACH_TYPE')
> >>>
> >>
> >> No I don't believe it should. BPFTOOL_DIR already contains
> >> 'tools/bpf/bpftool' and the os.path.join() concatenates the two path
> >> fragments.
> >>
> >> Where is this suggestion coming from? Did you face an issue with the script?
> >
> > No, I didn't face any issues with this script.
> >
> > The suggestion cames from the script at:
> >
> > ./scripts/documentation-file-ref-check
> >
> > which is meant to discover broken doc references.
> >
> > Such script has already a rule to handle stuff under tools/:
> >
> > # Accept relative Documentation patches for tools/
> > if ($f =~ m/tools/) {
> > my $path = $f;
> > $path =~ s,(.*)/.*,$1,;
> > next if (grep -e, glob("$path/$ref $path/../$ref $path/$fulref"));
> > }
> >
> > but it seems it needs a fixup in order for it to stop reporting issues
> > at test_bpftool_synctypes.py:
> >
> > $ ./scripts/documentation-file-ref-check
> > ...
> > tools/testing/selftests/bpf/test_bpftool_synctypes.py: Documentation/bpftool-prog.rst
> > tools/testing/selftests/bpf/test_bpftool_synctypes.py: Documentation/bpftool-map.rst
> > tools/testing/selftests/bpf/test_bpftool_synctypes.py: Documentation/bpftool-cgroup.rst
>
> Oh, I see, thanks for explaining. I didn't know this script would catch
> the paths in bpftool's test file.
>
> >
> > I'll drop the patches touching it for a next version, probably
> > adding a fix for such script.
> >
> > Thanks,
> > Mauro
> >
>
> Sounds good to me, thanks a lot!

The enclosed patch should do the trick.

> Quentin

Thanks,
Mauro

[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"));
}