import time import subprocess import os import signal import thread_manager from print import print_test def _cmp_header(expected: str, value: str): pass def _test(valgrind: bool, title: str, excutable: str, args: str, exit_code: int, delay: float, log_path: str) -> None: log_path = f"{log_path}/{title}" if not os.path.exists(log_path): os.makedirs(log_path) normal_file = open(f"{log_path}/normal.log", "w") your_file = open(f"{log_path}/your.log", "w") your_program = subprocess.Popen(f"{excutable} {args}".split(" "), stdout=your_file, stderr=your_file) normal_program = subprocess.Popen(f"ping {args}".split(" "), stdout=normal_file, stderr=normal_file) time.sleep(delay) your_program.send_signal(signal.SIGINT) normal_program.send_signal(signal.SIGINT) your_exit = your_program.wait() normal_exit = normal_program.wait() your_file.close() normal_file.close() if valgrind == False: return f = open(f"{log_path}/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_excution(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(valgrind, test["title"], excutable, test['args'], test.get("exit", 0), test.get("delay", 1), f"{log_path}/{category_name}") #) thread_manager.wait_pool() print("\n" * 1)