Commit 1a1717f1 authored by Jan Kiene's avatar Jan Kiene
Browse files

execute codec binaries always in temporary dir

parent 9f4c783c
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -176,7 +176,7 @@ def test_param_file_tests(

    # bitrate can be a filename: remove leading "../"
    if bitrate.startswith("../"):
        bitrate = bitrate[3:]
        bitrate = Path(bitrate[3:]).absolute()

    testv_base = testv_file.split("/")[-1]
    if testv_base.endswith(".pcm"):
@@ -331,8 +331,12 @@ def test_param_file_tests(
            ref_tracefile_dec = f"{reference_path}/param_file/dec/{tracefile_dec}"

            # check for same RTP sequence number in last line of tracefile
            dut_rtp_num_last = np.genfromtxt(dut_tracefile_dec, delimiter=";", usecols=[0])[-1]
            ref_rtp_num_last = np.genfromtxt(ref_tracefile_dec, delimiter=";", usecols=[0])[-1]
            dut_rtp_num_last = np.genfromtxt(
                dut_tracefile_dec, delimiter=";", usecols=[0]
            )[-1]
            ref_rtp_num_last = np.genfromtxt(
                ref_tracefile_dec, delimiter=";", usecols=[0]
            )[-1]
            tracefile_last_rtp_numbers_differ = dut_rtp_num_last != ref_rtp_num_last

        # same sequence number -> likely no crash, assume length difference is due to difference in TSM
+3 −1
Original line number Diff line number Diff line
@@ -35,6 +35,8 @@ __doc__ = """

import errno
import os
import tempfile
from pathlib import Path

import pytest
from cut_bs import cut_from_start
+51 −21
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import platform
import textwrap
from pathlib import Path
from subprocess import TimeoutExpired, run
import tempfile
from typing import Optional, Union
from .constants import MLD_PATTERN, MAX_DIFF_PATTERN, SSNR_PATTERN

@@ -311,7 +312,7 @@ def dut_encoder_path(request) -> str:

class EncoderFrontend:
    def __init__(self, path, enc_type, timeout=None) -> None:
        self._path = path
        self._path = str(Path(path).absolute())
        self._type = enc_type
        self.returncode = None
        self.stdout = None
@@ -320,7 +321,7 @@ class EncoderFrontend:

    def run(
        self,
        bitrate: int,
        bitrate: Union[int, Path],
        input_sampling_rate: int,
        input_path: Path,
        output_bitstream_path: Path,
@@ -365,12 +366,17 @@ class EncoderFrontend:
        log_dbg_msg(f"{self._type} encoder command:\n{cmd_str}")

        try:
            with tempfile.TemporaryDirectory() as tmp_dir:
                if run_dir is None:
                    cwd = tmp_dir
                else:
                    cwd = run_dir
                result = run(
                    command,
                    capture_output=True,
                    check=False,
                    timeout=self.timeout,
                cwd=run_dir,
                    cwd=cwd,
                )
        except TimeoutExpired:
            pytest.fail(f"{self._type} encoder run timed out after {self.timeout}s.")
@@ -492,7 +498,7 @@ def dut_decoder_path(request) -> str:

class DecoderFrontend:
    def __init__(self, path, dec_type, timeout=None, fr=20) -> None:
        self._path = path
        self._path = str(Path(path).absolute())
        self._type = dec_type
        self.returncode = None
        self.stdout = None
@@ -546,7 +552,12 @@ class DecoderFrontend:

            try:
                if not os.path.exists(str(input_bitstream_path) + eid_output_suffix):
                    result = run(eid_command, check=True, cwd=run_dir)
                    with tempfile.TemporaryDirectory() as tmp_dir:
                        if run_dir is None:
                            cwd = tmp_dir
                        else:
                            cwd = run_dir
                        result = run(eid_command, check=True, cwd=cwd)
            except Exception as e:
                pytest.fail(f"eid-xor operation failed! - {e}")

@@ -566,14 +577,28 @@ class DecoderFrontend:
                raise ValueError(f'Wrong system "{system}"!')

            if not os.path.isfile(netsim_path):
                raise FileNotFoundError(f"network simulator binary {netsim_path} not found!\n")
                raise FileNotFoundError(
                    f"network simulator binary {netsim_path} not found!\n"
                )
            netsim_bitstream_path = input_bitstream_path.with_suffix(".netsimout")
            tracefile_path = input_bitstream_path.with_suffix(".netsimtrace")
            # TODO: need to check if the "1" works with every profile
            netsim_command = [netsim_path, netsim_profile, input_bitstream_path, netsim_bitstream_path, tracefile_path, "1"]
            netsim_command = [
                netsim_path,
                netsim_profile,
                input_bitstream_path,
                netsim_bitstream_path,
                tracefile_path,
                "1",
            ]
            print(netsim_command)
            try:
                run(netsim_command, check=True, cwd=run_dir)
                with tempfile.TemporaryDirectory() as tmp_dir:
                    if run_dir is None:
                        cwd = tmp_dir
                    else:
                        cwd = run_dir
                    run(netsim_command, check=True, cwd=cwd)
            except Exception as e:
                pytest.fail(f"netsim operation failed! - {e}")

@@ -601,12 +626,17 @@ class DecoderFrontend:
        log_dbg_msg(f"{self._type} decoder command:\n{cmd_str}")

        try:
            with tempfile.TemporaryDirectory() as tmp_dir:
                if run_dir is None:
                    cwd = tmp_dir
                else:
                    cwd = run_dir
                result = run(
                    command,
                    capture_output=True,
                    check=False,
                    timeout=self.timeout,
                cwd=run_dir,
                    cwd=cwd,
                )
        except TimeoutExpired:
            pytest.fail(f"{self._type} decoder run timed out after {self.timeout}s.")
+1 −1

File changed.

Contains only whitespace changes.