[PATCH 8/8] selftests/bpf: fix Python string escapes in f-strings

Benjamin Gray
2023-08-14T06:17:19Z

tools/testing/selftests/bpf/test_bpftool_synctypes.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/bpf/test_bpftool_synctypes.py b/tools/testing/selftests/bpf/test_bpftool_synctypes.py
index b21bc1a35bf4..a93144b3b2b0 100755
--- a/tools/testing/selftests/bpf/test_bpftool_synctypes.py
+++ b/tools/testing/selftests/bpf/test_bpftool_synctypes.py
@@ -66,7 +66,7 @@ class ArrayParser(BlockParser):

def __init__(self, reader, array_name):
self.array_name = array_name
- self.start_marker = re.compile(f'(static )?const bool {self.array_name}\[.*\] = {{\n')
+ self.start_marker = re.compile(f'(static )?const bool {self.array_name}\\[.*\\] = {{\n')
super().__init__(reader)

def search_block(self):
@@ -226,7 +226,7 @@ class FileExtractor(object):

@block_name: name of the blog to parse, 'TYPE' in the example
"""
- start_marker = re.compile(f'\*{block_name}\* := {{')
+ start_marker = re.compile(f'\\*{block_name}\\* := {{')
pattern = re.compile('\\*\\*([\\w/-]+)\\*\\*')
end_marker = re.compile('}\n')
return self.__get_description_list(start_marker, pattern, end_marker)
@@ -245,7 +245,7 @@ class FileExtractor(object):

@block_name: name of the blog to parse, 'TYPE' in the example
"""
- start_marker = re.compile(f'"\s*{block_name} := {{')
+ start_marker = re.compile(f'"\\s*{block_name} := {{')
pattern = re.compile('([\\w/]+) [|}]')
end_marker = re.compile('}')
return self.__get_description_list(start_marker, pattern, end_marker)
@@ -264,7 +264,7 @@ class FileExtractor(object):

@macro: macro starting the block, 'HELP_SPEC_OPTIONS' in the example
"""
- start_marker = re.compile(f'"\s*{macro}\s*" [|}}]')
+ start_marker = re.compile(f'"\\s*{macro}\\s*" [|}}]')
pattern = re.compile('([\\w-]+) ?(?:\\||}[ }\\]])')
end_marker = re.compile('}\\\\n')
return self.__get_description_list(start_marker, pattern, end_marker)
--
2.41.0