Commit 4170d05c authored by Jan Kiene's avatar Jan Kiene
Browse files

add test for binaries present and fix in find_binary

parent 32b09c14
Loading
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ default:


stages:
  - check
  - test
  - analyze

@@ -31,6 +32,18 @@ stages:
  - cd $dir


# ------------------------------------
# check pre-conditions are met
# ------------------------------------
check_for_binaries:
  stage: check
  tags:
    - linux
  script:
    - *print-common-info
    - tests/test_binaries_present.py


# ------------------------------------
# functionality tests
# ------------------------------------
+7 −4
Original line number Diff line number Diff line
@@ -138,7 +138,7 @@ def find_binary(
    binary: str,
    raise_error: Optional[bool] = True,
    logger: Optional[logging.Logger] = None,
    binary_path: Optional[str] = None,
    binary_path: Optional[Path] = None,
) -> Union[Path, None]:
    """Attempt to find and return the path to the given binary"""
    # prioritise binaries placed in the directory over $PATH
@@ -150,9 +150,12 @@ def find_binary(
        bin = which(binary)

    if not bin and raise_error:
        raise FileNotFoundError(
            f"Binary {binary} was neither found in {binary_path.absolute()} nor in {BIN_DIR.absolute()} or in $PATH!"
        )
        msg = f"Binary {binary} was not found - neither in {BIN_DIR.absolute()} nor in $PATH"
        if binary_path is None:
            msg += " and binary_paths.yml file contains no items."
        else:
            msg += " nor in {binary_path.absolute()}."
        raise FileNotFoundError(msg)
    elif not bin:
        if logger:
            logger.debug(f"Couldn't find binary {binary}")
+41 −0
Original line number Diff line number Diff line
#!/usr/bin/env python3

#
#  (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
#  Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
#  Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
#  Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
#  contributors to this repository. All Rights Reserved.
#
#  This software is protected by copyright law and by international treaties.
#  The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
#  Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
#  Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
#  Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
#  contributors to this repository retain full ownership rights in their respective contributions in
#  the software. This notice grants no license of any kind, including but not limited to patent
#  license, nor is any license granted by implication, estoppel or otherwise.
#
#  Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
#  contributions.
#
#  This software is provided "AS IS", without any express or implied warranties. The software is in the
#  development stage. It is intended exclusively for experts who have experience with such software and
#  solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
#  and fitness for a particular purpose are hereby disclaimed and excluded.
#
#  Any dispute, controversy or claim arising under or in relation to providing this software shall be
#  submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
#  accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
#  the United Nations Convention on Contracts on the International Sales of Goods.
#

import pytest
from ivas_processing_scripts.utils import find_binary

BINARIES = ["bs1770demo", "p50fbmnru", "esdru", "eid-xor", "gen-patt", "filter", "random", "networkSimulator_g192", "masaRenderer"]


@pytest.mark.parametrize("binary", BINARIES)
def test_find_binary(binary):
    assert(find_binary(binary, raise_error=False) is not None)