Browse Source

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

The LLEXT EDK test works by packaging an EDK and then testing its
functionality to build the extension in an external CMake build step.
That CMakelists.txt file currently references the required tools using
the ZEPHYR_SDK_INSTALL_DIR environment variable, which must be manually
set by the user.

This change modifies the test to read the newly added 'build_info.yml'
file, generated by Zephyr during the first build step. This allows to
set the ZEPHYR_SDK_INSTALL_DIR environment variable automatically based
on the (possibly auto-discovered) SDK path.

A few minor compliance cleanups are also included.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
pull/83796/head
Luca Burelli 6 months ago committed by Benjamin Cabé
parent
commit
ddd795a028
  1. 19
      tests/misc/llext-edk/pytest/test_edk.py

19
tests/misc/llext-edk/pytest/test_edk.py

@ -10,16 +10,22 @@ from pathlib import Path
from subprocess import check_output from subprocess import check_output
import pytest import pytest
import yaml
from twister_harness import DeviceAdapter from twister_harness import DeviceAdapter
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
def test_edk(unlaunched_dut: DeviceAdapter): def test_edk(unlaunched_dut: DeviceAdapter):
# Need to have the ZEPHYR_SDK_INSTALL_DIR environment variable set, # Get the SDK path from build_info.yml
# otherwise can't actually build the edk build_dir = str(unlaunched_dut.device_config.build_dir)
if os.environ.get("ZEPHYR_SDK_INSTALL_DIR") is None: with open(Path(build_dir) / "build_info.yml") as f:
logger.warning("ZEPHYR_SDK_INSTALL_DIR is not set, skipping test") build_info = yaml.safe_load(f)
pytest.skip("ZEPHYR_SDK_INSTALL_DIR is not set") 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? # Can we build the edk?
command = [ command = [
@ -64,6 +70,7 @@ def test_edk(unlaunched_dut: DeviceAdapter):
# knows where the EDK is installed # knows where the EDK is installed
edk_dir = Path(tempdir) / "llext-edk" edk_dir = Path(tempdir) / "llext-edk"
env = os.environ.copy() env = os.environ.copy()
env.update({"ZEPHYR_SDK_INSTALL_DIR": sdk_dir})
env.update({"LLEXT_EDK_INSTALL_DIR": edk_dir}) env.update({"LLEXT_EDK_INSTALL_DIR": edk_dir})
# Build the extension using the edk # Build the extension using the edk
@ -92,7 +99,7 @@ def test_edk(unlaunched_dut: DeviceAdapter):
"--build-dir", "--build-dir",
unlaunched_dut.device_config.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}") logger.debug(f"west command: {command}")
output = check_output(command, text=True) output = check_output(command, text=True)

Loading…
Cancel
Save