Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests/bpf: Clear out Python syntax warnings

Invalid escape sequences are used, and produced syntax warnings:

$ test_bpftool_synctypes.py
test_bpftool_synctypes.py:69: SyntaxWarning: invalid escape sequence '\['
self.start_marker = re.compile(f'(static )?const bool {self.array_name}\[.*\] = {{\n')
test_bpftool_synctypes.py:83: SyntaxWarning: invalid escape sequence '\['
pattern = re.compile('\[(BPF_\w*)\]\s*= (true|false),?$')
test_bpftool_synctypes.py:181: SyntaxWarning: invalid escape sequence '\s'
pattern = re.compile('^\s*(BPF_\w+),?(\s+/\*.*\*/)?$')
test_bpftool_synctypes.py:229: SyntaxWarning: invalid escape sequence '\*'
start_marker = re.compile(f'\*{block_name}\* := {{')
test_bpftool_synctypes.py:229: SyntaxWarning: invalid escape sequence '\*'
start_marker = re.compile(f'\*{block_name}\* := {{')
test_bpftool_synctypes.py:230: SyntaxWarning: invalid escape sequence '\*'
pattern = re.compile('\*\*([\w/-]+)\*\*')
test_bpftool_synctypes.py:248: SyntaxWarning: invalid escape sequence '\s'
start_marker = re.compile(f'"\s*{block_name} := {{')
test_bpftool_synctypes.py:249: SyntaxWarning: invalid escape sequence '\w'
pattern = re.compile('([\w/]+) [|}]')
test_bpftool_synctypes.py:267: SyntaxWarning: invalid escape sequence '\s'
start_marker = re.compile(f'"\s*{macro}\s*" [|}}]')
test_bpftool_synctypes.py:267: SyntaxWarning: invalid escape sequence '\s'
start_marker = re.compile(f'"\s*{macro}\s*" [|}}]')
test_bpftool_synctypes.py:268: SyntaxWarning: invalid escape sequence '\w'
pattern = re.compile('([\w-]+) ?(?:\||}[ }\]])')
test_bpftool_synctypes.py:287: SyntaxWarning: invalid escape sequence '\w'
pattern = re.compile('(?:.*=\')?([\w/]+)')
test_bpftool_synctypes.py:319: SyntaxWarning: invalid escape sequence '\w'
pattern = re.compile('([\w-]+) ?(?:\||}[ }\]"])')
test_bpftool_synctypes.py:341: SyntaxWarning: invalid escape sequence '\|'
start_marker = re.compile('\|COMMON_OPTIONS\| replace:: {')
test_bpftool_synctypes.py:342: SyntaxWarning: invalid escape sequence '\*'
pattern = re.compile('\*\*([\w/-]+)\*\*')

Escaping them clears out the warnings.

$ tools/testing/selftests/bpf/test_bpftool_synctypes.py; echo $?
0

Signed-off-by: Ariel Otilibili <ariel.otilibili-anieli@eurecom.fr>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Tested-by: Quentin Monnet <qmo@kernel.org>
Reviewed-by: Quentin Monnet <qmo@kernel.org>
Link: https://docs.python.org/3/library/re.html
Link: https://lore.kernel.org/bpf/20241211220012.714055-2-ariel.otilibili-anieli@eurecom.fr

authored by

Ariel Otilibili and committed by
Daniel Borkmann
c5d2bac9 8eef6ac4

