4
0
Files
public-tests-2026/main.py
2026-03-08 18:08:25 +00:00

64 lines
2.1 KiB
Python
Executable File

#!/usr/bin/env python3
import argparse
import platform
import testsuites.intro as intro
import testsuites.fixed_floating as fixed_floating
from testsuites import Testsuite, DynamicWrapper
from typing import Dict, Any, List
__TESTSUITES: List[Testsuite] = [
intro.instance, fixed_floating.instance
]
__SUITENAMES: List[str] = [t.name() for t in __TESTSUITES]
__SELECTOR: Dict[str, Testsuite] = dict(zip(__SUITENAMES, __TESTSUITES))
def __args() -> Dict[str, Any]:
parser = argparse.ArgumentParser()
parser.add_argument("--executable-path", help = "path to the executable file to be tested", type = str, required = True)
parser.add_argument("--suite", help = "test set selection", type = str, required = True, choices = __SELECTOR)
parser.add_argument("--timeout-factor", help = "maximum program execution time multiplier (default: 1.0)", type = float, default = 1.0)
available_dynamic_analyzers: List[DynamicWrapper] = [DynamicWrapper.NO_WRAPPER]
if platform.system() == "Linux":
available_dynamic_analyzers.append(DynamicWrapper.VALGRIND_ANALYZER)
available_dynamic_analyzers.append(DynamicWrapper.GDB_DEBUGGER)
parser.add_argument("--dynamic-wrapper", help = "", type = str, default = DynamicWrapper.NO_WRAPPER.value, choices = [ada.value for ada in available_dynamic_analyzers])
parser.add_argument("--report-output-path", help = "path to the generated JSON report with the specified file name (default: no generation)", type = str, default = None)
return vars(parser.parse_args())
def __main():
args = __args()
executable_path = str(args["executable_path"])
suite = str(args["suite"])
timeout_factor = float(args["timeout_factor"])
dynamic_wrapper = DynamicWrapper(args["dynamic_wrapper"])
report_output_path = args["report_output_path"]
testsuite = __SELECTOR[suite]
tester = testsuite.get_tester()
tester.warm(executable_path, timeout_factor)
result = tester.run(executable_path, timeout_factor, dynamic_wrapper)
if report_output_path is not None:
coefficients = testsuite.get_coefficients()
result.export_report(str(report_output_path), coefficients)
exit(result.exitcode())
if __name__ == "__main__":
__main()