Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: Bluetooth: Mesh: Use bsim settings backend #61074

Merged
merged 3 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion tests/bsim/bluetooth/mesh/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ endif()
if(CONFIG_SETTINGS)

target_sources(app PRIVATE
src/settings_test_backend.c
src/test_persistence.c
src/test_replay_cache.c
src/test_provision.c
Expand Down
47 changes: 41 additions & 6 deletions tests/bsim/bluetooth/mesh/_mesh_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,30 @@ function RunTest(){
s_id=$1
shift 1

testids=()
for testid in $@ ; do
if [ "$testid" == "--" ]; then
declare -A testids
testid=""
testid_in_order=()

for arg in $@ ; do
if [ "$arg" == "--" ]; then
shift 1
break
fi

testids+=( $testid )
if [[ "$arg" == "-"* ]]; then
testids["${testid}"]+="$arg "
else
testid=$arg
testid_in_order+=($testid)
testids["${testid}"]=""
fi

shift 1
done

test_options=$@

for testid in ${testids[@]} ; do
for testid in ${testid_in_order[@]}; do
if Skip $testid; then
echo "Skipping $testid (device #$idx)"
let idx=idx+1
Expand All @@ -58,7 +68,7 @@ function RunTest(){
Execute \
${exe_name} \
-v=${verbosity_level} -s=$s_id -d=$idx -sync_preboot -RealEncryption=1 \
-testid=$testid ${test_options}
-testid=$testid ${testids["${testid}"]} ${test_options}
let idx=idx+1
done

Expand All @@ -70,3 +80,28 @@ function RunTest(){

wait_for_background_jobs
}

function RunTestFlash(){
s_id=$1
ext_arg="${s_id} "
idx=0
shift 1

for arg in $@ ; do
if [ "$arg" == "--" ]; then
ext_arg+=$@
break
fi

ext_arg+="$arg "

if [[ "$arg" != "-"* ]]; then
ext_arg+="-flash=../results/${s_id}/${s_id}_${idx}.bin "
let idx=idx+1
fi

shift 1
done

RunTest ${ext_arg}
}
8 changes: 6 additions & 2 deletions tests/bsim/bluetooth/mesh/overlay_pst.conf
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
CONFIG_SETTINGS=y
CONFIG_SETTINGS_CUSTOM=y
CONFIG_BT_SETTINGS=y
CONFIG_BT_MESH_SETTINGS_LOG_LEVEL_DBG=y
CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_MAP=y
CONFIG_NVS=y

CONFIG_BT_PERIPHERAL=y
CONFIG_BT_MESH_GATT_PROXY=y
CONFIG_BT_MESH_PB_GATT=y
# Disable GATT advertising to prevent interfering with the test scenarios.
CONFIG_BT_MESH_GATT_PROXY_ENABLED=n
PavelVPV marked this conversation as resolved.
Show resolved Hide resolved

CONFIG_BT_MESH_MODEL_GROUP_COUNT=4
CONFIG_BT_MESH_CDB_NODE_COUNT=3
Expand Down
15 changes: 4 additions & 11 deletions tests/bsim/bluetooth/mesh/src/mesh_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "mesh_test.h"
#include "argparse.h"
#include <bs_pc_backchannel.h>
#include "settings_test_backend.h"
#include "mesh/crypto.h"

#define LOG_MODULE_NAME mesh_test
Expand Down Expand Up @@ -256,7 +255,10 @@ void bt_mesh_device_setup(const struct bt_mesh_prov *prov, const struct bt_mesh_

if (IS_ENABLED(CONFIG_BT_SETTINGS)) {
LOG_INF("Loading stored settings");
settings_load();
if (IS_ENABLED(CONFIG_BT_MESH_USES_MBEDTLS_PSA)) {
settings_load_subtree("itsemul");
}
settings_load_subtree("bt");
PavelVPV marked this conversation as resolved.
Show resolved Hide resolved
}

LOG_INF("Mesh initialized");
Expand Down Expand Up @@ -550,12 +552,3 @@ void bt_mesh_test_sar_conf_set(struct bt_mesh_sar_tx *tx_set, struct bt_mesh_sar
}
}
#endif /* defined(CONFIG_BT_MESH_SAR_CFG) */

void bt_mesh_test_host_files_remove(void)
{
#if defined(CONFIG_SETTINGS)
/* crypto library initialization to be able to remove stored keys. */
bt_mesh_crypto_init();
settings_test_backend_clear();
#endif
}
2 changes: 0 additions & 2 deletions tests/bsim/bluetooth/mesh/src/mesh_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,4 @@ uint16_t bt_mesh_test_own_addr_get(uint16_t start_addr);
void bt_mesh_test_sar_conf_set(struct bt_mesh_sar_tx *tx_set, struct bt_mesh_sar_rx *rx_set);
#endif

void bt_mesh_test_host_files_remove(void);

#endif /* ZEPHYR_TESTS_BLUETOOTH_BSIM_BT_BSIM_TEST_MESH_MESH_TEST_H_ */
6 changes: 3 additions & 3 deletions tests/bsim/bluetooth/mesh/src/psa_its_emul.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ static int itsemul_set(const char *name, size_t len_rd, settings_read_cb read_cb
return 0;
}

BT_MESH_SETTINGS_DEFINE(psa_its_emu, "itsemul", itsemul_set);
SETTINGS_STATIC_HANDLER_DEFINE(psa_its_emu, "itsemul", NULL, itsemul_set, NULL, NULL);
PavelVPV marked this conversation as resolved.
Show resolved Hide resolved

psa_status_t psa_its_get_info(psa_storage_uid_t uid, struct psa_storage_info_t *p_info)
{
Expand Down Expand Up @@ -164,7 +164,7 @@ psa_status_t psa_its_set(psa_storage_uid_t uid, uint32_t data_length, const void
return PSA_ERROR_STORAGE_FAILURE;
}

snprintk(path, sizeof(path), "bt/mesh/itsemul/%llu", uid);
snprintk(path, sizeof(path), "itsemul/%llu", uid);

p_item->uid = uid;
p_pst_item = &p_item->pst_item;
Expand Down Expand Up @@ -196,7 +196,7 @@ psa_status_t psa_its_remove(psa_storage_uid_t uid)
}
memset(p_item, 0, sizeof(psa_its_item_t));

snprintk(path, sizeof(path), "bt/mesh/itsemul/%llu", uid);
snprintk(path, sizeof(path), "itsemul/%llu", uid);

if (settings_delete(path)) {
LOG_ERR("Failed to remove its item: %s", path);
Expand Down
232 changes: 0 additions & 232 deletions tests/bsim/bluetooth/mesh/src/settings_test_backend.c

This file was deleted.

Loading