Commit 60ec82e7 authored by Jan Kiene's avatar Jan Kiene
Browse files

change command execution handling, integrate USAN capture

parent f064eb3a
Loading
Loading
Loading
Loading
Loading
+1 −5
Original line number Diff line number Diff line
@@ -618,11 +618,7 @@ renderer-usan:
    - mv IVAS_dec IVAS_dec_ref
    - mv IVAS_rend IVAS_rend_ref
    - testcase_timeout=180
    - UBSAN_OPTIONS=suppressions=scripts/ubsan.supp,report_error_type=1,log_path=usan_log_catchall python3 -m pytest -q -n auto -rA --junit-xml=report-junit.xml tests/renderer/test_renderer.py tests/split_rendering/test_split_rendering.py --create_ref --testcase_timeout=$testcase_timeout
    - grep_exit_code=0
    - touch usan_log_empty # Creates an empty file, this is to avoid "grep: usan_log_*: No such file or directory" in case no USAN failures are reported from pytest
    - grep UndefinedBehaviorSanitizer usan_log_* || grep_exit_code=$?
    - if [ $grep_exit_code != 1 ] ; then echo "Run errors in test_renderer.py with Clang undefined-behavior-sanitizer"; exit 1; fi
    - UBSAN_OPTIONS=suppressions=scripts/ubsan.supp,report_error_type=1 python3 -m pytest -q -n auto -rA --junit-xml=report-junit.xml tests/renderer/test_renderer.py tests/split_rendering/test_split_rendering.py --create_ref --testcase_timeout=$testcase_timeout

  artifacts:
    name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--job-$CI_JOB_NAME--results"
+31 −30
Original line number Diff line number Diff line
@@ -67,53 +67,54 @@ from ..cmp_pcm import cmp_pcm
from ..conftest import parse_properties, get_split_idx


def run_cmd(cmd, test_info, env=None):
    logging.info(f"\nRunning command\n{' '.join(cmd)}\n")
def _run_cmd(cmd, env, test_info=None):
    """
    Helper function for running some command.
    Raises a SystemError if either the return code is non-zero or a USAN printout is detected
    """
    proc = sp.run(cmd, capture_output=True, text=True, env=env)
    stdout = proc.stdout + proc.stderr

    # check for USAN error first
    if "UndefinedBehaviorSanitizer" in stdout:
        error = f"USAN error detected in stdout of command: {' '.join(cmd)}\n{stdout}"
        if test_info is not None:
            test_info.error = error
        raise SystemError(error)

    # then handle possible crash
    try:
        sp.run(cmd, check=True, capture_output=True, text=True, env=env)
        proc.check_returncode()
    except sp.CalledProcessError as e:
        test_info.error = f"Command returned non-zero exit status ({e.returncode}): {' '.join(e.cmd)}\n{e.stderr}\n{e.stdout}"
        raise SystemError(test_info.error)
        error = f"Command returned non-zero exit status ({e.returncode}): {' '.join(e.cmd)}\n{e.stderr}\n{e.stdout}"
        if test_info is not None:
            test_info.error = error
        raise SystemError(error)


def run_cmd(cmd, test_info, env=None):
    logging.info(f"\nRunning command\n{' '.join(cmd)}\n")
    _run_cmd(cmd, env, test_info)


def run_isar_ext_rend_cmd(cmd, env=None):
    logging.info(f"\nRunning ISAR EXT REND command\n{' '.join(cmd)}\n")
    try:
        sp.run(cmd, check=True, capture_output=True, text=True, env=env)
    except sp.CalledProcessError as e:
        raise SystemError(
            f"Command returned non-zero exit status ({e.returncode}): {' '.join(e.cmd)}\n{e.stderr}\n{e.stdout}"
        )
    _run_cmd(cmd, env)


def run_ivas_isar_enc_cmd(cmd, env=None):
    logging.info(f"\nRunning IVAS ISAR encoder command\n{' '.join(cmd)}\n")
    try:
        sp.run(cmd, check=True, capture_output=True, text=True, env=env)
    except sp.CalledProcessError as e:
        raise SystemError(
            f"Command returned non-zero exit status ({e.returncode}): {' '.join(e.cmd)}\n{e.stderr}\n{e.stdout}"
        )
    _run_cmd(cmd, env)


def run_ivas_isar_dec_cmd(cmd, env=None):
    logging.info(f"\nDUT decoder command:\n\t{' '.join(cmd)}\n")
    try:
        sp.run(cmd, check=True, capture_output=True, text=True, env=env)
    except sp.CalledProcessError as e:
        raise SystemError(
            f"Command returned non-zero exit status ({e.returncode}): {' '.join(e.cmd)}\n{e.stderr}\n{e.stdout}"
        )
    _run_cmd(cmd, env)


def run_isar_post_rend_cmd(cmd, env=None):
    logging.info(f"\nRunning ISAR post renderer command\n{' '.join(cmd)}\n")
    try:
        sp.run(cmd, check=True, capture_output=True, text=True, env=env)
    except sp.CalledProcessError as e:
        raise SystemError(
            f"Command returned non-zero exit status ({e.returncode}): {' '.join(e.cmd)}\n{e.stderr}\n{e.stdout}"
        )
    _run_cmd(cmd, env)


def check_BE(