diff mbox series

[bpf-next] selftests/bpf: Fix parsing of prog types in UAPI hdr for bpftool sync

Message ID 20220404140944.64744-1-quentin@isovalent.com (mailing list archive)
State Accepted
Commit 4eeebce6ac4ad80ee8243bb847c98e0e55848d47
Delegated to: BPF
Headers show
Series [bpf-next] selftests/bpf: Fix parsing of prog types in UAPI hdr for bpftool sync | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for bpf-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 7 maintainers not CCed: songliubraving@fb.com shuah@kernel.org kafai@fb.com linux-kselftest@vger.kernel.org yhs@fb.com john.fastabend@gmail.com kpsingh@kernel.org
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
bpf/vmtest-bpf-next-PR fail PR summary

Commit Message

Quentin Monnet April 4, 2022, 2:09 p.m. UTC
The script for checking that various lists of types in bpftool remain in
sync with the UAPI BPF header uses a regex to parse enum bpf_prog_type.
If this enum contains a set of values different from the list of program
types in bpftool, it complains.

This script should have reported the addition, some time ago, of the new
BPF_PROG_TYPE_SYSCALL, which was not reported to bpftool's program types
list. It failed to do so, because it failed to parse that new type from
the enum. This is because the new value, in the BPF header, has an
explicative comment on the same line, and the regex does not support
that.

Let's update the script to support parsing enum values when they have
comments on the same line.

Cc: Andrii Nakryiko <andrii@kernel.org>
Cc: Milan Landaverde <milan@mdaverde.com>
Signed-off-by: Quentin Monnet <quentin@isovalent.com>
---
 tools/testing/selftests/bpf/test_bpftool_synctypes.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

patchwork-bot+netdevbpf@kernel.org April 4, 2022, 9:50 p.m. UTC | #1
Hello:

This patch was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:

On Mon,  4 Apr 2022 15:09:44 +0100 you wrote:
> The script for checking that various lists of types in bpftool remain in
> sync with the UAPI BPF header uses a regex to parse enum bpf_prog_type.
> If this enum contains a set of values different from the list of program
> types in bpftool, it complains.
> 
> This script should have reported the addition, some time ago, of the new
> BPF_PROG_TYPE_SYSCALL, which was not reported to bpftool's program types
> list. It failed to do so, because it failed to parse that new type from
> the enum. This is because the new value, in the BPF header, has an
> explicative comment on the same line, and the regex does not support
> that.
> 
> [...]

Here is the summary with links:
  - [bpf-next] selftests/bpf: Fix parsing of prog types in UAPI hdr for bpftool sync
    https://git.kernel.org/bpf/bpf-next/c/4eeebce6ac4a

You are awesome, thank you!
diff mbox series

Patch

diff --git a/tools/testing/selftests/bpf/test_bpftool_synctypes.py b/tools/testing/selftests/bpf/test_bpftool_synctypes.py
index 6bf21e47882a..c0e7acd698ed 100755
--- a/tools/testing/selftests/bpf/test_bpftool_synctypes.py
+++ b/tools/testing/selftests/bpf/test_bpftool_synctypes.py
@@ -180,7 +180,7 @@  class FileExtractor(object):
         @enum_name: name of the enum to parse
         """
         start_marker = re.compile(f'enum {enum_name} {{\n')
-        pattern = re.compile('^\s*(BPF_\w+),?$')
+        pattern = re.compile('^\s*(BPF_\w+),?(\s+/\*.*\*/)?$')
         end_marker = re.compile('^};')
         parser = BlockParser(self.reader)
         parser.search_block(start_marker)