mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:17:44 +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
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)
|
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):
|
def test_pdf(filename):
|
||||||
pdf_path = os.path.join(os.path.dirname(__file__), '../Build/lagom/bin/pdf')
|
pdf_path = os.path.join(os.path.dirname(__file__), '../Build/lagom/bin/pdf')
|
||||||
r = subprocess.run([pdf_path, '--debugging-stats', filename],
|
r = subprocess.run([pdf_path, '--debugging-stats', filename],
|
||||||
capture_output=True)
|
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():
|
def main():
|
||||||
|
@ -68,16 +73,15 @@ def main():
|
||||||
keys.sort(key=lambda x: len(stack_to_files[x]), reverse=True)
|
keys.sort(key=lambda x: len(stack_to_files[x]), reverse=True)
|
||||||
for stack in reversed(keys[:5]):
|
for stack in reversed(keys[:5]):
|
||||||
files = stack_to_files[stack]
|
files = stack_to_files[stack]
|
||||||
print(stack.decode('utf-8'), end='')
|
print(stack.decode('utf-8', 'backslashreplace'), end='')
|
||||||
print(f'In {len(files)} files:')
|
print(f'In {len(files)} files:')
|
||||||
for file in files:
|
for file in files:
|
||||||
print(f' {file}')
|
print(f' {file}')
|
||||||
print()
|
print()
|
||||||
|
|
||||||
print(f'{len(keys)} distinct crash stacks')
|
|
||||||
|
|
||||||
percent = 100 * num_crashes / len(results)
|
percent = 100 * num_crashes / len(results)
|
||||||
print(f'{num_crashes} crashes ({percent:.1f}%)')
|
print(f'{num_crashes} crashes ({percent:.1f}%)')
|
||||||
|
print(f'{len(keys)} distinct crash stacks')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue