Commit 95a6bd24 authored by norvell's avatar norvell
Browse files

Formal improvements to test_param_file.py

parent 65b558c9
Loading
Loading
Loading
Loading
Loading
+36 −18
Original line number Diff line number Diff line
@@ -53,15 +53,15 @@ from tests.constants import (
)

PASSTHROUGH_CONF = [
    (r'[\s\S]*',"EXT"), # Any input with EXT output is pass-through
    (r'-stereo',"STEREO"),
    (r'-sba\s?[-+]?1',"FOA"),
    (r'-sba\s?[-+]?2',"HOA2"),
    (r'-sba\s?[-+]?3',"HOA3"),
    (r'-mc\s5_1\s',"5_1"),
    (r'-mc\s7_1\s',"7_1"),
    (r'-mc\s5_1_4',"5_1_4"),
    (r'-mc\s7_1_4',"7_1_4"),
    (r"[\s\S]*", "EXT"),  # Any input with EXT output is pass-through
    (r"-stereo", "STEREO"),
    (r"-sba\s?[-+]?1", "FOA"),
    (r"-sba\s?[-+]?2", "HOA2"),
    (r"-sba\s?[-+]?3", "HOA3"),
    (r"-mc\s5_1\s", "5_1"),
    (r"-mc\s7_1\s", "7_1"),
    (r"-mc\s5_1_4", "5_1_4"),
    (r"-mc\s7_1_4", "7_1_4"),
]

VALID_DEC_OUTPUT_CONF = [
@@ -179,9 +179,15 @@ def test_param_file_tests(

    # If compare_to_input is set, only run pass-through test cases
    if compare_to_input:
        passthrough = [(a, b) for (a, b) in PASSTHROUGH_CONF if re.search(a, enc_opts) and b in dec_opts.split()]
        passthrough = [
            (a, b)
            for (a, b) in PASSTHROUGH_CONF
            if re.search(a, enc_opts) and b in dec_opts.split()
        ]
        if len(passthrough) != 1:
            pytest.skip()
            pytest.skip(
                "All non-passthrough modes are skipped when --compare-to-input is set"
            )

    tag_str = convert_test_string_to_tag(test_tag)

@@ -418,17 +424,17 @@ def test_param_file_tests(
        # shift differences between the two signals - cut longer signal to shorter size
        allow_differing_lengths = not tracefile_last_rtp_numbers_differ

        md_out_files = get_expected_md_files(ref_output_file, enc_split, output_config)

        if compare_to_input:
            # If comparing to input, set input as reference and allow different length
            ref_output_file = testv_file
            ref_file = testv_file
            allow_differing_lengths = True
            input_md = [x for x in enc_split if "csv" in x]
        else:
            ref_file = ref_output_file

        fs = int(sampling_rate) * 1000
        output_differs, reason = cmp_pcm(
            ref_output_file,
            ref_file,
            dut_output_file,
            output_config,
            fs,
@@ -449,11 +455,23 @@ def test_param_file_tests(
            record_property(k, v)

        metadata_differs = False

        md_out_files = get_expected_md_files(ref_output_file, enc_split, output_config)

        if compare_to_input:
            md_file_pairs = [(Path(f"{dut_base_path}/param_file/dec/{md_file}"), md_in_file) for (md_file,md_in_file) in zip(md_out_files,input_md)]
            md_file_pairs = [
                (Path(f"{dut_base_path}/param_file/dec/{md_file}"), md_in_file)
                for (md_file, md_in_file) in zip(md_out_files, input_md)
            ]
        else:
            md_file_pairs = [(Path(f"{dut_base_path}/param_file/dec/{md_file}"), Path(f"{reference_path}/param_file/dec/{md_file}")) for md_file in md_out_files]
        for (dut_metadata_file, ref_metadata_file) in md_file_pairs:
            md_file_pairs = [
                (
                    Path(f"{dut_base_path}/param_file/dec/{md_file}"),
                    Path(f"{reference_path}/param_file/dec/{md_file}"),
                )
                for md_file in md_out_files
            ]
        for dut_metadata_file, ref_metadata_file in md_file_pairs:
            md_file = os.path.basename(dut_metadata_file)
            try:
                if not filecmp.cmp(dut_metadata_file, ref_metadata_file):