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 <jordan.yates@data61.csiro.au>
This commit is contained in:
parent
024ecdd672
commit
749b112fa8
6 changed files with 77 additions and 0 deletions
9
tests/lib/devicetree/api_ext/CMakeLists.txt
Normal file
9
tests/lib/devicetree/api_ext/CMakeLists.txt
Normal file
|
@ -0,0 +1,9 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||
project(devicetree_extensions)
|
||||
|
||||
FILE(GLOB app_sources src/*.c)
|
||||
target_sources(app PRIVATE ${app_sources})
|
1
tests/lib/devicetree/api_ext/README
Normal file
1
tests/lib/devicetree/api_ext/README
Normal file
|
@ -0,0 +1 @@
|
|||
Test cases for the devicetree.h extensions (GPIO, SPI, etc).
|
29
tests/lib/devicetree/api_ext/app.overlay
Normal file
29
tests/lib/devicetree/api_ext/app.overlay
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Commonwealth Scientific and Industrial Research
|
||||
* Organisation (CSIRO) ABN 41 687 119 230.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Application overlay for testing the devicetree.h extension API's.
|
||||
*
|
||||
* Names in this file should be chosen in a way that won't conflict
|
||||
* with real-world devicetree nodes, to allow these tests to run on
|
||||
* (and be extended to test) real hardware.
|
||||
*/
|
||||
|
||||
/ {
|
||||
test {
|
||||
#address-cells = < 0x1 >;
|
||||
#size-cells = < 0x1 >;
|
||||
|
||||
test_sram1: sram@20000000 {
|
||||
compatible = "mmio-sram";
|
||||
reg = < 0x20000000 0x1000 >;
|
||||
zephyr,memory-region = "SRAM_REGION";
|
||||
};
|
||||
test_sram2: sram@20001000 {
|
||||
compatible = "mmio-sram";
|
||||
reg = < 0x20001000 0x1000 >;
|
||||
};
|
||||
};
|
||||
};
|
1
tests/lib/devicetree/api_ext/prj.conf
Normal file
1
tests/lib/devicetree/api_ext/prj.conf
Normal file
|
@ -0,0 +1 @@
|
|||
CONFIG_ZTEST=y
|
30
tests/lib/devicetree/api_ext/src/main.c
Normal file
30
tests/lib/devicetree/api_ext/src/main.c
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Commonwealth Scientific and Industrial Research
|
||||
* Organisation (CSIRO) ABN 41 687 119 230.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <ztest.h>
|
||||
#include <devicetree.h>
|
||||
#include <device.h>
|
||||
#include <drivers/gpio.h>
|
||||
|
||||
#include <linker/devicetree_regions.h>
|
||||
|
||||
#define TEST_SRAM1 DT_NODELABEL(test_sram1)
|
||||
#define TEST_SRAM2 DT_NODELABEL(test_sram2)
|
||||
|
||||
static void test_linker_regions(void)
|
||||
{
|
||||
zassert_true(!strcmp(LINKER_DT_NODE_REGION_NAME(TEST_SRAM1), "SRAM_REGION"), "");
|
||||
zassert_true(!strcmp(LINKER_DT_NODE_REGION_NAME(TEST_SRAM2), "/test/sram@20001000"), "");
|
||||
}
|
||||
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(devicetree_api_ext,
|
||||
ztest_unit_test(test_linker_regions)
|
||||
);
|
||||
ztest_run_test_suite(devicetree_api_ext);
|
||||
}
|
7
tests/lib/devicetree/api_ext/testcase.yaml
Normal file
7
tests/lib/devicetree/api_ext/testcase.yaml
Normal file
|
@ -0,0 +1,7 @@
|
|||
tests:
|
||||
libraries.devicetree_ext:
|
||||
tags: devicetree
|
||||
# We only need this to run on one platform so use native_posix as it
|
||||
# will mostly likely be the fastest.
|
||||
integration_platforms:
|
||||
- native_posix
|
Loading…
Add table
Add a link
Reference in a new issue