Commit 8c63cd97 authored by BOHMRR's avatar BOHMRR
Browse files

pytest: add --keep_files option

parent 629a2148
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -126,4 +126,6 @@ The custom options are listed as part of the pytest help `pytest -h`.
--reference_path=REFERENCE_PATH      If specified, use given directory as base directory for reference files.
--dut_base_path=DUT_BASE_PATH        If specified, use given directory as base data directory for dut files.
--param_file=PARAM_FILE              If specified, use given param file in test_param_file.
--keep_files                         By default, the DUT output files of successful tests are deleted.
                                     Use --keep_files to prevent these deletions.
```
+20 −0
Original line number Diff line number Diff line
@@ -28,6 +28,11 @@
   the United Nations Convention on Contracts on the International Sales of Goods.
"""

__doc__ = \
"""
Pytest customization (configuration and fixtures) for the IVAS codec test suite.
"""

import logging
from pathlib import Path
import platform
@@ -120,6 +125,13 @@ def pytest_addoption(parser):
        help="If specified, use given param file in test_param_file.",
    )

    parser.addoption(
        "--keep_files",
        action="store_true",
        help="By default, the DUT output files of successful tests are deleted."
        " Use --keep_files to prevent these deletions.",
    )


@pytest.fixture(scope="session", autouse=True)
def update_ref(request):
@@ -132,6 +144,14 @@ def update_ref(request):
    return int(request.config.getoption("--update_ref"))


@pytest.fixture(scope="session")
def keep_files(request) -> bool:
    """
    Return indication to not delete DUT output files.
    """
    return request.config.option.keep_files


@pytest.fixture(scope="session")
def dut_encoder_path(request) -> str:
    """
+15 −7
Original line number Diff line number Diff line
"""
Execute tests specified via a parameter file.
"""

__copyright__ = """
(C) 2022 Baseline Development Group with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
@@ -28,11 +24,16 @@ accordance with the laws of the Federal Republic of Germany excluding its confli
the United Nations Convention on Contracts on the International Sales of Goods.
"""

__doc__ = \
"""
Execute tests specified via a parameter file.
"""

import os
import errno
import pytest
import platform
from subprocess import run
import pytest
from cmp_custom import cmp_custom
from conftest import EncoderFrontend, DecoderFrontend
from testconfig import PARAM_FILE
@@ -123,6 +124,7 @@ def test_param_file_tests(
    test_vector_path,
    update_ref,
    rootdir,
    keep_files,
    test_tag,
):
    enc_opts, dec_opts, sim_opts = param_file_test_dict[test_tag]
@@ -271,8 +273,14 @@ def test_param_file_tests(
            f"{reference_path}/param_file/dec/{output_file}",
        )

        # clean-up
        # TODO: consider removing DUT output files when test result is OK (to save disk space)
        # remove DUT output files when test result is OK (to save disk space)
        if not keep_files:
            os.remove(f"{dut_base_path}/param_file/enc/{bitstream_file}")
            os.remove(f"{dut_base_path}/param_file/dec/{output_file}")
            if sim_opts != "":
                os.remove(f"{dut_base_path}/param_file/enc/{testv_base}_{tag_str}.192")
                os.remove(f"{dut_base_path}/param_file/enc/{netsim_trace_outfile}")
                os.remove(f"{dut_base_path}/param_file/dec/{tracefile_dec}")


def encode(
+30 −8
Original line number Diff line number Diff line
@@ -28,9 +28,14 @@
   the United Nations Convention on Contracts on the International Sales of Goods.
"""

__doc__ = \
"""
Execute SBA decoder tests using different PLC patterns.
"""

import os
import pytest
import errno
import pytest

from cmp_custom import cmp_custom
from conftest import DecoderFrontend
@@ -75,6 +80,7 @@ def test_sba_plc_system(
    dut_base_path,
    ref_decoder_path,
    update_ref,
    keep_files,
    ivas_br,
    dtx,
    tag,
@@ -85,7 +91,21 @@ def test_sba_plc_system(
    tag = tag + fs + 'c'

    #dec
    sba_dec_plc(dut_decoder_frontend, test_vector_path, reference_path, dut_base_path, ref_decoder_path, tag, fs, ivas_br, dtx, plc_pattern, update_ref, agc)
    sba_dec_plc(
        dut_decoder_frontend,
        test_vector_path,
        reference_path,
        dut_base_path,
        ref_decoder_path,
        tag,
        fs,
        ivas_br,
        dtx,
        plc_pattern,
        update_ref,
        agc,
        keep_files,
    )


#########################################################
@@ -102,7 +122,8 @@ def sba_dec_plc(
    dtx,
    plc_pattern,
    update_ref,
    agc
    agc,
    keep_files,
):

    #########  run cmd   #####################################
@@ -159,8 +180,9 @@ def sba_dec_plc(
            end_skip_samples
        )

        ##File removal##
        os.remove(dut_out_raw)

        ##report failure
        # report compare result
        assert cmp_result == 0, reason

        # remove DUT output files when test result is OK (to save disk space)
        if not keep_files:
            os.remove(dut_out_raw)
+27 −16
Original line number Diff line number Diff line
@@ -28,14 +28,15 @@
   the United Nations Convention on Contracts on the International Sales of Goods.
"""

__doc__ = \
"""
Test file to run C encoder and decoder code.
The outputs are compared with C generated references.
"""

import os
import pytest
import errno
import pytest

from cmp_custom import cmp_custom
from cut_pcm import cut_samples
@@ -86,9 +87,10 @@ def test_bypass_enc(
    ref_encoder_path,
    ref_decoder_path,
    update_ref,
    keep_files,
    tag,
    fs,
    bypass
    bypass,
):
    if update_ref == 1 and bypass == 1:
        pytest.skip()
@@ -133,7 +135,8 @@ def test_bypass_enc(
        bypass,
        agc,
        output_config,
        update_ref
        update_ref,
        keep_files,
    )


@@ -152,11 +155,12 @@ def test_sba_enc_system(
    ref_encoder_path,
    ref_decoder_path,
    update_ref,
    keep_files,
    ivas_br,
    dtx,
    tag,
    fs,
    agc
    agc,
):
    tag = tag + fs + 'c'
    max_bw = "FB"
@@ -202,7 +206,8 @@ def test_sba_enc_system(
        bypass,
        agc,
        output_config,
        update_ref
        update_ref,
        keep_files,
    )

@pytest.mark.create_ref
@@ -217,8 +222,9 @@ def test_spar_hoa2_enc_system(
    ref_encoder_path,
    ref_decoder_path,
    update_ref,
    keep_files,
    ivas_br,
    tag
    tag,
):
    fs = '48'
    dtx = '0'
@@ -263,7 +269,8 @@ def test_spar_hoa2_enc_system(
        bypass,
        agc,
        output_config,
        update_ref
        update_ref,
        keep_files,
    )

@pytest.mark.create_ref
@@ -278,8 +285,9 @@ def test_spar_hoa3_enc_system(
    ref_encoder_path,
    ref_decoder_path,
    update_ref,
    keep_files,
    ivas_br,
    tag
    tag,
):
    fs = '48'
    dtx = '0'
@@ -324,7 +332,8 @@ def test_spar_hoa3_enc_system(
        bypass,
        agc,
        output_config,
        update_ref
        update_ref,
        keep_files,
    )

@pytest.mark.create_ref
@@ -341,10 +350,11 @@ def test_sba_enc_BWforce_system(
    ref_encoder_path,
    ref_decoder_path,
    update_ref,
    keep_files,
    ivas_br,
    dtx,
    tag,
    sample_rate_bw_idx
    sample_rate_bw_idx,
):
    fs = sample_rate_bw_idx[0]
    bw = sample_rate_bw_idx[1]
@@ -386,7 +396,8 @@ def test_sba_enc_BWforce_system(
        bypass,
        agc,
        output_config,
        update_ref
        update_ref,
        keep_files,
    )


@@ -515,7 +526,7 @@ def sba_dec(
    agc,
    output_config,
    update_ref,
    keep_files=False
    keep_files,
):

    #########  run cmd   #####################################
@@ -581,10 +592,10 @@ def sba_dec(
            end_skip_samples
        )

        ##File removal##
        # report compare result
        assert cmp_result == 0, reason

        # remove DUT output files when test result is OK (to save disk space)
        if not keep_files:
            os.remove(dut_in_pkt)
            os.remove(dut_out_raw)

        ##report failure
        assert cmp_result == 0, reason