Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: llext-edk: get the Zephyr SDK path from build_info.yml #83661

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions tests/misc/llext-edk/pytest/test_edk.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,22 @@
from subprocess import check_output

import pytest
import yaml
from twister_harness import DeviceAdapter

logger = logging.getLogger(__name__)


def test_edk(unlaunched_dut: DeviceAdapter):
# Need to have the ZEPHYR_SDK_INSTALL_DIR environment variable set,
# otherwise can't actually build the edk
if os.environ.get("ZEPHYR_SDK_INSTALL_DIR") is None:
logger.warning("ZEPHYR_SDK_INSTALL_DIR is not set, skipping test")
pytest.skip("ZEPHYR_SDK_INSTALL_DIR is not set")
# Get the SDK path from build_info.yml
build_dir = str(unlaunched_dut.device_config.build_dir)
with open(Path(build_dir) / "build_info.yml") as f:
build_info = yaml.safe_load(f)
if build_info["cmake"]["toolchain"]["name"] != "zephyr":
logger.warning("This test requires the Zephyr SDK to be used, skipping")
pytest.skip("The Zephyr SDK must be used")

sdk_dir = build_info["cmake"]["toolchain"]["path"]

# Can we build the edk?
command = [
Expand Down Expand Up @@ -64,6 +70,7 @@ def test_edk(unlaunched_dut: DeviceAdapter):
# knows where the EDK is installed
edk_dir = Path(tempdir) / "llext-edk"
env = os.environ.copy()
env.update({"ZEPHYR_SDK_INSTALL_DIR": sdk_dir})
env.update({"LLEXT_EDK_INSTALL_DIR": edk_dir})

# Build the extension using the edk
Expand Down Expand Up @@ -92,7 +99,7 @@ def test_edk(unlaunched_dut: DeviceAdapter):
"--build-dir",
unlaunched_dut.device_config.build_dir,
"--",
f"-DEXTENSION_DIR={tempdir_extension}/build/"
f"-DEXTENSION_DIR={tempdir_extension}/build/",
]
logger.debug(f"west command: {command}")
output = check_output(command, text=True)
Expand Down
Loading