Skip to content

Commit

Permalink
tests: add integration test for assert
Browse files Browse the repository at this point in the history
add test for assert

Signed-off-by: Robert Gałat <robert.galat@nordicsemi.no>
  • Loading branch information
RobertGalatNordic committed Dec 16, 2024
1 parent 2ad48d4 commit 69ae765
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests_new/integration/assert/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#
# Copyright (c) 2024 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_assert_test)

# add test file
FILE(GLOB app_sources src/*.c)
target_sources(app PRIVATE ${app_sources})
target_include_directories(app PRIVATE .)
16 changes: 16 additions & 0 deletions tests_new/integration/assert/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#
# Copyright (c) 2022 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#
config SIDEWALK_BUILD
default y

config SIDEWALK_ASSERT
default y

config SIDEWALK_LOG_LEVEL
default 0

source "Kconfig.zephyr"
source "${ZEPHYR_BASE}/../sidewalk/Kconfig.dependencies"
8 changes: 8 additions & 0 deletions tests_new/integration/assert/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#
# Copyright (c) 2024 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#
CONFIG_ZTEST=y
CONFIG_MAIN_THREAD_PRIORITY=14
CONFIG_ZTEST_ASSERT_HOOK=y
35 changes: 35 additions & 0 deletions tests_new/integration/assert/src/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* Copyright (c) 2024 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

#include <zephyr/ztest.h>
#include <sid_pal_assert_ifc.h>
#include <zephyr/ztest_error_hook.h>

void before(void *fixture)
{
// Set assert behaviour to normal
ztest_set_assert_valid(false);
}

ZTEST(pal_assert, test_sid_pal_assert_true)
{
SID_PAL_ASSERT(true);
}
ZTEST(pal_assert, test_sid_pal_assert_false)
{
// Expect asserts to fail
ztest_set_assert_valid(true);
SID_PAL_ASSERT(false);
}

ZTEST(pal_assert, test_sid_pal_assert_false_raw)
{
// Expect asserts to fail
ztest_set_assert_valid(true);
sid_pal_assert(__LINE__, __FILE__);
}

ZTEST_SUITE(pal_assert, NULL, NULL, before, NULL, NULL);
18 changes: 18 additions & 0 deletions tests_new/integration/assert/testcase.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
tests:
sidewalk.test.integration.assert:
sysbuild: true
tags: Sidewalk
platform_allow:
- native_sim
- nrf52840dk/nrf52840
- nrf5340dk/nrf5340/cpuapp
- nrf54l15dk/nrf54l15/cpuapp
- nrf54l15dk/nrf54l15/cpuapp/ns
- nrf54l15dk/nrf54l10/cpuapp
integration_platforms:
- native_sim
- nrf52840dk/nrf52840
- nrf5340dk/nrf5340/cpuapp
- nrf54l15dk/nrf54l15/cpuapp
- nrf54l15dk/nrf54l15/cpuapp/ns
- nrf54l15dk/nrf54l10/cpuapp

0 comments on commit 69ae765

Please sign in to comment.