From 39c9a995cbea84d9ab160bef8656bf764055f79c Mon Sep 17 00:00:00 2001 From: Alberto Escolar Piedras Date: Wed, 20 Mar 2024 14:39:53 +0100 Subject: [PATCH] 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 (f) ests/bsim bt att: Use common s --- .../bluetooth/host/att/long_read/_build.sh | 14 -------- .../bsim/bluetooth/host/att/long_read/run.sh | 26 -------------- .../host/att/long_read/test_scripts/_build.sh | 16 +++++++++ .../host/att/long_read/test_scripts/run.sh | 22 ++++++++++++ .../att/mtu_update/test_scripts/_compile.sh | 13 +++---- .../host/att/mtu_update/test_scripts/_env.sh | 15 -------- .../att/mtu_update/test_scripts/run_test.sh | 8 ++--- .../bluetooth/host/att/open_close/_build.sh | 16 --------- .../bsim/bluetooth/host/att/open_close/run.sh | 36 ------------------- .../att/open_close/test_scripts/_build.sh | 16 +++++++++ .../host/att/open_close/test_scripts/run.sh | 24 +++++++++++++ .../host/att/pipeline/scripts/_compile.sh | 20 ----------- .../att/pipeline/test_scripts/_compile.sh | 15 ++++++++ .../pipeline/{scripts => test_scripts}/run.sh | 9 ++--- .../read_fill_buf/test_scripts/_compile.sh | 20 +++++------ .../att/read_fill_buf/test_scripts/_env.sh | 16 --------- .../read_fill_buf/test_scripts/run_tests.sh | 33 ++++------------- .../retry_on_sec_err/test_scripts/_compile.sh | 22 ++++++------ .../att/retry_on_sec_err/test_scripts/_env.sh | 15 -------- .../retry_on_sec_err/test_scripts/run_test.sh | 8 +++-- .../test_scripts/run_test_security_request.sh | 9 ++--- .../host/att/sequential/scripts/_compile.sh | 18 ---------- .../att/sequential/test_scripts/_compile.sh | 15 ++++++++ .../{scripts => test_scripts}/sequential.sh | 14 +++----- 24 files changed, 158 insertions(+), 262 deletions(-) delete mode 100755 tests/bsim/bluetooth/host/att/long_read/_build.sh delete mode 100755 tests/bsim/bluetooth/host/att/long_read/run.sh create mode 100755 tests/bsim/bluetooth/host/att/long_read/test_scripts/_build.sh create mode 100755 tests/bsim/bluetooth/host/att/long_read/test_scripts/run.sh delete mode 100755 tests/bsim/bluetooth/host/att/mtu_update/test_scripts/_env.sh delete mode 100755 tests/bsim/bluetooth/host/att/open_close/_build.sh delete mode 100755 tests/bsim/bluetooth/host/att/open_close/run.sh create mode 100755 tests/bsim/bluetooth/host/att/open_close/test_scripts/_build.sh create mode 100755 tests/bsim/bluetooth/host/att/open_close/test_scripts/run.sh delete mode 100755 tests/bsim/bluetooth/host/att/pipeline/scripts/_compile.sh create mode 100755 tests/bsim/bluetooth/host/att/pipeline/test_scripts/_compile.sh rename tests/bsim/bluetooth/host/att/pipeline/{scripts => test_scripts}/run.sh (92%) delete mode 100755 tests/bsim/bluetooth/host/att/read_fill_buf/test_scripts/_env.sh delete mode 100755 tests/bsim/bluetooth/host/att/retry_on_sec_err/test_scripts/_env.sh delete mode 100755 tests/bsim/bluetooth/host/att/sequential/scripts/_compile.sh create mode 100755 tests/bsim/bluetooth/host/att/sequential/test_scripts/_compile.sh rename tests/bsim/bluetooth/host/att/sequential/{scripts => test_scripts}/sequential.sh (64%) diff --git a/tests/bsim/bluetooth/host/att/long_read/_build.sh b/tests/bsim/bluetooth/host/att/long_read/_build.sh deleted file mode 100755 index 637512b3826..00000000000 --- a/tests/bsim/bluetooth/host/att/long_read/_build.sh +++ /dev/null @@ -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}" diff --git a/tests/bsim/bluetooth/host/att/long_read/run.sh b/tests/bsim/bluetooth/host/att/long_read/run.sh deleted file mode 100755 index b1b7a5c6eb0..00000000000 --- a/tests/bsim/bluetooth/host/att/long_read/run.sh +++ /dev/null @@ -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 diff --git a/tests/bsim/bluetooth/host/att/long_read/test_scripts/_build.sh b/tests/bsim/bluetooth/host/att/long_read/test_scripts/_build.sh new file mode 100755 index 00000000000..af200055c53 --- /dev/null +++ b/tests/bsim/bluetooth/host/att/long_read/test_scripts/_build.sh @@ -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 diff --git a/tests/bsim/bluetooth/host/att/long_read/test_scripts/run.sh b/tests/bsim/bluetooth/host/att/long_read/test_scripts/run.sh new file mode 100755 index 00000000000..b6b9ca57fec --- /dev/null +++ b/tests/bsim/bluetooth/host/att/long_read/test_scripts/run.sh @@ -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 diff --git a/tests/bsim/bluetooth/host/att/mtu_update/test_scripts/_compile.sh b/tests/bsim/bluetooth/host/att/mtu_update/test_scripts/_compile.sh index 2eedd8970c6..ca1f96b562c 100755 --- a/tests/bsim/bluetooth/host/att/mtu_update/test_scripts/_compile.sh +++ b/tests/bsim/bluetooth/host/att/mtu_update/test_scripts/_compile.sh @@ -3,17 +3,12 @@ # 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" -: "${BSIM_COMPONENTS_PATH:?BSIM_COMPONENTS_PATH must be defined}" : "${ZEPHYR_BASE:?ZEPHYR_BASE must be defined}" WORK_DIR="${WORK_DIR:-${ZEPHYR_BASE}/bsim_out}" -BOARD="${BOARD:-nrf52_bsim}" -BOARD_ROOT="${BOARD_ROOT:-${ZEPHYR_BASE}}" INCR_BUILD=1 -mkdir -p ${WORK_DIR} source ${ZEPHYR_BASE}/tests/bsim/compile.source -app="tests/bsim/bluetooth/$test_name" compile + +app="$(guess_test_relpath)" compile + +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/host/att/mtu_update/test_scripts/_env.sh b/tests/bsim/bluetooth/host/att/mtu_update/test_scripts/_env.sh deleted file mode 100755 index 8d101eabcdd..00000000000 --- a/tests/bsim/bluetooth/host/att/mtu_update/test_scripts/_env.sh +++ /dev/null @@ -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}" diff --git a/tests/bsim/bluetooth/host/att/mtu_update/test_scripts/run_test.sh b/tests/bsim/bluetooth/host/att/mtu_update/test_scripts/run_test.sh index 255f6f4f9fa..c49ac8369b2 100755 --- a/tests/bsim/bluetooth/host/att/mtu_update/test_scripts/run_test.sh +++ b/tests/bsim/bluetooth/host/att/mtu_update/test_scripts/run_test.sh @@ -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" +simulation_id="$(guess_test_long_name)" 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 diff --git a/tests/bsim/bluetooth/host/att/open_close/_build.sh b/tests/bsim/bluetooth/host/att/open_close/_build.sh deleted file mode 100755 index 649682554f5..00000000000 --- a/tests/bsim/bluetooth/host/att/open_close/_build.sh +++ /dev/null @@ -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}" diff --git a/tests/bsim/bluetooth/host/att/open_close/run.sh b/tests/bsim/bluetooth/host/att/open_close/run.sh deleted file mode 100755 index 3d8372e08ae..00000000000 --- a/tests/bsim/bluetooth/host/att/open_close/run.sh +++ /dev/null @@ -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 diff --git a/tests/bsim/bluetooth/host/att/open_close/test_scripts/_build.sh b/tests/bsim/bluetooth/host/att/open_close/test_scripts/_build.sh new file mode 100755 index 00000000000..af200055c53 --- /dev/null +++ b/tests/bsim/bluetooth/host/att/open_close/test_scripts/_build.sh @@ -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 diff --git a/tests/bsim/bluetooth/host/att/open_close/test_scripts/run.sh b/tests/bsim/bluetooth/host/att/open_close/test_scripts/run.sh new file mode 100755 index 00000000000..e66c4f13d9c --- /dev/null +++ b/tests/bsim/bluetooth/host/att/open_close/test_scripts/run.sh @@ -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 diff --git a/tests/bsim/bluetooth/host/att/pipeline/scripts/_compile.sh b/tests/bsim/bluetooth/host/att/pipeline/scripts/_compile.sh deleted file mode 100755 index 836f306cf1c..00000000000 --- a/tests/bsim/bluetooth/host/att/pipeline/scripts/_compile.sh +++ /dev/null @@ -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}" diff --git a/tests/bsim/bluetooth/host/att/pipeline/test_scripts/_compile.sh b/tests/bsim/bluetooth/host/att/pipeline/test_scripts/_compile.sh new file mode 100755 index 00000000000..3579ab2e772 --- /dev/null +++ b/tests/bsim/bluetooth/host/att/pipeline/test_scripts/_compile.sh @@ -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 diff --git a/tests/bsim/bluetooth/host/att/pipeline/scripts/run.sh b/tests/bsim/bluetooth/host/att/pipeline/test_scripts/run.sh similarity index 92% rename from tests/bsim/bluetooth/host/att/pipeline/scripts/run.sh rename to tests/bsim/bluetooth/host/att/pipeline/test_scripts/run.sh index 1edaf2e05a0..416484c27d2 100755 --- a/tests/bsim/bluetooth/host/att/pipeline/scripts/run.sh +++ b/tests/bsim/bluetooth/host/att/pipeline/test_scripts/run.sh @@ -2,16 +2,13 @@ # Copyright 2023 Nordic Semiconductor ASA # 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" tester_exe="bs_${BOARD}_tests_bsim_bluetooth_host_att_pipeline_tester_prj_conf" -source ${ZEPHYR_BASE}/tests/bsim/sh_common.source - -test_name="att_pipeline" -simulation_id="${test_name}" +simulation_id="att_pipeline" verbosity_level=2 -EXECUTE_TIMEOUT=30 sim_length_us=100e6 cd ${BSIM_OUT_PATH}/bin diff --git a/tests/bsim/bluetooth/host/att/read_fill_buf/test_scripts/_compile.sh b/tests/bsim/bluetooth/host/att/read_fill_buf/test_scripts/_compile.sh index ee045695cda..1fa38a6d27f 100755 --- a/tests/bsim/bluetooth/host/att/read_fill_buf/test_scripts/_compile.sh +++ b/tests/bsim/bluetooth/host/att/read_fill_buf/test_scripts/_compile.sh @@ -1,18 +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]}")")" +: "${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 -west build -b nrf52_bsim && \ - cp -v build/zephyr/zephyr.exe "${test_exe_d0}" -popd +source ${ZEPHYR_BASE}/tests/bsim/compile.source -pushd server -west build -b nrf52_bsim && \ - cp -v build/zephyr/zephyr.exe "${test_exe_d1}" -popd +app="$(guess_test_relpath)"/client compile +app="$(guess_test_relpath)"/server compile + +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/host/att/read_fill_buf/test_scripts/_env.sh b/tests/bsim/bluetooth/host/att/read_fill_buf/test_scripts/_env.sh deleted file mode 100755 index c911274987f..00000000000 --- a/tests/bsim/bluetooth/host/att/read_fill_buf/test_scripts/_env.sh +++ /dev/null @@ -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" diff --git a/tests/bsim/bluetooth/host/att/read_fill_buf/test_scripts/run_tests.sh b/tests/bsim/bluetooth/host/att/read_fill_buf/test_scripts/run_tests.sh index 8c5adcad765..8f540dfaba1 100755 --- a/tests/bsim/bluetooth/host/att/read_fill_buf/test_scripts/run_tests.sh +++ b/tests/bsim/bluetooth/host/att/read_fill_buf/test_scripts/run_tests.sh @@ -3,26 +3,13 @@ # 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" +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source -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 - echo -E "$@" - timeout 30 $@ & - process_ids="$process_ids $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" +verbosity_level=2 +simulation_id="read_fill_buf" +test_exe_d0="${BSIM_OUT_PATH}/bin/bs_${BOARD}_$(guess_test_long_name)_client_prj_conf" +test_exe_d1="${BSIM_OUT_PATH}/bin/bs_${BOARD}_$(guess_test_long_name)_server_prj_conf" cd ${BSIM_OUT_PATH}/bin @@ -37,12 +24,4 @@ Execute "$test_exe_d1" \ Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s="${simulation_id}" \ -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 diff --git a/tests/bsim/bluetooth/host/att/retry_on_sec_err/test_scripts/_compile.sh b/tests/bsim/bluetooth/host/att/retry_on_sec_err/test_scripts/_compile.sh index 88a5454b674..1fa38a6d27f 100755 --- a/tests/bsim/bluetooth/host/att/retry_on_sec_err/test_scripts/_compile.sh +++ b/tests/bsim/bluetooth/host/att/retry_on_sec_err/test_scripts/_compile.sh @@ -1,18 +1,16 @@ -#!/bin/env bash -# Copyright 2023 Codecoup +#!/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]}")")" +: "${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 -west build -b nrf52_bsim && \ - cp -v build/zephyr/zephyr.exe "${test_exe_d0}" -popd +source ${ZEPHYR_BASE}/tests/bsim/compile.source -pushd server -west build -b nrf52_bsim && \ - cp -v build/zephyr/zephyr.exe "${test_exe_d1}" -popd +app="$(guess_test_relpath)"/client compile +app="$(guess_test_relpath)"/server compile + +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/host/att/retry_on_sec_err/test_scripts/_env.sh b/tests/bsim/bluetooth/host/att/retry_on_sec_err/test_scripts/_env.sh deleted file mode 100755 index 66b074ca3d8..00000000000 --- a/tests/bsim/bluetooth/host/att/retry_on_sec_err/test_scripts/_env.sh +++ /dev/null @@ -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" diff --git a/tests/bsim/bluetooth/host/att/retry_on_sec_err/test_scripts/run_test.sh b/tests/bsim/bluetooth/host/att/retry_on_sec_err/test_scripts/run_test.sh index 8ea8f38cddc..b822a7c1a96 100755 --- a/tests/bsim/bluetooth/host/att/retry_on_sec_err/test_scripts/run_test.sh +++ b/tests/bsim/bluetooth/host/att/retry_on_sec_err/test_scripts/run_test.sh @@ -3,12 +3,14 @@ # SPDX-License-Identifier: Apache-2.0 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 +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 printf "\n\n===== ATT retry on security error (auto security elevation) ======\n\n" diff --git a/tests/bsim/bluetooth/host/att/retry_on_sec_err/test_scripts/run_test_security_request.sh b/tests/bsim/bluetooth/host/att/retry_on_sec_err/test_scripts/run_test_security_request.sh index 8d7c86c4d04..311def7e06f 100755 --- a/tests/bsim/bluetooth/host/att/retry_on_sec_err/test_scripts/run_test_security_request.sh +++ b/tests/bsim/bluetooth/host/att/retry_on_sec_err/test_scripts/run_test_security_request.sh @@ -3,12 +3,13 @@ # SPDX-License-Identifier: Apache-2.0 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 +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 printf "\n\n==== ATT retry on security error (peripheral security request) ====\n\n" diff --git a/tests/bsim/bluetooth/host/att/sequential/scripts/_compile.sh b/tests/bsim/bluetooth/host/att/sequential/scripts/_compile.sh deleted file mode 100755 index 2e81445690f..00000000000 --- a/tests/bsim/bluetooth/host/att/sequential/scripts/_compile.sh +++ /dev/null @@ -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}" diff --git a/tests/bsim/bluetooth/host/att/sequential/test_scripts/_compile.sh b/tests/bsim/bluetooth/host/att/sequential/test_scripts/_compile.sh new file mode 100755 index 00000000000..3579ab2e772 --- /dev/null +++ b/tests/bsim/bluetooth/host/att/sequential/test_scripts/_compile.sh @@ -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 diff --git a/tests/bsim/bluetooth/host/att/sequential/scripts/sequential.sh b/tests/bsim/bluetooth/host/att/sequential/test_scripts/sequential.sh similarity index 64% rename from tests/bsim/bluetooth/host/att/sequential/scripts/sequential.sh rename to tests/bsim/bluetooth/host/att/sequential/test_scripts/sequential.sh index 61153432781..c7db4e95820 100755 --- a/tests/bsim/bluetooth/host/att/sequential/scripts/sequential.sh +++ b/tests/bsim/bluetooth/host/att/sequential/test_scripts/sequential.sh @@ -2,22 +2,18 @@ # Copyright 2023 Nordic Semiconductor ASA # 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 -test_name="att_sequential" -simulation_id="${test_name}" +simulation_id="att_sequential" 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 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" \ -v=${verbosity_level} -s="${simulation_id}" -d=1 -testid=tester -RealEncryption=0 -rs=100