add: tester: valgrind test

This commit is contained in:
2025-12-17 06:56:48 -06:00
parent f45128e380
commit cefd7e7c1f
5 changed files with 36 additions and 10 deletions

View File

@@ -6,7 +6,7 @@ import time
import thread_manager
from print import print_test
def _test(title: str, excutable: str, args: str, exit_code: int, log_path: str) -> None:
def _test(valgrind: bool, title: str, excutable: str, args: str, exit_code: int, log_path: str) -> None:
if not os.path.exists(log_path):
os.makedirs(log_path)
f = open(f"{log_path}/{title}.log", "w")
@@ -17,10 +17,21 @@ def _test(title: str, excutable: str, args: str, exit_code: int, log_path: str)
f.close()
print_test(exit_code, value, title, args)
def test_parsing(excutable: str, tests_category: dict[str, list[dict[str, str]]], log_path: str):
if valgrind == False:
return
f = open(f"{log_path}/{title}_valgrind.log", "w")
p = subprocess.Popen(f"valgrind --leak-check=full --show-leak-kinds=all --errors-for-leak-kinds=all --error-exitcode=79 {excutable} {args}".split(" "), stdout=f, stderr=f)
time.sleep(1)
p.send_signal(signal.SIGINT)
value = p.wait()
f.close()
print_test(exit_code, value, f"{title}_VALGRIND", args)
def test_parsing(valgrind: bool, excutable: str, tests_category: dict[str, list[dict[str, str]]], log_path: str):
for category_name, tests in tests_category.items():
print(category_name)
for test in tests:
thread_manager.add_to_queu(_test, (test["title"], excutable, test['args'], test['exit'], f"{log_path}/{category_name}"))
thread_manager.add_to_queu(_test, (valgrind, test["title"], excutable, test['args'], test['exit'], f"{log_path}/{category_name}"))
thread_manager.wait_pool()
print("\n" * 1)