tests/bsim bt host/att: Test scripts cleanup

Use the common scripts so we have a consitent way of
running the tests, report failures in the same way,
can stop them with ctrl+C, properly wait for
all processes to exit..
Let's also place the test scripts in the test_scripts/
folder as it is convention.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>

(f) ests/bsim bt att:  Use common s
This commit is contained in:
Alberto Escolar Piedras 2024-03-20 14:39:53 +01:00 committed by Alberto Escolar
commit 39c9a995cb
24 changed files with 158 additions and 262 deletions

View file

@ -1,14 +0,0 @@
#!/usr/bin/env bash
set -eu
dotslash="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
bin_dir="${BSIM_OUT_PATH}/bin"
BOARD="${BOARD:-nrf52_bsim}"
cd "${dotslash}"
compile_path="${bin_dir}/bs_${BOARD}_"
compile_path+="$(realpath --relative-to "$(west topdir)"/zephyr prj.conf | tr /. _)"
west build -b nrf52_bsim
cp -v build/zephyr/zephyr.exe "${compile_path}"

View file

@ -1,26 +0,0 @@
#!/usr/bin/env bash
set -eu
dotslash="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
bin_dir="${BSIM_OUT_PATH}/bin"
BOARD="${BOARD:-nrf52_bsim}"
cd "${dotslash}"
compile_path="${bin_dir}/bs_${BOARD}_"
compile_path+="$(realpath --relative-to "$(west topdir)"/zephyr prj.conf | tr /. _)"
args_all=(-s=long_read -D=2)
args_dev=(-v=2 -RealEncryption=1 -testid=the_test)
sim_seconds=60
echo "Simulation time: $sim_seconds seconds"
# bs_2G4_phy_v1 requires pwd to at its location
cd "${BSIM_OUT_PATH}/bin"
("${compile_path}" "${args_all[@]}" "${args_dev[@]}" -d=0 || echo d0 $?) &
("${compile_path}" "${args_all[@]}" "${args_dev[@]}" -d=1 || echo d1 $?) &
(./bs_2G4_phy_v1 "${args_all[@]}" -v=6 -sim_length=$((sim_seconds * 10 ** 6)) || echo phy $?) &
wait

View file

@ -0,0 +1,16 @@
#!/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

@ -0,0 +1,22 @@
#!/usr/bin/env bash
# Copyright 2023 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0
set -eu
source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
simulation_id="long_read"
dev_exe=bs_${BOARD}_$(guess_test_long_name)_prj_conf
args_all=(-s=${simulation_id} -D=2)
args_dev=(-v=2 -RealEncryption=1 -testid=the_test)
cd "${BSIM_OUT_PATH}/bin"
Execute ./${dev_exe} "${args_all[@]}" "${args_dev[@]}" -d=0
Execute ./${dev_exe} "${args_all[@]}" "${args_dev[@]}" -d=1
Execute ./bs_2G4_phy_v1 "${args_all[@]}" -v=6 -sim_length=60e6
wait_for_background_jobs

View file

@ -3,17 +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]}")")"
# Read variable definitions output by _env.sh
source "${bash_source_dir}/_env.sh"
: "${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 source ${ZEPHYR_BASE}/tests/bsim/compile.source
app="tests/bsim/bluetooth/$test_name" compile
app="$(guess_test_relpath)" compile
wait_for_background_jobs

View file

@ -1,15 +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_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"
central_exe="${bsim_bin}/bs_${BOARD}_tests_bsim_bluetooth_host_att_mtu_update_prj_conf"
peripheral_exe="${central_exe}"

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
simulation_id="$test_name" simulation_id="$(guess_test_long_name)"
verbosity_level=2 verbosity_level=2
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,16 +0,0 @@
#!/usr/bin/env bash
# Copyright (c) 2023 Nordic Semiconductor
# SPDX-License-Identifier: Apache-2.0
set -eu
dotslash="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
bin_dir="${BSIM_OUT_PATH}/bin"
BOARD="${BOARD:-nrf52_bsim}"
cd "${dotslash}"
compile_path="${bin_dir}/bs_${BOARD}_"
compile_path+="$(realpath --relative-to "$(west topdir)"/zephyr prj.conf | tr /. _)"
west build -b nrf52_bsim
cp -v build/zephyr/zephyr.exe "${compile_path}"

View file

