Skip to content

Commit 318ccb2

Browse files
committed
tests: settings: its: enable functional tests for TF-M ITS
Run on mps2/an521/cpu0/ns. Signed-off-by: Dmitrii Sharshakov <[email protected]>
1 parent ca8baf5 commit 318ccb2

File tree

6 files changed

+52
-1
lines changed

6 files changed

+52
-1
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
cmake_minimum_required(VERSION 3.20.0)
4+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
5+
project(functional_psa)
6+
7+
# The code is in the library common to several tests.
8+
target_sources(app PRIVATE settings_test_psa.c)
9+
10+
add_subdirectory(../src func_test_bindir)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CONFIG_TFM_ITS_MAX_ASSET_SIZE=512
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CONFIG_ZTEST=y
2+
3+
CONFIG_SETTINGS=y
4+
CONFIG_SETTINGS_RUNTIME=y
5+
6+
# 10 is not sufficient for the test
7+
CONFIG_SETTINGS_TFM_ITS_NUM_ENTRIES=11
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/* SPDX-License-Identifier: Apache-2.0 */
2+
/* Copyright (c) 2022 Dmitrii Sharshakov <[email protected]> */
3+
4+
#include <zephyr/ztest.h>
5+
6+
ZTEST_SUITE(settings_functional, NULL, NULL, NULL, NULL, NULL);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
tests:
2+
settings.functional.psa-its:
3+
platform_allow:
4+
- mps2/an521/cpu0/ns
5+
integration_platforms:
6+
- mps2/an521/cpu0/ns
7+
tags:
8+
- settings
9+
- trusted-firmware-m
10+
extra_args:
11+
- CONFIG_SETTINGS_TFM_ITS=y
12+
- CONFIG_TFM_ITS_MAX_ASSET_SIZE_OVERRIDE=y

tests/subsys/settings/functional/src/settings_basic_test.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ LOG_MODULE_REGISTER(settings_basic_test);
2424
#elif defined(CONFIG_SETTINGS_FILE)
2525
#include <zephyr/fs/fs.h>
2626
#include <zephyr/fs/littlefs.h>
27+
#elif defined(CONFIG_SETTINGS_TFM_ITS)
28+
#include <psa/internal_trusted_storage.h>
29+
#include <zephyr/psa/its_ids.h>
30+
31+
#include "settings_its_priv.h"
2732
#else
2833
#error "Settings backend not selected"
2934
#endif
@@ -38,7 +43,17 @@ LOG_MODULE_REGISTER(settings_basic_test);
3843
*/
3944
ZTEST(settings_functional, test_clear_settings)
4045
{
41-
#if !defined(CONFIG_SETTINGS_FILE)
46+
#if defined(CONFIG_SETTINGS_TFM_ITS)
47+
psa_status_t status;
48+
psa_storage_uid_t uid = ZEPHYR_PSA_SETTINGS_TFM_ITS_UID_RANGE_BEGIN;
49+
50+
/* Remove all potentially accessed ITS entries in the UID range */
51+
for (; uid < (sizeof(entries) / CONFIG_TFM_ITS_MAX_ASSET_SIZE) + 1; uid++) {
52+
status = psa_its_remove(uid);
53+
zassert_true((status == PSA_SUCCESS) || (status == PSA_ERROR_DOES_NOT_EXIST),
54+
"psa_its_remove failed");
55+
}
56+
#elif !defined(CONFIG_SETTINGS_FILE)
4257
const struct flash_area *fap;
4358
int rc;
4459

0 commit comments

Comments
 (0)