Loading tests/cmp_pcm.py +12 −4 Original line number Diff line number Diff line Loading @@ -57,11 +57,17 @@ def cmp_pcm( # In case of wav input, override the nchannels with the one from the wav header nchannels = s1.shape[1] # In case number of channels do not match, fail already now. Could happen in case of # comparison to input with for a non-passthrough mode. if s1.shape[1] != s2.shape[1]: reason = "FAIL: Number of channels differ." return 1, reason if allow_differing_lengths: # to allow for MLD comparison, shorten longer file min_len = min(s1.shape[0], s2.shape[0]) s1 = s1[:min_len, :] s2 = s2[:min_len, :] # to allow for MLD comparison, pad shorter file max_len = max(s1.shape[0], s2.shape[0]) s1 = np.pad(s1,((0,max_len - s1.shape[0]),(0,0)),mode='constant',constant_values=0) s2 = np.pad(s2,((0,max_len - s2.shape[0]),(0,0)),mode='constant',constant_values=0) elif s1.shape != s2.shape: print( f"file size in samples: file 1 = {s1.shape[0]},", Loading Loading @@ -176,6 +182,8 @@ if __name__ == "__main__": parser.add_argument("--get_mld", action="store_true") parser.add_argument("--mld_lim", type=float, default=0, dest="mld_lim") parser.add_argument("--get_odg", action="store_true") parser.add_argument("--get_ssnr", action="store_true") parser.add_argument("--allow_differing_lengths", action="store_true") args = parser.parse_args() result, msg = cmp_pcm(**vars(args)) Loading tests/codec_be_on_mr_nonselection/test_param_file.py +6 −0 Original line number Diff line number Diff line Loading @@ -161,6 +161,7 @@ def test_param_file_tests( get_ssnr, get_enc_stats, get_odg, compare_to_input, ): enc_opts, dec_opts, sim_opts, eid_opts = param_file_test_dict[test_tag] Loading Loading @@ -396,6 +397,11 @@ 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 if compare_to_input: # If comparing to input, set input as reference and allow different length ref_output_file = testv_file allow_differing_lengths = True fs = int(sampling_rate) * 1000 output_differs, reason = cmp_pcm( ref_output_file, Loading tests/codec_be_on_mr_nonselection/test_sba.py +26 −5 Original line number Diff line number Diff line Loading @@ -114,6 +114,7 @@ def test_pca_enc( get_ssnr, get_odg, get_enc_stats, compare_to_input, ): pca = True bitrate = "256000" Loading Loading @@ -165,6 +166,7 @@ def test_pca_enc( sba_dec( record_property, props_to_record, test_vector_path, dut_decoder_frontend, ref_decoder_frontend, reference_path, Loading @@ -187,6 +189,7 @@ def test_pca_enc( abs_tol=abs_tol, get_ssnr=get_ssnr, get_odg=get_odg, compare_to_input=compare_to_input, ) Loading Loading @@ -223,6 +226,7 @@ def test_sba_enc_system( get_ssnr, get_odg, get_enc_stats, compare_to_input, ): plc_pattern = None Loading Loading @@ -333,6 +337,7 @@ def test_sba_enc_system( sba_dec( record_property, props_to_record, test_vector_path, dut_decoder_frontend, ref_decoder_frontend, reference_path, Loading @@ -355,6 +360,7 @@ def test_sba_enc_system( abs_tol=abs_tol, get_ssnr=get_ssnr, get_odg=get_odg, compare_to_input=compare_to_input, ) Loading Loading @@ -383,6 +389,7 @@ def test_spar_hoa2_enc_system( get_ssnr, get_odg, get_enc_stats, compare_to_input, ): sampling_rate = "48" pca = False Loading Loading @@ -467,6 +474,7 @@ def test_spar_hoa2_enc_system( sba_dec( record_property, props_to_record, test_vector_path, dut_decoder_frontend, ref_decoder_frontend, reference_path, Loading @@ -489,6 +497,7 @@ def test_spar_hoa2_enc_system( abs_tol=abs_tol, get_ssnr=get_ssnr, get_odg=get_odg, compare_to_input=compare_to_input, ) Loading Loading @@ -517,6 +526,7 @@ def test_spar_hoa3_enc_system( get_ssnr, get_odg, get_enc_stats, compare_to_input, ): sampling_rate = "48" pca = False Loading Loading @@ -595,6 +605,7 @@ def test_spar_hoa3_enc_system( sba_dec( record_property, props_to_record, test_vector_path, dut_decoder_frontend, ref_decoder_frontend, reference_path, Loading @@ -617,6 +628,7 @@ def test_spar_hoa3_enc_system( abs_tol=abs_tol, get_ssnr=get_ssnr, get_odg=get_odg, compare_to_input=compare_to_input, ) Loading Loading @@ -649,6 +661,7 @@ def test_sba_enc_BWforce_system( get_ssnr, get_odg, get_enc_stats, compare_to_input, ): sid = 0 plc_pattern = None Loading Loading @@ -743,6 +756,7 @@ def test_sba_enc_BWforce_system( sba_dec( record_property, props_to_record, test_vector_path, dut_decoder_frontend, ref_decoder_frontend, reference_path, Loading @@ -765,6 +779,7 @@ def test_sba_enc_BWforce_system( abs_tol=abs_tol, get_ssnr=get_ssnr, get_odg=get_odg, compare_to_input=compare_to_input, ) Loading Loading @@ -801,6 +816,7 @@ def test_sba_plc_system( get_ssnr, get_odg, get_enc_stats, compare_to_input, ): sid = 0 pca = False Loading Loading @@ -872,6 +888,7 @@ def test_sba_plc_system( sba_dec( record_property, props_to_record, test_vector_path, dut_decoder_frontend, ref_decoder_frontend, reference_path, Loading @@ -894,6 +911,7 @@ def test_sba_plc_system( abs_tol=abs_tol, get_ssnr=get_ssnr, get_odg=get_odg, compare_to_input=compare_to_input, ) Loading Loading @@ -1026,6 +1044,7 @@ def sba_enc( def sba_dec( record_property, props_to_record, test_vector_path, dut_decoder_frontend, ref_decoder_frontend, reference_path, Loading @@ -1048,6 +1067,7 @@ def sba_dec( abs_tol=0, get_ssnr=False, get_odg=False, compare_to_input=False, ): dut_pkt_dir = f"{dut_base_path}/sba_bs/pkt" ref_pkt_dir = f"{reference_path}/sba_bs/pkt" Loading Loading @@ -1115,6 +1135,11 @@ def sba_dec( plc_file=plc_file, ) if compare_to_input: # If comparing to input, set input as reference and allow different length ref_out_file = test_vector_path allow_differing_lengths = True sampling_rate_Hz = int(sampling_rate) * 1000 cmp_result, reason = cmp_pcm( dut_out_file, Loading @@ -1124,6 +1149,7 @@ def sba_dec( get_mld=get_mld, mld_lim=get_mld_lim, abs_tol=abs_tol, allow_differing_lengths=allow_differing_lengths, get_ssnr=get_ssnr, get_odg=get_odg, ) Loading @@ -1136,8 +1162,3 @@ def sba_dec( # report compare result if cmp_result != 0: pytest.fail(text_to_parse) # remove DUT output files when test result is OK (to save disk space) # if not keep_files: # os.remove(dut_out_file) # os.remove(dut_pkt_file) tests/conftest.py +12 −0 Original line number Diff line number Diff line Loading @@ -260,6 +260,12 @@ def pytest_addoption(parser): default=0, ) parser.addoption( "--compare_to_input", action="store_true", help="Compare output to the input file instead of reference output", default=False, ) @pytest.fixture(scope="session", autouse=True) def update_ref(request): Loading Loading @@ -968,6 +974,12 @@ def encoder_only(request) -> bool: """ return request.config.getoption("--encoder_only") @pytest.fixture(scope="session", autouse=True) def compare_to_input(request) -> bool: """ Return value of cmdl param --compare_to_input """ return request.config.getoption("--compare_to_input") def pytest_configure(config): config.addinivalue_line("markers", "serial: mark test to run only in serial") Loading Loading
tests/cmp_pcm.py +12 −4 Original line number Diff line number Diff line Loading @@ -57,11 +57,17 @@ def cmp_pcm( # In case of wav input, override the nchannels with the one from the wav header nchannels = s1.shape[1] # In case number of channels do not match, fail already now. Could happen in case of # comparison to input with for a non-passthrough mode. if s1.shape[1] != s2.shape[1]: reason = "FAIL: Number of channels differ." return 1, reason if allow_differing_lengths: # to allow for MLD comparison, shorten longer file min_len = min(s1.shape[0], s2.shape[0]) s1 = s1[:min_len, :] s2 = s2[:min_len, :] # to allow for MLD comparison, pad shorter file max_len = max(s1.shape[0], s2.shape[0]) s1 = np.pad(s1,((0,max_len - s1.shape[0]),(0,0)),mode='constant',constant_values=0) s2 = np.pad(s2,((0,max_len - s2.shape[0]),(0,0)),mode='constant',constant_values=0) elif s1.shape != s2.shape: print( f"file size in samples: file 1 = {s1.shape[0]},", Loading Loading @@ -176,6 +182,8 @@ if __name__ == "__main__": parser.add_argument("--get_mld", action="store_true") parser.add_argument("--mld_lim", type=float, default=0, dest="mld_lim") parser.add_argument("--get_odg", action="store_true") parser.add_argument("--get_ssnr", action="store_true") parser.add_argument("--allow_differing_lengths", action="store_true") args = parser.parse_args() result, msg = cmp_pcm(**vars(args)) Loading
tests/codec_be_on_mr_nonselection/test_param_file.py +6 −0 Original line number Diff line number Diff line Loading @@ -161,6 +161,7 @@ def test_param_file_tests( get_ssnr, get_enc_stats, get_odg, compare_to_input, ): enc_opts, dec_opts, sim_opts, eid_opts = param_file_test_dict[test_tag] Loading Loading @@ -396,6 +397,11 @@ 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 if compare_to_input: # If comparing to input, set input as reference and allow different length ref_output_file = testv_file allow_differing_lengths = True fs = int(sampling_rate) * 1000 output_differs, reason = cmp_pcm( ref_output_file, Loading
tests/codec_be_on_mr_nonselection/test_sba.py +26 −5 Original line number Diff line number Diff line Loading @@ -114,6 +114,7 @@ def test_pca_enc( get_ssnr, get_odg, get_enc_stats, compare_to_input, ): pca = True bitrate = "256000" Loading Loading @@ -165,6 +166,7 @@ def test_pca_enc( sba_dec( record_property, props_to_record, test_vector_path, dut_decoder_frontend, ref_decoder_frontend, reference_path, Loading @@ -187,6 +189,7 @@ def test_pca_enc( abs_tol=abs_tol, get_ssnr=get_ssnr, get_odg=get_odg, compare_to_input=compare_to_input, ) Loading Loading @@ -223,6 +226,7 @@ def test_sba_enc_system( get_ssnr, get_odg, get_enc_stats, compare_to_input, ): plc_pattern = None Loading Loading @@ -333,6 +337,7 @@ def test_sba_enc_system( sba_dec( record_property, props_to_record, test_vector_path, dut_decoder_frontend, ref_decoder_frontend, reference_path, Loading @@ -355,6 +360,7 @@ def test_sba_enc_system( abs_tol=abs_tol, get_ssnr=get_ssnr, get_odg=get_odg, compare_to_input=compare_to_input, ) Loading Loading @@ -383,6 +389,7 @@ def test_spar_hoa2_enc_system( get_ssnr, get_odg, get_enc_stats, compare_to_input, ): sampling_rate = "48" pca = False Loading Loading @@ -467,6 +474,7 @@ def test_spar_hoa2_enc_system( sba_dec( record_property, props_to_record, test_vector_path, dut_decoder_frontend, ref_decoder_frontend, reference_path, Loading @@ -489,6 +497,7 @@ def test_spar_hoa2_enc_system( abs_tol=abs_tol, get_ssnr=get_ssnr, get_odg=get_odg, compare_to_input=compare_to_input, ) Loading Loading @@ -517,6 +526,7 @@ def test_spar_hoa3_enc_system( get_ssnr, get_odg, get_enc_stats, compare_to_input, ): sampling_rate = "48" pca = False Loading Loading @@ -595,6 +605,7 @@ def test_spar_hoa3_enc_system( sba_dec( record_property, props_to_record, test_vector_path, dut_decoder_frontend, ref_decoder_frontend, reference_path, Loading @@ -617,6 +628,7 @@ def test_spar_hoa3_enc_system( abs_tol=abs_tol, get_ssnr=get_ssnr, get_odg=get_odg, compare_to_input=compare_to_input, ) Loading Loading @@ -649,6 +661,7 @@ def test_sba_enc_BWforce_system( get_ssnr, get_odg, get_enc_stats, compare_to_input, ): sid = 0 plc_pattern = None Loading Loading @@ -743,6 +756,7 @@ def test_sba_enc_BWforce_system( sba_dec( record_property, props_to_record, test_vector_path, dut_decoder_frontend, ref_decoder_frontend, reference_path, Loading @@ -765,6 +779,7 @@ def test_sba_enc_BWforce_system( abs_tol=abs_tol, get_ssnr=get_ssnr, get_odg=get_odg, compare_to_input=compare_to_input, ) Loading Loading @@ -801,6 +816,7 @@ def test_sba_plc_system( get_ssnr, get_odg, get_enc_stats, compare_to_input, ): sid = 0 pca = False Loading Loading @@ -872,6 +888,7 @@ def test_sba_plc_system( sba_dec( record_property, props_to_record, test_vector_path, dut_decoder_frontend, ref_decoder_frontend, reference_path, Loading @@ -894,6 +911,7 @@ def test_sba_plc_system( abs_tol=abs_tol, get_ssnr=get_ssnr, get_odg=get_odg, compare_to_input=compare_to_input, ) Loading Loading @@ -1026,6 +1044,7 @@ def sba_enc( def sba_dec( record_property, props_to_record, test_vector_path, dut_decoder_frontend, ref_decoder_frontend, reference_path, Loading @@ -1048,6 +1067,7 @@ def sba_dec( abs_tol=0, get_ssnr=False, get_odg=False, compare_to_input=False, ): dut_pkt_dir = f"{dut_base_path}/sba_bs/pkt" ref_pkt_dir = f"{reference_path}/sba_bs/pkt" Loading Loading @@ -1115,6 +1135,11 @@ def sba_dec( plc_file=plc_file, ) if compare_to_input: # If comparing to input, set input as reference and allow different length ref_out_file = test_vector_path allow_differing_lengths = True sampling_rate_Hz = int(sampling_rate) * 1000 cmp_result, reason = cmp_pcm( dut_out_file, Loading @@ -1124,6 +1149,7 @@ def sba_dec( get_mld=get_mld, mld_lim=get_mld_lim, abs_tol=abs_tol, allow_differing_lengths=allow_differing_lengths, get_ssnr=get_ssnr, get_odg=get_odg, ) Loading @@ -1136,8 +1162,3 @@ def sba_dec( # report compare result if cmp_result != 0: pytest.fail(text_to_parse) # remove DUT output files when test result is OK (to save disk space) # if not keep_files: # os.remove(dut_out_file) # os.remove(dut_pkt_file)
tests/conftest.py +12 −0 Original line number Diff line number Diff line Loading @@ -260,6 +260,12 @@ def pytest_addoption(parser): default=0, ) parser.addoption( "--compare_to_input", action="store_true", help="Compare output to the input file instead of reference output", default=False, ) @pytest.fixture(scope="session", autouse=True) def update_ref(request): Loading Loading @@ -968,6 +974,12 @@ def encoder_only(request) -> bool: """ return request.config.getoption("--encoder_only") @pytest.fixture(scope="session", autouse=True) def compare_to_input(request) -> bool: """ Return value of cmdl param --compare_to_input """ return request.config.getoption("--compare_to_input") def pytest_configure(config): config.addinivalue_line("markers", "serial: mark test to run only in serial") Loading