Skip to content

Commit

Permalink
suit: Add flash_ipuc pseudo-driver tests
Browse files Browse the repository at this point in the history
Add tests for the pseudo-flash driver that writes data through SUIT
IPUC.

Ref: NCSDK-30809

Signed-off-by: Tomasz Chyrowicz <[email protected]>
  • Loading branch information
tomchy committed Jan 16, 2025
1 parent 006680a commit ca552a3
Show file tree
Hide file tree
Showing 9 changed files with 1,153 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/test-spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
- "subsys/pcd/*"
- "subsys/net/lib/*fota*/**/*"
- "subsys/net/lib/downloader/**/*"
- "tests/drivers/flash/flash_ipuc/**/*"
- "tests/subsys/bootloader/**/*"
- "tests/subsys/dfu/**/*"

Expand Down
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,7 @@
/tests/crypto/ @stephen-nordic @magnev
/tests/drivers/audio/pdm_loopback/ @nrfconnect/ncs-low-level-test
/tests/drivers/gpio/ @nrfconnect/ncs-low-level-test @nrfconnect/ncs-ll-ursus
/tests/drivers/flash/flash_ipuc/ @nrfconnect/ncs-charon
/tests/drivers/flash/flash_rpc/ @nrfconnect/ncs-pluto
/tests/drivers/flash_patch/ @nrfconnect/ncs-pluto
/tests/drivers/fprotect/ @nrfconnect/ncs-pluto
Expand Down
25 changes: 25 additions & 0 deletions tests/drivers/flash/flash_ipuc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#
# Copyright (c) 2025 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(flash_ipuc)

target_include_directories(app PRIVATE ${ZEPHYR_NRF_MODULE_DIR}/subsys/suit/ipuc/include)
target_include_directories(app PRIVATE mocks)

zephyr_compile_definitions(CONFIG_FLASH_IPUC_COUNT=2)
zephyr_compile_definitions(CONFIG_FLASH_IPUC_LOG_LEVEL)
zephyr_compile_definitions(CONFIG_FLASH_IPUC_LOG_LEVEL_DBG)
# Pretend to call API as nRF54H20 application FW
zephyr_compile_definitions(CONFIG_SOC_NRF54H20_CPUAPP)

target_sources(app PRIVATE
src/main.c
${ZEPHYR_NRF_MODULE_DIR}/drivers/flash/flash_ipuc/flash_ipuc.c
)
8 changes: 8 additions & 0 deletions tests/drivers/flash/flash_ipuc/boards/native_sim.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#
# Copyright (c) 2025 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

CONFIG_FLASH_SIMULATOR=y
CONFIG_FLASH_SIMULATOR_DOUBLE_WRITES=y
8 changes: 8 additions & 0 deletions tests/drivers/flash/flash_ipuc/boards/native_sim_64.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#
# Copyright (c) 2025 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

CONFIG_FLASH_SIMULATOR=y
CONFIG_FLASH_SIMULATOR_DOUBLE_WRITES=y
29 changes: 29 additions & 0 deletions tests/drivers/flash/flash_ipuc/mocks/mock_suit_ipuc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright (c) 2025 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

#ifndef MOCK_SUIT_IPUC_H__
#define MOCK_SUIT_IPUC_H__

#include <suit_ipuc.h>
#include <zephyr/fff.h>

DEFINE_FFF_GLOBALS;

FAKE_VALUE_FUNC(int, suit_ipuc_get_count, size_t *);
FAKE_VALUE_FUNC(int, suit_ipuc_get_info, size_t, struct zcbor_string *, suit_manifest_role_t *);
FAKE_VALUE_FUNC(int, suit_ipuc_write_setup, struct zcbor_string *, struct zcbor_string *,
struct zcbor_string *);
FAKE_VALUE_FUNC(int, suit_ipuc_write, struct zcbor_string *, size_t, uintptr_t, size_t, bool);

static inline void mock_suit_ipuc_reset(void)
{
RESET_FAKE(suit_ipuc_get_count);
RESET_FAKE(suit_ipuc_get_info);
RESET_FAKE(suit_ipuc_write_setup);
RESET_FAKE(suit_ipuc_write);
}

#endif /* MOCK_SUIT_IPUC_H__ */
15 changes: 15 additions & 0 deletions tests/drivers/flash/flash_ipuc/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#
# Copyright (c) 2025 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

CONFIG_ZTEST=y
CONFIG_SUIT=y
CONFIG_SUIT_UTILS=y
CONFIG_SUIT_METADATA=y

CONFIG_ZCBOR=y
CONFIG_ZCBOR_CANONICAL=y

CONFIG_FLASH=y
Loading

0 comments on commit ca552a3

Please sign in to comment.