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

also compare metadata files for BE

parent 9b749e19
Loading
Loading
Loading
Loading
+17 −10
Original line number Diff line number Diff line
@@ -70,12 +70,8 @@ def apply_error_pattern_on_bitstream(
        subprocess.run(cmd)


def is_be_to_reference(dut_file: Path):
    assert dut_file.parent == DUT_PATH

    # TODO: handle .wav files differently
    ref_file = REF_PATH.joinpath(dut_file.name)
    return filecmp.cmp(ref_file, dut_file)
def files_equal(dut_file, ref_file):
    return filecmp.cmp(dut_file, ref_file)


def run_check(
@@ -123,7 +119,8 @@ def run_check(
        add_option_list=options + [str(f) for f in metadata],
    )

    if not is_ref_creation and not is_be_to_reference(dut_bitstream):
    ref_bitstream = REF_PATH.joinpath(dut_bitstream.name)
    if not is_ref_creation and not files_equal(dut_bitstream, ref_bitstream):
        pytest.fail("Bitstream file differs from reference")

    dut_bitstream_to_decoder = dut_bitstream
@@ -133,6 +130,16 @@ def run_check(

    decoder_frontend.run(output_mode, sampling_rate, dut_bitstream_to_decoder, dut_output)

    # TODO: also compare metadata if present
    if not is_ref_creation and not is_be_to_reference(dut_output):
    # NOTE: file comparison is done via filecmp which compares the whole file, including the header for wav files
    #       this should not be a problem as both the reference and the tdut output was generated by the codec, so 
    #       diverging headers should also indicate a problem - still, keep in mind if something bogus happens
    if not is_ref_creation:
        ref_output = REF_PATH.joinpath(dut_output.name)
        if not files_equal(dut_output, ref_output):
            pytest.fail("Decoder output differs from reference")
        for md in metadata:
            md_suffix = "".join(md.suffixes)
            dut_md = DUT_PATH.joinpath(dut_output.with_suffix(md_suffix).name)
            ref_md = REF_PATH.joinpath(dut_output.with_suffix(md_suffix).name)
            if not files_equal(dut_md, ref_md):
                pytest.fail("Metadata file {md.name} differs from reference")