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: def bold(text: str) -> None:
color(text, '1') color(text, '1')
def red(text: str) -> None: def test_result(test: list[str], result: bool or None) -> None:
color(text, '31;1') text = ':: TEST :: ' + ' :: '.join(test)
esc = '\x1B[' + ({True: '32', False: '31', None: ''}[result]) + 'm' if sys.stderr.isatty() else ''
def green(text: str) -> None: result = {True: 'PASSED', False: 'FAILED', None: 'SKIPPED'}[result]
color(text, '32;1') bold(f'{text} {"." * (80 - len(text))} {esc}{result}')
def socket_thread(socket: str, handler: type[intercept.Handler]) -> None: def socket_thread(socket: str, handler: type[intercept.Handler]) -> None:
@@ -61,9 +61,9 @@ def main() -> None:
bold(':: REPORT ::') bold(':: REPORT ::')
for call, status in ctx['results'].items(): for call, status in ctx['results'].items():
if status == 'passed': if status == 'passed':
green(f':: TEST :: INTERRUPT HANDLING :: {call} :: PASSED') test_result(['Interrupt handling', str(call)], True)
else: 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: def bold(text: str) -> None:
color(text, '1') color(text, '1')
def red(text: str) -> None: def test_result(test: list[str], result: bool or None) -> None:
color(text, '31;1') text = ':: TEST :: ' + ' :: '.join(test)
esc = '\x1B[' + ({True: '32', False: '31', None: ''}[result]) + 'm' if sys.stderr.isatty() else ''
def green(text: str) -> None: result = {True: 'PASSED', False: 'FAILED', None: 'SKIPPED'}[result]
color(text, '32;1') bold(f'{text} {"." * (80 - len(text))} {esc}{result}')
def main() -> None: def main() -> None:
@@ -58,22 +58,22 @@ def main() -> None:
bold(':: REPORT ::') bold(':: REPORT ::')
neutral('::') neutral('::')
if len(parser.allocated) > 0: if len(parser.allocated) > 0:
red(':: TEST :: MEMORY LEAKS :: FAILED ::') test_result(['Memory leaks'], False)
red(":: Not free'd:") neutral(":: Not free'd:")
for ptr, (call, size) in parser.allocated.items(): 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: else:
green(':: TEST :: MEMORY LEAKS :: PASSED ::') test_result(['Memory leaks'], True)
green(":: All allocated memory blocks were free'd!") neutral(":: All allocated memory blocks were free'd!")
neutral('::') neutral('::')
if len(parser.invalid_frees) > 0: if len(parser.invalid_frees) > 0:
red(':: TEST :: INVALID FREES :: FAILED ::') test_result(['Invalid frees'], False)
red(':: Invalid/double frees:') neutral(':: Invalid/double frees:')
for (call, ptr) in parser.invalid_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: else:
green(':: TEST :: INVALID FREES :: PASSED ::') test_result(['Invalid frees'], True)
green(':: No invalid/double frees occured!') neutral(':: No invalid/double frees occured!')
neutral('::') neutral('::')
neutral(f':: #allocs: {parser.num_alloc}, #reallocs: {parser.num_realloc}, #frees: {parser.num_free}') neutral(f':: #allocs: {parser.num_alloc}, #reallocs: {parser.num_realloc}, #frees: {parser.num_free}')
neutral(f':: Max dynamically allocated: {parser.max_allocated} bytes') 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: def bold(text: str) -> None:
color(text, '1') color(text, '1')
def red(text: str) -> None: def test_result(test: list[str], result: bool or None) -> None:
color(text, '31;1') text = ':: TEST :: ' + ' :: '.join(test)
esc = '\x1B[' + ({True: '32', False: '31', None: ''}[result]) + 'm' if sys.stderr.isatty() else ''
def green(text: str) -> None: result = {True: 'PASSED', False: 'FAILED', None: 'SKIPPED'}[result]
color(text, '32;1') bold(f'{text} {"." * (80 - len(text))} {esc}{result}')
def socket_thread(socket: str, handler: type[intercept.Handler]) -> None: 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): 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) failed.append(errno)
if len(failed) > 0: if len(failed) > 0:
red(f':: TEST :: RETURN VALUE CHECK :: {call} :: FAILED') test_result(['Return value check', str(call)], False)
else: else:
green(f':: TEST :: RETURN VALUE CHECK :: {call} :: PASSED') test_result(['Return value check', str(call)], True)