1#!/usr/bin/env bash
2# Copyright 2022 Nordic Semiconductor ASA
3# SPDX-License-Identifier: Apache-2.0
4set -eu
5
6source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
7
8simulation_id="settings"
9verbosity_level=2
10EXECUTE_TIMEOUT=120
11test_exe="./bs_${BOARD_TS}_$(guess_test_long_name)_prj_conf"
12
13cd ${BSIM_OUT_PATH}/bin
14
15# Remove the files used by the custom SETTINGS backend
16TO_DELETE="${simulation_id}_server.log ${simulation_id}_client.log"
17echo "remove settings files ${TO_DELETE}"
18rm ${TO_DELETE} || true
19
20Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s="${simulation_id}" -D=8 -sim_length=30e6 $@
21
22# Only one `server` device is really running at a time. This is a necessary hack
23# because bsim doesn't support plugging devices in and out of a running
24# simulation, but this test needs a way to power-cycle the `server` device a few
25# times.
26#
27# Each device will wait until the previous instance (called 'test round') has
28# finished executing before starting up.
29Execute "$test_exe" -v=${verbosity_level} \
30    -s="${simulation_id}" -d=0 -testid=server -RealEncryption=1 -argstest 0 6 "server"
31Execute "$test_exe" -v=${verbosity_level} \
32    -s="${simulation_id}" -d=1 -testid=server -RealEncryption=1 -argstest 1 6 "server"
33Execute "$test_exe" -v=${verbosity_level} \
34    -s="${simulation_id}" -d=2 -testid=server -RealEncryption=1 -argstest 2 6 "server"
35Execute "$test_exe" -v=${verbosity_level} \
36    -s="${simulation_id}" -d=3 -testid=server -RealEncryption=1 -argstest 3 6 "server"
37Execute "$test_exe" -v=${verbosity_level} \
38    -s="${simulation_id}" -d=4 -testid=server -RealEncryption=1 -argstest 4 6 "server"
39Execute "$test_exe" -v=${verbosity_level} \
40    -s="${simulation_id}" -d=5 -testid=server -RealEncryption=1 -argstest 5 6 "server"
41Execute "$test_exe" -v=${verbosity_level} \
42    -s="${simulation_id}" -d=6 -testid=server -RealEncryption=1 -argstest 6 6 "server"
43
44Execute "$test_exe" -v=${verbosity_level} \
45    -s="${simulation_id}" -d=7 -testid=client -RealEncryption=1 -argstest 0 0 "client"
46
47wait_for_background_jobs
48