-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[KRKNWK-18043] Signed-off-by: Krzysztof Taborowski <[email protected]>
- Loading branch information
1 parent
3f9cbb1
commit 5aa5ffe
Showing
5 changed files
with
110 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,18 @@ | ||
# | ||
# Copyright (c) 2022 Nordic Semiconductor ASA | ||
# | ||
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
# | ||
|
||
cmake_minimum_required(VERSION 3.20.0) | ||
|
||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) | ||
project(sidewalk_test_critical_region) | ||
|
||
# add test file | ||
FILE(GLOB app_sources src/*.c) | ||
target_sources(app PRIVATE ${app_sources}) | ||
target_include_directories(app PRIVATE .) | ||
|
||
# generate runner for the test | ||
test_runner_generate(${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,15 @@ | ||
# | ||
# Copyright (c) 2022 Nordic Semiconductor ASA | ||
# | ||
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
# | ||
config SIDEWALK_BUILD | ||
default y | ||
|
||
config SIDEWALK_CRITICAL_REGION | ||
default y | ||
|
||
config SIDEWALK_CRITICAL_REGION_RE_ENTRY_MAX | ||
default 2 | ||
|
||
source "Kconfig.zephyr" |
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,9 @@ | ||
# | ||
# Copyright (c) 2022 Nordic Semiconductor ASA | ||
# | ||
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
# | ||
CONFIG_UNITY=y | ||
CONFIG_MAIN_THREAD_PRIORITY=14 | ||
CONFIG_NO_OPTIMIZATIONS=y | ||
CONFIG_RESET_ON_FATAL_ERROR=n |
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,62 @@ | ||
/* | ||
* Copyright (c) 2022 Nordic Semiconductor ASA | ||
* | ||
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
*/ | ||
#include <unity.h> | ||
#include <sid_pal_critical_region_ifc.h> | ||
#include <sid_error.h> | ||
|
||
#if defined(CONFIG_CPU_CORTEX_M) | ||
#include <cmsis_core.h> | ||
#else | ||
#error "Architecture not supported" | ||
#endif | ||
|
||
#define TEST_IRQ (30) | ||
#define TEST_IRQ_PRIO (2) | ||
#define TEST_IRQ_FLAGS (0) | ||
|
||
#define UNCHANGED 0 | ||
#define CHANGED 1 | ||
static volatile int resource; | ||
|
||
static void irq_cb(void) | ||
{ | ||
resource = CHANGED; | ||
} | ||
|
||
static void trigger_irq(int irq) | ||
{ | ||
NVIC_SetPendingIRQ(irq); | ||
} | ||
|
||
void test_sid_pal_critical_region_with_timer(void) | ||
{ | ||
IRQ_CONNECT(TEST_IRQ, TEST_IRQ_PRIO, irq_cb, NULL, TEST_IRQ_FLAGS); | ||
irq_enable(TEST_IRQ); | ||
|
||
resource = UNCHANGED; | ||
trigger_irq(TEST_IRQ); | ||
TEST_ASSERT_EQUAL_UINT32(CHANGED, resource); | ||
|
||
sid_pal_enter_critical_region(); | ||
resource = UNCHANGED; | ||
trigger_irq(TEST_IRQ); | ||
TEST_ASSERT_EQUAL_UINT32(UNCHANGED, resource); | ||
sid_pal_exit_critical_region(); | ||
|
||
trigger_irq(TEST_IRQ); | ||
TEST_ASSERT_EQUAL_UINT32(CHANGED, resource); | ||
} | ||
|
||
/* It is required to be added to each test. That is because unity is using | ||
* different main signature (returns int) and zephyr expects main which does | ||
* not return value. | ||
*/ | ||
extern int unity_main(void); | ||
|
||
int main(void) | ||
{ | ||
return unity_main(); | ||
} |
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: | ||
sidewalk.functional.critical_region: | ||
platform_allow: nrf52840dk_nrf52840 nrf5340dk_nrf5340_cpuapp | ||
integration_platforms: | ||
- nrf52840dk_nrf52840 | ||
- nrf5340dk_nrf5340_cpuapp |