tests/bsim bt host/adv: 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.

Also, remove all timeouts which were unnecessarily too short

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
This commit is contained in:
Alberto Escolar Piedras 2024-03-20 11:51:23 +01:00 committed by Alberto Escolar
commit 5acc7c4815
16 changed files with 36 additions and 96 deletions

View file

@ -8,7 +8,6 @@ source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
simulation_id="adv_chain"
verbosity_level=2
EXECUTE_TIMEOUT=10
cd ${BSIM_OUT_PATH}/bin

View file

@ -1,11 +1,16 @@
#!/bin/env bash
#!/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]}")")"
source "${bash_source_dir}/_env.sh"
: "${ZEPHYR_BASE:?ZEPHYR_BASE must be defined}"
west build -b nrf52_bsim && \
cp -v build/zephyr/zephyr.exe "${test_exe}"
WORK_DIR="${WORK_DIR:-${ZEPHYR_BASE}/bsim_out}"
INCR_BUILD=1
source ${ZEPHYR_BASE}/tests/bsim/compile.source
app="$(guess_test_relpath)" compile
wait_for_background_jobs

View file

@ -1,15 +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}"
test_name="$(basename "$(realpath "$bash_source_dir/..")")"
bsim_bin="${BSIM_OUT_PATH}/bin"
verbosity_level=2
BOARD="${BOARD:-nrf52_bsim}"
simulation_id="$test_name"
test_exe="${bsim_bin}/bs_${BOARD}_tests_bsim_bluetooth_host_adv_encrypted_${test_name}_prj_conf"

View file

@ -1,67 +1,41 @@
#!/bin/env bash
#!/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]}")")"
source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
# Read variable definitions output by _env.sh
source "${bash_source_dir}/_env.sh"
process_ids=""
exit_code=0
function Execute() {
if [ ! -f $1 ]; then
echo -e " \e[91m$(pwd)/$(basename $1) cannot be found (did you forget to\
compile it?)\e[39m"
exit 1
fi
timeout 30 $@ &
process_ids="$process_ids $!"
}
: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}"
simulation_id="$(guess_test_long_name)"
verbosity_level=2
test_exe="bs_${BOARD}_$(guess_test_long_name)_prj_conf"
cd ${BSIM_OUT_PATH}/bin
data_set=1
Execute "$test_exe" \
Execute ./"$test_exe" \
-v=${verbosity_level} -s="${simulation_id}_${data_set}" -d=0 -testid=central \
-RealEncryption=1 -argstest data-set="${data_set}"
Execute "$test_exe" \
Execute ./"$test_exe" \
-v=${verbosity_level} -s="${simulation_id}_${data_set}" -d=1 -testid=peripheral \
-RealEncryption=1 -argstest data-set="${data_set}"
Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s="${simulation_id}_${data_set}" \
-D=2 -sim_length=60e6 $@
for process_id in $process_ids; do
wait $process_id || let "exit_code=$?"
done
process_ids=''
wait_for_background_jobs
data_set=2
Execute "$test_exe" \
Execute ./"$test_exe" \
-v=${verbosity_level} -s="${simulation_id}_${data_set}" -d=0 -testid=central \
-RealEncryption=1 -argstest data-set="${data_set}"
Execute "$test_exe" \
Execute ./"$test_exe" \
-v=${verbosity_level} -s="${simulation_id}_${data_set}" -d=1 -testid=peripheral \
-RealEncryption=1 -argstest data-set="${data_set}"
Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s="${simulation_id}_${data_set}" \
-D=2 -sim_length=60e6 $@
for process_id in $process_ids; do
wait $process_id || let "exit_code=$?"
done
if [ ${exit_code} -ne 0 ]; then
exit_code=1
fi
exit $exit_code # the last exit code != 0
wait_for_background_jobs

View file

@ -6,7 +6,6 @@ source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
simulation_id="ead_sample"
verbosity_level=2
EXECUTE_TIMEOUT=30
cd ${BSIM_OUT_PATH}/bin

View file

@ -11,7 +11,6 @@ source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
simulation_id="ext_adv"
verbosity_level=2
EXECUTE_TIMEOUT=10
cd ${BSIM_OUT_PATH}/bin

View file

@ -13,7 +13,6 @@ source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
simulation_id="ext_adv_conn"
verbosity_level=2
EXECUTE_TIMEOUT=10
cd ${BSIM_OUT_PATH}/bin

View file

@ -13,7 +13,6 @@ source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
simulation_id="ext_adv_conn_x5"
verbosity_level=2
EXECUTE_TIMEOUT=10
cd ${BSIM_OUT_PATH}/bin

View file

@ -9,7 +9,6 @@ source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
simulation_id="per_adv"
verbosity_level=2
EXECUTE_TIMEOUT=10
cd ${BSIM_OUT_PATH}/bin

View file

@ -9,7 +9,6 @@ source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
simulation_id="per_adv_conn"
verbosity_level=2
EXECUTE_TIMEOUT=10
cd ${BSIM_OUT_PATH}/bin

View file

@ -9,7 +9,6 @@ source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
simulation_id="per_adv_conn_privacy"
verbosity_level=2
EXECUTE_TIMEOUT=10
cd ${BSIM_OUT_PATH}/bin

View file

@ -9,7 +9,6 @@ source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
simulation_id="per_adv_long_data"
verbosity_level=2
EXECUTE_TIMEOUT=10
cd ${BSIM_OUT_PATH}/bin

View file

@ -1,16 +1,17 @@
#!/usr/bin/env bash
# Copyright 2022 Nordic Semiconductor ASA
# Copyright 2023 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0
set -eu
bash_source_dir="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
# Read variable definitions output by _env.sh
source "${bash_source_dir}/_env.sh"
: "${ZEPHYR_BASE:?ZEPHYR_BASE must be defined}"
# Place yourself in the test's root (i.e. ./../)
west build -b nrf52_bsim -d build_test && \
cp build_test/zephyr/zephyr.exe "${test_exe}"
WORK_DIR="${WORK_DIR:-${ZEPHYR_BASE}/bsim_out}"
INCR_BUILD=1
west build -b nrf52_bsim -d build_test_2 -- -DCONF_FILE=prj_2.conf && \
cp build_test_2/zephyr/zephyr.exe "${test_2_exe}"
source ${ZEPHYR_BASE}/tests/bsim/compile.source
app="$(guess_test_relpath)" compile
app="$(guess_test_relpath)" conf_file=prj_2.conf compile
wait_for_background_jobs

View file

@ -1,11 +0,0 @@
#!/usr/bin/env bash
# Copyright 2022 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0
set -eu
bash_source_dir="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
test_name="$(basename "$(realpath "$bash_source_dir/..")")"
bsim_bin="${BSIM_OUT_PATH}/bin"
BOARD="${BOARD:-nrf52_bsim}"
test_exe="${bsim_bin}/bs_${BOARD}_tests_bsim_bluetooth_host_adv_resume_prj_conf"
test_2_exe="${bsim_bin}/bs_${BOARD}_tests_bsim_bluetooth_host_adv_resume_prj_2_conf"

View file

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

View file

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