Skip to content

Commit 3cef86f

Browse files
tests: add integration test for assert
add test for assert Signed-off-by: Robert Gałat <[email protected]>
1 parent 2ad48d4 commit 3cef86f

File tree

5 files changed

+92
-0
lines changed

5 files changed

+92
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#
2+
# Copyright (c) 2024 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
cmake_minimum_required(VERSION 3.20.0)
8+
9+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
10+
project(sidewalk_assert_test)
11+
12+
# add test file
13+
FILE(GLOB app_sources src/*.c)
14+
target_sources(app PRIVATE ${app_sources})
15+
target_include_directories(app PRIVATE .)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#
2+
# Copyright (c) 2022 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
config SIDEWALK_BUILD
7+
default y
8+
9+
config SIDEWALK_ASSERT
10+
default y
11+
12+
config SIDEWALK_LOG_LEVEL
13+
default 0
14+
15+
source "Kconfig.zephyr"
16+
source "${ZEPHYR_BASE}/../sidewalk/Kconfig.dependencies"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#
2+
# Copyright (c) 2024 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
CONFIG_ZTEST=y
7+
CONFIG_MAIN_THREAD_PRIORITY=14
8+
CONFIG_ZTEST_ASSERT_HOOK=y
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* Copyright (c) 2024 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
#include <zephyr/ztest.h>
8+
#include <sid_pal_assert_ifc.h>
9+
#include <zephyr/ztest_error_hook.h>
10+
11+
void before(void *fixture)
12+
{
13+
// Set assert behaviour to normal
14+
ztest_set_assert_valid(false);
15+
}
16+
17+
ZTEST(pal_assert, test_sid_pal_assert_true)
18+
{
19+
SID_PAL_ASSERT(true);
20+
}
21+
ZTEST(pal_assert, test_sid_pal_assert_false)
22+
{
23+
// Expect asserts to fail
24+
ztest_set_assert_valid(true);
25+
SID_PAL_ASSERT(false);
26+
}
27+
28+
ZTEST(pal_assert, test_sid_pal_assert_false_raw)
29+
{
30+
// Expect asserts to fail
31+
ztest_set_assert_valid(true);
32+
sid_pal_assert(__LINE__, __FILE__);
33+
}
34+
35+
ZTEST_SUITE(pal_assert, NULL, NULL, before, NULL, NULL);
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
tests:
2+
sidewalk.test.integration.assert:
3+
sysbuild: true
4+
tags: Sidewalk
5+
platform_allow:
6+
- native_sim
7+
- nrf52840dk/nrf52840
8+
- nrf5340dk/nrf5340/cpuapp
9+
- nrf54l15dk/nrf54l15/cpuapp
10+
- nrf54l15dk/nrf54l15/cpuapp/ns
11+
- nrf54l15dk/nrf54l10/cpuapp
12+
integration_platforms:
13+
- native_sim
14+
- nrf52840dk/nrf52840
15+
- nrf5340dk/nrf5340/cpuapp
16+
- nrf54l15dk/nrf54l15/cpuapp
17+
- nrf54l15dk/nrf54l15/cpuapp/ns
18+
- nrf54l15dk/nrf54l10/cpuapp

0 commit comments

Comments
 (0)