diff options
author | Benjamin Klimczak <benjamin.klimczak@arm.com> | 2022-12-14 11:20:11 +0000 |
---|---|---|
committer | Benjamin Klimczak <benjamin.klimczak@arm.com> | 2023-01-04 10:11:33 +0000 |
commit | dcd0bd31985c27e1d07333351b26cf8ad12ad1fd (patch) | |
tree | a3388ff5f91e7cdc7ec41271a1a76cdbfae38ece /tests/test_backend_config.py | |
parent | 4b4cf29cb1e7d917ae001e258ff01f7846c34778 (diff) | |
download | mlia-dcd0bd31985c27e1d07333351b26cf8ad12ad1fd.tar.gz |
MLIA-589 Create an API to get target information
Change-Id: Ieeaa9188ea1e29e2ccaad7475d457bce71e3140d
Diffstat (limited to 'tests/test_backend_config.py')
-rw-r--r-- | tests/test_backend_config.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/test_backend_config.py b/tests/test_backend_config.py new file mode 100644 index 0000000..bd50945 --- /dev/null +++ b/tests/test_backend_config.py @@ -0,0 +1,42 @@ +# SPDX-FileCopyrightText: Copyright 2022, Arm Limited and/or its affiliates. +# SPDX-License-Identifier: Apache-2.0 +"""Tests for the backend config module.""" +from mlia.backend.config import BackendConfiguration +from mlia.backend.config import BackendType +from mlia.backend.config import System +from mlia.core.common import AdviceCategory + +UNSUPPORTED_SYSTEM = next(sys for sys in System if not sys.is_compatible()) + + +def test_system() -> None: + """Test the class 'System'.""" + assert System.CURRENT.is_compatible() + assert not UNSUPPORTED_SYSTEM.is_compatible() + assert UNSUPPORTED_SYSTEM != System.CURRENT + assert System.LINUX_AMD64 != System.LINUX_AARCH64 + + +def test_backend_config() -> None: + """Test the class 'BackendConfiguration'.""" + cfg = BackendConfiguration( + [AdviceCategory.OPERATORS], [System.CURRENT], BackendType.CUSTOM + ) + assert cfg.supported_advice == [AdviceCategory.OPERATORS] + assert cfg.supported_systems == [System.CURRENT] + assert cfg.type == BackendType.CUSTOM + assert str(cfg) + assert cfg.is_supported() + assert cfg.is_supported(advice=AdviceCategory.OPERATORS) + assert not cfg.is_supported(advice=AdviceCategory.PERFORMANCE) + assert cfg.is_supported(check_system=True) + assert cfg.is_supported(check_system=False) + cfg.supported_systems = None + assert cfg.is_supported(check_system=True) + assert cfg.is_supported(check_system=False) + cfg.supported_systems = [UNSUPPORTED_SYSTEM] + assert not cfg.is_supported(check_system=True) + assert cfg.is_supported(check_system=False) + assert not cfg.is_supported(advice=AdviceCategory.OPERATORS, check_system=True) + assert cfg.is_supported(advice=AdviceCategory.OPERATORS, check_system=False) + assert not cfg.is_supported(advice=AdviceCategory.PERFORMANCE, check_system=False) |