summaryrefslogtreecommitdiff
path: root/zephyr/zmake/tests/test_project.py
diff options
context:
space:
mode:
authorJack Rosenthal <jrosenth@chromium.org>2021-02-17 19:33:16 -0700
committerCommit Bot <commit-bot@chromium.org>2021-02-23 00:51:52 +0000
commite193be9c9b02c97cb303605eb473d7a3a4ba7a65 (patch)
treede7195694b595ee8ce9679d5d65ea39d74debc9b /zephyr/zmake/tests/test_project.py
parentcc83ab7cf383f268452ddf8ea1ad406dbb28c885 (diff)
downloadchrome-ec-e193be9c9b02c97cb303605eb473d7a3a4ba7a65.tar.gz
zephyr: zmake: prune modules to only those required by the project
Implement a new configuration option: "modules", which allows projects to require only specific modules. This is needed for chameleon so they can only require the modules they need (instead of all modules supported by zmake). From pfagerburg@: When zmake pulled in one of the EC modules, that module wanted a bunch of EC symbols to be defined in Chameleon's Kconfig, e.g., CROS_EC_RO and CROS_EC_RW. BUG=b:180545676 BRANCH=none TEST=provided unit test Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I17bf2ac9a8f75f2879e5a67b991fd60d77071c32 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2702509 Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'zephyr/zmake/tests/test_project.py')
-rw-r--r--zephyr/zmake/tests/test_project.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/zephyr/zmake/tests/test_project.py b/zephyr/zmake/tests/test_project.py
index 03c9d3a917..5d6fd0b5ed 100644
--- a/zephyr/zmake/tests/test_project.py
+++ b/zephyr/zmake/tests/test_project.py
@@ -5,9 +5,11 @@
import hypothesis
import hypothesis.strategies as st
import pathlib
+import pytest
import string
import tempfile
+import zmake.modules
import zmake.project
@@ -80,3 +82,45 @@ def test_find_dts_overlays(modules):
assert actual_dts_files == set(map(str, expected_dts_files))
setup_modules_and_dispatch(modules, testcase)
+
+
+module_lists = st.lists(st.one_of(*map(st.just, zmake.modules.known_modules)),
+ unique=True)
+
+
+@hypothesis.given(module_lists)
+@hypothesis.settings(deadline=None)
+def test_prune_modules(modules):
+ """Test the Project.prune_modules method in the usual case (all
+ modules available)."""
+ module_paths = {
+ name: pathlib.Path('/fake/module/path', name)
+ for name in zmake.modules.known_modules
+ }
+
+ with TemporaryProject(
+ {'board': 'native_posix',
+ 'toolchain': 'coreboot-sdk',
+ 'output-type': 'elf',
+ 'supported-zephyr-versions': ['v2.5'],
+ 'modules': modules}) as project:
+ assert set(project.prune_modules(module_paths)) == set(modules)
+
+
+def test_prune_modules_unavailable():
+ """The Project.prune_modules method should raise a KeyError when
+ not all modules are available."""
+
+ # Missing 'cmsis'
+ module_paths = {
+ 'hal_stm32': pathlib.Path('/mod/halstm'),
+ }
+
+ with TemporaryProject(
+ {'board': 'native_posix',
+ 'toolchain': 'coreboot-sdk',
+ 'output-type': 'elf',
+ 'supported-zephyr-versions': ['v2.5'],
+ 'modules': ['hal_stm32', 'cmsis']}) as project:
+ with pytest.raises(KeyError):
+ project.prune_modules(module_paths)