+14 -14
+14 -14
tools/testing/selftests/bpf/test_bpftool_synctypes.py
··· 66 66 67 67 def __init__(self, reader, array_name): 68 68 self.array_name = array_name 69 - self.start_marker = re.compile(f'(static )?const bool {self.array_name}\[.*\] = {{\n') 69 + self.start_marker = re.compile(fr'(static )?const bool {self.array_name}\[.*\] = {{\n') 70 70 super().__init__(reader) 71 71 72 72 def search_block(self): ··· 80 80 Parse a block and return data as a dictionary. Items to extract must be 81 81 on separate lines in the file. 82 82 """ 83 - pattern = re.compile('\[(BPF_\w*)\]\s*= (true|false),?$') 83 + pattern = re.compile(r'\[(BPF_\w*)\]\s*= (true|false),?$') 84 84 entries = set() 85 85 while True: 86 86 line = self.reader.readline() ··· 178 178 @enum_name: name of the enum to parse 179 179 """ 180 180 start_marker = re.compile(f'enum {enum_name} {{\n') 181 - pattern = re.compile('^\s*(BPF_\w+),?(\s+/\*.*\*/)?$') 181 + pattern = re.compile(r'^\s*(BPF_\w+),?(\s+/\*.*\*/)?$') 182 182 end_marker = re.compile('^};') 183 183 parser = BlockParser(self.reader) 184 184 parser.search_block(start_marker) ··· 226 226 227 227 @block_name: name of the blog to parse, 'TYPE' in the example 228 228 """ 229 - start_marker = re.compile(f'\*{block_name}\* := {{') 230 - pattern = re.compile('\*\*([\w/-]+)\*\*') 229 + start_marker = re.compile(fr'\*{block_name}\* := {{') 230 + pattern = re.compile(r'\*\*([\w/-]+)\*\*') 231 231 end_marker = re.compile('}\n') 232 232 return self.__get_description_list(start_marker, pattern, end_marker) 233 233 ··· 245 245 246 246 @block_name: name of the blog to parse, 'TYPE' in the example 247 247 """ 248 - start_marker = re.compile(f'"\s*{block_name} := {{') 249 - pattern = re.compile('([\w/]+) [|}]') 248 + start_marker = re.compile(fr'"\s*{block_name} := {{') 249 + pattern = re.compile(r'([\w/]+) [|}]') 250 250 end_marker = re.compile('}') 251 251 return self.__get_description_list(start_marker, pattern, end_marker) 252 252 ··· 264 264 265 265 @macro: macro starting the block, 'HELP_SPEC_OPTIONS' in the example 266 266 """ 267 - start_marker = re.compile(f'"\s*{macro}\s*" [|}}]') 268 - pattern = re.compile('([\w-]+) ?(?:\||}[ }\]])') 267 + start_marker = re.compile(fr'"\s*{macro}\s*" [|}}]') 268 + pattern = re.compile(r'([\w-]+) ?(?:\||}[ }\]])') 269 269 end_marker = re.compile('}\\\\n') 270 270 return self.__get_description_list(start_marker, pattern, end_marker) 271 271 ··· 283 283 284 284 @block_name: name of the blog to parse, 'TYPE' in the example 285 285 """ 286 - start_marker = re.compile(f'local {block_name}=\'') 287 - pattern = re.compile('(?:.*=\')?([\w/]+)') 286 + start_marker = re.compile(fr'local {block_name}=\'') 287 + pattern = re.compile(r'(?:.*=\')?([\w/]+)') 288 288 end_marker = re.compile('\'$') 289 289 return self.__get_description_list(start_marker, pattern, end_marker) 290 290 ··· 316 316 {'-p', '-d', '--pretty', '--debug', '--json', '-j'} 317 317 """ 318 318 start_marker = re.compile(f'"OPTIONS :=') 319 - pattern = re.compile('([\w-]+) ?(?:\||}[ }\]"])') 319 + pattern = re.compile(r'([\w-]+) ?(?:\||}[ }\]"])') 320 320 end_marker = re.compile('#define') 321 321 322 322 parser = InlineListParser(self.reader) ··· 338 338 339 339 {'-p', '-d', '--pretty', '--debug', '--json', '-j'} 340 340 """ 341 - start_marker = re.compile('\|COMMON_OPTIONS\| replace:: {') 342 - pattern = re.compile('\*\*([\w/-]+)\*\*') 341 + start_marker = re.compile(r'\|COMMON_OPTIONS\| replace:: {') 342 + pattern = re.compile(r'\*\*([\w/-]+)\*\*') 343 343 end_marker = re.compile('}$') 344 344 345 345 parser = InlineListParser(self.reader)