Commit ebabc979 authored by BOHMRR's avatar BOHMRR
Browse files

pytest: improve reference generation

- no more reference bitstream (re-)generation in decoder plc test
- changed create_ref_serial to create_ref_part2: parallel execution in part 2 now possible
parent 03c50ca3
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -423,5 +423,5 @@ def pytest_configure(config):
        "markers", "create_ref: mark test capable of producing references"
    )
    config.addinivalue_line(
        "markers", "create_ref_serial: reference creation test that should not run in parallel"
        "markers", "create_ref_part2: reference creation test that depends on create_ref references"
    )
+6 −4
Original line number Diff line number Diff line
@@ -181,6 +181,8 @@ def main(argv):
            base_cmd = ["python3", "-m", "pytest"]
        base_cmd += [
            "scripts/ivas_pytests/tests",
            "-n",
            args.numprocesses,
            "--update_ref",
            "1",
            "-v",
@@ -207,11 +209,11 @@ def main(argv):
        my_env["TESTVECTOR_PATH_REL_TRUNK"] = "/scripts/ivas_pytests/testv/"  # leading "/" is important
        my_env["CREND_UNIT_TEST_BIN"] = CREND_UNITTEST_REF
        print("pytest command line to be executed from project root folder:")
        print(" ".join(base_cmd + ["-m", "create_ref", "-n", args.numprocesses]))
        subprocess.run(base_cmd + ["-m", "create_ref", "-n", args.numprocesses], check=False, env=my_env)
        print(" ".join(base_cmd + ["-m", "create_ref"]))
        subprocess.run(base_cmd + ["-m", "create_ref"], check=False, env=my_env)
        print("pytest command line to be executed from project root folder:")
        print(" ".join(base_cmd + ["-m", "create_ref_serial"]))
        subprocess.run(base_cmd + ["-m", "create_ref_serial"], check=False, env=my_env)
        print(" ".join(base_cmd + ["-m", "create_ref_part2"]))
        subprocess.run(base_cmd + ["-m", "create_ref_part2"], check=False, env=my_env)

    if args.create_only:
        return
+14 −73
Original line number Diff line number Diff line
@@ -47,10 +47,7 @@ dtx_set = ['0', '1']
ivas_br_list = ['32000', '64000', '96000', '256000']
sampling_rate_list = ['48', '32', '16']

# we need signals amplified by 24dB - until those are available, use existing 'stvFOA'
agc_tag_list = ['stvFOA']
# TODO: create and use new 24dB signals
# agc_tag_list = ['stvFOA_24dB_']

ch_count_foa = 4
AbsTol = '3'
@@ -65,7 +62,13 @@ def check_and_makedir(dir_path):
                raise  # raises the error again


@pytest.mark.create_ref_serial
# assumption:
# - the needed reference bitstreams are created by test_spar_foa_enc_system
# -> reference bitstreams are not any longer created as part of this test
# -> the parameters of this test (except additional parameter plc_pattern) need to be a subset of the parameters in test_spar_foa_enc_system
# -> the reference generation for this test (reference decoder output) needs to be done after completion of test_spar_foa_enc_system
#    -> therefore the marker create_ref_part2
@pytest.mark.create_ref_part2
@pytest.mark.parametrize("ivas_br", ivas_br_list)
@pytest.mark.parametrize("dtx", dtx_set)
@pytest.mark.parametrize("tag", tag_list)
@@ -76,7 +79,6 @@ def test_spar_foa_plc_system(
    data_system_tests_path,
    reference_path,
    dut_base_path,
    ref_encoder_path,
    ref_decoder_path,
    update_ref,
    ivas_br,
@@ -88,15 +90,17 @@ def test_spar_foa_plc_system(
    tag = tag + fs + 'c'
    agc = 0

    if update_ref == 1 and plc_pattern == plc_patterns[0] and ref_encoder_path:
        # enc
        spar_foa_ref_enc(ref_encoder_path, data_system_tests_path, reference_path, tag, fs, ivas_br, dtx, agc)

    #dec
    spar_foa_dec_plc(dut_decoder_frontend, data_system_tests_path, reference_path, dut_base_path, ref_decoder_path, tag, ch_count_foa, fs, ivas_br, dtx, plc_pattern, update_ref, agc)


@pytest.mark.create_ref_serial
# assumption:
# - the needed reference bitstreams are created by test_spar_foa_enc_agc_system
# -> reference bitstreams are not any longer created as part of this test
# -> the parameters of this test (except additional parameter plc_pattern) need to be a subset of the parameters in test_spar_foa_enc_agc_system
# -> the reference generation for this test (reference decoder output) needs to be done after completion of test_spar_foa_enc_agc_system
#    -> therefore the marker create_ref_part2
@pytest.mark.create_ref_part2
@pytest.mark.parametrize("ivas_br", ivas_br_list)
@pytest.mark.parametrize("dtx", dtx_set)
@pytest.mark.parametrize("tag", agc_tag_list)
@@ -107,7 +111,6 @@ def test_spar_foa_agc_plc_system(
    data_system_tests_path,
    reference_path,
    dut_base_path,
    ref_encoder_path,
    ref_decoder_path,
    update_ref,
    ivas_br,
@@ -119,59 +122,12 @@ def test_spar_foa_agc_plc_system(
    tag = tag + fs + 'c'
    agc = 1

    if update_ref == 1 and plc_pattern == plc_patterns[0] and ref_encoder_path:
        # enc
        spar_foa_ref_enc(ref_encoder_path, data_system_tests_path, reference_path, tag, fs, ivas_br, dtx, agc)

    # dec
    spar_foa_dec_plc(dut_decoder_frontend, data_system_tests_path, reference_path, dut_base_path, ref_decoder_path, tag, ch_count_foa, fs, ivas_br, dtx, plc_pattern, update_ref, agc)


#########################################################
############ test function ##############################
def spar_foa_ref_enc(
    ref_encoder_path,
    test_vector_path,
    reference_path,
    tag,
    sampling_rate,
    ivas_br,
    dtx,
    agc
):

    #########  run cmd   #####################################
    ref_out_dir = f"{reference_path}/spar_foa_bs/pkt"
    check_and_makedir(ref_out_dir)

    tag_out = f"{tag}_ivasbr{ivas_br[:-3]}k_DTX{dtx}"
    if agc == 1:
        tag_out += '_AGC1'

    input_path = f"{test_vector_path}/{tag}.pcm"
    cut_file = f"{test_vector_path}/{tag}_cut.pcm"
    # we expect that the reference generation for create_ref did already run and the cut PCM files are available
    assert os.path.exists(cut_file)
    input_path = cut_file

    ref_pkt_file = f"{ref_out_dir}/{tag_out}.pkt"

    dtx_mode = dtx == '1'

    ref_encoder = EncoderFrontend(ref_encoder_path, "REF")
    # call REF encoder
    ref_encoder.run(
        ivas_br,
        sampling_rate,
        input_path,
        ref_pkt_file,
        sba_order="+1",
        max_band="FB",
        agc_op=agc,
        dtx_mode=dtx_mode,
    )


def spar_foa_dec_plc(
    decoder_frontend,
    test_vector_path,
@@ -253,18 +209,3 @@ def spar_foa_dec_plc(

        ##report failure
        assert not test_fail

    if ref_decoder_path:
        # Unclear whether this clean-up is still needed
        # TODO: check temp file generation

        ##File removal##
        for count in range(ch_count, 25):
            ch_id = str(count + 1)
            temp_raw_file = f"{ref_out_dir}/out{ch_id}ch.raw"
            if os.path.isfile(temp_raw_file):
                os.remove(temp_raw_file)

        temp_md_file = f"{ref_out_dir}/MD_OUT_DUMMY.BIN"
        if os.path.isfile(temp_md_file):
            os.remove(temp_md_file)
+1 −1

File changed.

Contains only whitespace changes.