Commit 66f4cdf7 authored by Jan Kiene's avatar Jan Kiene
Browse files

add --decoder_only option and use it in test_param_files.py

parent f4fa0d24
Loading
Loading
Loading
Loading
+51 −37
Original line number Diff line number Diff line
@@ -127,6 +127,7 @@ def convert_test_string_to_tag(test_string):
@pytest.mark.parametrize("test_tag", list(param_file_test_dict.keys()))
def test_param_file_tests(
    record_property,
    decoder_only,
    dut_encoder_frontend: EncoderFrontend,
    dut_decoder_frontend: DecoderFrontend,
    ref_encoder_frontend: EncoderFrontend,
@@ -185,6 +186,7 @@ def test_param_file_tests(
    # -> construct bitstream filename
    bitstream_file = f"{testv_base}_{tag_str}.192"

    if not decoder_only:
        encode(
            dut_encoder_frontend,
            ref_encoder_frontend,
@@ -230,6 +232,7 @@ def test_param_file_tests(
            sim_split,
            update_ref,
            rootdir,
            decoder_only,
        )

    # check for eid-xor command line
@@ -255,6 +258,7 @@ def test_param_file_tests(
            eid_split,
            update_ref,
            rootdir,
            decoder_only,
        )

    # evaluate decoder options
@@ -320,6 +324,7 @@ def test_param_file_tests(
        dec_split,
        update_ref,
        tracefile_dec,
        decoder_only,
    )

    if update_ref in [0, 2]:
@@ -373,8 +378,9 @@ def test_param_file_tests(

        # remove DUT output files when test result is OK (to save disk space)
        if not keep_files:
            os.remove(f"{dut_base_path}/param_file/enc/{bitstream_file}")
            os.remove(f"{dut_base_path}/param_file/dec/{output_file}")
            if not decoder_only:
                os.remove(f"{dut_base_path}/param_file/enc/{bitstream_file}")
                if sim_opts != "":
                    os.remove(f"{dut_base_path}/param_file/enc/{testv_base}_{tag_str}.192")
                    os.remove(f"{dut_base_path}/param_file/enc/{netsim_trace_outfile}")
@@ -449,6 +455,7 @@ def simulate(
    sim_opts_list,
    update_ref,
    rootdir,
    decoder_only,
):
    """
    Call network simulator on REF and/or DUT encoder output.
@@ -477,20 +484,19 @@ def simulate(
    else:
        assert False, f"networkSimulator_g192 not available for {platform.system()}"

    if update_ref == 1 or update_ref == 2 and not os.path.exists(ref_out_file):
        # call network simulator on REF encoder output
    cmd_opts = sim_opts_list
    if update_ref == 1 or (update_ref == 2 and not os.path.exists(ref_out_file)) or decoder_only:
        # call network simulator on REF encoder output
        cmd_opts[1] = f"{ref_out_dir}/{netsim_infile}"
        cmd_opts[2] = f"{ref_out_dir}/{netsim_outfile}"  # ref_out_file
        cmd_opts[3] = f"{ref_out_dir}/{netsim_tracefile}"
        run(netsim + cmd_opts, check=False)

    if update_ref in [0, 2]:
    elif update_ref in [0, 2]:
        # call network simulator on DUT encoder output
        cmd_opts = sim_opts_list
        cmd_opts[1] = f"{dut_out_dir}/{netsim_infile}"
        cmd_opts[2] = f"{dut_out_dir}/{netsim_outfile}"  # dut_out_file

    if update_ref == 1 or (update_ref == 2 and not os.path.exists(ref_out_file)):
        cmd_opts[3] = f"{ref_out_dir}/{netsim_tracefile}"
    elif update_ref in [0, 2]:
        cmd_opts[3] = f"{dut_out_dir}/{netsim_tracefile}"

    run(netsim + cmd_opts, check=False)


@@ -500,6 +506,7 @@ def error_insertion(
    eid_opts_list,
    update_ref,
    rootdir,
    decoder_only,
):
    """
    Call eid-xor to insert frame erasure on REF and/or DUT encoder output.
@@ -522,18 +529,20 @@ def error_insertion(
    else:
        assert False, f"eid-xor not available for {platform.system()}"

    if update_ref == 1 or update_ref == 2 and not os.path.exists(ref_out_file):
        # call eid-xor on REF encoder output
    cmd_opts = eid_opts_list
        cmd_opts[-3] = f"{ref_out_dir}/{eid_xor_infile}"
        cmd_opts[-1] = f"{ref_out_dir}/{eid_xor_outfile}"  # ref_out_file
        run(eid_xor + cmd_opts, check=False)

    if update_ref in [0, 2]:
    if update_ref == 1 or (update_ref == 2 and not os.path.exists(ref_out_file)) or decoder_only:
        # call eid-xor on REF encoder output
        cmd_opts[-3] = f"{ref_out_dir}/{eid_xor_infile}"
    elif update_ref in [0, 2]:
        # call eid-xor on DUT encoder output
        cmd_opts = eid_opts_list
        cmd_opts[-3] = f"{dut_out_dir}/{eid_xor_infile}"

    if update_ref == 1 or (update_ref == 2 and not os.path.exists(ref_out_file)):
        cmd_opts[-1] = f"{ref_out_dir}/{eid_xor_outfile}"  # ref_out_file
    elif update_ref in [0, 2]:
        cmd_opts[-1] = f"{dut_out_dir}/{eid_xor_outfile}"  # ref_out_file

    run(eid_xor + cmd_opts, check=False)


@@ -549,6 +558,7 @@ def decode(
    dec_opts_list,
    update_ref,
    tracefile_dec,
    decoder_only,
):
    """
    Call REF and/or DUT decoder.
@@ -589,6 +599,10 @@ def decode(
                x if x != "tracefile_dec" else f"{dut_out_dir}/{tracefile_dec}"
                for x in dec_opts_list
            ]
        
        if decoder_only:
            dut_in_file = ref_in_file

        # call DUT decoder
        decoder_frontend.run(
            output_config,
+15 −0
Original line number Diff line number Diff line
@@ -191,6 +191,13 @@ def pytest_addoption(parser):
        default=20,
    )

    parser.addoption(
            "--decoder_only",
            help="Only run decoder parts of tests in 'codec_be_on_mr_nonselection'. Use ref encoder output bitstreams.",
            action="store_true",
            default=False,
            )

@pytest.fixture(scope="session", autouse=True)
def update_ref(request):
    """
@@ -692,6 +699,14 @@ def dut_base_path(request) -> str:
    return path


@pytest.fixture(scope="session", autouse=True)
def decoder_only(request) -> bool:
    """
    Return value of cmdl param --decoder_only
    """
    return request.config.getoption("--decoder_only")


def pytest_configure(config):
    config.addinivalue_line("markers", "serial: mark test to run only in serial")
    config.addinivalue_line(