aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGergely Nagy <gergely.nagy@arm.com>2022-09-21 09:22:15 +0100
committerGergely Nagy <gergely.nagy@arm.com>2022-09-30 10:14:16 +0100
commitdf5aa7561532f95ead0cd86053e0284b2723f566 (patch)
tree9f438fd020a55a522ce904222e00b49b31c14f2a
parentecdd89912ecd2a4ec715e96fe8eb0b8e59d8c273 (diff)
downloadmlia-df5aa7561532f95ead0cd86053e0284b2723f566.tar.gz
MLIA-647 Fix backend install for Corstone-300 on AVH/VHT
- Remove the extra 's' character which broke the path detection mechanism when installed from /opt/VHT location on AVH instances - Add unit tests to make sure we fixed the problem Change-Id: Ic33a3c6c4d2b33181268d0efbc0324962e741dd4
-rw-r--r--src/mlia/tools/metadata/corstone.py2
-rw-r--r--tests/test_tools_metadata_corstone.py46
2 files changed, 47 insertions, 1 deletions
diff --git a/src/mlia/tools/metadata/corstone.py b/src/mlia/tools/metadata/corstone.py
index feef7ad..0894207 100644
--- a/src/mlia/tools/metadata/corstone.py
+++ b/src/mlia/tools/metadata/corstone.py
@@ -353,7 +353,7 @@ def get_corstone_300_installation() -> Installation:
],
copy_source=False,
system_config=(
- "backends_configs/systems/corstone-300-vht/backend-config.json"
+ "backend_configs/systems/corstone-300-vht/backend-config.json"
),
),
),
diff --git a/tests/test_tools_metadata_corstone.py b/tests/test_tools_metadata_corstone.py
index e2b2ae5..bc3f31d 100644
--- a/tests/test_tools_metadata_corstone.py
+++ b/tests/test_tools_metadata_corstone.py
@@ -5,6 +5,7 @@ from __future__ import annotations
import tarfile
from pathlib import Path
+from typing import Iterable
from unittest.mock import MagicMock
import pytest
@@ -18,6 +19,8 @@ from mlia.tools.metadata.corstone import BackendInstaller
from mlia.tools.metadata.corstone import BackendMetadata
from mlia.tools.metadata.corstone import CompoundPathChecker
from mlia.tools.metadata.corstone import Corstone300Installer
+from mlia.tools.metadata.corstone import get_corstone_300_installation
+from mlia.tools.metadata.corstone import get_corstone_310_installation
from mlia.tools.metadata.corstone import get_corstone_installations
from mlia.tools.metadata.corstone import PackagePathChecker
from mlia.tools.metadata.corstone import PathChecker
@@ -417,3 +420,46 @@ def test_corstone_300_installer(
command_mock.assert_called_once_with(expected_command)
assert result == tmp_path / "corstone-300"
+
+
+@pytest.mark.parametrize(
+ "corstone_installation, expected_paths",
+ [
+ [
+ get_corstone_300_installation(),
+ {
+ "/opt/VHT/VHT_Corstone_SSE-300_Ethos-U55",
+ "/opt/VHT/VHT_Corstone_SSE-300_Ethos-U65",
+ },
+ ],
+ [get_corstone_310_installation(), {"/opt/VHT/VHT_Corstone_SSE-310"}],
+ ],
+)
+def test_corstone_vht_install(
+ corstone_installation: BackendInstallation,
+ expected_paths: set,
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ """Test if Corstone 300/310 could be installed from /opt/VHT."""
+
+ def _all_files_exist(paths: Iterable[Path]) -> bool:
+ """Check if all files exist."""
+ pathset = {item.as_posix() for item in paths}
+ return pathset == expected_paths
+
+ create_destination_and_install_mock = MagicMock()
+
+ monkeypatch.setattr(
+ "mlia.tools.metadata.corstone.all_files_exist", _all_files_exist
+ )
+
+ monkeypatch.setattr("mlia.backend.system.get_available_systems", lambda: [])
+
+ monkeypatch.setattr(
+ "mlia.backend.system.create_destination_and_install",
+ create_destination_and_install_mock,
+ )
+
+ corstone_installation.install(InstallFromPath(Path("/opt/VHT")))
+
+ create_destination_and_install_mock.assert_called_once()