1
0

proj: Update test report output

This commit is contained in:
2025-05-07 14:38:10 +02:00
parent 2ec7c9e7eb
commit 9eb0e13dd6
3 changed files with 29 additions and 29 deletions

View File

@@ -23,11 +23,11 @@ def color(text: str, col: str) -> None:
def bold(text: str) -> None:
color(text, '1')
def red(text: str) -> None:
color(text, '31;1')
def green(text: str) -> None:
color(text, '32;1')
def test_result(test: list[str], result: bool or None) -> None:
text = ':: TEST :: ' + ' :: '.join(test)
esc = '\x1B[' + ({True: '32', False: '31', None: ''}[result]) + 'm' if sys.stderr.isatty() else ''
result = {True: 'PASSED', False: 'FAILED', None: 'SKIPPED'}[result]
bold(f'{text} {"." * (80 - len(text))} {esc}{result}')
def socket_thread(socket: str, handler: type[intercept.Handler]) -> None:
@@ -61,9 +61,9 @@ def main() -> None:
bold(':: REPORT ::')
for call, status in ctx['results'].items():
if status == 'passed':
green(f':: TEST :: INTERRUPT HANDLING :: {call} :: PASSED')
test_result(['Interrupt handling', str(call)], True)
else:
red(f':: TEST :: INTERRUPT HANDLING :: {call} :: FAILED')
test_result(['Interrupt handling', str(call)], False)

View File

@@ -22,11 +22,11 @@ def color(text: str, col: str) -> None:
def bold(text: str) -> None:
color(text, '1')
def red(text: str) -> None:
color(text, '31;1')
def green(text: str) -> None:
color(text, '32;1')
def test_result(test: list[str], result: bool or None) -> None:
text = ':: TEST :: ' + ' :: '.join(test)
esc = '\x1B[' + ({True: '32', False: '31', None: ''}[result]) + 'm' if sys.stderr.isatty() else ''
result = {True: 'PASSED', False: 'FAILED', None: 'SKIPPED'}[result]
bold(f'{text} {"." * (80 - len(text))} {esc}{result}')
def main() -> None:
@@ -58,22 +58,22 @@ def main() -> None:
bold(':: REPORT ::')
neutral('::')
if len(parser.allocated) > 0:
red(':: TEST :: MEMORY LEAKS :: FAILED ::')
red(":: Not free'd:")
test_result(['Memory leaks'], False)
neutral(":: Not free'd:")
for ptr, (call, size) in parser.allocated.items():
red(f':: 0x{ptr:x}: {size:>6} bytes ({call})')
neutral(f':: 0x{ptr:x}: {size:>6} bytes ({call})')
else:
green(':: TEST :: MEMORY LEAKS :: PASSED ::')
green(":: All allocated memory blocks were free'd!")
test_result(['Memory leaks'], True)
neutral(":: All allocated memory blocks were free'd!")
neutral('::')
if len(parser.invalid_frees) > 0:
red(':: TEST :: INVALID FREES :: FAILED ::')
red(':: Invalid/double frees:')
test_result(['Invalid frees'], False)
neutral(':: Invalid/double frees:')
for (call, ptr) in parser.invalid_frees:
red(f':: {call.func_name}: 0x{ptr:x} ({call.discriminator})')
neutral(f':: {call.func_name}: 0x{ptr:x} ({call.discriminator})')
else:
green(':: TEST :: INVALID FREES :: PASSED ::')
green(':: No invalid/double frees occured!')
test_result(['Invalid frees'], True)
neutral(':: No invalid/double frees occured!')
neutral('::')
neutral(f':: #allocs: {parser.num_alloc}, #reallocs: {parser.num_realloc}, #frees: {parser.num_free}')
neutral(f':: Max dynamically allocated: {parser.max_allocated} bytes')

View File

@@ -24,11 +24,11 @@ def color(text: str, col: str) -> None:
def bold(text: str) -> None:
color(text, '1')
def red(text: str) -> None:
color(text, '31;1')
def green(text: str) -> None:
color(text, '32;1')
def test_result(test: list[str], result: bool or None) -> None:
text = ':: TEST :: ' + ' :: '.join(test)
esc = '\x1B[' + ({True: '32', False: '31', None: ''}[result]) + 'm' if sys.stderr.isatty() else ''
result = {True: 'PASSED', False: 'FAILED', None: 'SKIPPED'}[result]
bold(f'{text} {"." * (80 - len(text))} {esc}{result}')
def socket_thread(socket: str, handler: type[intercept.Handler]) -> None:
@@ -117,9 +117,9 @@ def main() -> None:
if any(p == default_path for p in paths) or any(c.func_name not in allowed_cleanup_functions for p in paths for c in p):
failed.append(errno)
if len(failed) > 0:
red(f':: TEST :: RETURN VALUE CHECK :: {call} :: FAILED')
test_result(['Return value check', str(call)], False)
else:
green(f':: TEST :: RETURN VALUE CHECK :: {call} :: PASSED')
test_result(['Return value check', str(call)], True)