aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitrii Agibov <dmitrii.agibov@arm.com>2022-10-04 14:14:47 +0100
committerDmitrii Agibov <dmitrii.agibov@arm.com>2022-10-04 15:12:33 +0100
commit2d6ec94a2a085e7fa4fc23c4c7dcda3206eec98c (patch)
tree80a7e00ec9b29508b8044c935da2afb4b7443789
parentdf5aa7561532f95ead0cd86053e0284b2723f566 (diff)
downloadmlia-2d6ec94a2a085e7fa4fc23c4c7dcda3206eec98c.tar.gz
MLIA-580 Fix test that produces untracked files
- Create separate test for the application execution, update test application configuration file - Use simple mock object in the test for the backend manager Change-Id: Ia0f7f29d43a55223d7b2fb47348b0779a26e2268
-rw-r--r--tests/test_backend_execution.py10
-rw-r--r--tests/test_backend_manager.py3
-rw-r--r--tests/test_resources/backends/applications/application4/backend-config.json4
-rw-r--r--tests/test_resources/backends/applications/application4/hello_app.txt4
-rw-r--r--tests/test_resources/backends/systems/system4/backend-config.json6
5 files changed, 14 insertions, 13 deletions
diff --git a/tests/test_backend_execution.py b/tests/test_backend_execution.py
index 07e7c98..6e1b30b 100644
--- a/tests/test_backend_execution.py
+++ b/tests/test_backend_execution.py
@@ -16,6 +16,7 @@ from mlia.backend.execution import ExecutionContext
from mlia.backend.execution import get_application_and_system
from mlia.backend.execution import get_application_by_name_and_system
from mlia.backend.execution import ParamResolver
+from mlia.backend.execution import run_application
from mlia.backend.system import load_system
@@ -201,3 +202,12 @@ def test_get_application_and_system(monkeypatch: Any) -> None:
with pytest.raises(ValueError, match="System test_system is not found"):
get_application_and_system("test_application", "test_system")
+
+
+def test_run_application() -> None:
+ """Test function run_application."""
+ ctx = run_application("application_4", [], "System 4", [])
+
+ assert isinstance(ctx, ExecutionContext)
+ assert ctx.stderr is not None and not ctx.stderr.decode()
+ assert ctx.stdout is not None and ctx.stdout.decode().strip() == "application_4"
diff --git a/tests/test_backend_manager.py b/tests/test_backend_manager.py
index a1e9198..c22b4c1 100644
--- a/tests/test_backend_manager.py
+++ b/tests/test_backend_manager.py
@@ -15,7 +15,6 @@ import pytest
from mlia.backend.application import get_application
from mlia.backend.execution import ExecutionContext
-from mlia.backend.execution import run_application
from mlia.backend.manager import BackendRunner
from mlia.backend.manager import DeviceInfo
from mlia.backend.manager import estimate_performance
@@ -377,7 +376,7 @@ class TestBackendRunner:
expected_command: list[str],
) -> None:
"""Test method run_application with local systems."""
- run_app = MagicMock(wraps=run_application)
+ run_app = MagicMock()
monkeypatch.setattr("mlia.backend.manager.run_application", run_app)
backend_runner = BackendRunner()
diff --git a/tests/test_resources/backends/applications/application4/backend-config.json b/tests/test_resources/backends/applications/application4/backend-config.json
index d4362be..11017e4 100644
--- a/tests/test_resources/backends/applications/application4/backend-config.json
+++ b/tests/test_resources/backends/applications/application4/backend-config.json
@@ -12,9 +12,7 @@
],
"commands": {
"run": [
- "cp {application.config_dir}/hello_app.txt {system.config_dir}",
- "echo '{user_params:0}' > {system.config_dir}/params.txt",
- "cat hello_app.txt"
+ "echo {application.name}"
]
},
"user_params": {
diff --git a/tests/test_resources/backends/applications/application4/hello_app.txt b/tests/test_resources/backends/applications/application4/hello_app.txt
deleted file mode 100644
index 2ec0d1d..0000000
--- a/tests/test_resources/backends/applications/application4/hello_app.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-SPDX-FileCopyrightText: Copyright 2022, Arm Limited and/or its affiliates.
-SPDX-License-Identifier: Apache-2.0
-
-Hello from APP!
diff --git a/tests/test_resources/backends/systems/system4/backend-config.json b/tests/test_resources/backends/systems/system4/backend-config.json
index 7701c05..daa4025 100644
--- a/tests/test_resources/backends/systems/system4/backend-config.json
+++ b/tests/test_resources/backends/systems/system4/backend-config.json
@@ -4,10 +4,8 @@
"description": "This is system 4",
"commands": {
"run": [
- "echo {application.name}",
- "{application.commands.run:0}",
- "{application.commands.run:1}",
- "{application.commands.run:2}"
+ "echo {system.name}",
+ "{application.commands.run:0}"
]
},
"user_params": {