File tree Expand file tree Collapse file tree 12 files changed +115
-0
lines changed
tests/cmake/sysbuild_snippets Expand file tree Collapse file tree 12 files changed +115
-0
lines changed Original file line number Diff line number Diff line change 1+ # SPDX-License-Identifier: Apache-2.0
2+
3+ cmake_minimum_required (VERSION 3.20.0)
4+
5+ find_package (Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE} )
6+ project (test_snippets)
7+
8+ FILE (GLOB app_sources src/*.c)
9+ target_sources (app PRIVATE ${app_sources} )
Original file line number Diff line number Diff line change 1+ # Copyright 2024 Nordic Semiconductor ASA
2+ # SPDX-License-Identifier: Apache-2.0
3+
4+ menu "Zephyr"
5+ source "Kconfig.zephyr"
6+ endmenu
7+
8+ # Test values set by the snippet config overlays and tested by the test logic
9+ config TEST_FOO_VAL
10+ int "Test value"
11+ default 12
12+ help
13+ This option's value should be overridden by sysbuild.
Original file line number Diff line number Diff line change 1+ # Copyright 2024 Nordic Semiconductor ASA
2+ # SPDX-License-Identifier: Apache-2.0
3+
4+ config TEST_FOO_VAL
5+ int "Test value"
6+ default 0
7+ help
8+ This option's value should be overridden by the 'foo' snippet config overlay.
9+
10+ config EXPECTED_SB_TEST_FOO_VAL
11+ int "Expected sysbuild test value"
12+ default 999999
13+ help
14+ Expected sysbuild value for the test.
15+
16+ config EXPECTED_APP_TEST_FOO_VAL
17+ int "Expected application test value"
18+ default 999999
19+ help
20+ Expected application value for the test.
21+
22+ source "${ZEPHYR_BASE}/share/sysbuild/Kconfig"
Original file line number Diff line number Diff line change 1+ CONFIG_ZTEST=y
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright (c) 2024 Nordic Semiconductor ASA
3+ *
4+ * SPDX-License-Identifier: Apache-2.0
5+ */
6+
7+ /* Empty file */
Original file line number Diff line number Diff line change 1+ # SPDX-License-Identifier: Apache-2.0
2+
3+ cmake_minimum_required (VERSION 3.20.0)
4+
5+ set (SNIPPET_ROOT "${CMAKE_CURRENT_SOURCE_DIR} " )
6+ set (sysbuild_snippets_SNIPPET_ROOT "${CMAKE_CURRENT_SOURCE_DIR} " CACHE INTERNAL "" )
7+ set (EXTRA_ZEPHYR_MODULES "${CMAKE_CURRENT_SOURCE_DIR} /test_module" CACHE INTERNAL "test_module directory" )
8+
9+ find_package (Sysbuild REQUIRED HINTS $ENV{ZEPHYR_BASE} )
10+
11+ project (sysbuild LANGUAGES)
Original file line number Diff line number Diff line change 1+ CONFIG_TEST_FOO_VAL=18382
Original file line number Diff line number Diff line change 1+ SB_CONFIG_TEST_FOO_VAL=464372
Original file line number Diff line number Diff line change 1+ name : foo
2+ append :
3+ SB_EXTRA_CONF_FILE : sb.conf
4+ EXTRA_CONF_FILE : app.conf
Original file line number Diff line number Diff line change 1+ # SPDX-License-Identifier: Apache-2.0
2+
3+ function (${SYSBUILD_CURRENT_MODULE_NAME} _post_cmake)
4+ ExternalProject_Get_Property(${DEFAULT_IMAGE} BINARY_DIR)
5+ import_kconfig(CONFIG_ ${BINARY_DIR} /zephyr/.config)
6+
7+ if ("${SB_CONFIG_TEST_FOO_VAL} " STREQUAL "${CONFIG_TEST_FOO_VAL} " )
8+ message (FATAL_ERROR "Values match (sysbuild and app): ${SB_CONFIG_TEST_FOO_VAL} and ${CONFIG_TEST_FOO_VAL} " )
9+ else ()
10+ message (NOTICE "Values diverge (sysbuild and app)" )
11+ endif ()
12+
13+ if ("${SB_CONFIG_EXPECTED_SB_TEST_FOO_VAL} " STREQUAL "${SB_CONFIG_TEST_FOO_VAL} " )
14+ message (NOTICE "Values match (sysbuild and snippet): ${SB_CONFIG_EXPECTED_SB_TEST_FOO_VAL} and ${SB_CONFIG_TEST_FOO_VAL} " )
15+ else ()
16+ message (FATAL_ERROR "Values diverge (sysbuild and snippet): ${SB_CONFIG_EXPECTED_SB_TEST_FOO_VAL} and ${SB_CONFIG_TEST_FOO_VAL} " )
17+ endif ()
18+
19+ if ("${SB_CONFIG_EXPECTED_APP_TEST_FOO_VAL} " STREQUAL "${CONFIG_TEST_FOO_VAL} " )
20+ message (NOTICE "Values match (app and snippet): ${SB_CONFIG_EXPECTED_APP_TEST_FOO_VAL} and ${CONFIG_TEST_FOO_VAL} " )
21+ else ()
22+ message (FATAL_ERROR "Values diverge (app and snippet): ${SB_CONFIG_EXPECTED_APP_TEST_FOO_VAL} and ${CONFIG_TEST_FOO_VAL} " )
23+ endif ()
24+ endfunction ()
You can’t perform that action at this time.
0 commit comments