Commit c27c5f94 authored by Jan Kiene's avatar Jan Kiene
Browse files

tests: add --{ref,dut}_renderer_path args to pytest

parent 9e96b65f
Loading
Loading
Loading
Loading
+70 −0
Original line number Diff line number Diff line
@@ -152,6 +152,18 @@ def pytest_addoption(parser):
        help="If specified, use given binary as REF ISAR post-renderer.",
    )

    parser.addoption(
        "--dut_renderer_path",
        action="store",
        help="If specified, use given binary as DUT renderer.",
    )

    parser.addoption(
        "--ref_renderer_path",
        action="store",
        help="If specified, use given binary as REF renderer.",
    )

    parser.addoption(
        "--test_vector_path",
        action="store",
@@ -1544,3 +1556,61 @@ def ref_postrend_frontend(ref_postrend_path, request) -> Optional[PostRendFronte
    # Fixture teardown
    if postrend is not None:
        postrend._check_run()


@pytest.fixture(scope="session")
def dut_renderer_path(request) -> Optional[str]:
    """
    Return path of DUT renderer binary.
    """
    if request.config.option.dut_renderer_path:
        return request.config.option.dut_renderer_path

    if request.config.option.create_ref:
        return None

    here = Path(__file__).parent.resolve()
    system = platform.system()

    if system == "Windows":
        path = here.joinpath("../IVAS_rend.exe")
    elif system in ["Darwin", "Linux"]:
        path = here.joinpath("../IVAS_rend")
    else:
        raise ValueError(f'Wrong system "{system}"!')

    path = str(path.resolve())

    if not os.path.isfile(path):
        raise FileNotFoundError(f"DUT renderer binary {path} not found!\n!")

    return path


@pytest.fixture(scope="session")
def ref_renderer_path(request) -> Optional[str]:
    """
    Return path of REF renderer binary.
    """
    if request.config.option.ref_renderer_path:
        return request.config.option.ref_renderer_path

    if not request.config.option.create_ref:
        return None

    here = Path(__file__).parent.resolve()
    system = platform.system()

    if system == "Windows":
        path = here.joinpath("../IVAS_rend_ref.exe")
    elif system in ["Darwin", "Linux"]:
        path = here.joinpath("../IVAS_rend_ref")
    else:
        raise ValueError(f'Wrong system "{system}"!')

    path = str(path.resolve())

    if not os.path.isfile(path):
        raise FileNotFoundError(f"REF renderer binary {path} not found!\n!")

    return path
+23 −8
Original line number Diff line number Diff line
@@ -295,8 +295,17 @@ def run_renderer(
    cmd[8] = str(out_fmt)
    cmd[10] = str(sr[:2])

    if test_info.config.option.create_ref:
        cmd[0] += BIN_SUFFIX_MERGETARGET
    if test_info.config.option.create_ref or render_for_peaq:
        explicit_path = test_info.config.getoption("--ref_renderer_path")
        if explicit_path is not None:
            cmd[0] = explicit_path
        else:
            cmd[0] += BIN_SUFFIX_MERGETARGET + binary_suffix
    else:
        explicit_path = test_info.config.getoption("--dut_renderer_path")
        if explicit_path is not None:
            cmd[0] = explicit_path
        else:
            cmd[0] += binary_suffix

    if in_meta_files is not None:
@@ -384,8 +393,11 @@ def run_renderer(
                cmd2[6] = odg_test  # out_file
                cmd2[8] = new_fmt  # out_fmt
                cmd2[10] = str(sr[:2])
                cmd2[0] += BIN_SUFFIX_MERGETARGET  # Use IVAS_rend_ref for re-rendering
                cmd2[0] += binary_suffix
                ref_path = test_info.config.getoption("--ref_renderer_path")
                if ref_path is not None:
                    cmd2[0] = ref_path
                else:
                    cmd2[0] += BIN_SUFFIX_MERGETARGET + binary_suffix
                if "MASA" in str(out_fmt):
                    cmd2.extend(["-im", out_file + ".met"])
                run_cmd(cmd2, test_info, env)
@@ -402,8 +414,11 @@ def run_renderer(

            if out_fmt_bin != in_fmt:
                # Render input to match out_fmt_bin using same config as input, but with IVAS_rend_ref
                cmd[0] += BIN_SUFFIX_MERGETARGET
                cmd[0] += binary_suffix
                ref_path = test_info.config.getoption("--ref_renderer_path")
                if ref_path is not None:
                    cmd[0] = ref_path
                else:
                    cmd[0] = RENDERER_CMD[0] + BIN_SUFFIX_MERGETARGET + binary_suffix
                cmd[6] = odg_input  # out_file
                cmd[8] = out_fmt_bin  # out_fmt
                run_cmd(cmd, test_info, env)
@@ -646,7 +661,7 @@ def binauralize_input_and_output(

        # Rendering configuration
        config_file = findstr(r"-render_config\s+(\S+)", dec_opts)
        binary_suffix = "_ref"
        binary_suffix = ""
        frame_size = findstr(r"-fr\s+(\S+)", dec_opts)
        # hrtf_file = findstr(r'-hrtf\s+(\S+)', dec_opts)
        hrtf_file = None  # Default HRTFs used for binaural rendering of output