tests/bsim bt host/misc: 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 return !=0 on error.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
This commit is contained in:
Alberto Escolar Piedras 2024-03-20 17:12:02 +01:00 committed by Alberto Escolar
commit e9c6f37daf
8 changed files with 44 additions and 56 deletions

View file

@ -1,18 +0,0 @@
#!/usr/bin/env bash
# Copyright 2023 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0
# Path checks, etc
source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
BOARD="${BOARD:-nrf52_bsim}"
dut_exe="bs_${BOARD}_tests_bsim_bluetooth_host_misc_disconnect_dut_prj_conf"
tester_exe="bs_${BOARD}_tests_bsim_bluetooth_host_misc_disconnect_tester_prj_conf"
# terminate running simulations (if any)
${BSIM_COMPONENTS_PATH}/common/stop_bsim.sh
west build -b ${BOARD} -d build_dut dut && \
cp build_dut/zephyr/zephyr.exe "${BSIM_OUT_PATH}/bin/${dut_exe}" &&
west build -b ${BOARD} -d build_tester tester && \
cp build_tester/zephyr/zephyr.exe "${BSIM_OUT_PATH}/bin/${tester_exe}"

View file

@ -0,0 +1,14 @@
#!/usr/bin/env bash
# Copyright 2023 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0
set -eu
: "${ZEPHYR_BASE:?ZEPHYR_BASE must be defined}"
WORK_DIR="${WORK_DIR:-${ZEPHYR_BASE}/bsim_out}"
INCR_BUILD=1
source ${ZEPHYR_BASE}/tests/bsim/compile.source
app="$(guess_test_relpath)"/dut compile
app="$(guess_test_relpath)"/tester compile
wait_for_background_jobs

View file

@ -2,16 +2,13 @@
# Copyright 2023 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0
BOARD="${BOARD:-nrf52_bsim}"
dut_exe="bs_${BOARD}_tests_bsim_bluetooth_host_misc_disconnect_dut_prj_conf"
tester_exe="bs_${BOARD}_tests_bsim_bluetooth_host_misc_disconnect_tester_prj_conf"
source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
test_name="misc_disconnect"
simulation_id="${test_name}"
dut_exe="bs_${BOARD}_$(guess_test_long_name)_dut_prj_conf"
tester_exe="bs_${BOARD}_$(guess_test_long_name)_tester_prj_conf"
simulation_id="misc_disconnect"
verbosity_level=2
EXECUTE_TIMEOUT=30
sim_length_us=10e6
cd ${BSIM_OUT_PATH}/bin
@ -46,3 +43,5 @@ for j in {0..1}; do
echo "${BSIM_OUT_PATH}/results/${simulation_id}/Trace_$i.Tx.pcap"
echo "${BSIM_OUT_PATH}/results/${simulation_id}/Trace_$i.Rx.pcap"
done
exit $exit_code

View file

@ -1,17 +0,0 @@
#!/usr/bin/env bash
# Copyright 2024 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0
# Path checks, etc
source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
# Place yourself in the test's root (i.e. ./../)
rm -rf ${BSIM_OUT_PATH}/bin/bs_nrf52_bsim_tests*
# terminate running simulations (if any)
${BSIM_COMPONENTS_PATH}/common/stop_bsim.sh
bsim_exe=bs_nrf52_bsim_tests_bsim_bluetooth_host_misc_hfc_prj_conf
west build -b nrf52_bsim && \
cp build/zephyr/zephyr.exe ${BSIM_OUT_PATH}/bin/${bsim_exe}

View file

@ -0,0 +1,14 @@
#!/usr/bin/env bash
# Copyright 2023 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0
set -eu
: "${ZEPHYR_BASE:?ZEPHYR_BASE must be defined}"
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,17 +1,14 @@
#!/usr/bin/env bash
#Copyright (c) 2024 NXP
#Copyright (c) 2024 Nordic Semiconductor ASA
# Copyright 2023 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0
set -eu
# Path checks, etc
source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
: "${ZEPHYR_BASE:?ZEPHYR_BASE must be defined}"
# Place yourself in the test's root (i.e. ./../)
rm -rf ${BSIM_OUT_PATH}/bin/bs_nrf52_bsim_tests*
WORK_DIR="${WORK_DIR:-${ZEPHYR_BASE}/bsim_out}"
INCR_BUILD=1
source ${ZEPHYR_BASE}/tests/bsim/compile.source
# terminate running simulations (if any)
${BSIM_COMPONENTS_PATH}/common/stop_bsim.sh
app="$(guess_test_relpath)" compile
bsim_exe=bs_nrf52_bsim_tests_bsim_bluetooth_host_misc_unregister_conn_cb_prj_conf
west build -b nrf52_bsim && \
cp build/zephyr/zephyr.exe ${BSIM_OUT_PATH}/bin/${bsim_exe}
wait_for_background_jobs

View file

@ -12,12 +12,11 @@ source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
#neither flag change can be found, callback function was unregistered as expected
simulation_id="unregister_conn_cb"
verbosity_level=2
EXECUTE_TIMEOUT=20
bsim_exe=./bs_${BOARD}_tests_bsim_bluetooth_host_misc_unregister_conn_cb_prj_conf
cd ${BSIM_OUT_PATH}/bin
bsim_exe=./bs_nrf52_bsim_tests_bsim_bluetooth_host_misc_unregister_conn_cb_prj_conf
Execute "${bsim_exe}" -v=${verbosity_level} -s=${simulation_id} -d=0 -testid=central -rs=420
Execute "${bsim_exe}" -v=${verbosity_level} -s=${simulation_id} -d=1 -testid=peripheral -rs=100