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:
Jordan Yates 2021-08-01 11:59:27 +10:00 committed by Carles Cufí
commit 749b112fa8
6 changed files with 77 additions and 0 deletions

View 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})

View file

@ -0,0 +1 @@
Test cases for the devicetree.h extensions (GPIO, SPI, etc).

View 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 >;
};
};
};

View file

@ -0,0 +1 @@
CONFIG_ZTEST=y

View 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);
}

View 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