tests/bsim bt host/privacy/*: Tests scripts cleanup

Ensure we call the common source script before using
the BOARD variable;
Use the common scripts to perform common functions
and do a cleanup.
Do not set variables to their defaults, set things
closer to were they are needed;
Do not perform unnecesary checks;
And in general avoid unnecessary complexity.

And for the 2 parts of the peripheral rpa sharing
test, use different sim_ids, so the traces for each
part can be checked.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
This commit is contained in:
Alberto Escolar Piedras 2024-03-20 17:14:40 +01:00 committed by Alberto Escolar
commit 06326dc8c2
14 changed files with 48 additions and 116 deletions

View file

@ -3,19 +3,11 @@
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
set -eu set -eu
bash_source_dir="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
source "${bash_source_dir}/_env.sh"
: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}"
: "${BSIM_COMPONENTS_PATH:?BSIM_COMPONENTS_PATH must be defined}"
: "${ZEPHYR_BASE:?ZEPHYR_BASE must be defined}" : "${ZEPHYR_BASE:?ZEPHYR_BASE must be defined}"
WORK_DIR="${WORK_DIR:-${ZEPHYR_BASE}/bsim_out}" WORK_DIR="${WORK_DIR:-${ZEPHYR_BASE}/bsim_out}"
BOARD="${BOARD:-nrf52_bsim}"
BOARD_ROOT="${BOARD_ROOT:-${ZEPHYR_BASE}}"
INCR_BUILD=1 INCR_BUILD=1
mkdir -p ${WORK_DIR} source ${ZEPHYR_BASE}/tests/bsim/compile.source
west build -b nrf52_bsim app="$(guess_test_relpath)" _compile
cp build/zephyr/zephyr.exe $central_exe

View file

@ -1,11 +0,0 @@
#!/usr/bin/env bash
# Copyright 2023 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0
set -eu
bash_source_dir="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
bsim_bin="${BSIM_OUT_PATH}/bin"
BOARD="${BOARD:-nrf52_bsim}"
central_exe="${bsim_bin}/bs_${BOARD}_tests_bsim_bluetooth_host_privacy_central_prj_conf"
peripheral_exe="${central_exe}"

View file

@ -3,14 +3,13 @@
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
set -eu set -eu
bash_source_dir="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
source "${bash_source_dir}/_env.sh"
source ${ZEPHYR_BASE}/tests/bsim/sh_common.source source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
verbosity_level=2 verbosity_level=2
simulation_id="$(basename "$(realpath "$bash_source_dir/..")")" simulation_id="$(guess_test_long_name)"
EXECUTE_TIMEOUT=30
central_exe="${BSIM_OUT_PATH}/bin/bs_${BOARD}_$(guess_test_long_name)_prj_conf"
peripheral_exe="${central_exe}"
cd ${BSIM_OUT_PATH}/bin cd ${BSIM_OUT_PATH}/bin

View file

@ -1,11 +1,13 @@
#!/bin/env bash #!/usr/bin/env bash
# Copyright 2023 Nordic Semiconductor ASA # Copyright 2023 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
set -eu set -eu
bash_source_dir="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
source "${bash_source_dir}/_env.sh" : "${ZEPHYR_BASE:?ZEPHYR_BASE must be defined}"
west build -b nrf52_bsim && \ WORK_DIR="${WORK_DIR:-${ZEPHYR_BASE}/bsim_out}"
cp -v build/zephyr/zephyr.exe "${test_exe}" INCR_BUILD=1
source ${ZEPHYR_BASE}/tests/bsim/compile.source
app="$(guess_test_relpath)" _compile

View file

@ -1,12 +0,0 @@
#!/bin/env bash
# Copyright 2023 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0
set -eu
bash_source_dir="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}"
bsim_bin="${BSIM_OUT_PATH}/bin"
BOARD="${BOARD:-nrf52_bsim}"
test_exe="${bsim_bin}/bs_${BOARD}_tests_bsim_bluetooth_host_privacy_device_prj_conf"

View file

@ -3,14 +3,12 @@
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
set -eu set -eu
bash_source_dir="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
source "${bash_source_dir}/_env.sh"
source ${ZEPHYR_BASE}/tests/bsim/sh_common.source source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
verbosity_level=2 verbosity_level=2
simulation_id="$(basename "$(realpath "$bash_source_dir/..")")" simulation_id="$(guess_test_long_name)"
EXECUTE_TIMEOUT=30 test_exe="${BSIM_OUT_PATH}/bin/bs_${BOARD}_$(guess_test_long_name)_prj_conf"
cd ${BSIM_OUT_PATH}/bin cd ${BSIM_OUT_PATH}/bin

View file

@ -3,13 +3,11 @@
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
set -eu set -eu
bash_source_dir="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
# Read variable definitions output by _env.sh : "${ZEPHYR_BASE:?ZEPHYR_BASE must be defined}"
source "${bash_source_dir}/_env.sh"
# terminate running simulations (if any) WORK_DIR="${WORK_DIR:-${ZEPHYR_BASE}/bsim_out}"
${BSIM_COMPONENTS_PATH}/common/stop_bsim.sh INCR_BUILD=1
source ${ZEPHYR_BASE}/tests/bsim/compile.source
west build -b nrf52_bsim && \ app="$(guess_test_relpath)" _compile
cp build/zephyr/zephyr.exe $central_exe

View file

@ -1,11 +0,0 @@
#!/usr/bin/env bash
# Copyright 2023 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0
set -eu
bash_source_dir="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
bsim_bin="${BSIM_OUT_PATH}/bin"
BOARD="${BOARD:-nrf52_bsim}"
central_exe="${bsim_bin}/bs_${BOARD}_tests_bsim_bluetooth_host_privacy_legacy_prj_conf"
peripheral_exe="${central_exe}"

View file

@ -3,14 +3,13 @@
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
set -eu set -eu
bash_source_dir="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
source "${bash_source_dir}/_env.sh"
source ${ZEPHYR_BASE}/tests/bsim/sh_common.source source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
verbosity_level=2 verbosity_level=2
simulation_id="$(basename "$(realpath "$bash_source_dir/..")")" simulation_id="$(guess_test_long_name)"
EXECUTE_TIMEOUT=30 central_exe="${BSIM_OUT_PATH}/bin/bs_${BOARD}_$(guess_test_long_name)_prj_conf"
peripheral_exe="${central_exe}"
cd ${BSIM_OUT_PATH}/bin cd ${BSIM_OUT_PATH}/bin

View file

@ -3,10 +3,16 @@
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
set -eu set -eu
bash_source_dir="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
# Read variable definitions output by _env.sh : "${ZEPHYR_BASE:?ZEPHYR_BASE must be defined}"
source "${bash_source_dir}/_env.sh"
west build -b nrf52_bsim && \ WORK_DIR="${WORK_DIR:-${ZEPHYR_BASE}/bsim_out}"
cp build/zephyr/zephyr.exe $central_exe INCR_BUILD=1
source ${ZEPHYR_BASE}/tests/bsim/compile.source
app="$(guess_test_relpath)" compile
app="$(guess_test_relpath)" conf_file=prj_rpa_expired.conf compile
app="$(guess_test_relpath)" conf_file=prj_rpa_sharing.conf compile
wait_for_background_jobs

View file

@ -1,14 +0,0 @@
#!/usr/bin/env bash
# Copyright 2023 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0
set -eu
bash_source_dir="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
bsim_bin="${BSIM_OUT_PATH}/bin"
BOARD="${BOARD:-nrf52_bsim}"
central_exe="${bsim_bin}/bs_${BOARD}_tests_bsim_bluetooth_host_privacy_peripheral_prj_conf"
peripheral_exe="${central_exe}"
central_exe_rpa_sharing="\
${bsim_bin}/bs_${BOARD}_tests_bsim_bluetooth_host_privacy_peripheral_prj_rpa_sharing_conf"
peripheral_exe_rpa_sharing="${central_exe_rpa_sharing}"

View file

@ -3,14 +3,13 @@
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
set -eu set -eu
bash_source_dir="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
source "${bash_source_dir}/_env.sh"
source ${ZEPHYR_BASE}/tests/bsim/sh_common.source source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
verbosity_level=2 verbosity_level=2
simulation_id="host_privacy_peripheral" simulation_id="host_privacy_peripheral"
EXECUTE_TIMEOUT=30
central_exe="${BSIM_OUT_PATH}/bin/bs_${BOARD}_$(guess_test_long_name)_prj_conf"
peripheral_exe="${central_exe}"
cd ${BSIM_OUT_PATH}/bin cd ${BSIM_OUT_PATH}/bin
@ -18,12 +17,10 @@ Execute "$central_exe" \
-v=${verbosity_level} -s=${simulation_id} -d=0 -testid=central -RealEncryption=1 \ -v=${verbosity_level} -s=${simulation_id} -d=0 -testid=central -RealEncryption=1 \
-flash="${simulation_id}.central.log.bin" -flash_erase -flash="${simulation_id}.central.log.bin" -flash_erase
Execute "$peripheral_exe" \ Execute "$peripheral_exe" \
-v=${verbosity_level} -s=${simulation_id} -d=1 -testid=peripheral -RealEncryption=1 \ -v=${verbosity_level} -s=${simulation_id} -d=1 -testid=peripheral -RealEncryption=1 \
-flash="${simulation_id}.peripheral.log.bin" -flash_erase -flash="${simulation_id}.peripheral.log.bin" -flash_erase
Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=${simulation_id} \ Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=${simulation_id} \
-D=2 -sim_length=70e6 $@ -D=2 -sim_length=70e6 $@
@ -33,12 +30,10 @@ Execute "$central_exe" \
-v=${verbosity_level} -s=${simulation_id}.2 -d=0 -testid=central -RealEncryption=1 \ -v=${verbosity_level} -s=${simulation_id}.2 -d=0 -testid=central -RealEncryption=1 \
-flash="${simulation_id}.central.log.bin" -flash_rm -flash="${simulation_id}.central.log.bin" -flash_rm
Execute "$peripheral_exe" \ Execute "$peripheral_exe" \
-v=${verbosity_level} -s=${simulation_id}.2 -d=1 -testid=peripheral -RealEncryption=1 \ -v=${verbosity_level} -s=${simulation_id}.2 -d=1 -testid=peripheral -RealEncryption=1 \
-flash="${simulation_id}.peripheral.log.bin" -flash_rm -flash="${simulation_id}.peripheral.log.bin" -flash_rm
Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=${simulation_id}.2 \ Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=${simulation_id}.2 \
-D=2 -sim_length=70e6 $@ -D=2 -sim_length=70e6 $@

View file

@ -3,21 +3,17 @@
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
set -eu set -eu
bash_source_dir="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
source "${bash_source_dir}/_env.sh"
source ${ZEPHYR_BASE}/tests/bsim/sh_common.source source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
verbosity_level=2 verbosity_level=2
simulation_id="rpa_expired" simulation_id="rpa_expired"
EXECUTE_TIMEOUT=30
cd ${BSIM_OUT_PATH}/bin
central_exe_rpa_expired="\ central_exe_rpa_expired="\
${bsim_bin}/bs_${BOARD}_tests_bsim_bluetooth_host_privacy_peripheral_prj_rpa_expired_conf" ${BSIM_OUT_PATH}/bin/bs_${BOARD}_$(guess_test_long_name)_prj_rpa_expired_conf"
peripheral_exe_rpa_expired="${central_exe_rpa_expired}" peripheral_exe_rpa_expired="${central_exe_rpa_expired}"
cd ${BSIM_OUT_PATH}/bin
Execute "$central_exe_rpa_expired" \ Execute "$central_exe_rpa_expired" \
-v=${verbosity_level} -s=${simulation_id} -d=0 -testid=central_rpa_check \ -v=${verbosity_level} -s=${simulation_id} -d=0 -testid=central_rpa_check \
-RealEncryption=1 -flash="${simulation_id}.central.log.bin" -flash_erase -RealEncryption=1 -flash="${simulation_id}.central.log.bin" -flash_erase

View file

@ -3,15 +3,14 @@
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
set -eu set -eu
bash_source_dir="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
source "${bash_source_dir}/_env.sh"
source ${ZEPHYR_BASE}/tests/bsim/sh_common.source source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
verbosity_level=2 verbosity_level=2
simulation_id="$(basename "$(realpath "$bash_source_dir/..")")" simulation_id="$(guess_test_long_name)_rpa_sharing"
simulation_id="${simulation_id}_rpa_sharing"
EXECUTE_TIMEOUT=30 central_exe_rpa_sharing="\
${BSIM_OUT_PATH}/bin/bs_${BOARD}_$(guess_test_long_name)_prj_rpa_sharing_conf"
peripheral_exe_rpa_sharing="${central_exe_rpa_sharing}"
cd ${BSIM_OUT_PATH}/bin cd ${BSIM_OUT_PATH}/bin
@ -19,28 +18,24 @@ Execute "$central_exe_rpa_sharing" \
-v=${verbosity_level} -s=${simulation_id} -d=0 -testid=central -RealEncryption=1 \ -v=${verbosity_level} -s=${simulation_id} -d=0 -testid=central -RealEncryption=1 \
-flash="${simulation_id}.central.log.bin" -flash="${simulation_id}.central.log.bin"
Execute "$peripheral_exe_rpa_sharing" \ Execute "$peripheral_exe_rpa_sharing" \
-v=${verbosity_level} -s=${simulation_id} -d=1 -testid=peripheral -RealEncryption=1 \ -v=${verbosity_level} -s=${simulation_id} -d=1 -testid=peripheral -RealEncryption=1 \
-flash="${simulation_id}.peripheral.log.bin" -flash="${simulation_id}.peripheral.log.bin"
Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=${simulation_id} \ Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=${simulation_id} \
-D=2 -sim_length=70e6 $@ -D=2 -sim_length=70e6 $@
wait_for_background_jobs wait_for_background_jobs
Execute "$central_exe_rpa_sharing" \ Execute "$central_exe_rpa_sharing" \
-v=${verbosity_level} -s=${simulation_id} -d=0 -testid=central -RealEncryption=1 \ -v=${verbosity_level} -s=${simulation_id}_2 -d=0 -testid=central -RealEncryption=1 \
-flash="${simulation_id}.central.log.bin" -flash_rm -flash="${simulation_id}.central.log.bin" -flash_rm
Execute "$peripheral_exe_rpa_sharing" \ Execute "$peripheral_exe_rpa_sharing" \
-v=${verbosity_level} -s=${simulation_id} -d=1 -testid=peripheral -RealEncryption=1 \ -v=${verbosity_level} -s=${simulation_id}_2 -d=1 -testid=peripheral -RealEncryption=1 \
-flash="${simulation_id}.peripheral.log.bin" -flash_rm -flash="${simulation_id}.peripheral.log.bin" -flash_rm
Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=${simulation_id}_2 \
Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=${simulation_id} \
-D=2 -sim_length=70e6 $@ -D=2 -sim_length=70e6 $@
wait_for_background_jobs wait_for_background_jobs