From 1f43570770bd490d4f2fa568ef2377fa619e7e7a Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Mon, 16 Sep 2024 13:43:41 +0200 Subject: [PATCH 1/7] Change test_264444.py to recycle the logging and cmp_pcm tools --- tests/cmp_pcm.py | 3 +- tests/conftest.py | 10 +-- tests/test_26444.py | 148 ++++++++++++++++++++++++++++---------------- 3 files changed, 100 insertions(+), 61 deletions(-) diff --git a/tests/cmp_pcm.py b/tests/cmp_pcm.py index e299047492..72cd5af7ce 100755 --- a/tests/cmp_pcm.py +++ b/tests/cmp_pcm.py @@ -15,7 +15,7 @@ sys.path.append(os.path.join(os.path.dirname(THIS_PATH), "../scripts")) import numpy as np import pyaudio3dtools import pyivastest -from .constants import ODG_PATTERN_PQEVALAUDIO +from constants import ODG_PATTERN_PQEVALAUDIO def cmp_pcm( @@ -167,6 +167,7 @@ if __name__ == "__main__": parser.add_argument("-s", "--sampling_rate", type=int, default=48000, dest="fs") 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") args = parser.parse_args() result, msg = cmp_pcm(**vars(args)) diff --git a/tests/conftest.py b/tests/conftest.py index 06658dd7e1..b6fffa197a 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -451,9 +451,6 @@ def ref_encoder_path(request) -> str: if request.config.option.ref_encoder_path: return request.config.option.ref_encoder_path - if request.config.option.update_ref == "0": - return None - # assume specifically named encoder when update_ref is selected, but no ref_encoder_path is specified here = Path(__file__).parent.resolve() system = platform.system() @@ -474,7 +471,7 @@ def ref_encoder_path(request) -> str: @pytest.fixture(scope="function") -def ref_encoder_frontend(ref_encoder_path, request) -> Union[None, EncoderFrontend]: +def ref_encoder_frontend(ref_encoder_path, request) -> EncoderFrontend: """ Return a :class:`conftest.EncoderFrontend` instance as REF for the test session. """ @@ -700,9 +697,6 @@ def ref_decoder_path(request) -> str: if request.config.option.ref_decoder_path: return request.config.option.ref_decoder_path - if request.config.option.update_ref == "0": - return None - # assume specifically named decoder when update_ref is selected, but no ref_decoder_path is specified here = Path(__file__).parent.resolve() system = platform.system() @@ -723,7 +717,7 @@ def ref_decoder_path(request) -> str: @pytest.fixture(scope="function") -def ref_decoder_frontend(ref_decoder_path, request) -> Union[None, DecoderFrontend]: +def ref_decoder_frontend(ref_decoder_path, request) -> DecoderFrontend: """ Return a :class:`conftest.DecoderFrontend` instance as DUT for the test session. """ diff --git a/tests/test_26444.py b/tests/test_26444.py index d23c01e8a8..cebc5eb045 100644 --- a/tests/test_26444.py +++ b/tests/test_26444.py @@ -34,10 +34,13 @@ Execute tests specified via a parameter file. import filecmp import os -import subprocess - +import re import pytest +from tests.cmp_pcm import cmp_pcm +from tests.conftest import DecoderFrontend, EncoderFrontend, parse_properties + + test_dict = {} TEST_DIR = "evs_be_test" scripts = [ @@ -47,6 +50,7 @@ scripts = [ "Readme_EVS_enc.txt", "Readme_JBM_dec.txt", ] + for s in scripts: with open(os.path.join(TEST_DIR, s), "r", encoding="UTF-8") as fp: tag = "" @@ -71,61 +75,101 @@ for s in scripts: diff_opts = "" @pytest.mark.parametrize("test_tag", list(test_dict.keys())) -def test_evs_26444(runner_frontend, test_tag): +def test_evs_26444( + record_property, + props_to_record, + dut_encoder_frontend: EncoderFrontend, + dut_decoder_frontend: DecoderFrontend, + ref_decoder_frontend: DecoderFrontend, + test_tag, + get_mld, + get_mld_lim, + abs_tol, + get_ssnr, + get_odg, +): enc_opts, dec_opts, diff_opts = test_dict[test_tag] - result = None - if enc_opts: - enc_opts = enc_opts.replace("./", TEST_DIR + "/") - enc_opts = enc_opts.replace("-rf rf_config.cfg", "-rf " + TEST_DIR + "/rf_config.cfg") # Special handling of this arguments since the path is missing - cmd = ["./IVAS_cod", "-q"] + enc_opts.split()[1:] - print(" ".join(["Encoder command: "] + cmd)) - runner_frontend.run(cmd) - if dec_opts: - dec_opts = dec_opts.replace("./", TEST_DIR + "/") - cmd = ["./IVAS_dec", "-q"] + dec_opts.split()[1:] - print(" ".join(["Decoder command: "] + cmd)) - runner_frontend.run(cmd) - - result = runner_frontend.result - - if result != None and result.returncode: - pytest.fail("Non-zero returncode for command: " + " ".join(cmd)) - diff_opts = diff_opts.replace("./", TEST_DIR + "/") - if ";" in diff_opts: - cmd1, cmd2 = diff_opts.split(";") - cmd1 = cmd1.split() - cmd2 = cmd2.split() - result1 = filecmp.cmp(cmd1[0], cmd1[1]) - result2 = filecmp.cmp(cmd2[2], cmd2[3]) - else: - cmd1 = diff_opts.split() - result1 = filecmp.cmp(cmd1[0], cmd1[1]) - result2 = True - if not (result1 and result2): - pytest.fail("Output differs") + if enc_opts: + args = enc_opts.split()[1:] -class Runner: - def __init__(self) -> None: - self.returncode = None - self.result = None + bitrate = args[-4] + sampling_rate = args[-3] + in_file = args[-2] + out_file = args[-1] + add_option_list = args[:-4] + + dut_encoder_frontend.run( + bitrate, + sampling_rate, + in_file, + out_file, + add_option_list=add_option_list, + run_dir=TEST_DIR, + ) - def run(self, cmd: str) -> None: - result = subprocess.run(cmd, capture_output=True, check=False) - self.result = result - self.returncode = result.returncode - def _check_run(self): - if self.returncode is not None: - if self.returncode: - pytest.fail( "Command terminated with a non-0 return code" ) - -@pytest.fixture(scope="function") -def runner_frontend() -> Runner: - runner = Runner() - yield runner + if dec_opts: + args = dec_opts.split()[1:] + output_config = "" # Empty for EVS operation + sampling_rate = args[-3] + in_file = args[-2] + out_file = args[-1] + add_option_list = args[:-3] + + dut_decoder_frontend.run( + output_config, + sampling_rate, + in_file, + out_file, + add_option_list=add_option_list, + run_dir=TEST_DIR, + ) + + # Run comparison on encoder and decoder test cases + equal = True + for diff_opt in diff_opts.split(';'): + pattern = r'(\$DIFF_BIN\s?-w\s?)?' + diff_opt = re.sub(pattern, '', diff_opt).strip() + [ref, test] = diff_opt.split()[:2] + if enc_opts and (get_mld or get_ssnr or get_odg): + for file in [ref, test]: + output_config = "" # Empty for EVS operation + in_file = file + out_file = file + '.wav' + add_option_list = [] + ref_decoder_frontend.run( + output_config, + sampling_rate, + in_file, + out_file, + add_option_list=add_option_list, + ) + + fs = int(sampling_rate) * 1000 + output_differs, reason = cmp_pcm( + ref + ".wav", + test + ".wav", + output_config, + fs, + get_mld=get_mld, + mld_lim=get_mld_lim, + abs_tol=abs_tol, + allow_differing_lengths=False, + get_ssnr=get_ssnr, + get_odg=get_odg, + ) + + props = parse_properties(reason, output_differs, props_to_record) + for k, v in props.items(): + record_property(k, v) + equal &= output_differs == False + + else: + equal &= filecmp.cmp(ref, test) + + if not equal: + pytest.fail("Output differs") - # Fixture teardown - runner._check_run() -- GitLab From e0c090e9359a7e822b5e146f86becce72cc9d791 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Mon, 16 Sep 2024 15:04:15 +0200 Subject: [PATCH 2/7] Add measurement of decoder outputs for test_26444 --- scripts/parse_xml_report.py | 17 ++++++++++++-- tests/test_26444.py | 45 +++++++++++++++++++++++-------------- 2 files changed, 43 insertions(+), 19 deletions(-) diff --git a/scripts/parse_xml_report.py b/scripts/parse_xml_report.py index 366e02aba5..627f11a55c 100644 --- a/scripts/parse_xml_report.py +++ b/scripts/parse_xml_report.py @@ -12,7 +12,7 @@ Parse a junit report and create a summary report. PROPERTIES = ["MLD", "MAXIMUM ABS DIFF", "MIN_SSNR", "MIN_ODG"] -FORMATS = { +IVAS_FORMATS = { "Stereo": r"stereo", "ISM": r"ISM", "Multichannel": r"Multi-channel", @@ -23,6 +23,15 @@ FORMATS = { "Renderer": r"renderer", } +EVS_FORMATS = { + "AMRWB I/O dec": r"Readme_AMRWB_IO_dec", + "AMRWB I/O enc": r"Readme_AMRWB_IO_enc", + "EVS dec": r"Readme_EVS_dec", + "EVS enc": r"Readme_EVS_enc", + "EVS JBM dec": r"Readme_JBM_dec", +} + + CATEGORIES = { "Normal operation": r".*", "DTX": r"DTX", @@ -42,10 +51,14 @@ if __name__ == "__main__": help="XML junit report input file, e.g. report-junit.xml", ) parser.add_argument("csv_file", type=str, help="Output CSV file, e.g. report.csv") + parser.add_argument("--evs", action="store_true") args = parser.parse_args() xml_report = args.xml_report csv_file = args.csv_file - + if (args.evs): + FORMATS = EVS_FORMATS + else: + FORMATS = IVAS_FORMATS tree = ElementTree.parse(xml_report) testsuite = tree.find(".//testsuite") diff --git a/tests/test_26444.py b/tests/test_26444.py index cebc5eb045..18bdd75b2e 100644 --- a/tests/test_26444.py +++ b/tests/test_26444.py @@ -36,6 +36,7 @@ import filecmp import os import re import pytest +import shutil from tests.cmp_pcm import cmp_pcm from tests.conftest import DecoderFrontend, EncoderFrontend, parse_properties @@ -134,24 +135,34 @@ def test_evs_26444( pattern = r'(\$DIFF_BIN\s?-w\s?)?' diff_opt = re.sub(pattern, '', diff_opt).strip() [ref, test] = diff_opt.split()[:2] - if enc_opts and (get_mld or get_ssnr or get_odg): - for file in [ref, test]: - output_config = "" # Empty for EVS operation - in_file = file - out_file = file + '.wav' - add_option_list = [] - ref_decoder_frontend.run( - output_config, - sampling_rate, - in_file, - out_file, - add_option_list=add_option_list, - ) - - fs = int(sampling_rate) * 1000 + # Run audio file comparison if MLD/SSNR/PEAQ is requested and the test is either a bitstream or audio (not JBM tracefile) + if (get_mld or get_ssnr or get_odg) and ("COD" in ref or "OUT" in ref): + if enc_opts: + for file in [ref, test]: + output_config = "" # Empty for EVS operation + in_file = file + out_file = file + '.wav' + add_option_list = [] + ref_decoder_frontend.run( + output_config, + sampling_rate, + in_file, + out_file, + add_option_list=add_option_list, + ) + fs = int(sampling_rate) * 1000 + reffile = ref + ".wav" + testfile = test + ".wav" + else: + fs = int(re.search(r'(\d+)kHz', ref).group(1)) * 1000 + # pyaudio3dtools.audiofile.readfile only handles .wav, .pcm and .raw suffixes. + reffile = ref +".pcm" + testfile = test + ".pcm" + shutil.copy(ref, reffile) + shutil.copy(test, testfile) output_differs, reason = cmp_pcm( - ref + ".wav", - test + ".wav", + reffile, + testfile, output_config, fs, get_mld=get_mld, -- GitLab From 2f743053b527d5c7e2a82677415d3c5dccd497b6 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Mon, 16 Sep 2024 15:41:27 +0200 Subject: [PATCH 3/7] Restore import in cmp_pcm.py --- tests/cmp_pcm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cmp_pcm.py b/tests/cmp_pcm.py index 72cd5af7ce..d048fa4b10 100755 --- a/tests/cmp_pcm.py +++ b/tests/cmp_pcm.py @@ -15,7 +15,7 @@ sys.path.append(os.path.join(os.path.dirname(THIS_PATH), "../scripts")) import numpy as np import pyaudio3dtools import pyivastest -from constants import ODG_PATTERN_PQEVALAUDIO +from .constants import ODG_PATTERN_PQEVALAUDIO def cmp_pcm( -- GitLab From 9cb4fc22a97cc260bc2046bdca137782546a6e57 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Mon, 16 Sep 2024 16:44:42 +0200 Subject: [PATCH 4/7] Add EVS categories for improved parsing --- scripts/create_histogram_summary.py | 15 +++++++++++++-- scripts/parse_xml_report.py | 24 +++++++++++++++++------- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/scripts/create_histogram_summary.py b/scripts/create_histogram_summary.py index 1ab951ac72..48f62d5641 100644 --- a/scripts/create_histogram_summary.py +++ b/scripts/create_histogram_summary.py @@ -10,7 +10,7 @@ matplotlib.use("Agg") import matplotlib.pyplot as plt import csv import os -from parse_xml_report import FORMATS, CATEGORIES +from parse_xml_report import IVAS_FORMATS, EVS_FORMATS, IVAS_CATEGORIES, EVS_CATEGORIES """ Parses a CSV report and creates a summary report. @@ -44,12 +44,23 @@ if __name__ == "__main__": help="Measure, any of: MLD, DIFF, SSNR, default: MLD", default=["MLD"], ) + parser.add_argument( + "--evs", + action="store_true", + help="Parse using EVS 26.444 formats", + ) args = parser.parse_args() csv_report = args.csv_report csv_summary = args.csv_summary csv_image = args.csv_image measure = args.measure[0] - + if args.evs: + FORMATS = EVS_FORMATS + CATEGORIES = EVS_CATEGORIES + else: + FORMATS = IVAS_FORMATS + CATEGORIES = IVAS_CATEGORIES + limits_per_measure = { "MLD": ("MLD", [0, 5, 10, math.inf]), "DIFF": ("MAXIMUM ABS DIFF", [0, 1024, 16384, 32769]), diff --git a/scripts/parse_xml_report.py b/scripts/parse_xml_report.py index 627f11a55c..396a86d977 100644 --- a/scripts/parse_xml_report.py +++ b/scripts/parse_xml_report.py @@ -24,15 +24,15 @@ IVAS_FORMATS = { } EVS_FORMATS = { - "AMRWB I/O dec": r"Readme_AMRWB_IO_dec", - "AMRWB I/O enc": r"Readme_AMRWB_IO_enc", - "EVS dec": r"Readme_EVS_dec", - "EVS enc": r"Readme_EVS_enc", - "EVS JBM dec": r"Readme_JBM_dec", + "AMRWBIO_dec": r"Readme_AMRWB_IO_dec", + "AMRWBIO_enc": r"Readme_AMRWB_IO_enc", + "EVS_dec": r"Readme_EVS_dec", + "EVS_enc": r"Readme_EVS_enc", + "EVS_JBM_dec": r"Readme_JBM_dec", } -CATEGORIES = { +IVAS_CATEGORIES = { "Normal operation": r".*", "DTX": r"DTX", "PLC": r"%", @@ -40,6 +40,14 @@ CATEGORIES = { "JBM": r"JBM", } +EVS_CATEGORIES = { + "Normal operation": r".*", + "DTX": r"DTX", + "PLC": r"b10|f06", + "Bitrate switching": r"sw", + "JBM": r"JBM", +} + # Main routine if __name__ == "__main__": parser = argparse.ArgumentParser( @@ -51,14 +59,16 @@ if __name__ == "__main__": help="XML junit report input file, e.g. report-junit.xml", ) parser.add_argument("csv_file", type=str, help="Output CSV file, e.g. report.csv") - parser.add_argument("--evs", action="store_true") + parser.add_argument("--evs", action="store_true", help="Parse using EVS 26.444 formats",) args = parser.parse_args() xml_report = args.xml_report csv_file = args.csv_file if (args.evs): FORMATS = EVS_FORMATS + CATEGORIES = EVS_CATEGORIES else: FORMATS = IVAS_FORMATS + CATEGORIES = IVAS_CATEGORIES tree = ElementTree.parse(xml_report) testsuite = tree.find(".//testsuite") -- GitLab From c523bb0aa446880c4cf4a07ab36704b953f06e42 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Tue, 17 Sep 2024 08:59:12 +0200 Subject: [PATCH 5/7] Restore conftest.py. Require -ref_decoder_path for audio comparison in test_26444 --- tests/conftest.py | 10 ++++++++-- tests/test_26444.py | 3 ++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index b6fffa197a..06658dd7e1 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -451,6 +451,9 @@ def ref_encoder_path(request) -> str: if request.config.option.ref_encoder_path: return request.config.option.ref_encoder_path + if request.config.option.update_ref == "0": + return None + # assume specifically named encoder when update_ref is selected, but no ref_encoder_path is specified here = Path(__file__).parent.resolve() system = platform.system() @@ -471,7 +474,7 @@ def ref_encoder_path(request) -> str: @pytest.fixture(scope="function") -def ref_encoder_frontend(ref_encoder_path, request) -> EncoderFrontend: +def ref_encoder_frontend(ref_encoder_path, request) -> Union[None, EncoderFrontend]: """ Return a :class:`conftest.EncoderFrontend` instance as REF for the test session. """ @@ -697,6 +700,9 @@ def ref_decoder_path(request) -> str: if request.config.option.ref_decoder_path: return request.config.option.ref_decoder_path + if request.config.option.update_ref == "0": + return None + # assume specifically named decoder when update_ref is selected, but no ref_decoder_path is specified here = Path(__file__).parent.resolve() system = platform.system() @@ -717,7 +723,7 @@ def ref_decoder_path(request) -> str: @pytest.fixture(scope="function") -def ref_decoder_frontend(ref_decoder_path, request) -> DecoderFrontend: +def ref_decoder_frontend(ref_decoder_path, request) -> Union[None, DecoderFrontend]: """ Return a :class:`conftest.DecoderFrontend` instance as DUT for the test session. """ diff --git a/tests/test_26444.py b/tests/test_26444.py index 18bdd75b2e..de1f4d0158 100644 --- a/tests/test_26444.py +++ b/tests/test_26444.py @@ -136,7 +136,8 @@ def test_evs_26444( diff_opt = re.sub(pattern, '', diff_opt).strip() [ref, test] = diff_opt.split()[:2] # Run audio file comparison if MLD/SSNR/PEAQ is requested and the test is either a bitstream or audio (not JBM tracefile) - if (get_mld or get_ssnr or get_odg) and ("COD" in ref or "OUT" in ref): + # and the ref_decoder_path is specified (otherwise ref_decoder_frontend is None) + if (get_mld or get_ssnr or get_odg) and ("COD" in ref or "OUT" in ref) and ref_decoder_frontend: if enc_opts: for file in [ref, test]: output_config = "" # Empty for EVS operation -- GitLab From ba2973ef2dee931a260869af8f6db5d0eb7784e8 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 17 Sep 2024 13:01:30 +0200 Subject: [PATCH 6/7] run formatter --- scripts/create_histogram_summary.py | 10 +++++---- scripts/parse_xml_report.py | 8 +++++-- tests/cmp_pcm.py | 20 ++++++++++++----- tests/test_26444.py | 35 ++++++++++++++++------------- 4 files changed, 45 insertions(+), 28 deletions(-) diff --git a/scripts/create_histogram_summary.py b/scripts/create_histogram_summary.py index 48f62d5641..6e940c883a 100644 --- a/scripts/create_histogram_summary.py +++ b/scripts/create_histogram_summary.py @@ -3,9 +3,11 @@ import argparse import math import numpy as np + # These next three lines are added as a precaution in case the gitlab runner # needs DISPLAY to render the plots, even if they are written to file. import matplotlib + matplotlib.use("Agg") import matplotlib.pyplot as plt import csv @@ -45,9 +47,9 @@ if __name__ == "__main__": default=["MLD"], ) parser.add_argument( - "--evs", - action="store_true", - help="Parse using EVS 26.444 formats", + "--evs", + action="store_true", + help="Parse using EVS 26.444 formats", ) args = parser.parse_args() csv_report = args.csv_report @@ -60,7 +62,7 @@ if __name__ == "__main__": else: FORMATS = IVAS_FORMATS CATEGORIES = IVAS_CATEGORIES - + limits_per_measure = { "MLD": ("MLD", [0, 5, 10, math.inf]), "DIFF": ("MAXIMUM ABS DIFF", [0, 1024, 16384, 32769]), diff --git a/scripts/parse_xml_report.py b/scripts/parse_xml_report.py index 396a86d977..3be7a9ca0b 100644 --- a/scripts/parse_xml_report.py +++ b/scripts/parse_xml_report.py @@ -59,11 +59,15 @@ if __name__ == "__main__": help="XML junit report input file, e.g. report-junit.xml", ) parser.add_argument("csv_file", type=str, help="Output CSV file, e.g. report.csv") - parser.add_argument("--evs", action="store_true", help="Parse using EVS 26.444 formats",) + parser.add_argument( + "--evs", + action="store_true", + help="Parse using EVS 26.444 formats", + ) args = parser.parse_args() xml_report = args.xml_report csv_file = args.csv_file - if (args.evs): + if args.evs: FORMATS = EVS_FORMATS CATEGORIES = EVS_CATEGORIES else: diff --git a/tests/cmp_pcm.py b/tests/cmp_pcm.py index d048fa4b10..5b335840e6 100755 --- a/tests/cmp_pcm.py +++ b/tests/cmp_pcm.py @@ -128,18 +128,26 @@ def cmp_pcm( def pqevalaudio_wrapper( - ref_sig: np.ndarray, - eval_sig: np.ndarray, - fs: int, - ) -> str: + ref_sig: np.ndarray, + eval_sig: np.ndarray, + fs: int, +) -> str: with tempfile.TemporaryDirectory() as tmp_dir: tmp_dir = Path(tmp_dir) tmp_file_ref = str(tmp_dir.joinpath("ref.wav")) tmp_file_eval = str(tmp_dir.joinpath("eval.wav")) # PQevalAudio neeeds 48 kHz sampling rate - r48 = np.clip( pyaudio3dtools.audioarray.resample(ref_sig.astype(float), fs, 48000), -32768, 32767 ).astype(np.int16) - t48 = np.clip( pyaudio3dtools.audioarray.resample(eval_sig.astype(float), fs, 48000), -32768, 32767 ).astype(np.int16) + r48 = np.clip( + pyaudio3dtools.audioarray.resample(ref_sig.astype(float), fs, 48000), + -32768, + 32767, + ).astype(np.int16) + t48 = np.clip( + pyaudio3dtools.audioarray.resample(eval_sig.astype(float), fs, 48000), + -32768, + 32767, + ).astype(np.int16) pyaudio3dtools.audiofile.writefile(tmp_file_ref, r48, 48000) pyaudio3dtools.audiofile.writefile(tmp_file_eval, t48, 48000) diff --git a/tests/test_26444.py b/tests/test_26444.py index de1f4d0158..bd3fb98c0c 100644 --- a/tests/test_26444.py +++ b/tests/test_26444.py @@ -75,6 +75,7 @@ for s in scripts: dec_opts = "" diff_opts = "" + @pytest.mark.parametrize("test_tag", list(test_dict.keys())) def test_evs_26444( record_property, @@ -87,10 +88,10 @@ def test_evs_26444( get_mld_lim, abs_tol, get_ssnr, - get_odg, + get_odg, ): enc_opts, dec_opts, diff_opts = test_dict[test_tag] - + diff_opts = diff_opts.replace("./", TEST_DIR + "/") if enc_opts: @@ -101,7 +102,7 @@ def test_evs_26444( in_file = args[-2] out_file = args[-1] add_option_list = args[:-4] - + dut_encoder_frontend.run( bitrate, sampling_rate, @@ -111,10 +112,9 @@ def test_evs_26444( run_dir=TEST_DIR, ) - if dec_opts: args = dec_opts.split()[1:] - output_config = "" # Empty for EVS operation + output_config = "" # Empty for EVS operation sampling_rate = args[-3] in_file = args[-2] out_file = args[-1] @@ -127,22 +127,26 @@ def test_evs_26444( out_file, add_option_list=add_option_list, run_dir=TEST_DIR, - ) + ) # Run comparison on encoder and decoder test cases equal = True - for diff_opt in diff_opts.split(';'): - pattern = r'(\$DIFF_BIN\s?-w\s?)?' - diff_opt = re.sub(pattern, '', diff_opt).strip() + for diff_opt in diff_opts.split(";"): + pattern = r"(\$DIFF_BIN\s?-w\s?)?" + diff_opt = re.sub(pattern, "", diff_opt).strip() [ref, test] = diff_opt.split()[:2] # Run audio file comparison if MLD/SSNR/PEAQ is requested and the test is either a bitstream or audio (not JBM tracefile) # and the ref_decoder_path is specified (otherwise ref_decoder_frontend is None) - if (get_mld or get_ssnr or get_odg) and ("COD" in ref or "OUT" in ref) and ref_decoder_frontend: + if ( + (get_mld or get_ssnr or get_odg) + and ("COD" in ref or "OUT" in ref) + and ref_decoder_frontend + ): if enc_opts: for file in [ref, test]: - output_config = "" # Empty for EVS operation + output_config = "" # Empty for EVS operation in_file = file - out_file = file + '.wav' + out_file = file + ".wav" add_option_list = [] ref_decoder_frontend.run( output_config, @@ -155,9 +159,9 @@ def test_evs_26444( reffile = ref + ".wav" testfile = test + ".wav" else: - fs = int(re.search(r'(\d+)kHz', ref).group(1)) * 1000 - # pyaudio3dtools.audiofile.readfile only handles .wav, .pcm and .raw suffixes. - reffile = ref +".pcm" + fs = int(re.search(r"(\d+)kHz", ref).group(1)) * 1000 + # pyaudio3dtools.audiofile.readfile only handles .wav, .pcm and .raw suffixes. + reffile = ref + ".pcm" testfile = test + ".pcm" shutil.copy(ref, reffile) shutil.copy(test, testfile) @@ -184,4 +188,3 @@ def test_evs_26444( if not equal: pytest.fail("Output differs") - -- GitLab From 2822dd963a3c469cf366c601065b54e2e24f4355 Mon Sep 17 00:00:00 2001 From: norvell Date: Tue, 17 Sep 2024 11:10:20 +0000 Subject: [PATCH 7/7] Update test_26444.py --- tests/test_26444.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_26444.py b/tests/test_26444.py index bd3fb98c0c..fa6214c66a 100644 --- a/tests/test_26444.py +++ b/tests/test_26444.py @@ -181,7 +181,7 @@ def test_evs_26444( props = parse_properties(reason, output_differs, props_to_record) for k, v in props.items(): record_property(k, v) - equal &= output_differs == False + equal &= not output_differs else: equal &= filecmp.cmp(ref, test) -- GitLab