-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an initial test suite for the basic SNIPPET_ROOT, SNIPPET, and 'append' features in snippet.yml. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
- Loading branch information
1 parent
e36febd
commit fb7477a
Showing
10 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
cmake_minimum_required(VERSION 3.20.0) | ||
|
||
set(SNIPPET_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/extra_snippet_root") | ||
set(SNIPPET foo bar) | ||
|
||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) | ||
project(test_snippets) | ||
|
||
FILE(GLOB app_sources src/*.c) | ||
target_sources(app PRIVATE ${app_sources}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Copyright 2023 Nordic Semiconductor ASA | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
mainmenu "Snippet tests" | ||
|
||
menu "Zephyr" | ||
source "Kconfig.zephyr" | ||
endmenu | ||
|
||
config FOO | ||
int "Helper option for testing snippet foo" | ||
default 1 | ||
help | ||
This option's value should be overridden by the foo snippet. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/ { | ||
/* This node will be deleted by the bar snippet. */ | ||
deleted-by-bar {}; | ||
}; |
3 changes: 3 additions & 0 deletions
3
tests/cmake/snippets/extra_snippet_root/snippets/bar/bar.overlay
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/ { | ||
/delete-node/ deleted-by-bar; | ||
}; |
3 changes: 3 additions & 0 deletions
3
tests/cmake/snippets/extra_snippet_root/snippets/bar/snippet.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
name: bar | ||
append: | ||
DTC_OVERLAY_FILE: bar.overlay |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
CONFIG_ZTEST=y | ||
CONFIG_ZTEST_NEW_API=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CONFIG_FOO=2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
name: foo | ||
append: | ||
OVERLAY_CONFIG: foo.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright (c) 2023 Nordic Semiconductor ASA | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <zephyr/ztest.h> | ||
#include <zephyr/devicetree.h> | ||
|
||
ZTEST_SUITE(snippet_tests, NULL, NULL, NULL, NULL, NULL); | ||
|
||
ZTEST(snippet_tests, test_foo) | ||
{ | ||
zassert_equal(CONFIG_FOO, 2, "foo snippet should set CONFIG_FOO=2"); | ||
} | ||
|
||
ZTEST(snippet_tests, test_bar) | ||
{ | ||
zassert_equal(DT_NODE_EXISTS(DT_PATH(deleted_by_bar)), 0, | ||
"bar snippet should delete /deleted-by-bar node"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
tests: | ||
cmake.snippets: | ||
tags: snippets | ||
platform_allow: native_posix qemu_x86 qemu_x86_64 qemu_cortex_m3 | ||
integration_platforms: | ||
- native_posix |