diff --git a/ci/run_scheduled_sanitizer_test.py b/ci/run_scheduled_sanitizer_test.py index 481ae56473b9993af0ee6fa44747467239bc1d8c..7c8f53aff8d026a7a4118050eb684e24b818c897 100644 --- a/ci/run_scheduled_sanitizer_test.py +++ b/ci/run_scheduled_sanitizer_test.py @@ -8,104 +8,111 @@ import pathlib DURATION = "120" CFG = "ci_linux.json" -SUPPORTED_TESTS = [ "CLANG1", "CLANG2", "CLANG3", "VALGRIND" ] +SUPPORTED_TESTS = ["CLANG1", "CLANG2", "CLANG3", "VALGRIND"] EP_FILE = "ep_015.g192" GENPATT_CMD = f"gen-patt -tailstat -fer -g192 -gamma 0 -rate 0.15 -tol 0.001 -reset -n {int(DURATION) * 50} {EP_FILE}" EIDXOR_CMD = "eid-xor -vbr -fer {bitstream} {ep_file} {out_file}" +MC_MODES = ["5_1", "5_1_2", "5_1_4", "7_1", "7_1_4"] SCRIPT_DIR = pathlib.Path("./scripts").resolve() + def main(args): - in_format = args.in_format - out_formats = args.out_formats - tests = args.tests - run_fec = not args.skip_fec + in_format = args.in_format + out_formats = args.out_formats + tests = args.tests + run_fec = not args.skip_fec - assert all([t in SUPPORTED_TESTS for t in tests]) + assert all([t in SUPPORTED_TESTS for t in tests]) - modes = get_modes(in_format) - returncode = run_check(modes, out_formats, tests, run_fec=run_fec) + modes = get_modes(in_format) + returncode = run_check(modes, out_formats, tests, run_fec=run_fec) - sys.exit(returncode) + sys.exit(returncode) def get_modes(in_format: str) -> list: - cmd = [SCRIPT_DIR.joinpath("runIvasCodec.py"), "-l"] - list_process = subprocess.run(cmd, capture_output=True) + cmd = [SCRIPT_DIR.joinpath("runIvasCodec.py"), "-l"] + list_process = subprocess.run(cmd, capture_output=True) + + output = list_process.stdout.decode("utf8") + + # correction for multichannel modes to avoid selecting some mono modes... + if in_format in MC_MODES: + in_format = "MC_" + in_format - output = list_process.stdout.decode("utf8") - return [m for m in output.splitlines() if in_format in m] + return [m for m in output.splitlines() if in_format in m] def run_check(modes: list, out_formats: list, tests: list, run_fec: bool = True): - ### always run encoder and decoder with no frameloss - cmd_no_fec = [ - str(SCRIPT_DIR.joinpath("IvasBuildAndRunChecks.py")), - "-U", - DURATION, - "-p", - CFG, - "--checks", - *tests, - "-m", - *modes, - "--oc", - *out_formats, - ] - print(cmd_no_fec) + ### always run encoder and decoder with no frameloss + cmd_no_fec = [ + str(SCRIPT_DIR.joinpath("IvasBuildAndRunChecks.py")), + "-U", + DURATION, + "-p", + CFG, + "--checks", + *tests, + "-m", + *modes, + "--oc", + *out_formats, + ] + print(cmd_no_fec) - proc = subprocess.Popen(cmd_no_fec, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - for c in iter(lambda: proc.stdout.read(1), b""): - sys.stdout.buffer.write(c) - proc.wait() + proc = subprocess.Popen(cmd_no_fec, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + for c in iter(lambda: proc.stdout.read(1), b""): + sys.stdout.buffer.write(c) + proc.wait() - if proc.returncode not in [0, 101]: - raise IvasBuildAndRunFailed("Failed at first run (no PLC)") + if proc.returncode not in [0, 101]: + raise IvasBuildAndRunFailed("Failed at first run (no PLC)") - returncode_no_fec = proc.returncode + returncode_no_fec = proc.returncode - if not run_fec: - return returncode_no_fec + if not run_fec: + return returncode_no_fec - ### second run: decoder only with disturbed bitstream + ### second run: decoder only with disturbed bitstream - # generate error pattern - subprocess.call(GENPATT_CMD.split()) + # generate error pattern + subprocess.call(GENPATT_CMD.split()) - # cleanup to avoid script errors - # we want "logs" and "dec" subfolders to be empty -> delete and recreate them - cleanup_folders = ["logs", "dec"] - for t in tests: - for fol in cleanup_folders: - for fi in pathlib.Path(t).joinpath(fol).iterdir(): - fi.unlink() + # cleanup to avoid script errors + # we want "logs" and "dec" subfolders to be empty -> delete and recreate them + cleanup_folders = ["logs", "dec"] + for t in tests: + for fol in cleanup_folders: + for fi in pathlib.Path(t).joinpath(fol).iterdir(): + fi.unlink() - cmd_fec = cmd_no_fec + ["--decoder_only", "-f", EP_FILE] - print(cmd_fec) + cmd_fec = cmd_no_fec + ["--decoder_only", "-f", EP_FILE] + print(cmd_fec) - proc = subprocess.Popen(cmd_fec, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - for c in iter(lambda: proc.stdout.read(1), b""): - sys.stdout.buffer.write(c) - proc.wait() + proc = subprocess.Popen(cmd_fec, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + for c in iter(lambda: proc.stdout.read(1), b""): + sys.stdout.buffer.write(c) + proc.wait() - returncode_fec = proc.returncode + returncode_fec = proc.returncode - if returncode_fec not in [0, 101]: - raise IvasBuildAndRunFailed("failed at second run (PLC)") + if returncode_fec not in [0, 101]: + raise IvasBuildAndRunFailed("failed at second run (PLC)") - return 101 if 101 in [returncode_no_fec, returncode_fec] else 0 + return 101 if 101 in [returncode_no_fec, returncode_fec] else 0 class IvasBuildAndRunFailed(Exception): - pass + pass if __name__ == "__main__": - parser = argparse.ArgumentParser() - parser.add_argument("in_format", type=str) - parser.add_argument("out_formats", type=str, nargs="+") - parser.add_argument("--tests", type=str, nargs="+", default=["CLANG1", "CLANG2"]) - parser.add_argument("--skip_fec", action="store_true") + parser = argparse.ArgumentParser() + parser.add_argument("in_format", type=str) + parser.add_argument("out_formats", type=str, nargs="+") + parser.add_argument("--tests", type=str, nargs="+", default=["CLANG1", "CLANG2"]) + parser.add_argument("--skip_fec", action="store_true") - sys.exit(main(parser.parse_args())) \ No newline at end of file + sys.exit(main(parser.parse_args()))