mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 12:35:14 +00:00
Meta: Tweak test_pdf.py script
* Elide parser offsets to better group parser errors * Use `backslashreplace` for decoding crash stacks so that we don't crash when printing crash stacks if the error output isn't valid utf-8 * Swap last two lines of output, reads a bit better
This commit is contained in:
parent
04aec4a032
commit
3dd68f6026
Notes:
sideshowbarker
2024-07-17 03:03:37 +09:00
Author: https://github.com/nico Commit: https://github.com/SerenityOS/serenity/commit/3dd68f6026 Pull-request: https://github.com/SerenityOS/serenity/pull/21532
1 changed files with 8 additions and 4 deletions
|
@ -30,11 +30,16 @@ def elide_aslr(s):
|
|||
return re.sub(rb'\b0x[0-9a-f]+\b', b'0xc3ns0r3d', s)
|
||||
|
||||
|
||||
def elide_parser_offset(s):
|
||||
return re.sub(rb'\bParser error at offset [0-9]+:', b'Parser error:', s)
|
||||
|
||||
|
||||
def test_pdf(filename):
|
||||
pdf_path = os.path.join(os.path.dirname(__file__), '../Build/lagom/bin/pdf')
|
||||
r = subprocess.run([pdf_path, '--debugging-stats', filename],
|
||||
capture_output=True)
|
||||
return Result(filename, r.returncode, r.stdout, elide_aslr(r.stderr))
|
||||
return Result(filename, r.returncode, r.stdout,
|
||||
elide_parser_offset(elide_aslr(r.stderr)))
|
||||
|
||||
|
||||
def main():
|
||||
|
@ -68,16 +73,15 @@ def main():
|
|||
keys.sort(key=lambda x: len(stack_to_files[x]), reverse=True)
|
||||
for stack in reversed(keys[:5]):
|
||||
files = stack_to_files[stack]
|
||||
print(stack.decode('utf-8'), end='')
|
||||
print(stack.decode('utf-8', 'backslashreplace'), end='')
|
||||
print(f'In {len(files)} files:')
|
||||
for file in files:
|
||||
print(f' {file}')
|
||||
print()
|
||||
|
||||
print(f'{len(keys)} distinct crash stacks')
|
||||
|
||||
percent = 100 * num_crashes / len(results)
|
||||
print(f'{num_crashes} crashes ({percent:.1f}%)')
|
||||
print(f'{len(keys)} distinct crash stacks')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Add table
Reference in a new issue