From d40a03d5ddfa591112bb7079b8f23c1222409f28 Mon Sep 17 00:00:00 2001 From: jbleclere Date: Mon, 24 Jan 2022 12:35:29 +0000 Subject: [PATCH] Update test_abi_compliance.py to check ABI-Dumper app usability --- tests/test_abi_compliance.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tests/test_abi_compliance.py b/tests/test_abi_compliance.py index 0ac29ed3..0436bbe1 100644 --- a/tests/test_abi_compliance.py +++ b/tests/test_abi_compliance.py @@ -7,6 +7,7 @@ import pytest from shutil import copy from os.path import join, isdir, basename, splitext +from subprocess import run, CalledProcessError, PIPE from tests.conftest import perform_once @@ -22,7 +23,6 @@ def _run(*command, **kwargs): Returns: subprocess.CompletedProcess """ - from subprocess import run, CalledProcessError, PIPE result = run(*command, stdout=PIPE, stderr=PIPE, universal_newlines=True, **kwargs) try: @@ -43,6 +43,21 @@ def make(path, target=None): cwd=path) +def check_dump_abi(): + """ + Check ABI Dumper app is installed. + Returns: + True: ABI Dumper app is available + False: ABI Dumper app is not available + """ + try: + res = _run(['abi-dumper', '-v']) + res.check_returncode() + return True + except (FileNotFoundError, CalledProcessError): + return False + + def dump_abi(dump_file, so_file, include, version, name): """ Dump library ABI. @@ -124,10 +139,14 @@ def test_abi_compliance(tmpdir, accelize_drm): """ perform_once(__name__ + '.test_abi_compliance') + + if not accelize_drm.pytest_build_environment: pytest.skip('This test is only performed on build environment.') elif not accelize_drm.pytest_build_type == 'debug': pytest.xfail('This test needs libraries compiled in debug mode.') + elif not check_dump_abi(): + pytest.xfail('This test cannot be performed because ABI-Dumper app is not usable.') # Initialize test from concurrent.futures import ThreadPoolExecutor, as_completed