switch-pico/tests/test_configuration_service_native.py

65 lines
1.8 KiB
Python

import shutil
import subprocess
from pathlib import Path
def test_configuration_service_native(tmp_path: Path) -> None:
root = Path(__file__).resolve().parents[1]
compiler = shutil.which("c++") or shutil.which("g++")
assert compiler is not None, "a host C++ compiler is required"
executable = tmp_path / "configuration_service_test"
subprocess.run(
[
compiler,
"-std=c++17",
"-Wall",
"-Wextra",
"-Werror",
"-pedantic",
f"-I{root / 'tests' / 'bluepad32_native_stubs'}",
f"-I{root / 'src' / 'firmware'}",
str(root / "tests" / "configuration_service_test.cpp"),
str(
root
/ "src"
/ "firmware"
/ "configuration"
/ "adapter_configuration.cpp"
),
str(root / "src" / "firmware" / "core" / "controller_identity.cpp"),
str(
root
/ "src"
/ "firmware"
/ "configuration"
/ "configuration_service.cpp"
),
str(
root
/ "src"
/ "firmware"
/ "configuration"
/ "configuration_storage.cpp"
),
str(
root
/ "src"
/ "firmware"
/ "configuration"
/ "configuration_transaction.cpp"
),
"-o",
str(executable),
],
check=True,
cwd=root,
)
for scenario in (
"lifecycle",
"v2-migration",
"v3-migration",
"native-approvals",
"abandoned-receive",
):
subprocess.run([str(executable), scenario], check=True, cwd=root)