Commit 03c50ca3 authored by BOHMRR's avatar BOHMRR
Browse files

pytest: count non-zero return codes of DUT encoder and decoder as errors and...

pytest: count non-zero return codes of DUT encoder and decoder as errors and let non-BE MR pipeline fail
parent 474fe913
Loading
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -165,7 +165,8 @@ self-test-on-merge-request:
    - exit_code=0
    - python3 ./scripts/ivas_pytests/self_test_b.py --encref IVAS_cod_ref --decref IVAS_dec_ref --encdut IVAS_cod_test --decdut IVAS_dec_test || exit_code=$?
    - if [ $exit_code -eq 1 ] && [ $non_be_flag == 0 ]; then echo "pytest run had failures and non-BE flag not present"; exit $EXIT_CODE_FAIL; fi
    - if [ $exit_code -eq 1 ]; then echo "pytest run had failures and non-BE flag present"; exit $EXIT_CODE_NON_BE; fi
    - zero_errors=$(cat report-junit.xml | grep -c 'testsuite errors="0"') || true
    - if [ $exit_code -eq 1 ] && [ $zero_errors == 1]; then echo "pytest run had failures, but no errors and non-BE flag present"; exit $EXIT_CODE_NON_BE; fi
    - if [ $exit_code -ne 0 ]; then echo "pytest run had errors"; exit $EXIT_CODE_FAIL; fi;
    # return exit code from selftest if everything went well with the pytest run
    - exit $selftest_exit_code
+1 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@
# note: per convention, this file is placed in the root directory of the repository
[pytest]
addopts = -ra --tb=short --basetemp=./tmp -v
junit_family=xunit1
log_file_level = DEBUG
log_format = %(asctime)s %(levelname)s %(message)s
log_date_format = %Y-%m-%d %H:%M:%S
+12 −8
Original line number Diff line number Diff line
@@ -206,11 +206,13 @@ class EncoderFrontend:
        if self.stderr:
            stderr_str = textwrap.indent(self.stderr, prefix="\t")
            log_dbg_msg(f"{self._type} encoder stderr:\n{stderr_str}")
        assert self.returncode == 0, self._type + " encoder terminated with a non-0 return code"
        if self.returncode:
            pytest.fail(f"{self._type} encoder terminated with a non-0 return code: {self.returncode}")

    def _check_run(self):
        if self.returncode is not None:
            if self.returncode:
            assert self.returncode == 0, self._type + " encoder terminated with a non-0 return code"
                pytest.fail(f"{self._type} encoder terminated with a non-0 return code: {self.returncode}")
        else:
            logger.warning("%s encoder was set-up, but not run", self._type)
        # next assert is not OK since stderr contains messages even when encoding was successful
@@ -223,7 +225,7 @@ def dut_encoder_frontend(dut_encoder_path) -> EncoderFrontend:
    yield encoder

    # Fixture teardown
#    encoder._check_run()
    encoder._check_run()


@pytest.fixture(scope="session")
@@ -322,11 +324,13 @@ class DecoderFrontend:
        if self.stderr:
            stderr_str = textwrap.indent(self.stderr, prefix="\t")
            log_dbg_msg(f"{self._type} decoder stderr:\n{stderr_str}")
        assert self.returncode == 0, self._type + " decoder terminated with a non-0 return code"
        if self.returncode:
            pytest.fail(f"{self._type} decoder terminated with a non-0 return code: {self.returncode}")

    def _check_run(self):
        if self.returncode is not None:
            if self.returncode:
            assert self.returncode == 0, self._type + " decoder terminated with a non-0 return code"
                pytest.fail(f"{self._type} decoder terminated with a non-0 return code: {self.returncode}")
        else:
            logger.warning("%s decoder was set-up, but not run", self._type)
        # next assert is not OK since stderr contains messages even when decoding was successful
@@ -339,7 +343,7 @@ def dut_decoder_frontend(dut_decoder_path) -> DecoderFrontend:
    yield decoder

    # Fixture teardown
#    decoder._check_run()
    decoder._check_run()


@pytest.fixture(scope="session")