diff --git a/subsys/sal/sid_pal/src/CMakeLists.txt b/subsys/sal/sid_pal/src/CMakeLists.txt index 8b8295157d..2a0550dfcd 100644 --- a/subsys/sal/sid_pal/src/CMakeLists.txt +++ b/subsys/sal/sid_pal/src/CMakeLists.txt @@ -52,11 +52,11 @@ zephyr_library_sources_ifdef(CONFIG_SIDEWALK_CRITICAL_REGION sid_critical_region zephyr_library_sources_ifdef(CONFIG_SIDEWALK_GPIO sid_gpio.c sid_gpio_utils.c) -if(CONFIG_SOC_SERIES_NRF53X) +if(CONFIG_HAS_HW_NRF_TEMP) +zephyr_library_sources_ifdef(CONFIG_SIDEWALK_TEMPERATURE sid_temperature.c) +else() zephyr_library_sources_ifdef(CONFIG_SIDEWALK_TEMPERATURE sid_temperature_mock.c) message("Note: Sidewalk uses MOCK temperature implementation") -else() -zephyr_library_sources_ifdef(CONFIG_SIDEWALK_TEMPERATURE sid_temperature.c) endif() # CONFIG_SOC_SERIES_NRF53X zephyr_library_sources_ifdef(CONFIG_SIDEWALK_SW_INTERRUPTS sid_sw_interrupts.c) diff --git a/tests/functional/critical_region/CMakeLists.txt b/tests/functional/critical_region/CMakeLists.txt deleted file mode 100644 index bf903d06fb..0000000000 --- a/tests/functional/critical_region/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -# -# 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}) diff --git a/tests/functional/critical_region/prj.conf b/tests/functional/critical_region/prj.conf deleted file mode 100644 index 3ef526ea9c..0000000000 --- a/tests/functional/critical_region/prj.conf +++ /dev/null @@ -1,9 +0,0 @@ -# -# 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 diff --git a/tests/functional/critical_region/src/main.c b/tests/functional/critical_region/src/main.c deleted file mode 100644 index fb1d9cd333..0000000000 --- a/tests/functional/critical_region/src/main.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2022 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - */ -#include -#include -#include - -#if defined(CONFIG_CPU_CORTEX_M) -#include -#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(); -} diff --git a/tests/functional/crypto/prj.conf b/tests/functional/crypto/prj.conf deleted file mode 100644 index be62f3c8fa..0000000000 --- a/tests/functional/crypto/prj.conf +++ /dev/null @@ -1,8 +0,0 @@ -# -# Copyright (c) 2022 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause -# -CONFIG_ZTEST=y -CONFIG_MAIN_THREAD_PRIORITY=14 -CONFIG_CONSOLE_PUTCHAR_BUFSIZE=512 diff --git a/tests/functional/mfg_storage/src/main.c b/tests/functional/mfg_storage/src/main.c deleted file mode 100644 index 3ef52c0c62..0000000000 --- a/tests/functional/mfg_storage/src/main.c +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright (c) 2022 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - */ - -#include - -#include -#include - -#include -#include -#include -#include -#include - -#define MFG_VERSION_1_VAL 0x01000000 - -/* Flash block size in bytes */ -#define MFG_STORAGE_SIZE (DT_PROP(DT_CHOSEN(zephyr_flash), erase_block_size)) -/** - * Last block in the flash storage will be used for manufacturing storage. - * MFG_START_OFFSET = 0x0FF000 - * MFG_END_OFFSET = 0x100000 - */ -#define MFG_END_OFFSET (FIXED_PARTITION_OFFSET(mfg_storage) + FIXED_PARTITION_SIZE(mfg_storage)) -#define MFG_START_OFFSET (MFG_END_OFFSET - MFG_STORAGE_SIZE) - -static uint8_t test_data_buffer[512]; - -/****************************************************************** -* NOTE: DO NOT CHANGE THE ORDER OF THE TESTS! -* ****************************************************************/ -static void hton_buff(uint8_t *buffer, size_t buff_len) -{ - uint32_t val_l = 0; - size_t i = 0; - uint8_t mod_len = buff_len % sizeof(uint32_t); - - if (sizeof(uint32_t) <= buff_len) { - for (i = 0; i < (buff_len - mod_len); i += sizeof(uint32_t)) { - memcpy(&val_l, &buffer[i], sizeof(val_l)); - val_l = sys_cpu_to_be32(val_l); - memcpy(&buffer[i], &val_l, sizeof(val_l)); - } - } - // if 1 == mod_len then last byte shall be copied directly do destination buffer. - if (2 == mod_len) { - uint16_t val_s = 0; - memcpy(&val_s, &buffer[i], sizeof(val_s)); - val_s = sys_cpu_to_be16(val_s); - memcpy(&buffer[i], &val_s, sizeof(val_s)); - } else if (3 == mod_len) { - val_l = 0; - memcpy(&val_l, &buffer[i], 3 * sizeof(uint8_t)); - val_l = sys_cpu_to_be24(val_l); - memcpy(&buffer[i], &val_l, 3 * sizeof(uint8_t)); - } -} - -static void mfg_set_version(uint32_t version) -{ - uint8_t write_buff[SID_PAL_MFG_STORE_MAX_FLASH_WRITE_LEN]; - - memcpy(write_buff, &version, SID_PAL_MFG_STORE_VERSION_SIZE); - zassert_equal(0, sid_pal_mfg_store_write(SID_PAL_MFG_STORE_VERSION, write_buff, - SID_PAL_MFG_STORE_VERSION_SIZE)); - version = sys_cpu_to_be32(version); - zassert_equal(version, sid_pal_mfg_store_get_version()); -} - -static void mfg_clr_memory(void) -{ - zassert_equal(0, sid_pal_mfg_store_erase()); - zassert_true(sid_pal_mfg_store_is_empty()); -} - -ZTEST(mfg_storage, test_1sid_pal_mfg_storage_no_init) -{ - uint8_t read_buffer[SID_PAL_MFG_STORE_VERSION_SIZE] = { 0 }; - - zassert_equal(SID_ERROR_UNINITIALIZED, - sid_pal_mfg_store_write(SID_PAL_MFG_STORE_VERSION, read_buffer, - SID_PAL_MFG_STORE_VERSION_SIZE)); - zassert_equal(SID_ERROR_UNINITIALIZED, sid_pal_mfg_store_erase()); - zassert_false(sid_pal_mfg_store_is_empty()); - memset(read_buffer, 0xAA, SID_PAL_MFG_STORE_VERSION_SIZE); - memset(test_data_buffer, 0xAA, SID_PAL_MFG_STORE_VERSION_SIZE); - sid_pal_mfg_store_read(SID_PAL_MFG_STORE_VERSION, read_buffer, - SID_PAL_MFG_STORE_VERSION_SIZE); - zassert_mem_equal(read_buffer, test_data_buffer, SID_PAL_MFG_STORE_VERSION_SIZE); -} - -ZTEST(mfg_storage, test_2sid_pal_mfg_storage_init) -{ - static const sid_pal_mfg_store_region_t mfg_store_region = { - .addr_start = PM_MFG_STORAGE_ADDRESS, - .addr_end = PM_MFG_STORAGE_END_ADDRESS, - }; - - sid_pal_mfg_store_init(mfg_store_region); - zassert_equal(0, sid_pal_mfg_store_erase()); -} - -ZTEST(mfg_storage, test_3sid_pal_mfg_storage_write) -{ - uint8_t write_buff[SID_PAL_MFG_STORE_MAX_FLASH_WRITE_LEN] = { 0 }; - - zassert_equal(SID_ERROR_INVALID_ARGS, - sid_pal_mfg_store_write(SID_PAL_MFG_STORE_VERSION, write_buff, 0)); - zassert_equal(SID_ERROR_OUT_OF_RESOURCES, - sid_pal_mfg_store_write(SID_PAL_MFG_STORE_VERSION, write_buff, 128)); - zassert_equal(SID_ERROR_INCOMPATIBLE_PARAMS, - sid_pal_mfg_store_write(SID_PAL_MFG_STORE_VERSION, write_buff, 3)); - zassert_equal(SID_ERROR_NOT_FOUND, - sid_pal_mfg_store_write(999, write_buff, SID_PAL_MFG_STORE_VERSION_SIZE)); - zassert_equal(SID_ERROR_NULL_POINTER, - sid_pal_mfg_store_write(SID_PAL_MFG_STORE_VERSION, NULL, - SID_PAL_MFG_STORE_VERSION_SIZE)); - - mfg_set_version(MFG_VERSION_1_VAL); -} - -ZTEST(mfg_storage, test_4sid_pal_mfg_storage_read) -{ - uint32_t version = MFG_VERSION_1_VAL; - uint8_t read_buff[64]; - - sid_pal_mfg_store_read(SID_PAL_MFG_STORE_VERSION, read_buff, - SID_PAL_MFG_STORE_VERSION_SIZE); - zassert_mem_equal(&version, read_buff, SID_PAL_MFG_STORE_VERSION_SIZE); -} - -ZTEST(mfg_storage, test_5sid_pal_mfg_storage_erase) -{ - zassert_false(sid_pal_mfg_store_is_empty()); - mfg_clr_memory(); -} - -ZTEST(mfg_storage, test_6sid_pal_mfg_storage_dev_id_get) -{ - uint8_t dev_id[SID_PAL_MFG_STORE_DEVID_SIZE]; - uint8_t fake_dev_id[8] = { 0xAC, 0xBC, 0xCC, 0xDC, 0x11, 0x12, 0x13, 0x14 }; - - memset(dev_id, 0x00, sizeof(dev_id)); - mfg_clr_memory(); - - zassert_false(sid_pal_mfg_store_dev_id_get(dev_id)); - zassert_equal(0xBF, dev_id[0]); - // dev id is unique for every chip, so we cannot verify it in another way: - zassert_not_equal(0x00, dev_id[1]); - zassert_not_equal(0x00, dev_id[2]); - zassert_not_equal(0x00, dev_id[3]); - zassert_not_equal(0x00, dev_id[4]); - - memset(dev_id, 0x00, sizeof(dev_id)); - // Set fake dev_id. - zassert_equal(SID_ERROR_NOT_FOUND, - sid_pal_mfg_store_write(SID_PAL_MFG_STORE_DEVID, fake_dev_id, - sizeof(fake_dev_id))); -} - -ZTEST(mfg_storage, test_7sid_pal_mfg_storage_sn_get) -{ - uint8_t serial_num[SID_PAL_MFG_STORE_SERIAL_NUM_SIZE]; - uint8_t fake_serial_num[20]; - - for (int cnt = 0; cnt < sizeof(fake_serial_num); cnt++) { - fake_serial_num[cnt] = cnt; - } - - mfg_clr_memory(); - - // No serial number. - zassert_false(sid_pal_mfg_store_serial_num_get(serial_num)); - - // Set fake serial number. - zassert_equal(0, sid_pal_mfg_store_write(SID_PAL_MFG_STORE_SERIAL_NUM, fake_serial_num, - sizeof(fake_serial_num))); - zassert_true(sid_pal_mfg_store_serial_num_get(serial_num)); - zassert_mem_equal(fake_serial_num, serial_num, SID_PAL_MFG_STORE_SERIAL_NUM_SIZE); - - // Set version to MFG_VERSION_1_VAL - mfg_set_version(MFG_VERSION_1_VAL); - zassert_true(sid_pal_mfg_store_serial_num_get(serial_num)); - hton_buff(serial_num, SID_PAL_MFG_STORE_SERIAL_NUM_SIZE); - zassert_mem_equal(fake_serial_num, serial_num, SID_PAL_MFG_STORE_SERIAL_NUM_SIZE); -} - -ZTEST(mfg_storage, test_sanity) -{ - zassert_equal(true, true); -} - -ZTEST_SUITE(mfg_storage, NULL, NULL, NULL, NULL, NULL); diff --git a/tests/functional/mfg_storage/testcase.yaml b/tests/functional/mfg_storage/testcase.yaml deleted file mode 100644 index f0b454d391..0000000000 --- a/tests/functional/mfg_storage/testcase.yaml +++ /dev/null @@ -1,29 +0,0 @@ -tests: - sidewalk.test.integration.mfg_storage: - skip: true - 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 - - sidewalk.test.integration.mfg_storage_deprecated: - skip: true - sysbuild: true - tags: Sidewalk - platform_allow: nrf52840dk/nrf52840 nrf5340dk/nrf5340/cpuapp nrf54l15dk/nrf54l15/cpuapp - integration_platforms: - - nrf52840dk/nrf52840 - - nrf5340dk/nrf5340/cpuapp - - nrf54l15dk/nrf54l15/cpuapp - extra_configs: - - CONFIG_DEPRECATED_SIDEWALK_MFG_STORAGE=y diff --git a/tests/functional/spi_bus/boards/nrf54l15dk_nrf54l15_cpuapp_ns.conf b/tests/functional/spi_bus/boards/nrf54l15dk_nrf54l15_cpuapp_ns.conf deleted file mode 100644 index f46f9a650b..0000000000 --- a/tests/functional/spi_bus/boards/nrf54l15dk_nrf54l15_cpuapp_ns.conf +++ /dev/null @@ -1,21 +0,0 @@ -# -# Copyright (c) 2024 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause -# - -# Multirole is the only currently supported role by SoftDevice. -CONFIG_BT_LL_SOFTDEVICE_MULTIROLE=y - -# nRF54L15 requires bigger stack sizes than nRF52/nRF53 families -CONFIG_MPSL_WORK_STACK_SIZE=2048 - -# Not supported for 54L15 _NS -CONFIG_FPROTECT=n - -# Set the ZMS sector count to match the settings partition size that is 40 kB for this application. -CONFIG_SETTINGS_ZMS_SECTOR_COUNT=10 - -# Disable tf-m uart to reuse pins for semtech -CONFIG_TFM_LOG_LEVEL_SILENCE=y -CONFIG_TFM_SECURE_UART=n diff --git a/tests/functional/spi_bus/testcase.yaml b/tests/functional/spi_bus/testcase.yaml deleted file mode 100644 index 2666aa16f1..0000000000 --- a/tests/functional/spi_bus/testcase.yaml +++ /dev/null @@ -1,19 +0,0 @@ -tests: - sidewalk.test.integration.spi_bus: - sysbuild: true - 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 - tags: Sidewalk - harness: ztest - harness_config: - fixture: semtech_shield diff --git a/tests/functional/storage/Kconfig b/tests/functional/storage/Kconfig deleted file mode 100644 index 1f788caa4f..0000000000 --- a/tests/functional/storage/Kconfig +++ /dev/null @@ -1,24 +0,0 @@ -# -# Copyright (c) 2022 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause -# -config SIDEWALK_BUILD - default y - -config SIDEWALK_STORAGE - default y - imply NVS if !SOC_FLASH_NRF_RRAM - imply NVS_LOOKUP_CACHE if !SOC_FLASH_NRF_RRAM - imply NVS_LOOKUP_CACHE_FOR_SETTINGS if !SOC_FLASH_NRF_RRAM - imply ZMS if SOC_FLASH_NRF_RRAM - imply ZMS_LOOKUP_CACHE if SOC_FLASH_NRF_RRAM - imply ZMS_LOOKUP_CACHE_FOR_SETTINGS if SOC_FLASH_NRF_RRAM - imply FLASH_MAP - imply FLASH - imply SETTINGS - -config SIDEWALK_LOG_LEVEL - default 0 - -source "Kconfig.zephyr" diff --git a/tests/functional/storage/boards/nrf54l15dk_nrf54l15_cpuapp_ns.overlay b/tests/functional/storage/boards/nrf54l15dk_nrf54l15_cpuapp_ns.overlay deleted file mode 100644 index d2fb60c213..0000000000 --- a/tests/functional/storage/boards/nrf54l15dk_nrf54l15_cpuapp_ns.overlay +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2024 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - */ - -// restore full RRAM and SRAM space - by default some parts are dedicated to FLRP -&cpuapp_rram { - reg = <0x0 DT_SIZE_K(1524)>; -}; - -&cpuapp_sram { - reg = <0x20000000 DT_SIZE_K(256)>; - ranges = <0x0 0x20000000 0x40000>; -}; - - -// Change IRQ ids to handle button interrupts. - -// The default values for nRF54L15 are 219 and 269, -// but with TF-M they are reserved for the secure domain -// (218 and 268 are reserved for the non-secure domain). -&gpiote20 { - interrupts = <218 NRF_DEFAULT_IRQ_PRIORITY>; -}; - -&gpiote30 { - interrupts = <268 NRF_DEFAULT_IRQ_PRIORITY>; -}; diff --git a/tests/functional/time/CMakeLists.txt b/tests/functional/time/CMakeLists.txt deleted file mode 100644 index a908c40594..0000000000 --- a/tests/functional/time/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -# -# 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_functional_test) - -# add test file -FILE(GLOB app_sources src/*.c) -target_sources(app PRIVATE ${app_sources}) -target_include_directories(app PRIVATE .) diff --git a/tests/functional/time/prj.conf b/tests/functional/time/prj.conf deleted file mode 100644 index c003000614..0000000000 --- a/tests/functional/time/prj.conf +++ /dev/null @@ -1,14 +0,0 @@ -# -# Copyright (c) 2022 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause -# - -CONFIG_TEST=y -CONFIG_ZTEST=y - -CONFIG_MAIN_THREAD_PRIORITY=14 - -# Llibraries -CONFIG_NEWLIB_LIBC=y -CONFIG_FPU=y diff --git a/tests/integration/crypto/CMakeLists.txt b/tests/integration/crypto/CMakeLists.txt new file mode 100644 index 0000000000..6a7211a57d --- /dev/null +++ b/tests/integration/crypto/CMakeLists.txt @@ -0,0 +1,15 @@ +# +# 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_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}) diff --git a/tests/functional/crypto/Kconfig b/tests/integration/crypto/Kconfig similarity index 100% rename from tests/functional/crypto/Kconfig rename to tests/integration/crypto/Kconfig diff --git a/tests/functional/crypto/Kconfig.defconfig b/tests/integration/crypto/Kconfig.defconfig similarity index 100% rename from tests/functional/crypto/Kconfig.defconfig rename to tests/integration/crypto/Kconfig.defconfig diff --git a/tests/integration/crypto/boards/native_sim.conf b/tests/integration/crypto/boards/native_sim.conf new file mode 100644 index 0000000000..3407565e6b --- /dev/null +++ b/tests/integration/crypto/boards/native_sim.conf @@ -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 diff --git a/tests/functional/crypto/boards/nrf5340dk_nrf5340_cpuapp_ns.conf b/tests/integration/crypto/boards/nrf5340dk_nrf5340_cpuapp_ns.conf similarity index 100% rename from tests/functional/crypto/boards/nrf5340dk_nrf5340_cpuapp_ns.conf rename to tests/integration/crypto/boards/nrf5340dk_nrf5340_cpuapp_ns.conf diff --git a/tests/functional/spi_bus/prj.conf b/tests/integration/crypto/prj.conf similarity index 83% rename from tests/functional/spi_bus/prj.conf rename to tests/integration/crypto/prj.conf index 500cf51632..ab0019a262 100644 --- a/tests/functional/spi_bus/prj.conf +++ b/tests/integration/crypto/prj.conf @@ -3,8 +3,7 @@ # # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause # - -# Sidewalk -CONFIG_UNITY=y CONFIG_ZTEST=y CONFIG_MAIN_THREAD_PRIORITY=14 + +CONFIG_PSA_WANT_ALG_SHA_512=y diff --git a/tests/functional/crypto/src/main.c b/tests/integration/crypto/src/main.c similarity index 99% rename from tests/functional/crypto/src/main.c rename to tests/integration/crypto/src/main.c index 0926a68e9b..033c973b48 100644 --- a/tests/functional/crypto/src/main.c +++ b/tests/integration/crypto/src/main.c @@ -300,8 +300,6 @@ ZTEST(crypto, test_sid_pal_crypto_hash_256) zassert_equal(SID_ERROR_OUT_OF_RESOURCES, sid_pal_crypto_hash(¶ms)); } -#if defined(CONFIG_SOC_SERIES_NRF54LX) - ZTEST(crypto, test_sid_pal_crypto_hash_512) { sid_pal_hash_params_t params; @@ -375,8 +373,6 @@ ZTEST(crypto, test_sid_pal_crypto_hash_512) zassert_equal(SID_ERROR_NONE, sid_pal_crypto_hash(¶ms)); } -#endif /* CONFIG_SOC_SERIES_NRF54LX */ - /********************************************** * HMAC * ********************************************/ @@ -516,7 +512,6 @@ ZTEST(crypto, test_sid_pal_crypto_hmac_sha256_fake_key) zassert_not_equal(0, memcmp(openssl_test_hmac_sha256_vector, digest, SHA256_LEN)); } -#if defined(CONFIG_SOC_SERIES_NRF54LX) ZTEST(crypto, test_sid_pal_crypto_hmac_sha512) { sid_pal_hmac_params_t params; @@ -636,8 +631,6 @@ ZTEST(crypto, test_sid_pal_crypto_hmac_sha512_fake_key) zassert_not_equal(0, memcmp(openssl_test_hmac_sha512_vector, digest, SHA512_LEN)); } -#endif /* CONFIG_SOC_SERIES_NRF54LX */ - /********************************************** * END HMAC * ********************************************/ @@ -2017,7 +2010,6 @@ ZTEST(crypto, test_sid_pal_crypto_ecc_dsa) params.key = public_Ed25519; params.key_size = sizeof(public_Ed25519); sid_error_t ret = sid_pal_crypto_ecc_dsa(¶ms); - printk("ret: %d\n", ret); zassert_equal(SID_ERROR_NONE, ret); // Bad public key diff --git a/tests/functional/crypto/testcase.yaml b/tests/integration/crypto/testcase.yaml similarity index 100% rename from tests/functional/crypto/testcase.yaml rename to tests/integration/crypto/testcase.yaml diff --git a/tests/functional/spi_bus/CMakeLists.txt b/tests/integration/mfg/CMakeLists.txt similarity index 90% rename from tests/functional/spi_bus/CMakeLists.txt rename to tests/integration/mfg/CMakeLists.txt index a908c40594..b95e88c5c1 100644 --- a/tests/functional/spi_bus/CMakeLists.txt +++ b/tests/integration/mfg/CMakeLists.txt @@ -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_mfg_test) # add test file FILE(GLOB app_sources src/*.c) diff --git a/tests/functional/mfg_storage/Kconfig b/tests/integration/mfg/Kconfig similarity index 87% rename from tests/functional/mfg_storage/Kconfig rename to tests/integration/mfg/Kconfig index 0a28c57745..e01359cf6c 100644 --- a/tests/functional/mfg_storage/Kconfig +++ b/tests/integration/mfg/Kconfig @@ -7,13 +7,6 @@ config SIDEWALK_BUILD default y config SIDEWALK_MFG_STORAGE - imply FLASH - default y - -config SIDEWALK_LOG_LEVEL - default 0 - -config SHELL default y config SIDEWALK_MFG_STORAGE_DIAGNOSTIC @@ -28,4 +21,8 @@ config SIDEWALK_TLV_FLASH config SIDEWALK_TLV_RAM default y +config SIDEWALK_LOG_LEVEL + default 0 + source "Kconfig.zephyr" +source "${ZEPHYR_BASE}/../sidewalk/Kconfig.dependencies" diff --git a/tests/integration/mfg/boards/nrf54l15dk_nrf54l10_cpuapp.overlay b/tests/integration/mfg/boards/nrf54l15dk_nrf54l10_cpuapp.overlay new file mode 100644 index 0000000000..e5d21541b8 --- /dev/null +++ b/tests/integration/mfg/boards/nrf54l15dk_nrf54l10_cpuapp.overlay @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +&cpuapp_rram { + reg = <0x0 DT_SIZE_K(1024)>; +}; + +&cpuapp_sram { + reg = <0x20000000 DT_SIZE_K(192)>; + ranges = <0x0 0x20000000 DT_SIZE_K(192)>; +}; diff --git a/tests/functional/mfg_storage/boards/nrf54l15dk_nrf54l15_cpuapp.overlay b/tests/integration/mfg/boards/nrf54l15dk_nrf54l15_cpuapp.overlay similarity index 100% rename from tests/functional/mfg_storage/boards/nrf54l15dk_nrf54l15_cpuapp.overlay rename to tests/integration/mfg/boards/nrf54l15dk_nrf54l15_cpuapp.overlay diff --git a/tests/functional/mfg_storage/boards/nrf54l15dk_nrf54l15_cpuapp_ns.overlay b/tests/integration/mfg/boards/nrf54l15dk_nrf54l15_cpuapp_ns.overlay similarity index 100% rename from tests/functional/mfg_storage/boards/nrf54l15dk_nrf54l15_cpuapp_ns.overlay rename to tests/integration/mfg/boards/nrf54l15dk_nrf54l15_cpuapp_ns.overlay diff --git a/tests/integration/mfg/pm_static.yml b/tests/integration/mfg/pm_static.yml new file mode 100644 index 0000000000..38e6c17c13 --- /dev/null +++ b/tests/integration/mfg/pm_static.yml @@ -0,0 +1,4 @@ +mfg_storage: + address: 0xff000 + region: flash_primary + size: 0x1000 diff --git a/tests/integration/mfg/pm_static_nrf54l15dk_nrf54l10_cpuapp.yml b/tests/integration/mfg/pm_static_nrf54l15dk_nrf54l10_cpuapp.yml new file mode 100644 index 0000000000..38e6c17c13 --- /dev/null +++ b/tests/integration/mfg/pm_static_nrf54l15dk_nrf54l10_cpuapp.yml @@ -0,0 +1,4 @@ +mfg_storage: + address: 0xff000 + region: flash_primary + size: 0x1000 diff --git a/tests/functional/mfg_storage/pm_static_nrf54l15dk_nrf54l15_cpuapp.yml b/tests/integration/mfg/pm_static_nrf54l15dk_nrf54l15_cpuapp.yml similarity index 100% rename from tests/functional/mfg_storage/pm_static_nrf54l15dk_nrf54l15_cpuapp.yml rename to tests/integration/mfg/pm_static_nrf54l15dk_nrf54l15_cpuapp.yml diff --git a/tests/functional/mfg_storage/pm_static_nrf54l15dk_nrf54l15_cpuapp_ns.yml b/tests/integration/mfg/pm_static_nrf54l15dk_nrf54l15_cpuapp_ns.yml similarity index 100% rename from tests/functional/mfg_storage/pm_static_nrf54l15dk_nrf54l15_cpuapp_ns.yml rename to tests/integration/mfg/pm_static_nrf54l15dk_nrf54l15_cpuapp_ns.yml diff --git a/tests/functional/mfg_storage/prj.conf b/tests/integration/mfg/prj.conf similarity index 99% rename from tests/functional/mfg_storage/prj.conf rename to tests/integration/mfg/prj.conf index 718ae4c500..bca7c1d7cc 100644 --- a/tests/functional/mfg_storage/prj.conf +++ b/tests/integration/mfg/prj.conf @@ -3,7 +3,6 @@ # # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause # - CONFIG_ZTEST=y CONFIG_MAIN_THREAD_PRIORITY=14 CONFIG_PARTITION_MANAGER_ENABLED=y diff --git a/tests/integration/mfg/src/main.c b/tests/integration/mfg/src/main.c new file mode 100644 index 0000000000..ff5f38424b --- /dev/null +++ b/tests/integration/mfg/src/main.c @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2022 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +#include + +#include +#include +#include + +ZTEST(mfg, test_mfg_storage_read_write) +{ + uint8_t write_data[SID_PAL_MFG_STORE_DEVID_SIZE] = { 1, 2, 3, 4, 5 }; + uint8_t read_data[SID_PAL_MFG_STORE_DEVID_SIZE] = { 0 }; + + sid_pal_mfg_store_region_t mfg_store_region = { + .addr_start = (uintptr_t)(FIXED_PARTITION_OFFSET(mfg_storage)), + .addr_end = (uintptr_t)(FIXED_PARTITION_OFFSET(mfg_storage) + + FIXED_PARTITION_SIZE(mfg_storage)), + .app_value_to_offset = NULL + }; + sid_pal_mfg_store_init(mfg_store_region); + + zassert_equal(SID_ERROR_NONE, sid_pal_mfg_store_write(SID_PAL_MFG_STORE_SERIAL_NUM, write_data, sizeof(write_data))); + + sid_pal_mfg_store_read(SID_PAL_MFG_STORE_DEVID, read_data, sizeof(read_data)); + zassert_mem_equal(write_data, read_data, sizeof(write_data), + "Read data does not match written data"); + + sid_pal_mfg_store_deinit(); +} + +ZTEST_SUITE(mfg, NULL, NULL, NULL, NULL, NULL); diff --git a/tests/integration/mfg/testcase.yaml b/tests/integration/mfg/testcase.yaml new file mode 100644 index 0000000000..24c5a67cf2 --- /dev/null +++ b/tests/integration/mfg/testcase.yaml @@ -0,0 +1,9 @@ +tests: + sidewalk.test.integration.mfg: + skip: true + sysbuild: true + tags: Sidewalk + platform_allow: + - nrf52840dk/nrf52840 + integration_platforms: + - nrf52840dk/nrf52840 diff --git a/tests/integration/spi/CMakeLists.txt b/tests/integration/spi/CMakeLists.txt new file mode 100644 index 0000000000..d6ac360f55 --- /dev/null +++ b/tests/integration/spi/CMakeLists.txt @@ -0,0 +1,15 @@ +# +# 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_spi_test) + +# add test file +FILE(GLOB app_sources src/main.c) +target_sources(app PRIVATE ${app_sources}) +target_include_directories(app PRIVATE .) diff --git a/tests/functional/spi_bus/Kconfig b/tests/integration/spi/Kconfig similarity index 81% rename from tests/functional/spi_bus/Kconfig rename to tests/integration/spi/Kconfig index 3c4ce35a2e..618b39690c 100644 --- a/tests/functional/spi_bus/Kconfig +++ b/tests/integration/spi/Kconfig @@ -9,22 +9,22 @@ config SIDEWALK_BUILD config SIDEWALK_SUBGHZ_SUPPORT default y +config SIDEWALK_TEMPERATURE + default n + config SIDEWALK_SUBGHZ_TRIM_CAP_VAL hex "value for trim cap used by subGHz radio" range 0x0 0xFFFF default 0x1212 - help - The value of the trim cap. Default value works for Semtech SX1262 shield config SIDEWALK_SPI_BUS default y - imply SPI - imply PM - imply PM_DEVICE config SIDEWALK_GPIO default y - imply GPIO + +config SIDEWALK_GPIO_MAX + default 6 config SIDEWALK_GPIO_IRQ_PRIORITY default 1 @@ -38,7 +38,5 @@ config SIDEWALK_LOG_LEVEL config SPI_BUS_LOG_LEVEL default 0 -config SIDEWALK_GPIO_MAX - default 6 - source "Kconfig.zephyr" +source "${ZEPHYR_BASE}/../sidewalk/Kconfig.dependencies" diff --git a/tests/functional/spi_bus/boards/nrf52840dk_nrf52840.overlay b/tests/integration/spi/boards/nrf52840dk_nrf52840.overlay similarity index 100% rename from tests/functional/spi_bus/boards/nrf52840dk_nrf52840.overlay rename to tests/integration/spi/boards/nrf52840dk_nrf52840.overlay diff --git a/tests/functional/spi_bus/boards/nrf5340dk_nrf5340_cpuapp.overlay b/tests/integration/spi/boards/nrf5340dk_nrf5340_cpuapp.overlay similarity index 100% rename from tests/functional/spi_bus/boards/nrf5340dk_nrf5340_cpuapp.overlay rename to tests/integration/spi/boards/nrf5340dk_nrf5340_cpuapp.overlay diff --git a/tests/integration/spi/boards/nrf54l15dk_nrf54l10_cpuapp.overlay b/tests/integration/spi/boards/nrf54l15dk_nrf54l10_cpuapp.overlay new file mode 100644 index 0000000000..ecbeb1a16b --- /dev/null +++ b/tests/integration/spi/boards/nrf54l15dk_nrf54l10_cpuapp.overlay @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + + /{ + semtech_sx1262_gpios{ + compatible = "gpio-keys"; + semtech_sx1262_reset_gpios: reset { + gpios = <&gpio2 8 (GPIO_ACTIVE_LOW|GPIO_PULL_UP)>; + label = "semtech_sx1262 Reset"; + }; + semtech_sx1262_busy_gpios: busy { + gpios = <&gpio2 6 (GPIO_ACTIVE_HIGH)>; + label = "semtech_sx1262 Busy"; + }; + semtech_sx1262_antenna_enable_gpios: antena_enable { + gpios = <&gpio2 10 (GPIO_ACTIVE_HIGH)>; + label = "semtech_sx1262 Antena Enable"; + }; + semtech_sx1262_dio1_gpios: dio1 { + gpios = <&gpio1 11 (GPIO_ACTIVE_HIGH|GPIO_PULL_DOWN)>; + label = "semtech_sx1262 DIO1"; + }; + }; +}; + +sid_semtech: &spi30 { + compatible = "nordic,nrf-spim"; + status = "okay"; + cs-gpios = <&gpio0 0 GPIO_ACTIVE_LOW>; + pinctrl-0 = <&spi30_default_alt>; + pinctrl-1 = <&spi30_sleep_alt>; + pinctrl-names = "default", "sleep"; + clock-frequency = ; +}; + +&cpuapp_rram { + reg = <0x0 DT_SIZE_K(1524)>; +}; + +&cpuapp_sram { + reg = <0x20000000 DT_SIZE_K(256)>; + ranges = <0x0 0x20000000 0x40000>; +}; + +&pinctrl { + spi30_default_alt: spi30_default_alt { + group1 { + psels = , + , + ; + }; + }; + + spi30_sleep_alt: spi30_sleep_alt { + group1 { + psels = , + , + ; + low-power-enable; + }; + }; +}; + +// TODO: re-enable HWFC once it's fixed +&uart20 { + /delete-property/ hw-flow-control; +}; diff --git a/tests/functional/spi_bus/boards/nrf54l15dk_nrf54l15_cpuapp.overlay b/tests/integration/spi/boards/nrf54l15dk_nrf54l15_cpuapp.overlay similarity index 76% rename from tests/functional/spi_bus/boards/nrf54l15dk_nrf54l15_cpuapp.overlay rename to tests/integration/spi/boards/nrf54l15dk_nrf54l15_cpuapp.overlay index b8809f5cad..ecbeb1a16b 100644 --- a/tests/functional/spi_bus/boards/nrf54l15dk_nrf54l15_cpuapp.overlay +++ b/tests/integration/spi/boards/nrf54l15dk_nrf54l15_cpuapp.overlay @@ -5,13 +5,6 @@ */ /{ - aliases { - state-notifier-connected = &led0; - state-notifier-time-sync = &led1; - state-notifier-registered = &led2; - state-notifier-working = &led3; - }; - semtech_sx1262_gpios{ compatible = "gpio-keys"; semtech_sx1262_reset_gpios: reset { @@ -31,9 +24,6 @@ label = "semtech_sx1262 DIO1"; }; }; - - // Use watchdog wdt31 as the application watchdog - watchdog0 = &wdt31; }; sid_semtech: &spi30 { @@ -46,7 +36,6 @@ sid_semtech: &spi30 { clock-frequency = ; }; -// restore full RRAM and SRAM space - by default some parts are dedicated to FLRP &cpuapp_rram { reg = <0x0 DT_SIZE_K(1524)>; }; @@ -75,26 +64,6 @@ sid_semtech: &spi30 { }; }; -&gpio0 { - status = "okay"; -}; - -&gpio1 { - status = "okay"; -}; - -&gpio2 { - status = "okay"; -}; - -&wdt31 { - status = "okay"; -}; - -&mx25r64 { - status = "disabled"; -}; - // TODO: re-enable HWFC once it's fixed &uart20 { /delete-property/ hw-flow-control; diff --git a/tests/integration/spi/boards/nrf54l15dk_nrf54l15_cpuapp_ns.conf b/tests/integration/spi/boards/nrf54l15dk_nrf54l15_cpuapp_ns.conf new file mode 100644 index 0000000000..9d282f3e7c --- /dev/null +++ b/tests/integration/spi/boards/nrf54l15dk_nrf54l15_cpuapp_ns.conf @@ -0,0 +1,9 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +# Disable tf-m uart to reuse pins for semtech +CONFIG_TFM_LOG_LEVEL_SILENCE=y +CONFIG_TFM_SECURE_UART=n diff --git a/tests/functional/spi_bus/boards/nrf54l15dk_nrf54l15_cpuapp_ns.overlay b/tests/integration/spi/boards/nrf54l15dk_nrf54l15_cpuapp_ns.overlay similarity index 83% rename from tests/functional/spi_bus/boards/nrf54l15dk_nrf54l15_cpuapp_ns.overlay rename to tests/integration/spi/boards/nrf54l15dk_nrf54l15_cpuapp_ns.overlay index baf527fc41..1de3413a75 100644 --- a/tests/functional/spi_bus/boards/nrf54l15dk_nrf54l15_cpuapp_ns.overlay +++ b/tests/integration/spi/boards/nrf54l15dk_nrf54l15_cpuapp_ns.overlay @@ -5,13 +5,6 @@ */ /{ - aliases { - state-notifier-connected = &led0; - state-notifier-time-sync = &led1; - state-notifier-registered = &led2; - state-notifier-working = &led3; - }; - semtech_sx1262_gpios{ compatible = "gpio-keys"; semtech_sx1262_reset_gpios: reset { @@ -71,25 +64,6 @@ sid_semtech: &spi30 { }; }; -&adc { - status = "disabled"; -}; -&uart21 { - status = "disabled"; -}; -&pwm20 { - status = "disabled"; -}; -&i2c20 { - status = "disabled"; -}; -&spi20 { - status = "disabled"; -}; -&spi22 { - status = "disabled"; -}; - // TODO: re-enable HWFC once it's fixed &uart20 { /delete-property/ hw-flow-control; diff --git a/tests/functional/pal_delay/prj.conf b/tests/integration/spi/prj.conf similarity index 99% rename from tests/functional/pal_delay/prj.conf rename to tests/integration/spi/prj.conf index 4c3e852a78..9320387007 100644 --- a/tests/functional/pal_delay/prj.conf +++ b/tests/integration/spi/prj.conf @@ -3,6 +3,5 @@ # # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause # - CONFIG_ZTEST=y CONFIG_MAIN_THREAD_PRIORITY=14 diff --git a/tests/functional/spi_bus/src/main.c b/tests/integration/spi/src/main.c similarity index 94% rename from tests/functional/spi_bus/src/main.c rename to tests/integration/spi/src/main.c index cf7528c699..220881d8a1 100644 --- a/tests/functional/spi_bus/src/main.c +++ b/tests/integration/spi/src/main.c @@ -17,6 +17,11 @@ #include #include +#if defined(CONFIG_SOC_POSIX) +#define NULL_STRUCT_INITIALIZER { 0 } +#define INVALID_DT_GPIO NULL_STRUCT_INITIALIZER +#endif /* CONFIG_SOC_POSIX */ + ZTEST(spi_bus, test_init_spi) { const struct sid_pal_serial_bus_iface *interface; @@ -90,14 +95,10 @@ ZTEST(spi_bus, test_send_spi) zassert_not_null(interface->xfer); uint8_t tx[] = { 0x1d, 0x08, 0xac, 0, 0 }; uint8_t rx[5] = { 0 }; - uint8_t invalid_rx[5] = { 0 }; sid_error_t e = interface->xfer(interface, &client, tx, rx, sizeof(rx)); + printk("err %d\n", e); zassert_equal(SID_ERROR_NONE, e); - for (int i = 0; i < ARRAY_SIZE(rx); i++) { - printf("%x ", rx[i]); - } - zassert_true(memcmp(rx, invalid_rx, ARRAY_SIZE(rx)) != 0); } ZTEST(spi_bus, test_only_tx_spi) @@ -118,9 +119,4 @@ ZTEST(spi_bus, test_only_tx_spi) zassert_equal(SID_ERROR_NONE, e); } -ZTEST(spi_bus, test_sanity) -{ - zassert_equal(true, true); -} - ZTEST_SUITE(spi_bus, NULL, NULL, NULL, NULL, NULL); diff --git a/tests/functional/time/testcase.yaml b/tests/integration/spi/testcase.yaml similarity index 80% rename from tests/functional/time/testcase.yaml rename to tests/integration/spi/testcase.yaml index 8a982c6407..e8afef2cdd 100644 --- a/tests/functional/time/testcase.yaml +++ b/tests/integration/spi/testcase.yaml @@ -1,15 +1,13 @@ tests: - sidewalk.test.integration.time: + sidewalk.test.integration.spi: 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 diff --git a/tests/functional/storage/CMakeLists.txt b/tests/integration/storage/CMakeLists.txt similarity index 93% rename from tests/functional/storage/CMakeLists.txt rename to tests/integration/storage/CMakeLists.txt index dfcbef6c5d..cdb0fd480d 100644 --- a/tests/functional/storage/CMakeLists.txt +++ b/tests/integration/storage/CMakeLists.txt @@ -7,10 +7,10 @@ cmake_minimum_required(VERSION 3.20.0) find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) -project(sidewalk_functional_test) -set(SIDEWALK_BASE $ENV{ZEPHYR_BASE}/../sidewalk) +project(sidewalk_storage_test) # add test file FILE(GLOB app_sources src/*.c) +set(SIDEWALK_BASE $ENV{ZEPHYR_BASE}/../sidewalk) target_sources(app PRIVATE ${app_sources} ${SIDEWALK_BASE}/utils/settings_utils/settings_utils.c) target_include_directories(app PRIVATE . ${SIDEWALK_BASE}/utils/include) diff --git a/tests/integration/storage/Kconfig b/tests/integration/storage/Kconfig new file mode 100644 index 0000000000..07a48ff7da --- /dev/null +++ b/tests/integration/storage/Kconfig @@ -0,0 +1,16 @@ +# +# Copyright (c) 2022 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# +config SIDEWALK_BUILD + default y + +config SIDEWALK_STORAGE + default y + +config SIDEWALK_LOG_LEVEL + default 0 + +source "Kconfig.zephyr" +source "${ZEPHYR_BASE}/../sidewalk/Kconfig.dependencies" diff --git a/tests/functional/temperature/prj.conf b/tests/integration/storage/prj.conf similarity index 92% rename from tests/functional/temperature/prj.conf rename to tests/integration/storage/prj.conf index 894584b362..9320387007 100644 --- a/tests/functional/temperature/prj.conf +++ b/tests/integration/storage/prj.conf @@ -3,8 +3,5 @@ # # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause # - -# Sidewalk - CONFIG_ZTEST=y CONFIG_MAIN_THREAD_PRIORITY=14 diff --git a/tests/functional/storage/src/main.c b/tests/integration/storage/src/main.c similarity index 88% rename from tests/functional/storage/src/main.c rename to tests/integration/storage/src/main.c index 1d34a1aa33..bc4b6dc8c9 100644 --- a/tests/functional/storage/src/main.c +++ b/tests/integration/storage/src/main.c @@ -45,27 +45,9 @@ static void *sid_pal_storage_test_init(void) return NULL; } -/****************************************************************** -* NOTE: DO NOT CHANGE THE ORDER OF THE TESTS! -* ****************************************************************/ -// ZTEST(functional_storage, test_1sid_pal_storage_no_init) -// { -// uint32_t len; - -// // NVM is not initialized. -// zassert_equal(SID_ERROR_STORAGE_ERASE_FAIL, -// sid_pal_storage_kv_group_delete(GROUP_ID_TEST_OK)); -// zassert_equal(SID_ERROR_STORAGE_WRITE_FAIL, -// sid_pal_storage_kv_record_set(GROUP_ID_TEST_OK, TEST_KEY_1, &test_data[0], -// sizeof(test_data[0]))); -// zassert_equal(SID_ERROR_STORAGE_READ_FAIL, -// sid_pal_storage_kv_record_get(GROUP_ID_TEST_OK, TEST_KEY_1, &test_read_data, -// sizeof(test_read_data))); -// zassert_equal(SID_ERROR_STORAGE_READ_FAIL, -// sid_pal_storage_kv_record_get_len(GROUP_ID_TEST_OK, TEST_KEY_1, &len)); -// zassert_equal(SID_ERROR_STORAGE_ERASE_FAIL, -// sid_pal_storage_kv_record_delete(GROUP_ID_TEST_OK, TEST_KEY_1)); -// } +/*********************************************** + * NOTE: DO NOT CHANGE THE ORDER OF THE TESTS! * + **********************************************/ ZTEST(functional_storage, test_2sid_pal_storage_kv_init) { @@ -261,9 +243,4 @@ ZTEST(functional_storage, test_8sid_pal_storage_erase_all_2) sid_pal_storage_kv_record_get_len(GROUP_ID_TEST_OK, test_key_x, &len)); } -ZTEST(functional_storage, test_sanity) -{ - zassert_equal(true, true); -} - ZTEST_SUITE(functional_storage, NULL, sid_pal_storage_test_init, NULL, NULL, NULL); diff --git a/tests/functional/storage/testcase.yaml b/tests/integration/storage/testcase.yaml similarity index 92% rename from tests/functional/storage/testcase.yaml rename to tests/integration/storage/testcase.yaml index 370f95866e..723eca181a 100644 --- a/tests/functional/storage/testcase.yaml +++ b/tests/integration/storage/testcase.yaml @@ -3,12 +3,14 @@ tests: 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 diff --git a/tests_new/integration/critical_region/CMakeLists.txt b/tests_new/integration/critical_region/CMakeLists.txt new file mode 100644 index 0000000000..df11303c62 --- /dev/null +++ b/tests_new/integration/critical_region/CMakeLists.txt @@ -0,0 +1,15 @@ +# +# 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_critical_region_test) + +# add test file +FILE(GLOB app_sources src/*.c) +target_sources(app PRIVATE ${app_sources}) +target_include_directories(app PRIVATE .) diff --git a/tests/functional/critical_region/Kconfig b/tests_new/integration/critical_region/Kconfig similarity index 68% rename from tests/functional/critical_region/Kconfig rename to tests_new/integration/critical_region/Kconfig index 60a5c6f59a..d978c521b0 100644 --- a/tests/functional/critical_region/Kconfig +++ b/tests_new/integration/critical_region/Kconfig @@ -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" diff --git a/tests/functional/crypto_keys/prj.conf b/tests_new/integration/critical_region/prj.conf similarity index 84% rename from tests/functional/crypto_keys/prj.conf rename to tests_new/integration/critical_region/prj.conf index aef3015656..6a6f60551e 100644 --- a/tests/functional/crypto_keys/prj.conf +++ b/tests_new/integration/critical_region/prj.conf @@ -5,4 +5,4 @@ # CONFIG_ZTEST=y CONFIG_MAIN_THREAD_PRIORITY=14 -CONFIG_NVS_LOG_LEVEL_WRN=y +CONFIG_NO_OPTIMIZATIONS=y diff --git a/tests_new/integration/critical_region/src/main.c b/tests_new/integration/critical_region/src/main.c new file mode 100644 index 0000000000..8fba14f5b0 --- /dev/null +++ b/tests_new/integration/critical_region/src/main.c @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2022 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +#include +#include +#include +#include + +#if defined(CONFIG_SOC_FAMILY_NORDIC_NRF) +#include +#elif defined(CONFIG_SOC_POSIX) +#include +#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); diff --git a/tests/functional/critical_region/testcase.yaml b/tests_new/integration/critical_region/testcase.yaml similarity index 88% rename from tests/functional/critical_region/testcase.yaml rename to tests_new/integration/critical_region/testcase.yaml index 6ac26b1c23..ad9ec1788f 100644 --- a/tests/functional/critical_region/testcase.yaml +++ b/tests_new/integration/critical_region/testcase.yaml @@ -1,13 +1,16 @@ 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 diff --git a/tests/functional/crypto_keys/CMakeLists.txt b/tests_new/integration/crypto_keys/CMakeLists.txt similarity index 100% rename from tests/functional/crypto_keys/CMakeLists.txt rename to tests_new/integration/crypto_keys/CMakeLists.txt diff --git a/tests/functional/crypto_keys/Kconfig b/tests_new/integration/crypto_keys/Kconfig similarity index 90% rename from tests/functional/crypto_keys/Kconfig rename to tests_new/integration/crypto_keys/Kconfig index 7ea11a2dc4..2ecbb007a4 100644 --- a/tests/functional/crypto_keys/Kconfig +++ b/tests_new/integration/crypto_keys/Kconfig @@ -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 diff --git a/tests/functional/crypto_keys/Kconfig.defconfig b/tests_new/integration/crypto_keys/Kconfig.defconfig similarity index 100% rename from tests/functional/crypto_keys/Kconfig.defconfig rename to tests_new/integration/crypto_keys/Kconfig.defconfig diff --git a/tests/functional/crypto_keys/boards/nrf52840dk_nrf52840.conf b/tests_new/integration/crypto_keys/boards/nrf52840dk_nrf52840.conf similarity index 100% rename from tests/functional/crypto_keys/boards/nrf52840dk_nrf52840.conf rename to tests_new/integration/crypto_keys/boards/nrf52840dk_nrf52840.conf diff --git a/tests/functional/crypto_keys/boards/nrf5340dk_nrf5340_cpuapp_ns.conf b/tests_new/integration/crypto_keys/boards/nrf5340dk_nrf5340_cpuapp_ns.conf similarity index 100% rename from tests/functional/crypto_keys/boards/nrf5340dk_nrf5340_cpuapp_ns.conf rename to tests_new/integration/crypto_keys/boards/nrf5340dk_nrf5340_cpuapp_ns.conf diff --git a/tests/functional/storage/prj.conf b/tests_new/integration/crypto_keys/prj.conf similarity index 91% rename from tests/functional/storage/prj.conf rename to tests_new/integration/crypto_keys/prj.conf index 364699b23a..9320387007 100644 --- a/tests/functional/storage/prj.conf +++ b/tests_new/integration/crypto_keys/prj.conf @@ -3,6 +3,5 @@ # # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause # -CONFIG_UNITY=y CONFIG_ZTEST=y CONFIG_MAIN_THREAD_PRIORITY=14 diff --git a/tests/functional/crypto_keys/src/main.c b/tests_new/integration/crypto_keys/src/main.c similarity index 88% rename from tests/functional/crypto_keys/src/main.c rename to tests_new/integration/crypto_keys/src/main.c index 761aa5e215..08a11c3030 100644 --- a/tests/functional/crypto_keys/src/main.c +++ b/tests_new/integration/crypto_keys/src/main.c @@ -25,19 +25,31 @@ static void *setup(void) return NULL; } -static void teardown(void *f) +static void teardown(void *arg) { + ARG_UNUSED(arg); sid_pal_crypto_deinit(); } -ZTEST(crypto_keys, test_sid_crypto_key_invalid_args) +static void before(void *arg) { - int err = -ENOEXEC; - uint8_t key_data[TEST_SYMMETRIC_KEY_SIZE]; - uint8_t ecc_key_data[TEST_ECC_PUBLIC_KEY_SIZE]; + ARG_UNUSED(arg); + int err = sid_crypto_keys_init(); + zassert_equal(0, err, "err: %d", err); +} - err = sid_crypto_keys_init(); +static void after(void *arg) +{ + ARG_UNUSED(arg); + int err = sid_crypto_keys_deinit(); zassert_equal(0, err, "err: %d", err); +} + +ZTEST(crypto_keys, test_sid_crypto_key_invalid_args) +{ + int err = -ENOEXEC; + uint8_t key_data[TEST_SYMMETRIC_KEY_SIZE] = { 0 }; + uint8_t ecc_key_data[TEST_ECC_PUBLIC_KEY_SIZE] = { 0 }; /* Invalid data */ psa_key_id_t new_key_id = PSA_KEY_ID_NULL; @@ -87,9 +99,6 @@ ZTEST(crypto_keys, test_sid_crypto_key_import) psa_key_id_t new_key_id = PSA_KEY_ID_NULL; int err = -ENOEXEC; - err = sid_crypto_keys_init(); - zassert_equal(0, err, "err: %d", err); - err = sid_crypto_keys_new_import(test_key_id, test_key_data, TEST_SYMMETRIC_KEY_SIZE); zassert_equal(0, err, "err: %d", err); @@ -103,9 +112,6 @@ ZTEST(crypto_keys, test_sid_crypto_key_import) err = sid_crypto_keys_delete(test_key_id); zassert_equal(0, err, "err: %d", err); - - err = sid_crypto_keys_deinit(); - zassert_equal(0, err, "err: %d", err); } ZTEST(crypto_keys, test_sid_crypto_key_generate) @@ -113,17 +119,11 @@ ZTEST(crypto_keys, test_sid_crypto_key_generate) uint8_t public_key[TEST_ECC_PUBLIC_KEY_SIZE] = { 0 }; int err = -ENOEXEC; - err = sid_crypto_keys_init(); - zassert_equal(0, err, "err: %d", err); - err = sid_crypto_keys_new_generate(test_key_ecc_id, public_key, TEST_ECC_PUBLIC_KEY_SIZE); zassert_equal(0, err, "err: %d", err); err = sid_crypto_keys_delete(test_key_ecc_id); zassert_equal(0, err, "err: %d", err); - - err = sid_crypto_keys_deinit(); - zassert_equal(0, err, "err: %d", err); } -ZTEST_SUITE(crypto_keys, NULL, setup, NULL, NULL, teardown); +ZTEST_SUITE(crypto_keys, NULL, setup, before, after, teardown); diff --git a/tests/functional/crypto_keys/testcase.yaml b/tests_new/integration/crypto_keys/testcase.yaml similarity index 100% rename from tests/functional/crypto_keys/testcase.yaml rename to tests_new/integration/crypto_keys/testcase.yaml diff --git a/tests/functional/pal_delay/CMakeLists.txt b/tests_new/integration/delay/CMakeLists.txt similarity index 90% rename from tests/functional/pal_delay/CMakeLists.txt rename to tests_new/integration/delay/CMakeLists.txt index 59c3e0df98..80fba35bb9 100644 --- a/tests/functional/pal_delay/CMakeLists.txt +++ b/tests_new/integration/delay/CMakeLists.txt @@ -7,7 +7,7 @@ cmake_minimum_required(VERSION 3.20.0) find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) -project(sidewalk_test_delay) +project(sidewalk_delay_test) # add test file FILE(GLOB app_sources src/*.c) diff --git a/tests/functional/pal_delay/Kconfig b/tests_new/integration/delay/Kconfig similarity index 80% rename from tests/functional/pal_delay/Kconfig rename to tests_new/integration/delay/Kconfig index a70eb951c3..5600a47316 100644 --- a/tests/functional/pal_delay/Kconfig +++ b/tests_new/integration/delay/Kconfig @@ -13,3 +13,4 @@ config SIDEWALK_LOG_LEVEL default 0 source "Kconfig.zephyr" +source "${ZEPHYR_BASE}/../sidewalk/Kconfig.dependencies" diff --git a/tests_new/integration/delay/boards/native_sim.conf b/tests_new/integration/delay/boards/native_sim.conf new file mode 100644 index 0000000000..04ac040d42 --- /dev/null +++ b/tests_new/integration/delay/boards/native_sim.conf @@ -0,0 +1,9 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +# Changed emulator default tick rate from 100 Hz to 10 kHz +# Test requires millisecond precision in timing +CONFIG_SYS_CLOCK_TICKS_PER_SEC=10000 diff --git a/tests_new/integration/delay/prj.conf b/tests_new/integration/delay/prj.conf new file mode 100644 index 0000000000..9320387007 --- /dev/null +++ b/tests_new/integration/delay/prj.conf @@ -0,0 +1,7 @@ +# +# Copyright (c) 2022 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# +CONFIG_ZTEST=y +CONFIG_MAIN_THREAD_PRIORITY=14 diff --git a/tests/functional/pal_delay/src/main.c b/tests_new/integration/delay/src/main.c similarity index 73% rename from tests/functional/pal_delay/src/main.c rename to tests_new/integration/delay/src/main.c index 4d5b8bb796..e3f9461c6b 100644 --- a/tests/functional/pal_delay/src/main.c +++ b/tests_new/integration/delay/src/main.c @@ -17,25 +17,26 @@ #define TIMESTAMP_US_GET() (k_ticks_to_us_floor64((uint64_t)k_uptime_ticks())) -ZTEST(pal_delay, test_sid_pal_delay) +ZTEST(pal_delay, test_sid_pal_delay_min) { + uint64_t delta = 0; uint64_t timestamp = TIMESTAMP_US_GET(); - sid_pal_delay_us(MIN_DELAY_US); - uint64_t delta = TIMESTAMP_US_GET() - timestamp; + delta = TIMESTAMP_US_GET() - timestamp; zassert_true(abs((int)(MIN_DELAY_US - delta)) <= MAX_DELAY_US_THRESHOLD, - "expected delay %d took %d", MIN_DELAY_US, delta); - timestamp = TIMESTAMP_US_GET(); - sid_pal_delay_us(DELAY_US); - delta = TIMESTAMP_US_GET() - timestamp; - zassert_true(abs((int)(DELAY_US - delta)) <= MAX_DELAY_US_THRESHOLD, - "expected delay %d took %d", DELAY_US, delta); + "expected delay %lld took %lld", MIN_DELAY_US, delta); } -ZTEST(pal_delay, test_sanity) +ZTEST(pal_delay, test_sid_pal_delay) { - zassert_equal(true, true); + uint64_t delta = 0; + uint64_t timestamp = TIMESTAMP_US_GET(); + sid_pal_delay_us(DELAY_US); + delta = TIMESTAMP_US_GET() - timestamp; + + zassert_true(abs((int)(DELAY_US - delta)) <= MAX_DELAY_US_THRESHOLD, + "expected delay %lld took %lld", DELAY_US, delta); } ZTEST_SUITE(pal_delay, NULL, NULL, NULL, NULL, NULL); diff --git a/tests/functional/pal_delay/testcase.yaml b/tests_new/integration/delay/testcase.yaml similarity index 92% rename from tests/functional/pal_delay/testcase.yaml rename to tests_new/integration/delay/testcase.yaml index a0e95362ec..172be83d12 100644 --- a/tests/functional/pal_delay/testcase.yaml +++ b/tests_new/integration/delay/testcase.yaml @@ -1,16 +1,18 @@ tests: sidewalk.test.integration.delay: 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 - tags: Sidewalk diff --git a/tests/functional/interrupts/CMakeLists.txt b/tests_new/integration/interrupts/CMakeLists.txt similarity index 87% rename from tests/functional/interrupts/CMakeLists.txt rename to tests_new/integration/interrupts/CMakeLists.txt index 98173588af..ee13ebc357 100644 --- a/tests/functional/interrupts/CMakeLists.txt +++ b/tests_new/integration/interrupts/CMakeLists.txt @@ -7,7 +7,7 @@ cmake_minimum_required(VERSION 3.20.0) find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) -project(sidewalk_test_critical_region) +project(sidewalk_interrupts_test) target_sources(app PRIVATE src/main.c) target_include_directories(app PRIVATE .) diff --git a/tests/functional/interrupts/Kconfig b/tests_new/integration/interrupts/Kconfig similarity index 85% rename from tests/functional/interrupts/Kconfig rename to tests_new/integration/interrupts/Kconfig index 8889051f45..dcee9eb012 100644 --- a/tests/functional/interrupts/Kconfig +++ b/tests_new/integration/interrupts/Kconfig @@ -21,3 +21,4 @@ config SIDEWALK_LOG_LEVEL default 0 source "Kconfig.zephyr" +source "${ZEPHYR_BASE}/../sidewalk/Kconfig.dependencies" diff --git a/tests/functional/interrupts/prj.conf b/tests_new/integration/interrupts/prj.conf similarity index 100% rename from tests/functional/interrupts/prj.conf rename to tests_new/integration/interrupts/prj.conf diff --git a/tests/functional/interrupts/src/main.c b/tests_new/integration/interrupts/src/main.c similarity index 60% rename from tests/functional/interrupts/src/main.c rename to tests_new/integration/interrupts/src/main.c index 7e5fd0e977..5d38a5c851 100644 --- a/tests/functional/interrupts/src/main.c +++ b/tests_new/integration/interrupts/src/main.c @@ -13,11 +13,11 @@ #define BUFFER_NO 10 #define BUFFER_SIZE 10 -static char buffer_in[BUFFER_NO][BUFFER_SIZE] = { +static char buffer_out[BUFFER_NO][BUFFER_SIZE]; +const char buffer_in[BUFFER_NO][BUFFER_SIZE] = { "test_0", "test_1", "test_2", "test_3", "test_4", "test_5", "test_6", "test_7", "test_8", "test_9", }; -static char buffer_out[BUFFER_NO][BUFFER_SIZE]; static void swi_callback(void) { @@ -25,10 +25,13 @@ static void swi_callback(void) (void)memcpy(buffer_out[cnt], buffer_in[cnt], BUFFER_SIZE); - cnt++; - if (cnt >= BUFFER_NO) { - cnt = 0; - } + cnt = (cnt + 1) % BUFFER_NO; +} + +static void before(void* arg) +{ + ARG_UNUSED(arg); + memset(buffer_out, 0, sizeof(buffer_out)); } ZTEST(interrupts, test_sid_pal_swi) @@ -46,4 +49,15 @@ ZTEST(interrupts, test_sid_pal_swi) zassert_equal(SID_ERROR_NONE, sid_pal_swi_deinit()); } -ZTEST_SUITE(interrupts, NULL, NULL, NULL, NULL, NULL); +ZTEST(interrupts, test_sid_pal_swi_invalid_state) +{ + zassert_equal(SID_ERROR_NONE, sid_pal_swi_init()); + zassert_equal(SID_ERROR_NONE, sid_pal_swi_start(swi_callback)); + zassert_equal(SID_ERROR_NONE, sid_pal_swi_trigger()); + zassert_equal(SID_ERROR_NONE, sid_pal_swi_stop()); + zassert_equal(SID_ERROR_INVALID_STATE, sid_pal_swi_trigger()); + zassert_equal(SID_ERROR_NONE, sid_pal_swi_deinit()); + zassert_equal(SID_ERROR_INVALID_STATE, sid_pal_swi_trigger()); +} + +ZTEST_SUITE(interrupts, NULL, NULL, before, NULL, NULL); diff --git a/tests/functional/interrupts/testcase.yaml b/tests_new/integration/interrupts/testcase.yaml similarity index 92% rename from tests/functional/interrupts/testcase.yaml rename to tests_new/integration/interrupts/testcase.yaml index 3a8a32be59..24d92b2bbe 100644 --- a/tests/functional/interrupts/testcase.yaml +++ b/tests_new/integration/interrupts/testcase.yaml @@ -3,12 +3,14 @@ tests: 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 diff --git a/tests_new/integration/mfg/src/main.c b/tests_new/integration/mfg/src/main.c new file mode 100644 index 0000000000..ff5f38424b --- /dev/null +++ b/tests_new/integration/mfg/src/main.c @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2022 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +#include + +#include +#include +#include + +ZTEST(mfg, test_mfg_storage_read_write) +{ + uint8_t write_data[SID_PAL_MFG_STORE_DEVID_SIZE] = { 1, 2, 3, 4, 5 }; + uint8_t read_data[SID_PAL_MFG_STORE_DEVID_SIZE] = { 0 }; + + sid_pal_mfg_store_region_t mfg_store_region = { + .addr_start = (uintptr_t)(FIXED_PARTITION_OFFSET(mfg_storage)), + .addr_end = (uintptr_t)(FIXED_PARTITION_OFFSET(mfg_storage) + + FIXED_PARTITION_SIZE(mfg_storage)), + .app_value_to_offset = NULL + }; + sid_pal_mfg_store_init(mfg_store_region); + + zassert_equal(SID_ERROR_NONE, sid_pal_mfg_store_write(SID_PAL_MFG_STORE_SERIAL_NUM, write_data, sizeof(write_data))); + + sid_pal_mfg_store_read(SID_PAL_MFG_STORE_DEVID, read_data, sizeof(read_data)); + zassert_mem_equal(write_data, read_data, sizeof(write_data), + "Read data does not match written data"); + + sid_pal_mfg_store_deinit(); +} + +ZTEST_SUITE(mfg, NULL, NULL, NULL, NULL, NULL); diff --git a/tests/functional/crypto/CMakeLists.txt b/tests_new/integration/temperature/CMakeLists.txt similarity index 90% rename from tests/functional/crypto/CMakeLists.txt rename to tests_new/integration/temperature/CMakeLists.txt index a908c40594..b61d000d42 100644 --- a/tests/functional/crypto/CMakeLists.txt +++ b/tests_new/integration/temperature/CMakeLists.txt @@ -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_temperature_test) # add test file FILE(GLOB app_sources src/*.c) diff --git a/tests/functional/temperature/Kconfig b/tests_new/integration/temperature/Kconfig similarity index 80% rename from tests/functional/temperature/Kconfig rename to tests_new/integration/temperature/Kconfig index cdd09fa10c..39f078586b 100644 --- a/tests/functional/temperature/Kconfig +++ b/tests_new/integration/temperature/Kconfig @@ -8,10 +8,9 @@ config SIDEWALK_BUILD config SIDEWALK_TEMPERATURE default y - imply SENSOR - imply TEMP_NRF5 config SIDEWALK_LOG_LEVEL default 0 source "Kconfig.zephyr" +source "${ZEPHYR_BASE}/../sidewalk/Kconfig.dependencies" diff --git a/tests_new/integration/temperature/prj.conf b/tests_new/integration/temperature/prj.conf new file mode 100644 index 0000000000..9320387007 --- /dev/null +++ b/tests_new/integration/temperature/prj.conf @@ -0,0 +1,7 @@ +# +# Copyright (c) 2022 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# +CONFIG_ZTEST=y +CONFIG_MAIN_THREAD_PRIORITY=14 diff --git a/tests/functional/temperature/src/main.c b/tests_new/integration/temperature/src/main.c similarity index 83% rename from tests/functional/temperature/src/main.c rename to tests_new/integration/temperature/src/main.c index a175517c6c..b81e2a2260 100644 --- a/tests/functional/temperature/src/main.c +++ b/tests_new/integration/temperature/src/main.c @@ -10,19 +10,22 @@ #include #include -#include "sid_pal_temperature_ifc.h" +#include #include -#define MAX_ABS_ERROR 1 +#define TEMP_ABS_ERR_MAX 1 +#define TEST_TEMP_VAL_MIN (-40) +#define TEST_TEMP_VAL_MAX (85) static void test_initialize() { zassert_equal(SID_ERROR_NONE, sid_pal_temperature_init()); } + static void validate_temp_reading(int16_t value) { - zassert_between_inclusive(value, -40, 85); + zassert_between_inclusive(value, TEST_TEMP_VAL_MIN, TEST_TEMP_VAL_MAX); } ZTEST(temperature, test_valid_temperature_range_for_SoC) @@ -72,7 +75,7 @@ ZTEST(temperature, test_multiple_fast_readings) results[i] = sid_pal_temperature_get(); } - analyze_temp_readings(results, ARRAY_SIZE(results), MAX_ABS_ERROR); + analyze_temp_readings(results, ARRAY_SIZE(results), TEMP_ABS_ERR_MAX); } ZTEST(temperature, test_multiple_slow_readings) @@ -84,12 +87,7 @@ ZTEST(temperature, test_multiple_slow_readings) results[i] = sid_pal_temperature_get(); k_sleep(K_MSEC(50)); } - analyze_temp_readings(results, ARRAY_SIZE(results), MAX_ABS_ERROR); -} - -ZTEST(temperature, test_sanity) -{ - zassert_equal(true, true); + analyze_temp_readings(results, ARRAY_SIZE(results), TEMP_ABS_ERR_MAX); } ZTEST_SUITE(temperature, NULL, NULL, NULL, NULL, NULL); diff --git a/tests/functional/temperature/testcase.yaml b/tests_new/integration/temperature/testcase.yaml similarity index 92% rename from tests/functional/temperature/testcase.yaml rename to tests_new/integration/temperature/testcase.yaml index 869e6c60ac..64ad33a8af 100644 --- a/tests/functional/temperature/testcase.yaml +++ b/tests_new/integration/temperature/testcase.yaml @@ -1,16 +1,18 @@ tests: sidewalk.test.integration.temperature: 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 - tags: Sidewalk diff --git a/tests/functional/mfg_storage/CMakeLists.txt b/tests_new/integration/timer/CMakeLists.txt similarity index 90% rename from tests/functional/mfg_storage/CMakeLists.txt rename to tests_new/integration/timer/CMakeLists.txt index a908c40594..ca1a93462b 100644 --- a/tests/functional/mfg_storage/CMakeLists.txt +++ b/tests_new/integration/timer/CMakeLists.txt @@ -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_timer_test) # add test file FILE(GLOB app_sources src/*.c) diff --git a/tests/functional/time/Kconfig b/tests_new/integration/timer/Kconfig similarity index 100% rename from tests/functional/time/Kconfig rename to tests_new/integration/timer/Kconfig diff --git a/tests_new/integration/timer/prj.conf b/tests_new/integration/timer/prj.conf new file mode 100644 index 0000000000..9320387007 --- /dev/null +++ b/tests_new/integration/timer/prj.conf @@ -0,0 +1,7 @@ +# +# Copyright (c) 2022 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# +CONFIG_ZTEST=y +CONFIG_MAIN_THREAD_PRIORITY=14 diff --git a/tests/functional/time/src/main.c b/tests_new/integration/timer/src/main.c similarity index 90% rename from tests/functional/time/src/main.c rename to tests_new/integration/timer/src/main.c index e085b9010f..8f3454fd50 100644 --- a/tests/functional/time/src/main.c +++ b/tests_new/integration/timer/src/main.c @@ -7,7 +7,6 @@ #include #include -#include #include static sid_pal_timer_t *p_null_timer = NULL; @@ -16,9 +15,6 @@ static int test_timer_arg; static int callback_arg; static int timer_callback_cnt; -/****************************************************************** -* sid_pal_timer_ifc -* ****************************************************************/ static void timer_callback(void *arg, sid_pal_timer_t *originator) { callback_arg = *((int *)arg); @@ -27,9 +23,11 @@ static void timer_callback(void *arg, sid_pal_timer_t *originator) static void relative_time_calculate(struct sid_timespec *when) { - struct sid_timespec now; + struct sid_timespec now = {0}; + uint64_t uptime_ns = k_ticks_to_ns_floor64(k_uptime_ticks()); + now.tv_sec = (sid_time_t)(uptime_ns / NSEC_PER_SEC); + now.tv_nsec = (uint32_t)(uptime_ns - ((uint64_t)now.tv_sec * NSEC_PER_SEC)); - zassert_equal(SID_ERROR_NONE, sid_pal_uptime_now(&now)); sid_time_add(&now, when); *when = now; } @@ -330,27 +328,4 @@ ZTEST(time, test_sid_pal_timer_one_shot_few_times) timer_deinit(); } -/****************************************************************** -* sid_pal_uptime_ifc -* ****************************************************************/ -ZTEST(time, test_sid_pal_uptime_get) -{ - struct sid_timespec sid_time = { 0 }; - int64_t uptime_msec = k_uptime_get(); - uint32_t uptime_sec = (uint32_t)(uptime_msec / MSEC_PER_SEC); - uint32_t uptime_nsec = (uint32_t)((uptime_msec * NSEC_PER_MSEC) % NSEC_PER_SEC); - - zassert_not_equal(0, uptime_msec, "Test data preparation failed."); - - zassert_equal(SID_ERROR_NONE, sid_pal_uptime_now(&sid_time)); - - zassert_true(sid_time.tv_sec >= uptime_sec); - zassert_true(sid_time.tv_nsec >= uptime_nsec); -} - -ZTEST(time, test_sanity) -{ - zassert_equal(true, true); -} - ZTEST_SUITE(time, NULL, NULL, NULL, NULL, NULL); diff --git a/tests/functional/time/src/sid_timer_stub.c b/tests_new/integration/timer/src/sid_timer_stub.c similarity index 100% rename from tests/functional/time/src/sid_timer_stub.c rename to tests_new/integration/timer/src/sid_timer_stub.c diff --git a/tests_new/integration/timer/testcase.yaml b/tests_new/integration/timer/testcase.yaml new file mode 100644 index 0000000000..84023ee291 --- /dev/null +++ b/tests_new/integration/timer/testcase.yaml @@ -0,0 +1,18 @@ +tests: + sidewalk.test.integration.timer: + 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 diff --git a/tests/functional/temperature/CMakeLists.txt b/tests_new/integration/uptime/CMakeLists.txt similarity index 90% rename from tests/functional/temperature/CMakeLists.txt rename to tests_new/integration/uptime/CMakeLists.txt index a908c40594..2732c8d8cb 100644 --- a/tests/functional/temperature/CMakeLists.txt +++ b/tests_new/integration/uptime/CMakeLists.txt @@ -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_uptime_test) # add test file FILE(GLOB app_sources src/*.c) diff --git a/tests_new/integration/uptime/Kconfig b/tests_new/integration/uptime/Kconfig new file mode 100644 index 0000000000..28a465f1d8 --- /dev/null +++ b/tests_new/integration/uptime/Kconfig @@ -0,0 +1,16 @@ +# +# Copyright (c) 2022 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# +config SIDEWALK_BUILD + default y + +config SIDEWALK_UPTIME + default y + +config SIDEWALK_LOG_LEVEL + default 0 + +source "Kconfig.zephyr" +source "${ZEPHYR_BASE}/../sidewalk/Kconfig.dependencies" diff --git a/tests_new/integration/uptime/prj.conf b/tests_new/integration/uptime/prj.conf new file mode 100644 index 0000000000..9320387007 --- /dev/null +++ b/tests_new/integration/uptime/prj.conf @@ -0,0 +1,7 @@ +# +# Copyright (c) 2022 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# +CONFIG_ZTEST=y +CONFIG_MAIN_THREAD_PRIORITY=14 diff --git a/tests_new/integration/uptime/src/main.c b/tests_new/integration/uptime/src/main.c new file mode 100644 index 0000000000..5ae3592979 --- /dev/null +++ b/tests_new/integration/uptime/src/main.c @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +#include +#include + +/** + * @brief Tests the Sidewalk uptime + * + * 1. Get kernel uptime, convert it to seconeds and nanoseconds. + * 2. Get Sidewalk uptime. + * 3. Get kernel uptime again, convert it to seconeds and nanoseconds. + * 4. Check if Sidewalk uptime is between the two kernel uptimes. + */ +ZTEST(uptime, test_sid_pal_uptime_get) +{ + struct sid_timespec time_befre, time_after, sid_time = { 0 }; + uint64_t uptime = k_ticks_to_ns_floor64(k_uptime_ticks()); + time_befre.tv_sec = (uint32_t)(uptime / NSEC_PER_SEC); + time_befre.tv_nsec = (uint32_t)(uptime % NSEC_PER_SEC); + + zassert_equal(SID_ERROR_NONE, sid_pal_uptime_now(&sid_time)); + + uptime = k_ticks_to_ns_ceil64(k_uptime_ticks()); + time_after.tv_sec = (uint32_t)(uptime / NSEC_PER_SEC); + time_after.tv_nsec = (uint32_t)(uptime % NSEC_PER_SEC); + + zassert_true(time_befre.tv_sec <= time_after.tv_sec, "Test data preparation failed."); + zassert_true((time_befre.tv_nsec <= time_after.tv_nsec) || + (time_befre.tv_sec < time_after.tv_sec), + "Test data preparation failed."); + + zassert_true(sid_time.tv_sec >= time_befre.tv_sec, "before: %d, sidewalk: %d", + time_befre.tv_sec, sid_time.tv_sec); + zassert_true((sid_time.tv_nsec >= time_befre.tv_nsec) || + (sid_time.tv_sec > time_befre.tv_sec), + "before: %d.%d, sidewalk: %d.%d", time_befre.tv_sec, time_befre.tv_nsec, + sid_time.tv_sec, sid_time.tv_nsec); + zassert_true(sid_time.tv_sec <= time_after.tv_sec, "sidewlk: %d.%d, after: %d.%d", + sid_time.tv_sec, time_after.tv_sec); + zassert_true((sid_time.tv_nsec <= time_after.tv_nsec) || + (sid_time.tv_sec < time_after.tv_sec), + "sidewlk: %d.%d, after: %d.%d", sid_time.tv_sec, sid_time.tv_nsec, + time_after.tv_sec, time_after.tv_nsec); +} + +ZTEST_SUITE(uptime, NULL, NULL, NULL, NULL, NULL); diff --git a/tests_new/integration/uptime/testcase.yaml b/tests_new/integration/uptime/testcase.yaml new file mode 100644 index 0000000000..260fc2aa8e --- /dev/null +++ b/tests_new/integration/uptime/testcase.yaml @@ -0,0 +1,18 @@ +tests: + sidewalk.test.integration.uptime: + 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