Commit 87facdcc authored by norvell's avatar norvell
Browse files

Merge branch 'ci/report-errors-in-test-26444' into 'main'

[BASOP CI] Fixes in test_26444.py to report errors

See merge request !1481
parents 83ae357d b0bc9d0e
Loading
Loading
Loading
Loading
Loading
+39 −5
Original line number Diff line number Diff line
@@ -70,17 +70,27 @@ for s in scripts:
                dec_opts = ""
                diff_opts = ""


@pytest.mark.parametrize("test_tag", list(test_dict.keys()))
def test_evs_26444(test_tag):
def test_evs_26444(runner_frontend, test_tag):
    enc_opts, dec_opts, diff_opts = test_dict[test_tag]
    
    result = None
    if enc_opts:
        enc_opts = enc_opts.replace("./", TEST_DIR + "/")
        subprocess.run(["./IVAS_cod", "-q"] + enc_opts.split()[1:])
        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 + "/")
        subprocess.run(["./IVAS_dec", "-q"] + dec_opts.split()[1:])
        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:
@@ -95,3 +105,27 @@ def test_evs_26444(test_tag):
        result2 = True
    if not (result1 and result2):
        pytest.fail("Output differs")


class Runner:
    def __init__(self) -> None:
        self.returncode = None
        self.result = None

    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

    # Fixture teardown
    runner._check_run()