-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests that simply run all (SIL) configs in everest-core/config (#437
) * Add tests that simply run all (SIL) configs in everest-core/config * Remove obsolete config-hil.yaml * Restrict config tests to files following the config-*.yaml convention * Fix pytest invocation example * Do not set pytest.everest_configs if directory doesn't exist * Skip test config --------- Signed-off-by: Kai-Uwe Hermann <[email protected]> Co-authored-by: Andreas Heinrich <[email protected]>
- Loading branch information
1 parent
49ea0bf
commit 3d4792c
Showing
4 changed files
with
85 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,29 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# Copyright 2020 - 2023 Pionix GmbH and Contributors to EVerest | ||
# Copyright Pionix GmbH and Contributors to EVerest | ||
|
||
from pathlib import Path | ||
import pytest | ||
|
||
import os | ||
|
||
def pytest_addoption(parser): | ||
parser.addoption("--everest-prefix", action="store", default="../build/dist", | ||
help="everest prefix path; default = '../build/dist'") | ||
|
||
|
||
def pytest_configure(config): | ||
everest_prefix = config.getoption('--everest-prefix') | ||
everest_config_path = Path(everest_prefix) / 'etc/everest' | ||
if not everest_config_path.exists(): | ||
return | ||
everest_configs = [path for path in everest_config_path.iterdir( | ||
) if path.name.startswith('config-') and path.name.endswith('.yaml')] | ||
pytest.everest_configs = {} | ||
pytest.everest_configs['params'] = [] | ||
pytest.everest_configs['ids'] = [] | ||
for config_path in everest_configs: | ||
config_id = config_path.stem | ||
if config_id == 'config-sil-gen-pm' or config_id == 'config-test-cpp-error-handling': | ||
# skip | ||
continue | ||
pytest.everest_configs['params'].append(config_path) | ||
pytest.everest_configs['ids'].append(config_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
|
||
#!/usr/bin/env python3 | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# Copyright Pionix GmbH and Contributors to EVerest | ||
|
||
from copy import deepcopy | ||
import logging | ||
import os | ||
from pathlib import Path | ||
import pty | ||
import pytest | ||
from tempfile import mkdtemp | ||
from typing import Dict | ||
|
||
from everest.testing.core_utils.fixtures import * | ||
from everest.testing.core_utils.everest_core import EverestCore | ||
|
||
from everest.testing.core_utils import EverestConfigAdjustmentStrategy | ||
|
||
|
||
class EverestCoreConfigSilGenPmConfigurationAdjustment(EverestConfigAdjustmentStrategy): | ||
def __init__(self): | ||
self.temporary_directory = mkdtemp() | ||
self.serial_port_0, self.serial_port_1 = pty.openpty() | ||
# FIXME: cleanup socket after test | ||
self.serial_port_0_name = os.ttyname(self.serial_port_0) | ||
|
||
def adjust_everest_configuration(self, everest_config: Dict): | ||
adjusted_config = deepcopy(everest_config) | ||
|
||
adjusted_config["active_modules"]["serial_comm_hub"]["config_implementation"]["main"]["serial_port"] = self.serial_port_0_name | ||
|
||
return adjusted_config | ||
|
||
|
||
@pytest.mark.everest_core_config('config-sil-gen-pm.yaml') | ||
@pytest.mark.everest_config_adaptions(EverestCoreConfigSilGenPmConfigurationAdjustment()) | ||
@pytest.mark.asyncio | ||
async def test_start_config_sil_gen_pm(everest_core: EverestCore): | ||
logging.info(">>>>>>>>> test_start_config_sil_gen_pm <<<<<<<<<") | ||
|
||
everest_core.start() | ||
|
||
|
||
class TestConfigsInDirectory: | ||
@pytest.fixture(params=pytest.everest_configs['params'], ids=pytest.everest_configs['ids']) | ||
def core_config(self, request) -> EverestEnvironmentCoreConfiguration: | ||
everest_prefix = Path(request.config.getoption("--everest-prefix")) | ||
|
||
everest_config_path = request.param | ||
|
||
return EverestEnvironmentCoreConfiguration( | ||
everest_core_path=everest_prefix, | ||
template_everest_config_path=everest_config_path, | ||
) | ||
|
||
@pytest.mark.asyncio | ||
async def test_config(self, everest_core: EverestCore): | ||
logging.info(">>>>>>>>> test_config <<<<<<<<<") | ||
everest_core.start() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters