Skip to content

Commit

Permalink
tests: refactor tests
Browse files Browse the repository at this point in the history
[KRKNWK-14886]
* Move crypto test to new location
* Move crypto keys test to new location
* Move delay test to new location
* Move critical_region test to new location
* Move interrupts test to new location
* Move storage test to new location
* Move time test to new location
* Add native_sim board support
* Port to ztest
* Remove sanity tests

Signed-off-by: Krzysztof Taborowski <[email protected]>
  • Loading branch information
ktaborowski committed Dec 9, 2024
1 parent 9d16395 commit ddcf163
Show file tree
Hide file tree
Showing 52 changed files with 226 additions and 223 deletions.
4 changes: 2 additions & 2 deletions Kconfig.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ config SIDEWALK_DEFAULTS
imply REBOOT

config SIDEWALK_BUILD
bool
bool "Sidewalk build test"
default SIDEWALK
help
An internal config to build the NCS Sidewalk Sources.
Expand Down Expand Up @@ -61,7 +61,7 @@ config SIDEWALK_ASSERT
If the assertion fails, program will trigger a fatal error.

config SIDEWALK_CRYPTO
bool
bool "sidewalk crypto test"
default SIDEWALK
imply NRF_SECURITY
imply HW_CC3XX
Expand Down
9 changes: 0 additions & 9 deletions tests/functional/critical_region/prj.conf

This file was deleted.

62 changes: 0 additions & 62 deletions tests/functional/critical_region/src/main.c

This file was deleted.

15 changes: 0 additions & 15 deletions tests/functional/critical_region/testcase.yaml

This file was deleted.

24 changes: 0 additions & 24 deletions tests/functional/storage/Kconfig

This file was deleted.

16 changes: 0 additions & 16 deletions tests/functional/storage/testcase.yaml

This file was deleted.

14 changes: 0 additions & 14 deletions tests/functional/time/prj.conf

This file was deleted.

16 changes: 0 additions & 16 deletions tests/functional/time/testcase.yaml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
cmake_minimum_required(VERSION 3.20.0)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(sidewalk_functional_test)
project(sidewalk_critical_region_test)