@ -1,36 +0,0 @@
#!/usr/bin/env bash
# Copyright (c) 2023 Nordic Semiconductor
# SPDX-License-Identifier: Apache-2.0
set -eu
dotslash="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
bin_dir="${BSIM_OUT_PATH}/bin"
BOARD="${BOARD:-nrf52_bsim}"
source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
cd "${dotslash}"
compile_name="bs_${BOARD}_"
compile_name+="$(realpath --relative-to "$(west topdir)"/zephyr prj.conf | tr /. _)"
compile_path="${bin_dir}/${compile_name}"
simulation_id="${compile_name}_$(basename "${BASH_SOURCE[0]}" | tr /. _)"
args_all=(-s="${simulation_id}" -D=2)
args_dev=(-v=2 -RealEncryption=1 -testid=the_test)
sim_seconds=200
echo "Simulation time: $sim_seconds seconds"
EXECUTE_TIMEOUT=60
# bs_2G4_phy_v1 requires pwd to at its location
cd "${BSIM_OUT_PATH}/bin"
Execute "${compile_path}" "${args_all[@]}" "${args_dev[@]}" -d=1
Execute ./bs_2G4_phy_v1 "${args_all[@]}" -v=6 -sim_length=$((sim_seconds * 10 ** 6))
Execute "${compile_path}" "${args_all[@]}" "${args_dev[@]}" -d=0
wait_for_background_jobs

View file

@ -0,0 +1,16 @@
#!/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

@ -0,0 +1,24 @@
#!/usr/bin/env bash
# Copyright (c) 2023 Nordic Semiconductor
# SPDX-License-Identifier: Apache-2.0
set -eu
source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
test_path=$(guess_test_long_name)
dev_exe="bs_${BOARD}_${test_path}_prj_conf"
simulation_id="${test_path}"
EXECUTE_TIMEOUT=60
cd "${BSIM_OUT_PATH}/bin"
args_all=(-s="${simulation_id}" -D=2)
args_dev=(-v=2 -RealEncryption=1 -testid=the_test)
Execute ./"${dev_exe}" "${args_all[@]}" "${args_dev[@]}" -d=1
Execute ./bs_2G4_phy_v1 "${args_all[@]}" -v=6 -sim_length=200e6
Execute ./"${dev_exe}" "${args_all[@]}" "${args_dev[@]}" -d=0
wait_for_background_jobs

View file

@ -1,20 +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_att_pipeline_dut_prj_conf"
tester_exe="bs_${BOARD}_tests_bsim_bluetooth_host_att_pipeline_tester_prj_conf"
# terminate running simulations (if any)
${BSIM_COMPONENTS_PATH}/common/stop_bsim.sh
west build -b ${BOARD} -d build_a dut && \
cp build_a/zephyr/zephyr.exe "${BSIM_OUT_PATH}/bin/${dut_exe}" &&
# b stands for bad
west build -b ${BOARD} -d build_b tester && \
cp build_b/zephyr/zephyr.exe "${BSIM_OUT_PATH}/bin/${tester_exe}"

View file

@ -0,0 +1,15 @@
#!/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 # Copyright 2023 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
BOARD="${BOARD:-nrf52_bsim}" source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
dut_exe="bs_${BOARD}_tests_bsim_bluetooth_host_att_pipeline_dut_prj_conf" dut_exe="bs_${BOARD}_tests_bsim_bluetooth_host_att_pipeline_dut_prj_conf"
tester_exe="bs_${BOARD}_tests_bsim_bluetooth_host_att_pipeline_tester_prj_conf" tester_exe="bs_${BOARD}_tests_bsim_bluetooth_host_att_pipeline_tester_prj_conf"
source ${ZEPHYR_BASE}/tests/bsim/sh_common.source simulation_id="att_pipeline"
test_name="att_pipeline"
simulation_id="${test_name}"
verbosity_level=2 verbosity_level=2
EXECUTE_TIMEOUT=30
sim_length_us=100e6 sim_length_us=100e6
cd ${BSIM_OUT_PATH}/bin cd ${BSIM_OUT_PATH}/bin

View file

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

View file

@ -1,16 +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_d0="${bsim_bin}/bs_${BOARD}_tests_bsim_bluetooth_host_att_${test_name}_client_prj_conf"
test_exe_d1="${bsim_bin}/bs_${BOARD}_tests_bsim_bluetooth_host_att_${test_name}_server_prj_conf"

View file

