add: tester: valgrind test
This commit is contained in:
2
Makefile
2
Makefile
@@ -32,7 +32,7 @@ re:
|
|||||||
tests:
|
tests:
|
||||||
$(MAKE) all
|
$(MAKE) all
|
||||||
mkdir -p log
|
mkdir -p log
|
||||||
python3 test/test.py build/$(NAME)
|
python3 test/test.py build/$(NAME) 1
|
||||||
|
|
||||||
.PHONY: all clean fclean re tests
|
.PHONY: all clean fclean re tests
|
||||||
-include $(DEP)
|
-include $(DEP)
|
||||||
|
|||||||
@@ -4,11 +4,12 @@ import os
|
|||||||
import signal
|
import signal
|
||||||
|
|
||||||
import thread_manager
|
import thread_manager
|
||||||
|
from print import print_test
|
||||||
|
|
||||||
def _cmp_header(expected: str, value: str):
|
def _cmp_header(expected: str, value: str):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _test(title: str, excutable: str, args: str, exit_code: int, delay: float, log_path: str) -> None:
|
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}"
|
log_path = f"{log_path}/{title}"
|
||||||
if not os.path.exists(log_path):
|
if not os.path.exists(log_path):
|
||||||
os.makedirs(log_path)
|
os.makedirs(log_path)
|
||||||
@@ -24,11 +25,23 @@ def _test(title: str, excutable: str, args: str, exit_code: int, delay: float, l
|
|||||||
your_file.close()
|
your_file.close()
|
||||||
normal_file.close()
|
normal_file.close()
|
||||||
|
|
||||||
def test_excution(excutable: str, tests_category: dict[str, list[dict[str, str]]], log_path: str):
|
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():
|
for category_name, tests in tests_category.items():
|
||||||
print(category_name)
|
print(category_name)
|
||||||
for test in tests:
|
for test in tests:
|
||||||
_test(test["title"], excutable, test['args'], test.get("exit", 0), test.get("delay", 1), f"{log_path}/{category_name}")
|
#thread_manager.add_to_queu(
|
||||||
thread_manager.add_to_queu(_test, (test["title"], excutable, test['args'], test.get("exit", 0), test.get("delay", 1), f"{log_path}/{category_name}"))
|
_test(valgrind, test["title"], excutable, test['args'], test.get("exit", 0), test.get("delay", 1), f"{log_path}/{category_name}")
|
||||||
|
#)
|
||||||
thread_manager.wait_pool()
|
thread_manager.wait_pool()
|
||||||
print("\n" * 1)
|
print("\n" * 1)
|
||||||
@@ -6,7 +6,7 @@ import time
|
|||||||
import thread_manager
|
import thread_manager
|
||||||
from print import print_test
|
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):
|
if not os.path.exists(log_path):
|
||||||
os.makedirs(log_path)
|
os.makedirs(log_path)
|
||||||
f = open(f"{log_path}/{title}.log", "w")
|
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()
|
f.close()
|
||||||
print_test(exit_code, value, title, args)
|
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():
|
for category_name, tests in tests_category.items():
|
||||||
print(category_name)
|
print(category_name)
|
||||||
for test in tests:
|
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()
|
thread_manager.wait_pool()
|
||||||
print("\n" * 1)
|
print("\n" * 1)
|
||||||
@@ -9,6 +9,7 @@ import parsing
|
|||||||
import execution
|
import execution
|
||||||
|
|
||||||
excutable: str = sys.argv[1]
|
excutable: str = sys.argv[1]
|
||||||
|
valgrind: bool = bool(sys.argv[2])
|
||||||
|
|
||||||
with open('test/tests.json', 'r') as file:
|
with open('test/tests.json', 'r') as file:
|
||||||
tests: dict[str, dict] = json.load(file)
|
tests: dict[str, dict] = json.load(file)
|
||||||
@@ -19,5 +20,5 @@ shutil.rmtree("log")
|
|||||||
|
|
||||||
for category_name, tests in tests.items():
|
for category_name, tests in tests.items():
|
||||||
print(category_name, end="\n" * 2)
|
print(category_name, end="\n" * 2)
|
||||||
tester[category_name](excutable, tests, f"log/{category_name}")
|
tester[category_name](valgrind, excutable, tests, f"log/{category_name}")
|
||||||
thread_manager.wait_pool()
|
thread_manager.wait_pool()
|
||||||
@@ -90,7 +90,8 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "invalid",
|
"title": "invalid",
|
||||||
"args": "domain.invalid"
|
"args": "domain.invalid",
|
||||||
|
"exit": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"payload_size": [
|
"payload_size": [
|
||||||
|
|||||||
Reference in New Issue
Block a user