Skip to content

Commit 749b112

Browse files
Jordan Yatescarlescufi
authored andcommitted
tests: devicetree: test LINKER_DT_NODE_REGION_NAME
Add a new application for testing non-core devicetree functionality. Add tests for the default and fallback case of `LINKER_DT_NODE_REGION_NAME`. Signed-off-by: Jordan Yates <[email protected]>
1 parent 024ecdd commit 749b112

File tree

6 files changed

+77
-0
lines changed

6 files changed

+77
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
cmake_minimum_required(VERSION 3.20)
4+
5+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
6+
project(devicetree_extensions)
7+
8+
FILE(GLOB app_sources src/*.c)
9+
target_sources(app PRIVATE ${app_sources})
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Test cases for the devicetree.h extensions (GPIO, SPI, etc).
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright (c) 2021, Commonwealth Scientific and Industrial Research
3+
* Organisation (CSIRO) ABN 41 687 119 230.
4+
*
5+
* SPDX-License-Identifier: Apache-2.0
6+
*
7+
* Application overlay for testing the devicetree.h extension API's.
8+
*
9+
* Names in this file should be chosen in a way that won't conflict
10+
* with real-world devicetree nodes, to allow these tests to run on
11+
* (and be extended to test) real hardware.
12+
*/
13+
14+
/ {
15+
test {
16+
#address-cells = < 0x1 >;
17+
#size-cells = < 0x1 >;
18+
19+
test_sram1: sram@20000000 {
20+
compatible = "mmio-sram";
21+
reg = < 0x20000000 0x1000 >;
22+
zephyr,memory-region = "SRAM_REGION";
23+
};
24+
test_sram2: sram@20001000 {
25+
compatible = "mmio-sram";
26+
reg = < 0x20001000 0x1000 >;
27+
};
28+
};
29+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CONFIG_ZTEST=y
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) 2021, Commonwealth Scientific and Industrial Research
3+
* Organisation (CSIRO) ABN 41 687 119 230.
4+
*
5+
* SPDX-License-Identifier: Apache-2.0
6+
*/
7+
8+
#include <ztest.h>
9+
#include <devicetree.h>
10+
#include <device.h>
11+
#include <drivers/gpio.h>
12+
13+
#include <linker/devicetree_regions.h>
14+
15+
#define TEST_SRAM1 DT_NODELABEL(test_sram1)
16+
#define TEST_SRAM2 DT_NODELABEL(test_sram2)
17+
18+
static void test_linker_regions(void)
19+
{
20+
zassert_true(!strcmp(LINKER_DT_NODE_REGION_NAME(TEST_SRAM1), "SRAM_REGION"), "");
21+
zassert_true(!strcmp(LINKER_DT_NODE_REGION_NAME(TEST_SRAM2), "/test/sram@20001000"), "");
22+
}
23+
24+
void test_main(void)
25+
{
26+
ztest_test_suite(devicetree_api_ext,
27+
ztest_unit_test(test_linker_regions)
28+
);
29+
ztest_run_test_suite(devicetree_api_ext);
30+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
tests:
2+
libraries.devicetree_ext:
3+
tags: devicetree
4+
# We only need this to run on one platform so use native_posix as it
5+
# will mostly likely be the fastest.
6+
integration_platforms:
7+
- native_posix

0 commit comments

Comments
 (0)