# add test file
FILE(GLOB app_sources src/*.c)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ config SIDEWALK_BUILD
config SIDEWALK_CRITICAL_REGION
default y

config SIDEWALK_CRITICAL_REGION_RE_ENTRY_MAX
default 2
config SIDEWALK_LOG_LEVEL
default 0

source "Kconfig.zephyr"
source "${ZEPHYR_BASE}/../sidewalk/Kconfig.dependencies"
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

CONFIG_ZTEST=y
CONFIG_MAIN_THREAD_PRIORITY=14
69 changes: 69 additions & 0 deletions tests_new/integration/critical_region/src/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Copyright (c) 2022 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/
#include <sid_pal_critical_region_ifc.h>
#include <sid_error.h>
#include <zephyr/ztest.h>
#include <zephyr/irq.h>

#if defined(CONFIG_SOC_FAMILY_NORDIC_NRF)
#include <cmsis_core.h>
#elif defined(CONFIG_SOC_POSIX)
#include <zephyr/arch/posix/posix_soc_if.h>
#else
#error "Architecture not supported"
#endif /* CONFIG_SOC */

#define TEST_IRQ (30)
#define TEST_IRQ_PRIO (2)
#define TEST_IRQ_FLAGS (0)

#define UNCHANGED 0
#define CHANGED 1
static volatile uint32_t resource;

static void irq_cb(const void *arg)
{
resource = CHANGED;
}

static void soc_irq_enable(int irq)
{
#if defined(CONFIG_SOC_FAMILY_NORDIC_NRF)
irq_enable(irq);
#elif defined(CONFIG_SOC_POSIX)
posix_irq_enable(irq);
#endif /* CONFIG_SOC */
}

static void soc_irq_trigger(int irq)
{
#if defined(CONFIG_SOC_FAMILY_NORDIC_NRF)
NVIC_SetPendingIRQ(irq);
#elif defined(CONFIG_SOC_POSIX)
posix_sw_set_pending_IRQ(irq);
#endif /* CONFIG_SOC */
}

ZTEST(sid_pal_suite, test_critical_region_with_timer)
{
IRQ_CONNECT(TEST_IRQ, TEST_IRQ_PRIO, irq_cb, NULL, TEST_IRQ_FLAGS);
soc_irq_enable(TEST_IRQ);

resource = UNCHANGED;
soc_irq_trigger(TEST_IRQ);
zassert_equal(resource, CHANGED, "IRQ should change resource");

sid_pal_enter_critical_region();
resource = UNCHANGED;
soc_irq_trigger(TEST_IRQ);
zassert_equal(resource, UNCHANGED, "Resource should not change in critical section");
sid_pal_exit_critical_region();

soc_irq_trigger(TEST_IRQ);
zassert_equal(resource, CHANGED, "IRQ should change resource after critical section");
}

ZTEST_SUITE(sid_pal_suite, NULL, NULL, NULL, NULL, NULL);
18 changes: 18 additions & 0 deletions tests_new/integration/critical_region/testcase.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
tests:
sidewalk.test.integration.critical_region:
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@
cmake_minimum_required(VERSION 3.20.0)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(sidewalk_test_critical_region)
project(sidewalk_functional_test)

zephyr_library_include_directories($ENV{ZEPHYR_BASE}/../modules/crypto/mbedtls/include)
# 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})
# zephyr_library_sources_ifdef(CONFIG_SIDEWALK_CRYPTO $ENV{ZEPHYR_BASE}/../sidewalk/subsys/sal/sid_pal/src/sid_crypto.c)
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#
config SIDEWALK_BUILD
default y

config SIDEWALK_CRYPTO
default y

config SIDEWALK_CRYPTO_LOG_LEVEL
default 0

Expand Down
File renamed without changes.
7 changes: 7 additions & 0 deletions tests_new/integration/crypto/boards/native_sim.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#
# Copyright (c) 2024 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#
CONFIG_MBEDTLS=y
CONFIG_MBEDTLS_PSA_CRYPTO_C=y
10 changes: 10 additions & 0 deletions tests_new/integration/crypto/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#
# Copyright (c) 2022 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#
CONFIG_ZTEST=y
CONFIG_MAIN_THREAD_PRIORITY=14

CONFIG_SIDEWALK_BUILD=y
CONFIG_SIDEWALK_CRYPTO=y
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
tests:
sidewalk.functional.delay:
sidewalk.test.integration.crypto:
sysbuild: true
tags: Sidewalk
platform_allow:
- nrf52840dk/nrf52840
- nrf5340dk/nrf5340/cpuapp
Expand All @@ -13,4 +14,3 @@ tests:
- nrf54l15dk/nrf54l15/cpuapp
- nrf54l15dk/nrf54l15/cpuapp/ns
- nrf54l15dk/nrf54l10/cpuapp
tags: Sidewalk
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ config SIDEWALK_CRYPTO_LOG_LEVEL
config SIDEWALK_LOG_LEVEL
default 0

config NVS_LOG_LEVEL
default 0

config ZMS_LOG_LEVEL
default 0

# Stacks
config MAIN_STACK_SIZE
default 8192
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#
CONFIG_UNITY=y
CONFIG_ZTEST=y
CONFIG_MAIN_THREAD_PRIORITY=14
File renamed without changes.
16 changes: 16 additions & 0 deletions tests_new/integration/crypto_keys/testcase.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
tests:
sidewalk.test.integration.crypto_keys:
sysbuild: true
tags: Sidewalk
platform_allow:
- nrf52840dk/nrf52840
- nrf5340dk/nrf5340/cpuapp
- nrf54l15dk/nrf54l15/cpuapp
- nrf54l15dk/nrf54l15/cpuapp/ns
- nrf54l15dk/nrf54l10/cpuapp
integration_platforms:
- nrf52840dk/nrf52840
- nrf5340dk/nrf5340/cpuapp
- nrf54l15dk/nrf54l15/cpuapp
- nrf54l15dk/nrf54l15/cpuapp/ns
- nrf54l15dk/nrf54l10/cpuapp

Check warning on line 16 in tests_new/integration/crypto_keys/testcase.yaml

View workflow job for this annotation

GitHub Actions / verify_PR / validate_compliance_with_zephyr

YAMLLint (new-line-at-end-of-file)

tests_new/integration/crypto_keys/testcase.yaml:16 no new line character at the end of file
Loading

0 comments on commit ddcf163

Please sign in to comment.