@ -3,26 +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]}")")"
# Read variable definitions output by _env.sh source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
source "${bash_source_dir}/_env.sh"
process_ids="" verbosity_level=2
exit_code=0 simulation_id="read_fill_buf"
test_exe_d0="${BSIM_OUT_PATH}/bin/bs_${BOARD}_$(guess_test_long_name)_client_prj_conf"
function Execute() { test_exe_d1="${BSIM_OUT_PATH}/bin/bs_${BOARD}_$(guess_test_long_name)_server_prj_conf"
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
echo -E "$@"
timeout 30 $@ &
process_ids="$process_ids $!"
}
: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}"
cd ${BSIM_OUT_PATH}/bin cd ${BSIM_OUT_PATH}/bin
@ -37,12 +24,4 @@ Execute "$test_exe_d1" \
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=60e6 $@ -D=2 -sim_length=60e6 $@
for process_id in $process_ids; do wait_for_background_jobs
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

View file

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

View file

@ -1,15 +0,0 @@
#!/bin/env bash
# Copyright 2023 Codecoup
# 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}"
test_exe_d0="${bsim_bin}/bs_${BOARD}_tests_bsim_bluetooth_host_att_${test_name}_client_prj_conf"
test_exe_d1="${bsim_bin}/bs_${BOARD}_tests_bsim_bluetooth_host_att_${test_name}_server_prj_conf"

View file

@ -3,12 +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]}")")"
simulation_id=$(basename "$0")
source "${bash_source_dir}/_env.sh"
source ${ZEPHYR_BASE}/tests/bsim/sh_common.source source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
simulation_id="retry_on_sec_err"
verbosity_level=2
test_exe_d0="./bs_${BOARD}_$(guess_test_long_name)_client_prj_conf"
test_exe_d1="./bs_${BOARD}_$(guess_test_long_name)_server_prj_conf"
cd ${BSIM_OUT_PATH}/bin cd ${BSIM_OUT_PATH}/bin
printf "\n\n===== ATT retry on security error (auto security elevation) ======\n\n" printf "\n\n===== ATT retry on security error (auto security elevation) ======\n\n"

View file

@ -3,12 +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]}")")"
simulation_id=$(basename "$0")
source "${bash_source_dir}/_env.sh"
source ${ZEPHYR_BASE}/tests/bsim/sh_common.source source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
simulation_id="retry_on_sec_err_seq_request"
verbosity_level=2
test_exe_d0="./bs_${BOARD}_$(guess_test_long_name)_client_prj_conf"
test_exe_d1="./bs_${BOARD}_$(guess_test_long_name)_server_prj_conf"
cd ${BSIM_OUT_PATH}/bin cd ${BSIM_OUT_PATH}/bin
printf "\n\n==== ATT retry on security error (peripheral security request) ====\n\n" printf "\n\n==== ATT retry on security error (peripheral security request) ====\n\n"

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_att_sequential_dut_prj_conf"
tester_exe="bs_${BOARD}_tests_bsim_bluetooth_host_att_sequential_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,15 @@
#!/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,22 +2,18 @@
# Copyright 2023 Nordic Semiconductor ASA # Copyright 2023 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
BOARD="${BOARD:-nrf52_bsim}"
dut_exe="bs_${BOARD}_tests_bsim_bluetooth_host_att_sequential_dut_prj_conf"
tester_exe="bs_${BOARD}_tests_bsim_bluetooth_host_att_sequential_tester_prj_conf"
source ${ZEPHYR_BASE}/tests/bsim/sh_common.source source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
test_name="att_sequential" simulation_id="att_sequential"
simulation_id="${test_name}"
verbosity_level=2 verbosity_level=2
EXECUTE_TIMEOUT=30
sim_length_us=10e6 dut_exe="bs_${BOARD}_$(guess_test_long_name)_dut_prj_conf"
tester_exe="bs_${BOARD}_$(guess_test_long_name)_tester_prj_conf"
cd ${BSIM_OUT_PATH}/bin cd ${BSIM_OUT_PATH}/bin
Execute ./bs_2G4_phy_v1 \ Execute ./bs_2G4_phy_v1 \
-v=${verbosity_level} -s="${simulation_id}" -D=2 -sim_length=${sim_length_us} $@ -v=${verbosity_level} -s="${simulation_id}" -D=2 -sim_length=10e6 $@
Execute "./$tester_exe" \ Execute "./$tester_exe" \
-v=${verbosity_level} -s="${simulation_id}" -d=1 -testid=tester -RealEncryption=0 -rs=100 -v=${verbosity_level} -s="${simulation_id}" -d=1 -testid=tester -RealEncryption=0 -rs=100