Skip to content

Commit 9861e8c

Browse files
committed
tests: cmake: snippets: Add board revision check
Adds a check that snippets are correctly applied to named boards with the correct board revision Signed-off-by: Jamie McCrae <[email protected]>
1 parent 2b1b447 commit 9861e8c

File tree

6 files changed

+104
-7
lines changed

6 files changed

+104
-7
lines changed

tests/cmake/snippets/Kconfig

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ config TEST_TYPE_BAR_FOO
3737
help
3838
Test the snippet processing order (1. bar, 2. foo)
3939

40+
config TEST_TYPE_VER_CHECK
41+
bool "Test Type: Version check"
42+
help
43+
Test board version snippet application
44+
45+
config TEST_TYPE_VER_CHECK_SPECIFIC
46+
bool "Test Type: Version check specific"
47+
help
48+
Test board version snippet application with specific board version
49+
4050
endchoice
4151

4252
# Test values set by the snippet config overlays and tested by the test logic
@@ -57,3 +67,14 @@ config TEST_COMMON_VAL
5767
help
5868
This option's value should be overridden by the snippet config
5969
overlays.
70+
71+
# Used for testing board version snippets
72+
config TEST_VER_CHECK_APPLIED
73+
bool "Test version check snippet applied"
74+
help
75+
This option's value should be set by the ver_check snippet.
76+
77+
config TEST_VER_CHECK_SPECIFIC_VERSION_APPLIED
78+
bool "Test version check with board version snippet applied"
79+
help
80+
This option's value should be set by the ver_check snippet.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: ver_check
2+
boards:
3+
nrf9160dk/nrf9160:
4+
revisions:
5+
"0.7.0":
6+
append:
7+
EXTRA_CONF_FILE: ver_check_0_7_0.conf
8+
append:
9+
EXTRA_CONF_FILE: ver_check.conf
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CONFIG_TEST_VER_CHECK_APPLIED=y
2+
CONFIG_TEST_VER_CHECK_SPECIFIC_VERSION_APPLIED=n
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CONFIG_TEST_VER_CHECK_SPECIFIC_VERSION_APPLIED=y

tests/cmake/snippets/src/main.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,23 @@
1919
#define TEST_BAR_VAL_BAR (964183)
2020
#define TEST_COMMON_VAL_BAR (109234)
2121

22+
/* Check board-specific snippet files */
23+
#if defined(CONFIG_TEST_TYPE_VER_CHECK)
24+
#if !defined(CONFIG_TEST_VER_CHECK_APPLIED)
25+
#error "Base ver_check snippet has not been applied"
26+
#endif
27+
#if defined(CONFIG_TEST_VER_CHECK_SPECIFIC_VERSION_APPLIED)
28+
#error "Board specific ver_check snippet has wrongly been applied"
29+
#endif
30+
#elif defined(CONFIG_TEST_TYPE_VER_CHECK_SPECIFIC)
31+
#if !defined(CONFIG_TEST_VER_CHECK_APPLIED)
32+
#error "Base ver_check snippet has not been applied"
33+
#endif
34+
#if !defined(CONFIG_TEST_VER_CHECK_SPECIFIC_VERSION_APPLIED)
35+
#error "Board specific ver_check snippet has not been applied"
36+
#endif
37+
#endif
38+
2239
ZTEST_SUITE(snippet_tests, NULL, NULL, NULL, NULL, NULL);
2340

2441
ZTEST(snippet_tests, test_overlay_config)

tests/cmake/snippets/testcase.yaml

Lines changed: 54 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,83 @@
11
common:
22
tags: snippets
3-
platform_allow:
4-
- native_sim
5-
- qemu_x86
6-
- qemu_x86_64
7-
- qemu_cortex_m3
8-
integration_platforms:
9-
- native_sim
103
sysbuild: false
114

125
tests:
136
# Test the initial state with no snippets applied
147
buildsystem.snippets.none:
158
extra_configs:
169
- CONFIG_TEST_TYPE_NONE=y
10+
platform_allow:
11+
- native_sim
12+
- qemu_x86
13+
- qemu_x86_64
14+
- qemu_cortex_m3
15+
integration_platforms:
16+
- native_sim
1717
# Test the `foo` snippet from the default application snippet root
1818
buildsystem.snippets.foo:
1919
extra_args: SNIPPET="foo"
2020
extra_configs:
2121
- CONFIG_TEST_TYPE_FOO=y
22+
platform_allow:
23+
- native_sim
24+
- qemu_x86
25+
- qemu_x86_64
26+
- qemu_cortex_m3
27+
integration_platforms:
28+
- native_sim
2229
# Test the `bar` snippet from an extra snippet root
2330
buildsystem.snippets.bar:
2431
extra_args: SNIPPET="bar"
2532
extra_configs:
2633
- CONFIG_TEST_TYPE_BAR=y
34+
platform_allow:
35+
- native_sim
36+
- qemu_x86
37+
- qemu_x86_64
38+
- qemu_cortex_m3
39+
integration_platforms:
40+
- native_sim
2741
# Test the snippet processing order (1. foo, 2. bar)
2842
buildsystem.snippets.foo_bar:
2943
extra_args: SNIPPET="foo;bar"
3044
extra_configs:
3145
- CONFIG_TEST_TYPE_FOO_BAR=y
46+
platform_allow:
47+
- native_sim
48+
- qemu_x86
49+
- qemu_x86_64
50+
- qemu_cortex_m3
51+
integration_platforms:
52+
- native_sim
3253
# Test the snippet processing order (1. bar, 2. foo)
3354
buildsystem.snippets.bar_foo:
3455
extra_args: SNIPPET="bar;foo"
3556
extra_configs:
3657
- CONFIG_TEST_TYPE_BAR_FOO=y
58+
platform_allow:
59+
- native_sim
60+
- qemu_x86
61+
- qemu_x86_64
62+
- qemu_cortex_m3
63+
integration_platforms:
64+
- native_sim
65+
# Test the snippet board version processing
66+
buildsystem.snippets.version_exclude:
67+
extra_args: SNIPPET="ver_check"
68+
extra_configs:
69+
- CONFIG_TEST_TYPE_VER_CHECK=y
70+
platform_allow:
71+
72+
integration_platforms:
73+
74+
build_only: true
75+
buildsystem.snippets.version_include:
76+
extra_args: SNIPPET="ver_check"
77+
extra_configs:
78+
- CONFIG_TEST_TYPE_VER_CHECK_SPECIFIC=y
79+
platform_allow:
80+
81+
integration_platforms:
82+
83+
build_only: true

0 commit comments

Comments
 (0)