diff --git a/tests/bsim/bluetooth/audio/compile.sh b/tests/bsim/bluetooth/audio/compile.sh index a77799ea477..c06c5a1e67b 100755 --- a/tests/bsim/bluetooth/audio/compile.sh +++ b/tests/bsim/bluetooth/audio/compile.sh @@ -7,13 +7,14 @@ #set -x #uncomment this line for debugging set -ue -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" + + : "${BSIM_COMPONENTS_PATH:?BSIM_COMPONENTS_PATH must be defined}" : "${ZEPHYR_BASE:?ZEPHYR_BASE must be set to point to the zephyr root\ directory}" WORK_DIR="${WORK_DIR:-${ZEPHYR_BASE}/bsim_out}" -BOARD="${BOARD:-nrf52_bsim}" + BOARD_ROOT="${BOARD_ROOT:-${ZEPHYR_BASE}}" mkdir -p ${WORK_DIR} diff --git a/tests/bsim/bluetooth/audio/test_scripts/bap_bass.sh b/tests/bsim/bluetooth/audio/test_scripts/bap_bass.sh index 7a08b12313f..cc0f059379a 100755 --- a/tests/bsim/bluetooth/audio/test_scripts/bap_bass.sh +++ b/tests/bsim/bluetooth/audio/test_scripts/bap_bass.sh @@ -6,21 +6,9 @@ SIMULATION_ID="bass" VERBOSITY_LEVEL=2 -PROCESS_IDS=""; EXIT_CODE=0 +EXECUTE_TIMEOUT=20 -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 20 $@ & PROCESS_IDS="$PROCESS_IDS $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" - -#Give a default value to BOARD if it does not have one yet: -BOARD="${BOARD:-nrf52_bsim}" +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source cd ${BSIM_OUT_PATH}/bin @@ -41,8 +29,4 @@ Execute ./bs_${BOARD}_tests_bsim_bluetooth_audio_prj_conf \ Execute ./bs_2G4_phy_v1 -v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} -D=3 \ -sim_length=60e6 $@ -for PROCESS_ID in $PROCESS_IDS; do - wait $PROCESS_ID || let "EXIT_CODE=$?" -done - -exit $EXIT_CODE #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/audio/test_scripts/bap_broadcast_audio.sh b/tests/bsim/bluetooth/audio/test_scripts/bap_broadcast_audio.sh index 2e5b7d4c2d2..10e9af21bbe 100755 --- a/tests/bsim/bluetooth/audio/test_scripts/bap_broadcast_audio.sh +++ b/tests/bsim/bluetooth/audio/test_scripts/bap_broadcast_audio.sh @@ -5,21 +5,9 @@ # SPDX-License-Identifier: Apache-2.0 VERBOSITY_LEVEL=2 -PROCESS_IDS=""; EXIT_CODE=0 +EXECUTE_TIMEOUT=20 -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 20 $@ & PROCESS_IDS="$PROCESS_IDS $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" - -#Give a default value to BOARD if it does not have one yet: -BOARD="${BOARD:-nrf52_bsim}" +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source cd ${BSIM_OUT_PATH}/bin @@ -38,9 +26,7 @@ Execute ./bs_${BOARD}_tests_bsim_bluetooth_audio_prj_conf \ 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 +wait_for_background_jobs printf "\n\n======== Broadcaster sink disconnect test =========\n\n" @@ -58,8 +44,4 @@ Execute ./bs_${BOARD}_tests_bsim_bluetooth_audio_prj_conf \ 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 - -exit $EXIT_CODE #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/audio/test_scripts/bap_unicast_audio.sh b/tests/bsim/bluetooth/audio/test_scripts/bap_unicast_audio.sh index 9d9b82ea9bc..5fd562a29f8 100755 --- a/tests/bsim/bluetooth/audio/test_scripts/bap_unicast_audio.sh +++ b/tests/bsim/bluetooth/audio/test_scripts/bap_unicast_audio.sh @@ -6,21 +6,9 @@ SIMULATION_ID="unicast_audio" VERBOSITY_LEVEL=2 -PROCESS_IDS=""; EXIT_CODE=0 +EXECUTE_TIMEOUT=20 -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 20 $@ & PROCESS_IDS="$PROCESS_IDS $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" - -#Give a default value to BOARD if it does not have one yet: -BOARD="${BOARD:-nrf52_bsim}" +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source cd ${BSIM_OUT_PATH}/bin @@ -29,7 +17,6 @@ printf "\n\n======== Unicast Audio test =========\n\n" Execute ./bs_${BOARD}_tests_bsim_bluetooth_audio_prj_conf \ -v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} -d=0 -testid=unicast_client -rs=23 - Execute ./bs_${BOARD}_tests_bsim_bluetooth_audio_prj_conf \ -v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} -d=1 -testid=unicast_server -rs=27 @@ -37,8 +24,4 @@ Execute ./bs_${BOARD}_tests_bsim_bluetooth_audio_prj_conf \ 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 - -exit $EXIT_CODE #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/audio/test_scripts/cap_broadcast.sh b/tests/bsim/bluetooth/audio/test_scripts/cap_broadcast.sh index 5f448cf2279..a18573e2192 100755 --- a/tests/bsim/bluetooth/audio/test_scripts/cap_broadcast.sh +++ b/tests/bsim/bluetooth/audio/test_scripts/cap_broadcast.sh @@ -6,21 +6,9 @@ SIMULATION_ID="cap_broadcast" VERBOSITY_LEVEL=2 -PROCESS_IDS=""; EXIT_CODE=0 +EXECUTE_TIMEOUT=20 -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 20 $@ & PROCESS_IDS="$PROCESS_IDS $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" - -#Give a default value to BOARD if it does not have one yet: -BOARD="${BOARD:-nrf52_bsim}" +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source cd ${BSIM_OUT_PATH}/bin @@ -36,8 +24,4 @@ Execute ./bs_${BOARD}_tests_bsim_bluetooth_audio_prj_conf \ 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 - -exit $EXIT_CODE #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/audio/test_scripts/cap_unicast.sh b/tests/bsim/bluetooth/audio/test_scripts/cap_unicast.sh index f0ed6f2c3bb..e657ac958ee 100755 --- a/tests/bsim/bluetooth/audio/test_scripts/cap_unicast.sh +++ b/tests/bsim/bluetooth/audio/test_scripts/cap_unicast.sh @@ -6,21 +6,9 @@ SIMULATION_ID="cap_unicast" VERBOSITY_LEVEL=2 -PROCESS_IDS=""; EXIT_CODE=0 +EXECUTE_TIMEOUT=20 -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 20 $@ & PROCESS_IDS="$PROCESS_IDS $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" - -#Give a default value to BOARD if it does not have one yet: -BOARD="${BOARD:-nrf52_bsim}" +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source cd ${BSIM_OUT_PATH}/bin @@ -36,8 +24,4 @@ Execute ./bs_${BOARD}_tests_bsim_bluetooth_audio_prj_conf \ 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 - -exit $EXIT_CODE #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/audio/test_scripts/csip.sh b/tests/bsim/bluetooth/audio/test_scripts/csip.sh index 20b307a2ff8..1490b3432fd 100755 --- a/tests/bsim/bluetooth/audio/test_scripts/csip.sh +++ b/tests/bsim/bluetooth/audio/test_scripts/csip.sh @@ -7,22 +7,10 @@ # Basic CSIP test. A set coordinator connects to multiple set members # lock thems, unlocks them and disconnects. +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source + VERBOSITY_LEVEL=2 -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 20 $@ & PROCESS_IDS="$PROCESS_IDS $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" - -#Give a default value to BOARD if it does not have one yet: -BOARD="${BOARD:-nrf52_bsim}" +EXECUTE_TIMEOUT=20 cd ${BSIM_OUT_PATH}/bin @@ -51,11 +39,7 @@ Execute ./bs_${BOARD}_tests_bsim_bluetooth_audio_prj_conf \ Execute ./bs_2G4_phy_v1 -v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} \ -D=4 -sim_length=60e6 $@ -for PROCESS_ID in $PROCESS_IDS; do - wait $PROCESS_ID || let "EXIT_CODE=$?" -done - -PROCESS_IDS=""; +wait_for_background_jobs # TEST WITH FORCE RELEASE @@ -82,9 +66,7 @@ Execute ./bs_${BOARD}_tests_bsim_bluetooth_audio_prj_conf \ Execute ./bs_2G4_phy_v1 -v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} \ -D=4 -sim_length=60e6 $@ -for PROCESS_ID in $PROCESS_IDS; do - wait $PROCESS_ID || let "EXIT_CODE=$?" -done +wait_for_background_jobs # TEST WITH SIRK ENC @@ -111,7 +93,4 @@ Execute ./bs_${BOARD}_tests_bsim_bluetooth_audio_prj_conf \ Execute ./bs_2G4_phy_v1 -v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} \ -D=4 -sim_length=60e6 $@ -for PROCESS_ID in $PROCESS_IDS; do - wait $PROCESS_ID || let "EXIT_CODE=$?" -done -exit $EXIT_CODE #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/audio/test_scripts/has.sh b/tests/bsim/bluetooth/audio/test_scripts/has.sh index b35c7c13186..e2bface0396 100755 --- a/tests/bsim/bluetooth/audio/test_scripts/has.sh +++ b/tests/bsim/bluetooth/audio/test_scripts/has.sh @@ -4,23 +4,11 @@ # # SPDX-License-Identifier: Apache-2.0 +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source + SIMULATION_ID="has" VERBOSITY_LEVEL=2 -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 20 $@ & PROCESS_IDS="$PROCESS_IDS $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" - -#Give a default value to BOARD if it does not have one yet: -BOARD="${BOARD:-nrf52_bsim}" +EXECUTE_TIMEOUT=20 cd ${BSIM_OUT_PATH}/bin @@ -35,8 +23,4 @@ Execute ./bs_${BOARD}_tests_bsim_bluetooth_audio_prj_conf \ 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 - -exit $EXIT_CODE #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/audio/test_scripts/ias.sh b/tests/bsim/bluetooth/audio/test_scripts/ias.sh index a310c1dd232..3547d6996e8 100755 --- a/tests/bsim/bluetooth/audio/test_scripts/ias.sh +++ b/tests/bsim/bluetooth/audio/test_scripts/ias.sh @@ -4,23 +4,11 @@ # # SPDX-License-Identifier: Apache-2.0 +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source + SIMULATION_ID="ias" VERBOSITY_LEVEL=2 -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 20 $@ & PROCESS_IDS="$PROCESS_IDS $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" - -#Give a default value to BOARD if it does not have one yet: -BOARD="${BOARD:-nrf52_bsim}" +EXECUTE_TIMEOUT=20 cd ${BSIM_OUT_PATH}/bin @@ -36,8 +24,4 @@ Execute ./bs_${BOARD}_tests_bsim_bluetooth_audio_prj_conf \ 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 - -exit $EXIT_CODE #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/audio/test_scripts/mcs_mcc.sh b/tests/bsim/bluetooth/audio/test_scripts/mcs_mcc.sh index 679b3026af1..1e31932efe7 100755 --- a/tests/bsim/bluetooth/audio/test_scripts/mcs_mcc.sh +++ b/tests/bsim/bluetooth/audio/test_scripts/mcs_mcc.sh @@ -4,23 +4,11 @@ # # SPDX-License-Identifier: Apache-2.0 +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source + SIMULATION_ID="mcs_mcc" VERBOSITY_LEVEL=2 -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 20 $@ & PROCESS_IDS="$PROCESS_IDS $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" - -#Give a default value to BOARD if it does not have one yet: -BOARD="${BOARD:-nrf52_bsim}" +EXECUTE_TIMEOUT=20 cd ${BSIM_OUT_PATH}/bin @@ -36,8 +24,4 @@ Execute ./bs_${BOARD}_tests_bsim_bluetooth_audio_prj_conf \ 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 - -exit $EXIT_CODE #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/audio/test_scripts/media_controller.sh b/tests/bsim/bluetooth/audio/test_scripts/media_controller.sh index 16a913a7dac..ab036d39497 100755 --- a/tests/bsim/bluetooth/audio/test_scripts/media_controller.sh +++ b/tests/bsim/bluetooth/audio/test_scripts/media_controller.sh @@ -4,23 +4,11 @@ # # SPDX-License-Identifier: Apache-2.0 +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source + SIMULATION_ID="media_controller" VERBOSITY_LEVEL=2 -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 20 $@ & PROCESS_IDS="$PROCESS_IDS $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" - -#Give a default value to BOARD if it does not have one yet: -BOARD="${BOARD:-nrf52_bsim}" +EXECUTE_TIMEOUT=20 cd ${BSIM_OUT_PATH}/bin @@ -33,9 +21,7 @@ Execute ./bs_${BOARD}_tests_bsim_bluetooth_audio_prj_conf \ Execute ./bs_2G4_phy_v1 -v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} \ -D=1 -sim_length=60e6 $@ -for PROCESS_ID in $PROCESS_IDS; do - wait $PROCESS_ID || let "EXIT_CODE=$?" -done +wait_for_background_jobs printf "\n\n======== Running media controller remote_player test =========\n\n" @@ -49,8 +35,4 @@ Execute ./bs_${BOARD}_tests_bsim_bluetooth_audio_prj_conf \ 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 - -exit $EXIT_CODE #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/audio/test_scripts/micp.sh b/tests/bsim/bluetooth/audio/test_scripts/micp.sh index 06c201319d3..3117f665116 100755 --- a/tests/bsim/bluetooth/audio/test_scripts/micp.sh +++ b/tests/bsim/bluetooth/audio/test_scripts/micp.sh @@ -4,23 +4,11 @@ # # SPDX-License-Identifier: Apache-2.0 +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source + SIMULATION_ID="micp" VERBOSITY_LEVEL=2 -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 20 $@ & PROCESS_IDS="$PROCESS_IDS $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" - -#Give a default value to BOARD if it does not have one yet: -BOARD="${BOARD:-nrf52_bsim}" +EXECUTE_TIMEOUT=20 cd ${BSIM_OUT_PATH}/bin @@ -33,9 +21,7 @@ Execute ./bs_${BOARD}_tests_bsim_bluetooth_audio_prj_conf \ Execute ./bs_2G4_phy_v1 -v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} \ -D=1 -sim_length=60e6 $@ -for PROCESS_ID in $PROCESS_IDS; do - wait $PROCESS_ID || let "EXIT_CODE=$?" -done +wait_for_background_jobs printf "\n\n==== Running MICP Microphone Device and MICP Microphone Controller test ====n\n" @@ -49,8 +35,4 @@ Execute ./bs_${BOARD}_tests_bsim_bluetooth_audio_prj_conf \ 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 - -exit $EXIT_CODE #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/audio/test_scripts/tbs.sh b/tests/bsim/bluetooth/audio/test_scripts/tbs.sh index 84b44a29dec..e5f9e09fbd5 100755 --- a/tests/bsim/bluetooth/audio/test_scripts/tbs.sh +++ b/tests/bsim/bluetooth/audio/test_scripts/tbs.sh @@ -7,21 +7,10 @@ SIMULATION_ID="tbs_ccp" VERBOSITY_LEVEL=2 -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 20 $@ & PROCESS_IDS="$PROCESS_IDS $!" -} +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" - -#Give a default value to BOARD if it does not have one yet: -BOARD="${BOARD:-nrf52_bsim}" +EXECUTE_TIMEOUT=20 cd ${BSIM_OUT_PATH}/bin @@ -35,7 +24,4 @@ Execute ./bs_${BOARD}_tests_bsim_bluetooth_audio_prj_conf \ 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 -exit $EXIT_CODE #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/audio/test_scripts/vcp.sh b/tests/bsim/bluetooth/audio/test_scripts/vcp.sh index 56e28e78aad..0be421894ba 100755 --- a/tests/bsim/bluetooth/audio/test_scripts/vcp.sh +++ b/tests/bsim/bluetooth/audio/test_scripts/vcp.sh @@ -4,23 +4,11 @@ # # SPDX-License-Identifier: Apache-2.0 +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source + SIMULATION_ID="vcp" VERBOSITY_LEVEL=2 -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 20 $@ & PROCESS_IDS="$PROCESS_IDS $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" - -#Give a default value to BOARD if it does not have one yet: -BOARD="${BOARD:-nrf52_bsim}" +EXECUTE_TIMEOUT=20 cd ${BSIM_OUT_PATH}/bin @@ -33,9 +21,7 @@ Execute ./bs_${BOARD}_tests_bsim_bluetooth_audio_prj_conf \ Execute ./bs_2G4_phy_v1 -v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} \ -D=1 -sim_length=60e6 $@ -for PROCESS_ID in $PROCESS_IDS; do - wait $PROCESS_ID || let "EXIT_CODE=$?" -done +wait_for_background_jobs printf "\n\n======== Running VCP Volume Renderer and VCP Volume Controller test =========\n\n" @@ -49,8 +35,4 @@ Execute ./bs_${BOARD}_tests_bsim_bluetooth_audio_prj_conf \ 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 - -exit $EXIT_CODE #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/host/adv/chain/tests_scripts/adv_chain.sh b/tests/bsim/bluetooth/host/adv/chain/tests_scripts/adv_chain.sh index 28b608efd34..ab3f1c07896 100755 --- a/tests/bsim/bluetooth/host/adv/chain/tests_scripts/adv_chain.sh +++ b/tests/bsim/bluetooth/host/adv/chain/tests_scripts/adv_chain.sh @@ -4,23 +4,11 @@ # Validate Extended Advertising AD Data fragment operation, PDU chaining and # Extended Scanning of chain PDUs +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source + simulation_id="adv_chain" verbosity_level=2 -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 10 $@ & process_ids="$process_ids $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" - -#Give a default value to BOARD if it does not have one yet: -BOARD="${BOARD:-nrf52_bsim}" +EXECUTE_TIMEOUT=10 cd ${BSIM_OUT_PATH}/bin @@ -33,7 +21,4 @@ Execute ./bs_${BOARD}_tests_bsim_bluetooth_host_adv_chain_prj_conf\ Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=${simulation_id} \ -D=2 -sim_length=10e6 $@ -for process_id in $process_ids; do - wait $process_id || let "exit_code=$?" -done -exit $exit_code #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/host/adv/periodic/tests_scripts/per_adv.sh b/tests/bsim/bluetooth/host/adv/periodic/tests_scripts/per_adv.sh index 3d1e189a776..aa2e8249fae 100755 --- a/tests/bsim/bluetooth/host/adv/periodic/tests_scripts/per_adv.sh +++ b/tests/bsim/bluetooth/host/adv/periodic/tests_scripts/per_adv.sh @@ -4,23 +4,12 @@ # Basic periodic advertising sync test: an advertiser advertises with periodic # advertising, and a scanner scans for and syncs to the periodic advertising. + +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source + simulation_id="per_adv" verbosity_level=2 -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 10 $@ & process_ids="$process_ids $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" - -#Give a default value to BOARD if it does not have one yet: -BOARD="${BOARD:-nrf52_bsim}" +EXECUTE_TIMEOUT=10 cd ${BSIM_OUT_PATH}/bin @@ -35,7 +24,4 @@ Execute ./bs_${BOARD}_tests_bsim_bluetooth_host_adv_periodic_prj_conf \ Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=${simulation_id} \ -D=2 -sim_length=20e6 $@ -for process_id in $process_ids; do - wait $process_id || let "exit_code=$?" -done -exit $exit_code #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/host/adv/periodic/tests_scripts/per_adv_conn.sh b/tests/bsim/bluetooth/host/adv/periodic/tests_scripts/per_adv_conn.sh index 70dbdb101b1..de535d78727 100755 --- a/tests/bsim/bluetooth/host/adv/periodic/tests_scripts/per_adv_conn.sh +++ b/tests/bsim/bluetooth/host/adv/periodic/tests_scripts/per_adv_conn.sh @@ -4,23 +4,12 @@ # Basic periodic advertising sync test: an advertiser advertises with periodic # advertising, and a scanner scans for and syncs to the periodic advertising. + +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source + simulation_id="per_adv_conn" verbosity_level=2 -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 10 $@ & process_ids="$process_ids $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" - -#Give a default value to BOARD if it does not have one yet: -BOARD="${BOARD:-nrf52_bsim}" +EXECUTE_TIMEOUT=10 cd ${BSIM_OUT_PATH}/bin @@ -35,7 +24,4 @@ Execute ./bs_${BOARD}_tests_bsim_bluetooth_host_adv_periodic_prj_conf \ Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=${simulation_id} \ -D=2 -sim_length=20e6 $@ -for process_id in $process_ids; do - wait $process_id || let "exit_code=$?" -done -exit $exit_code #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/host/adv/periodic/tests_scripts/per_adv_conn_privacy.sh b/tests/bsim/bluetooth/host/adv/periodic/tests_scripts/per_adv_conn_privacy.sh index eede26ce116..d7d2ad91414 100755 --- a/tests/bsim/bluetooth/host/adv/periodic/tests_scripts/per_adv_conn_privacy.sh +++ b/tests/bsim/bluetooth/host/adv/periodic/tests_scripts/per_adv_conn_privacy.sh @@ -4,23 +4,12 @@ # Basic periodic advertising sync test: an advertiser advertises with periodic # advertising, and a scanner scans for and syncs to the periodic advertising. + +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source + simulation_id="per_adv_conn_privacy" verbosity_level=2 -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 10 $@ & process_ids="$process_ids $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" - -#Give a default value to BOARD if it does not have one yet: -BOARD="${BOARD:-nrf52_bsim}" +EXECUTE_TIMEOUT=10 cd ${BSIM_OUT_PATH}/bin @@ -35,7 +24,4 @@ Execute ./bs_${BOARD}_tests_bsim_bluetooth_host_adv_periodic_prj_conf \ Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=${simulation_id} \ -D=2 -sim_length=20e6 $@ -for process_id in $process_ids; do - wait $process_id || let "exit_code=$?" -done -exit $exit_code #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/host/adv/periodic/tests_scripts/per_adv_long_data.sh b/tests/bsim/bluetooth/host/adv/periodic/tests_scripts/per_adv_long_data.sh index 6b4e65438bc..7cac7527c99 100755 --- a/tests/bsim/bluetooth/host/adv/periodic/tests_scripts/per_adv_long_data.sh +++ b/tests/bsim/bluetooth/host/adv/periodic/tests_scripts/per_adv_long_data.sh @@ -4,23 +4,12 @@ # Basic periodic advertising sync test: an advertiser advertises with periodic # advertising, and a scanner scans for and syncs to the periodic advertising. + +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source + simulation_id="per_adv_long_data" verbosity_level=2 -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 10 $@ & process_ids="$process_ids $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" - -#Give a default value to BOARD if it does not have one yet: -BOARD="${BOARD:-nrf52_bsim}" +EXECUTE_TIMEOUT=10 cd ${BSIM_OUT_PATH}/bin @@ -35,7 +24,4 @@ Execute ./bs_${BOARD}_tests_bsim_bluetooth_host_adv_periodic_prj_long_data_conf Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=${simulation_id} \ -D=2 -sim_length=20e6 $@ -for process_id in $process_ids; do - wait $process_id || let "exit_code=$?" -done -exit $exit_code #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/host/adv/resume/test_scripts/_env.sh b/tests/bsim/bluetooth/host/adv/resume/test_scripts/_env.sh index 98dff68bc08..ccd11480a19 100755 --- a/tests/bsim/bluetooth/host/adv/resume/test_scripts/_env.sh +++ b/tests/bsim/bluetooth/host/adv/resume/test_scripts/_env.sh @@ -4,8 +4,6 @@ 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" BOARD="${BOARD:-nrf52_bsim}" diff --git a/tests/bsim/bluetooth/host/adv/resume/test_scripts/run_adv_resume.sh b/tests/bsim/bluetooth/host/adv/resume/test_scripts/run_adv_resume.sh index 8d00beddf0a..ee9d971fb23 100755 --- a/tests/bsim/bluetooth/host/adv/resume/test_scripts/run_adv_resume.sh +++ b/tests/bsim/bluetooth/host/adv/resume/test_scripts/run_adv_resume.sh @@ -5,25 +5,12 @@ 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 simulation_id="${test_name}" verbosity_level=2 -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}" +EXECUTE_TIMEOUT=30 cd ${BSIM_OUT_PATH}/bin @@ -43,7 +30,4 @@ Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=${simulation_id} \ # gdb --args "$test_exe" \ # -v=${verbosity_level} -s=${simulation_id} -d=1 -testid=peripheral -RealEncryption=1 -for process_id in $process_ids; do - wait $process_id || let "exit_code=$?" -done -exit $exit_code #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/host/adv/resume/test_scripts/run_adv_resume_2.sh b/tests/bsim/bluetooth/host/adv/resume/test_scripts/run_adv_resume_2.sh index c7f37565627..b7f29d1b05c 100755 --- a/tests/bsim/bluetooth/host/adv/resume/test_scripts/run_adv_resume_2.sh +++ b/tests/bsim/bluetooth/host/adv/resume/test_scripts/run_adv_resume_2.sh @@ -5,25 +5,12 @@ 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 simulation_id="${test_name}_2" verbosity_level=2 -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}" +EXECUTE_TIMEOUT=30 cd ${BSIM_OUT_PATH}/bin @@ -36,7 +23,4 @@ Execute "$test_2_exe" \ Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s="${simulation_id}" \ -D=2 -sim_length=10e6 $@ -for process_id in $process_ids; do - wait $process_id || let "exit_code=$?" -done -exit $exit_code #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/host/att/eatt/tests_scripts/autoconnect.sh b/tests/bsim/bluetooth/host/att/eatt/tests_scripts/autoconnect.sh index 3aa2c68bee6..ac420c136e7 100755 --- a/tests/bsim/bluetooth/host/att/eatt/tests_scripts/autoconnect.sh +++ b/tests/bsim/bluetooth/host/att/eatt/tests_scripts/autoconnect.sh @@ -2,23 +2,11 @@ # Copyright (c) 2022 Nordic Semiconductor # SPDX-License-Identifier: Apache-2.0 +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source + simulation_id="connection" verbosity_level=2 -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 120 $@ & process_ids="$process_ids $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" - -#Give a default value to BOARD if it does not have one yet: -BOARD="${BOARD:-nrf52_bsim}" +EXECUTE_TIMEOUT=120 cd ${BSIM_OUT_PATH}/bin @@ -31,7 +19,4 @@ Execute ./bs_${BOARD}_tests_bsim_bluetooth_host_att_eatt_prj_autoconnect_conf \ Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=${simulation_id} \ -D=2 -sim_length=200e6 $@ -for process_id in $process_ids; do - wait $process_id || let "exit_code=$?" -done -exit $exit_code #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/host/att/eatt/tests_scripts/collision.sh b/tests/bsim/bluetooth/host/att/eatt/tests_scripts/collision.sh index eae7e1e9966..75da68b029b 100755 --- a/tests/bsim/bluetooth/host/att/eatt/tests_scripts/collision.sh +++ b/tests/bsim/bluetooth/host/att/eatt/tests_scripts/collision.sh @@ -2,23 +2,11 @@ # Copyright (c) 2022 Nordic Semiconductor # SPDX-License-Identifier: Apache-2.0 +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source + simulation_id="collision" verbosity_level=2 -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 120 $@ & process_ids="$process_ids $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" - -#Give a default value to BOARD if it does not have one yet: -BOARD="${BOARD:-nrf52_bsim}" +EXECUTE_TIMEOUT=120 cd ${BSIM_OUT_PATH}/bin @@ -31,7 +19,4 @@ Execute ./bs_${BOARD}_tests_bsim_bluetooth_host_att_eatt_prj_collision_conf \ Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=${simulation_id} \ -D=2 -sim_length=200e6 $@ -for process_id in $process_ids; do - wait $process_id || let "exit_code=$?" -done -exit $exit_code #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/host/att/eatt/tests_scripts/multiple_conn.sh b/tests/bsim/bluetooth/host/att/eatt/tests_scripts/multiple_conn.sh index d5f3482885d..5cc4ec693a0 100755 --- a/tests/bsim/bluetooth/host/att/eatt/tests_scripts/multiple_conn.sh +++ b/tests/bsim/bluetooth/host/att/eatt/tests_scripts/multiple_conn.sh @@ -2,23 +2,11 @@ # Copyright (c) 2022 Nordic Semiconductor # SPDX-License-Identifier: Apache-2.0 +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source + simulation_id="multiple_conn" verbosity_level=2 -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 120 $@ & process_ids="$process_ids $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" - -#Give a default value to BOARD if it does not have one yet: -BOARD="${BOARD:-nrf52_bsim}" +EXECUTE_TIMEOUT=120 cd ${BSIM_OUT_PATH}/bin @@ -31,7 +19,4 @@ Execute ./bs_${BOARD}_tests_bsim_bluetooth_host_att_eatt_prj_multiple_conn_conf Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=${simulation_id} \ -D=2 -sim_length=200e6 $@ -for process_id in $process_ids; do - wait $process_id || let "exit_code=$?" -done -exit $exit_code #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/host/att/eatt/tests_scripts/reconfigure.sh b/tests/bsim/bluetooth/host/att/eatt/tests_scripts/reconfigure.sh index 599329ce2b5..2a9000b2429 100755 --- a/tests/bsim/bluetooth/host/att/eatt/tests_scripts/reconfigure.sh +++ b/tests/bsim/bluetooth/host/att/eatt/tests_scripts/reconfigure.sh @@ -2,23 +2,11 @@ # Copyright (c) 2022 Nordic Semiconductor # SPDX-License-Identifier: Apache-2.0 +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source + simulation_id="reconfigure" verbosity_level=2 -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 120 $@ & process_ids="$process_ids $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" - -#Give a default value to BOARD if it does not have one yet: -BOARD="${BOARD:-nrf52_bsim}" +EXECUTE_TIMEOUT=120 cd ${BSIM_OUT_PATH}/bin @@ -31,7 +19,4 @@ Execute ./bs_${BOARD}_tests_bsim_bluetooth_host_att_eatt_prj_autoconnect_conf \ 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 -exit $exit_code #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/host/att/eatt_notif/test_scripts/eatt_notif.sh b/tests/bsim/bluetooth/host/att/eatt_notif/test_scripts/eatt_notif.sh index 0d3bcb2967d..3385b6fe6dc 100755 --- a/tests/bsim/bluetooth/host/att/eatt_notif/test_scripts/eatt_notif.sh +++ b/tests/bsim/bluetooth/host/att/eatt_notif/test_scripts/eatt_notif.sh @@ -4,23 +4,11 @@ # EATT notification reliability test +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source + simulation_id="eatt_notif" verbosity_level=2 -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 120 $@ & process_ids="$process_ids $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" - -#Give a default value to BOARD if it does not have one yet: -BOARD="${BOARD:-nrf52_bsim}" +EXECUTE_TIMEOUT=120 cd ${BSIM_OUT_PATH}/bin @@ -33,7 +21,4 @@ Execute ./bs_${BOARD}_tests_bsim_bluetooth_host_att_eatt_notif_prj_conf \ 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 -exit $exit_code #the last exit code != 0 +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 d6498bd2121..c6f204574bd 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 @@ -6,10 +6,7 @@ set -eu bash_source_dir="$(realpath "$(dirname "${BASH_SOURCE[0]}")")" # Read variable definitions output by _env.sh -source <("${bash_source_dir}/_env.sh") - - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" +source "${bash_source_dir}/_env.sh" : "${BSIM_COMPONENTS_PATH:?BSIM_COMPONENTS_PATH must be defined}" : "${ZEPHYR_BASE:?ZEPHYR_BASE must be defined}" 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 index 30ba589fe88..8d101eabcdd 100755 --- a/tests/bsim/bluetooth/host/att/mtu_update/test_scripts/_env.sh +++ b/tests/bsim/bluetooth/host/att/mtu_update/test_scripts/_env.sh @@ -13,18 +13,3 @@ 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}" - -function print_var { - # Print a shell-sourceable variable definition. - local var_name="$1" - local var_repr="${!var_name@Q}" - echo "$var_name=$var_repr" -} - -print_var test_name -print_var bsim_bin -print_var verbosity_level -print_var BOARD -print_var simulation_id -print_var central_exe -print_var peripheral_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 896508f9ed1..087aa9385d4 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 @@ -5,23 +5,12 @@ set -eu bash_source_dir="$(realpath "$(dirname "${BASH_SOURCE[0]}")")" -# Read variable definitions output by _env.sh -source <("${bash_source_dir}/_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 - timeout 30 $@ & - process_ids="$process_ids $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" +simulation_id="$test_name" +verbosity_level=2 +EXECUTE_TIMEOUT=30 cd ${BSIM_OUT_PATH}/bin @@ -34,7 +23,4 @@ Execute "$peripheral_exe" \ 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 -exit $exit_code #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/host/compile.sh b/tests/bsim/bluetooth/host/compile.sh index eada545d8b5..3a06e04165e 100755 --- a/tests/bsim/bluetooth/host/compile.sh +++ b/tests/bsim/bluetooth/host/compile.sh @@ -7,13 +7,12 @@ #set -x #uncomment this line for debugging set -ue -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" : "${BSIM_COMPONENTS_PATH:?BSIM_COMPONENTS_PATH must be defined}" : "${ZEPHYR_BASE:?ZEPHYR_BASE must be set to point to the zephyr root\ directory}" WORK_DIR="${WORK_DIR:-${ZEPHYR_BASE}/bsim_out}" -BOARD="${BOARD:-nrf52_bsim}" + BOARD_ROOT="${BOARD_ROOT:-${ZEPHYR_BASE}}" mkdir -p ${WORK_DIR} diff --git a/tests/bsim/bluetooth/host/gatt/caching/test_scripts/_run_test.sh b/tests/bsim/bluetooth/host/gatt/caching/test_scripts/_run_test.sh index 478febd7484..932e7c23a76 100755 --- a/tests/bsim/bluetooth/host/gatt/caching/test_scripts/_run_test.sh +++ b/tests/bsim/bluetooth/host/gatt/caching/test_scripts/_run_test.sh @@ -2,24 +2,10 @@ # Copyright 2022 Nordic Semiconductor ASA # SPDX-License-Identifier: Apache-2.0 +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source + verbosity_level=2 -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 120 $@ & - process_ids="$process_ids $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" - -#Give a default value to BOARD if it does not have one yet: -BOARD="${BOARD:-nrf52_bsim}" +EXECUTE_TIMEOUT=120 cd ${BSIM_OUT_PATH}/bin @@ -32,7 +18,4 @@ Execute ./bs_${BOARD}_tests_bsim_bluetooth_host_gatt_caching_prj_conf \ 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 -exit $exit_code #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/host/gatt/general/test_scripts/gatt.sh b/tests/bsim/bluetooth/host/gatt/general/test_scripts/gatt.sh index 53be981b117..eb6f22ace1a 100755 --- a/tests/bsim/bluetooth/host/gatt/general/test_scripts/gatt.sh +++ b/tests/bsim/bluetooth/host/gatt/general/test_scripts/gatt.sh @@ -5,23 +5,12 @@ # Basic GATT test: A central acting as a GATT client scans for and connects # to a peripheral acting as a GATT server. The GATT client will then attempt # to write and read to and from a few GATT characteristics. + +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source + simulation_id="gatt" verbosity_level=2 -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 120 $@ & process_ids="$process_ids $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" - -#Give a default value to BOARD if it does not have one yet: -BOARD="${BOARD:-nrf52_bsim}" +EXECUTE_TIMEOUT=120 cd ${BSIM_OUT_PATH}/bin @@ -34,7 +23,4 @@ Execute ./bs_${BOARD}_tests_bsim_bluetooth_host_gatt_general_prj_conf \ 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 -exit $exit_code #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/host/gatt/notify/test_scripts/_run_test.sh b/tests/bsim/bluetooth/host/gatt/notify/test_scripts/_run_test.sh index bd79acb3fdd..4d02d42a00c 100755 --- a/tests/bsim/bluetooth/host/gatt/notify/test_scripts/_run_test.sh +++ b/tests/bsim/bluetooth/host/gatt/notify/test_scripts/_run_test.sh @@ -1,25 +1,12 @@ #!/usr/bin/env bash # Copyright 2022 Nordic Semiconductor ASA # SPDX-License-Identifier: Apache-2.0 +set -eu + +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source verbosity_level=2 -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}" - -#Give a default value to BOARD if it does not have one yet: -BOARD="${BOARD:-nrf52_bsim}" +EXECUTE_TIMEOUT=30 cd ${BSIM_OUT_PATH}/bin @@ -32,7 +19,4 @@ Execute ./bs_${BOARD}_tests_bsim_bluetooth_host_gatt_notify_prj_conf \ 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 -exit $exit_code #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_enhanced_enhanced.sh b/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_enhanced_enhanced.sh index 68cf9409994..d8516fa35de 100755 --- a/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_enhanced_enhanced.sh +++ b/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_enhanced_enhanced.sh @@ -1,4 +1,3 @@ - #!/usr/bin/env bash # Copyright 2022 Nordic Semiconductor ASA # SPDX-License-Identifier: Apache-2.0 @@ -7,4 +6,3 @@ simulation_id="gatt_notify_enhanced_enhanced" \ server_id="gatt_server_enhanced" \ client_id="gatt_client_enhanced" \ $(dirname "${BASH_SOURCE[0]}")/_run_test.sh - diff --git a/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_enhanced_mixed.sh b/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_enhanced_mixed.sh index 75a4b9d83c9..4d82408fb91 100755 --- a/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_enhanced_mixed.sh +++ b/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_enhanced_mixed.sh @@ -1,4 +1,3 @@ - #!/usr/bin/env bash # Copyright 2022 Nordic Semiconductor ASA # SPDX-License-Identifier: Apache-2.0 @@ -7,4 +6,3 @@ simulation_id="gatt_notify_enhanced_mixed" \ server_id="gatt_server_enhanced" \ client_id="gatt_client_mixed" \ $(dirname "${BASH_SOURCE[0]}")/_run_test.sh - diff --git a/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_enhanced_none.sh b/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_enhanced_none.sh index e89b16ca20e..13a4e67e1f0 100755 --- a/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_enhanced_none.sh +++ b/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_enhanced_none.sh @@ -1,4 +1,3 @@ - #!/usr/bin/env bash # Copyright 2022 Nordic Semiconductor ASA # SPDX-License-Identifier: Apache-2.0 @@ -7,4 +6,3 @@ simulation_id="gatt_notify_enhanced_none" \ server_id="gatt_server_enhanced" \ client_id="gatt_client_none" \ $(dirname "${BASH_SOURCE[0]}")/_run_test.sh - diff --git a/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_enhanced_unenhanced.sh b/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_enhanced_unenhanced.sh index 5cc85731633..480fbabf467 100755 --- a/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_enhanced_unenhanced.sh +++ b/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_enhanced_unenhanced.sh @@ -1,4 +1,3 @@ - #!/usr/bin/env bash # Copyright 2022 Nordic Semiconductor ASA # SPDX-License-Identifier: Apache-2.0 @@ -7,4 +6,3 @@ simulation_id="gatt_notify_enhanced_unenhanced" \ server_id="gatt_server_enhanced" \ client_id="gatt_client_unenhanced" \ $(dirname "${BASH_SOURCE[0]}")/_run_test.sh - diff --git a/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_mixed_enhanced.sh b/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_mixed_enhanced.sh index a4ecf9d429b..16827e3988b 100755 --- a/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_mixed_enhanced.sh +++ b/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_mixed_enhanced.sh @@ -1,4 +1,3 @@ - #!/usr/bin/env bash # Copyright 2022 Nordic Semiconductor ASA # SPDX-License-Identifier: Apache-2.0 @@ -7,4 +6,3 @@ simulation_id="gatt_notify_mixed_enhanced" \ server_id="gatt_server_mixed" \ client_id="gatt_client_enhanced" \ $(dirname "${BASH_SOURCE[0]}")/_run_test.sh - diff --git a/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_mixed_mixed.sh b/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_mixed_mixed.sh index a9f38d8f37f..ed0a3e4f61e 100755 --- a/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_mixed_mixed.sh +++ b/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_mixed_mixed.sh @@ -1,4 +1,3 @@ - #!/usr/bin/env bash # Copyright 2022 Nordic Semiconductor ASA # SPDX-License-Identifier: Apache-2.0 @@ -7,4 +6,3 @@ simulation_id="gatt_notify_mixed_mixed" \ server_id="gatt_server_mixed" \ client_id="gatt_client_mixed" \ $(dirname "${BASH_SOURCE[0]}")/_run_test.sh - diff --git a/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_mixed_none.sh b/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_mixed_none.sh index 80afe822cfd..944d91f575e 100755 --- a/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_mixed_none.sh +++ b/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_mixed_none.sh @@ -1,4 +1,3 @@ - #!/usr/bin/env bash # Copyright 2022 Nordic Semiconductor ASA # SPDX-License-Identifier: Apache-2.0 @@ -7,4 +6,3 @@ simulation_id="gatt_notify_mixed_none" \ server_id="gatt_server_mixed" \ client_id="gatt_client_none" \ $(dirname "${BASH_SOURCE[0]}")/_run_test.sh - diff --git a/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_mixed_unenhanced.sh b/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_mixed_unenhanced.sh index 9ff73b2de4b..25d0f983945 100755 --- a/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_mixed_unenhanced.sh +++ b/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_mixed_unenhanced.sh @@ -1,4 +1,3 @@ - #!/usr/bin/env bash # Copyright 2022 Nordic Semiconductor ASA # SPDX-License-Identifier: Apache-2.0 @@ -7,4 +6,3 @@ simulation_id="gatt_notify_mixed_unenhanced" \ server_id="gatt_server_mixed" \ client_id="gatt_client_unenhanced" \ $(dirname "${BASH_SOURCE[0]}")/_run_test.sh - diff --git a/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_none_enhanced.sh b/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_none_enhanced.sh index 74eedd15ddc..514b8508ea9 100755 --- a/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_none_enhanced.sh +++ b/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_none_enhanced.sh @@ -1,4 +1,3 @@ - #!/usr/bin/env bash # Copyright 2022 Nordic Semiconductor ASA # SPDX-License-Identifier: Apache-2.0 @@ -7,4 +6,3 @@ simulation_id="gatt_notify_none_enhanced" \ server_id="gatt_server_none" \ client_id="gatt_client_enhanced" \ $(dirname "${BASH_SOURCE[0]}")/_run_test.sh - diff --git a/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_none_mixed.sh b/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_none_mixed.sh index 02541c6db74..7c74575a9f9 100755 --- a/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_none_mixed.sh +++ b/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_none_mixed.sh @@ -1,4 +1,3 @@ - #!/usr/bin/env bash # Copyright 2022 Nordic Semiconductor ASA # SPDX-License-Identifier: Apache-2.0 @@ -7,4 +6,3 @@ simulation_id="gatt_notify_none_mixed" \ server_id="gatt_server_none" \ client_id="gatt_client_mixed" \ $(dirname "${BASH_SOURCE[0]}")/_run_test.sh - diff --git a/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_none_none.sh b/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_none_none.sh index 6642f8ed2b5..1d988718f24 100755 --- a/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_none_none.sh +++ b/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_none_none.sh @@ -1,4 +1,3 @@ - #!/usr/bin/env bash # Copyright 2022 Nordic Semiconductor ASA # SPDX-License-Identifier: Apache-2.0 @@ -7,4 +6,3 @@ simulation_id="gatt_notify_none_none" \ server_id="gatt_server_none" \ client_id="gatt_client_none" \ $(dirname "${BASH_SOURCE[0]}")/_run_test.sh - diff --git a/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_none_unenhanced.sh b/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_none_unenhanced.sh index 2f2764186c7..9c8425e376f 100755 --- a/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_none_unenhanced.sh +++ b/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_none_unenhanced.sh @@ -1,4 +1,3 @@ - #!/usr/bin/env bash # Copyright 2022 Nordic Semiconductor ASA # SPDX-License-Identifier: Apache-2.0 @@ -7,4 +6,3 @@ simulation_id="gatt_notify_none_unenhanced" \ server_id="gatt_server_none" \ client_id="gatt_client_unenhanced" \ $(dirname "${BASH_SOURCE[0]}")/_run_test.sh - diff --git a/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_unenhanced_enhanced.sh b/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_unenhanced_enhanced.sh index ab91b23437d..4c7c499f166 100755 --- a/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_unenhanced_enhanced.sh +++ b/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_unenhanced_enhanced.sh @@ -1,4 +1,3 @@ - #!/usr/bin/env bash # Copyright 2022 Nordic Semiconductor ASA # SPDX-License-Identifier: Apache-2.0 @@ -7,4 +6,3 @@ simulation_id="gatt_notify_unenhanced_enhanced" \ server_id="gatt_server_unenhanced" \ client_id="gatt_client_enhanced" \ $(dirname "${BASH_SOURCE[0]}")/_run_test.sh - diff --git a/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_unenhanced_mixed.sh b/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_unenhanced_mixed.sh index 57063ac272b..4a0fdef0243 100755 --- a/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_unenhanced_mixed.sh +++ b/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_unenhanced_mixed.sh @@ -1,4 +1,3 @@ - #!/usr/bin/env bash # Copyright 2022 Nordic Semiconductor ASA # SPDX-License-Identifier: Apache-2.0 @@ -7,4 +6,3 @@ simulation_id="gatt_notify_unenhanced_mixed" \ server_id="gatt_server_unenhanced" \ client_id="gatt_client_mixed" \ $(dirname "${BASH_SOURCE[0]}")/_run_test.sh - diff --git a/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_unenhanced_none.sh b/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_unenhanced_none.sh index df360db4e5e..5b705823e72 100755 --- a/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_unenhanced_none.sh +++ b/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_unenhanced_none.sh @@ -1,4 +1,3 @@ - #!/usr/bin/env bash # Copyright 2022 Nordic Semiconductor ASA # SPDX-License-Identifier: Apache-2.0 @@ -7,4 +6,3 @@ simulation_id="gatt_notify_unenhanced_none" \ server_id="gatt_server_unenhanced" \ client_id="gatt_client_none" \ $(dirname "${BASH_SOURCE[0]}")/_run_test.sh - diff --git a/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_unenhanced_unenhanced.sh b/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_unenhanced_unenhanced.sh index 7b624969d5d..7da2f2ae39b 100755 --- a/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_unenhanced_unenhanced.sh +++ b/tests/bsim/bluetooth/host/gatt/notify/test_scripts/gatt_notify_unenhanced_unenhanced.sh @@ -1,4 +1,3 @@ - #!/usr/bin/env bash # Copyright 2022 Nordic Semiconductor ASA # SPDX-License-Identifier: Apache-2.0 @@ -7,4 +6,3 @@ simulation_id="gatt_notify_unenhanced_unenhanced" \ server_id="gatt_server_unenhanced" \ client_id="gatt_client_unenhanced" \ $(dirname "${BASH_SOURCE[0]}")/_run_test.sh - diff --git a/tests/bsim/bluetooth/host/gatt/notify_multiple/test_scripts/_notify-debug.sh b/tests/bsim/bluetooth/host/gatt/notify_multiple/test_scripts/_notify-debug.sh index 29ac8e41794..08de518bec4 100755 --- a/tests/bsim/bluetooth/host/gatt/notify_multiple/test_scripts/_notify-debug.sh +++ b/tests/bsim/bluetooth/host/gatt/notify_multiple/test_scripts/_notify-debug.sh @@ -11,10 +11,8 @@ # GDB can be run on the two devices at the same time without issues, just append # `debug` when running the script. - simulation_id="notify_multiple" verbosity_level=2 -process_ids=""; exit_code=0 : "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" diff --git a/tests/bsim/bluetooth/host/gatt/notify_multiple/test_scripts/notify.sh b/tests/bsim/bluetooth/host/gatt/notify_multiple/test_scripts/notify.sh index ee243473bea..b4cf3fd91a3 100755 --- a/tests/bsim/bluetooth/host/gatt/notify_multiple/test_scripts/notify.sh +++ b/tests/bsim/bluetooth/host/gatt/notify_multiple/test_scripts/notify.sh @@ -1,24 +1,13 @@ #!/usr/bin/env bash # Copyright 2022 Nordic Semiconductor ASA # SPDX-License-Identifier: Apache-2.0 +set -eu + +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source simulation_id="notify_multiple" verbosity_level=2 -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 120 $@ & process_ids="$process_ids $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" - -#Give a default value to BOARD if it does not have one yet: -BOARD="${BOARD:-nrf52_bsim}" +EXECUTE_TIMEOUT=120 cd ${BSIM_OUT_PATH}/bin @@ -31,7 +20,4 @@ Execute ./bs_${BOARD}_tests_bsim_bluetooth_host_gatt_notify_multiple_prj_conf \ 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 -exit $exit_code #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/host/gatt/settings/test_scripts/_compile.sh b/tests/bsim/bluetooth/host/gatt/settings/test_scripts/_compile.sh index 1805af4f425..cd43f722c83 100755 --- a/tests/bsim/bluetooth/host/gatt/settings/test_scripts/_compile.sh +++ b/tests/bsim/bluetooth/host/gatt/settings/test_scripts/_compile.sh @@ -1,8 +1,8 @@ #!/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]}")")" # Read variable definitions output by _env.sh diff --git a/tests/bsim/bluetooth/host/gatt/settings/test_scripts/_env.sh b/tests/bsim/bluetooth/host/gatt/settings/test_scripts/_env.sh index 348f8ec6d42..22e1f9e6518 100755 --- a/tests/bsim/bluetooth/host/gatt/settings/test_scripts/_env.sh +++ b/tests/bsim/bluetooth/host/gatt/settings/test_scripts/_env.sh @@ -4,8 +4,6 @@ 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" BOARD="${BOARD:-nrf52_bsim}" diff --git a/tests/bsim/bluetooth/host/gatt/settings/test_scripts/run_gatt_settings.sh b/tests/bsim/bluetooth/host/gatt/settings/test_scripts/run_gatt_settings.sh index dfa2fa9fe0e..269ecbc9072 100755 --- a/tests/bsim/bluetooth/host/gatt/settings/test_scripts/run_gatt_settings.sh +++ b/tests/bsim/bluetooth/host/gatt/settings/test_scripts/run_gatt_settings.sh @@ -1,27 +1,16 @@ #!/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]}")")" source "${bash_source_dir}/_env.sh" +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source + simulation_id="${test_name}" verbosity_level=2 -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 - $@ & - process_ids="$process_ids $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" +EXECUTE_TIMEOUT=30 cd ${BSIM_OUT_PATH}/bin @@ -57,7 +46,4 @@ Execute "$test_exe" -v=${verbosity_level} \ Execute "$test_exe" -v=${verbosity_level} \ -s="${simulation_id}" -d=7 -testid=client -RealEncryption=1 -argstest 0 0 "client" -for process_id in $process_ids; do - wait $process_id || let "exit_code=$?" -done -exit $exit_code #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/host/gatt/settings/test_scripts/run_gatt_settings_2.sh b/tests/bsim/bluetooth/host/gatt/settings/test_scripts/run_gatt_settings_2.sh index fb6d4e6f45a..873a0e670b0 100755 --- a/tests/bsim/bluetooth/host/gatt/settings/test_scripts/run_gatt_settings_2.sh +++ b/tests/bsim/bluetooth/host/gatt/settings/test_scripts/run_gatt_settings_2.sh @@ -1,27 +1,16 @@ #!/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]}")")" source "${bash_source_dir}/_env.sh" +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source + simulation_id="${test_name}_2" verbosity_level=2 -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 - $@ & - process_ids="$process_ids $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" +EXECUTE_TIMEOUT=120 cd ${BSIM_OUT_PATH}/bin @@ -57,7 +46,4 @@ Execute "$test_2_exe" -v=${verbosity_level} \ Execute "$test_2_exe" -v=${verbosity_level} \ -s="${simulation_id}" -d=7 -testid=client -RealEncryption=1 -argstest 0 0 "client_2" -for process_id in $process_ids; do - wait $process_id || let "exit_code=$?" -done -exit $exit_code #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/host/gatt/write/tests_scripts/gatt_write.sh b/tests/bsim/bluetooth/host/gatt/write/tests_scripts/gatt_write.sh index 30c05ea3a8a..749e6a6425d 100755 --- a/tests/bsim/bluetooth/host/gatt/write/tests_scripts/gatt_write.sh +++ b/tests/bsim/bluetooth/host/gatt/write/tests_scripts/gatt_write.sh @@ -2,24 +2,12 @@ # Copyright 2018 Oticon A/S # SPDX-License-Identifier: Apache-2.0 +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source + # Multiple connection between two devices with multiple peripheral identity simulation_id="gatt_write" verbosity_level=2 -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 60 $@ & process_ids="$process_ids $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" - -#Give a default value to BOARD if it does not have one yet: -BOARD="${BOARD:-nrf52_bsim}" +EXECUTE_TIMEOUT=60 cd ${BSIM_OUT_PATH}/bin @@ -32,7 +20,4 @@ Execute ./bs_${BOARD}_tests_bsim_bluetooth_host_gatt_write_prj_conf\ 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 -exit $exit_code #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/host/l2cap/general/tests_scripts/l2cap.sh b/tests/bsim/bluetooth/host/l2cap/general/tests_scripts/l2cap.sh index 54cf6c75615..adfae72c459 100755 --- a/tests/bsim/bluetooth/host/l2cap/general/tests_scripts/l2cap.sh +++ b/tests/bsim/bluetooth/host/l2cap/general/tests_scripts/l2cap.sh @@ -2,24 +2,12 @@ # Copyright (c) 2022 Nordic Semiconductor # SPDX-License-Identifier: Apache-2.0 +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source + # EATT test simulation_id="l2cap_ecred" verbosity_level=2 -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 120 $@ & process_ids="$process_ids $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" - -#Give a default value to BOARD if it does not have one yet: -BOARD="${BOARD:-nrf52_bsim}" +EXECUTE_TIMEOUT=120 cd ${BSIM_OUT_PATH}/bin @@ -32,7 +20,4 @@ Execute ./bs_${BOARD}_tests_bsim_bluetooth_host_l2cap_general_prj_conf \ 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 -exit $exit_code #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/host/l2cap/stress/tests_scripts/l2cap.sh b/tests/bsim/bluetooth/host/l2cap/stress/tests_scripts/l2cap.sh index e556fad38e2..1ef8cdc9d15 100755 --- a/tests/bsim/bluetooth/host/l2cap/stress/tests_scripts/l2cap.sh +++ b/tests/bsim/bluetooth/host/l2cap/stress/tests_scripts/l2cap.sh @@ -2,25 +2,12 @@ # Copyright (c) 2022 Nordic Semiconductor # SPDX-License-Identifier: Apache-2.0 +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source + # EATT test simulation_id="l2cap_stress" verbosity_level=2 -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 $!" - $@ & process_ids="$process_ids $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" - -#Give a default value to BOARD if it does not have one yet: -BOARD="${BOARD:-nrf52_bsim}" +EXECUTE_TIMEOUT=120 cd ${BSIM_OUT_PATH}/bin @@ -37,7 +24,4 @@ Execute "${bsim_exe}" -v=${verbosity_level} -s=${simulation_id} -d=6 -testid=per Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=${simulation_id} -D=7 -sim_length=270e6 $@ -for process_id in $process_ids; do - wait $process_id || let "exit_code=$?" -done -exit $exit_code #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/host/l2cap/userdata/tests_scripts/l2cap.sh b/tests/bsim/bluetooth/host/l2cap/userdata/tests_scripts/l2cap.sh index 05637864fe6..6700f12781b 100755 --- a/tests/bsim/bluetooth/host/l2cap/userdata/tests_scripts/l2cap.sh +++ b/tests/bsim/bluetooth/host/l2cap/userdata/tests_scripts/l2cap.sh @@ -2,25 +2,11 @@ # Copyright (c) 2022 Nordic Semiconductor # SPDX-License-Identifier: Apache-2.0 +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source + simulation_id="l2cap_ecred_userdata" verbosity_level=2 -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 120 $@ & - process_ids="$process_ids $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" - -#Give a default value to BOARD if it does not have one yet: -BOARD="${BOARD:-nrf52_bsim}" +EXECUTE_TIMEOUT=120 cd ${BSIM_OUT_PATH}/bin @@ -33,7 +19,4 @@ Execute ./bs_${BOARD}_tests_bsim_bluetooth_host_l2cap_userdata_prj_conf \ Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=${simulation_id} \ -D=2 -sim_length=30e6 $@ -for process_id in $process_ids; do - wait $process_id || let "exit_code=$?" -done -exit $exit_code #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/host/misc/disable/tests_scripts/disable.sh b/tests/bsim/bluetooth/host/misc/disable/tests_scripts/disable.sh index b3e390f82d5..8fb3bfa648e 100755 --- a/tests/bsim/bluetooth/host/misc/disable/tests_scripts/disable.sh +++ b/tests/bsim/bluetooth/host/misc/disable/tests_scripts/disable.sh @@ -2,24 +2,12 @@ # Copyright (c) 2022 Nordic Semiconductor # SPDX-License-Identifier: Apache-2.0 +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source + # Disable test: bt_enable and bt_disable are called in a loop. simulation_id="disable_test" verbosity_level=2 -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 120 $@ & process_ids="$process_ids $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" - -#Give a default value to BOARD if it does not have one yet: -BOARD="${BOARD:-nrf52_bsim}" +EXECUTE_TIMEOUT=120 cd ${BSIM_OUT_PATH}/bin @@ -29,7 +17,4 @@ Execute ./bs_${BOARD}_tests_bsim_bluetooth_host_misc_disable_prj_conf \ Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=${simulation_id} \ -D=1 -sim_length=60e6 $@ -for process_id in $process_ids; do - wait $process_id || let "exit_code=$?" -done -exit $exit_code #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/host/misc/disable/tests_scripts/disable_with_gatt.sh b/tests/bsim/bluetooth/host/misc/disable/tests_scripts/disable_with_gatt.sh index fef45b2f61d..5c3d8916c6b 100755 --- a/tests/bsim/bluetooth/host/misc/disable/tests_scripts/disable_with_gatt.sh +++ b/tests/bsim/bluetooth/host/misc/disable/tests_scripts/disable_with_gatt.sh @@ -2,27 +2,15 @@ # Copyright 2022 Nordic Semiconductor ASA # SPDX-License-Identifier: Apache-2.0 +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source + # Disable with GATT test: A central acting as a GATT client scans for and connects # to a peripheral acting as a GATT server. The GATT client will then attempt # to write and read to and from a few GATT characteristics. Both the central and # peripheral then disable bluetooth and the test repeats. simulation_id="disable_with_gatt" verbosity_level=2 -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 120 $@ & process_ids="$process_ids $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" - -#Give a default value to BOARD if it does not have one yet: -BOARD="${BOARD:-nrf52_bsim}" +EXECUTE_TIMEOUT=120 cd ${BSIM_OUT_PATH}/bin @@ -35,7 +23,4 @@ Execute ./bs_${BOARD}_tests_bsim_bluetooth_host_misc_disable_prj_conf \ Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=${simulation_id} \ -D=2 -sim_length=600e6 $@ -for process_id in $process_ids; do - wait $process_id || let "exit_code=$?" -done -exit $exit_code #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/host/misc/multiple_id/tests_scripts/multiple.sh b/tests/bsim/bluetooth/host/misc/multiple_id/tests_scripts/multiple.sh index e8c24354d05..c5e1cfdd242 100755 --- a/tests/bsim/bluetooth/host/misc/multiple_id/tests_scripts/multiple.sh +++ b/tests/bsim/bluetooth/host/misc/multiple_id/tests_scripts/multiple.sh @@ -2,24 +2,12 @@ # Copyright 2018 Oticon A/S # SPDX-License-Identifier: Apache-2.0 +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source + # Multiple connection between two devices with multiple peripheral identity simulation_id="multiple" verbosity_level=2 -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 1800 $@ & process_ids="$process_ids $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" - -#Give a default value to BOARD if it does not have one yet: -BOARD="${BOARD:-nrf52_bsim}" +EXECUTE_TIMEOUT=1800 cd ${BSIM_OUT_PATH}/bin @@ -32,7 +20,4 @@ Execute ./bs_${BOARD}_tests_bsim_bluetooth_host_misc_multiple_id_prj_conf\ Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=${simulation_id} \ -D=2 -sim_length=4500e6 $@ -for process_id in $process_ids; do - wait $process_id || let "exit_code=$?" -done -exit $exit_code #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/host/privacy/central/test_scripts/_compile.sh b/tests/bsim/bluetooth/host/privacy/central/test_scripts/_compile.sh index e7a3d65a2a4..ccdf03b687f 100755 --- a/tests/bsim/bluetooth/host/privacy/central/test_scripts/_compile.sh +++ b/tests/bsim/bluetooth/host/privacy/central/test_scripts/_compile.sh @@ -5,15 +5,12 @@ set -eu bash_source_dir="$(realpath "$(dirname "${BASH_SOURCE[0]}")")" -# Read variable definitions output by _env.sh -source <("${bash_source_dir}/_env.sh") - +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}" - WORK_DIR="${WORK_DIR:-${ZEPHYR_BASE}/bsim_bt_out}" BOARD="${BOARD:-nrf52_bsim}" BOARD_ROOT="${BOARD_ROOT:-${ZEPHYR_BASE}}" diff --git a/tests/bsim/bluetooth/host/privacy/central/test_scripts/_env.sh b/tests/bsim/bluetooth/host/privacy/central/test_scripts/_env.sh index 44e2f07ee4c..18c60bb7c45 100755 --- a/tests/bsim/bluetooth/host/privacy/central/test_scripts/_env.sh +++ b/tests/bsim/bluetooth/host/privacy/central/test_scripts/_env.sh @@ -5,8 +5,6 @@ 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 @@ -14,18 +12,3 @@ BOARD="${BOARD:-nrf52_bsim}" simulation_id="$test_name" central_exe="${bsim_bin}/bs_${BOARD}_tests_bsim_bluetooth_host_privacy_central_prj_conf" peripheral_exe="${central_exe}" - -function print_var { - # Print a shell-sourceable variable definition. - local var_name="$1" - local var_repr="${!var_name@Q}" - echo "$var_name=$var_repr" -} - -print_var test_name -print_var bsim_bin -print_var verbosity_level -print_var BOARD -print_var simulation_id -print_var central_exe -print_var peripheral_exe diff --git a/tests/bsim/bluetooth/host/privacy/central/test_scripts/run_test.sh b/tests/bsim/bluetooth/host/privacy/central/test_scripts/run_test.sh index e2a80ba51f4..3ba95eab78c 100755 --- a/tests/bsim/bluetooth/host/privacy/central/test_scripts/run_test.sh +++ b/tests/bsim/bluetooth/host/privacy/central/test_scripts/run_test.sh @@ -1,27 +1,14 @@ #!/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]}")")" -# Read variable definitions output by _env.sh -source <("${bash_source_dir}/_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 - timeout 30 $@ & - process_ids="$process_ids $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" +EXECUTE_TIMEOUT=30 cd ${BSIM_OUT_PATH}/bin @@ -34,8 +21,4 @@ Execute "$peripheral_exe" \ 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 - -exit $exit_code #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/host/privacy/device/test_scripts/run_tests.sh b/tests/bsim/bluetooth/host/privacy/device/test_scripts/run_tests.sh index 6c9ad8a0bbd..3a16a37c51d 100755 --- a/tests/bsim/bluetooth/host/privacy/device/test_scripts/run_tests.sh +++ b/tests/bsim/bluetooth/host/privacy/device/test_scripts/run_tests.sh @@ -5,23 +5,10 @@ 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 - timeout 30 $@ & - process_ids="$process_ids $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" +EXECUTE_TIMEOUT=30 cd ${BSIM_OUT_PATH}/bin @@ -75,11 +62,4 @@ for args in ${TEST_ARGS[@]}; do done done -for process_id in $process_ids; do - wait $process_id || let "exit_code=$?" - if [ ${exit_code} -ne 0 ]; then - exit_code=1 - fi -done - -exit $exit_code # the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/host/privacy/peripheral/test_scripts/_compile.sh b/tests/bsim/bluetooth/host/privacy/peripheral/test_scripts/_compile.sh index e7a3d65a2a4..2b3b54a1002 100755 --- a/tests/bsim/bluetooth/host/privacy/peripheral/test_scripts/_compile.sh +++ b/tests/bsim/bluetooth/host/privacy/peripheral/test_scripts/_compile.sh @@ -6,7 +6,7 @@ set -eu bash_source_dir="$(realpath "$(dirname "${BASH_SOURCE[0]}")")" # Read variable definitions output by _env.sh -source <("${bash_source_dir}/_env.sh") +source "${bash_source_dir}/_env.sh" : "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" diff --git a/tests/bsim/bluetooth/host/privacy/peripheral/test_scripts/_env.sh b/tests/bsim/bluetooth/host/privacy/peripheral/test_scripts/_env.sh index ac2d2d5888e..2e3593a3df4 100755 --- a/tests/bsim/bluetooth/host/privacy/peripheral/test_scripts/_env.sh +++ b/tests/bsim/bluetooth/host/privacy/peripheral/test_scripts/_env.sh @@ -5,8 +5,6 @@ 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 @@ -14,18 +12,3 @@ BOARD="${BOARD:-nrf52_bsim}" simulation_id="$test_name" central_exe="${bsim_bin}/bs_${BOARD}_tests_bsim_bluetooth_host_privacy_peripheral_prj_conf" peripheral_exe="${central_exe}" - -function print_var { - # Print a shell-sourceable variable definition. - local var_name="$1" - local var_repr="${!var_name@Q}" - echo "$var_name=$var_repr" -} - -print_var test_name -print_var bsim_bin -print_var verbosity_level -print_var BOARD -print_var simulation_id -print_var central_exe -print_var peripheral_exe diff --git a/tests/bsim/bluetooth/host/privacy/peripheral/test_scripts/run_test.sh b/tests/bsim/bluetooth/host/privacy/peripheral/test_scripts/run_test.sh index 8a28a5be46a..30c4f6bee15 100755 --- a/tests/bsim/bluetooth/host/privacy/peripheral/test_scripts/run_test.sh +++ b/tests/bsim/bluetooth/host/privacy/peripheral/test_scripts/run_test.sh @@ -5,23 +5,10 @@ set -eu bash_source_dir="$(realpath "$(dirname "${BASH_SOURCE[0]}")")" -# Read variable definitions output by _env.sh -source <("${bash_source_dir}/_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 - timeout 30 $@ & - process_ids="$process_ids $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" +EXECUTE_TIMEOUT=30 cd ${BSIM_OUT_PATH}/bin @@ -34,8 +21,4 @@ Execute "$peripheral_exe" \ Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=${simulation_id} \ -D=2 -sim_length=120e6 $@ -for process_id in $process_ids; do - wait $process_id || let "exit_code=$?" -done - -exit $exit_code #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/host/security/bond_overwrite_allowed/test_scripts/_compile.sh b/tests/bsim/bluetooth/host/security/bond_overwrite_allowed/test_scripts/_compile.sh index 33be3b19feb..2b722ca2a69 100755 --- a/tests/bsim/bluetooth/host/security/bond_overwrite_allowed/test_scripts/_compile.sh +++ b/tests/bsim/bluetooth/host/security/bond_overwrite_allowed/test_scripts/_compile.sh @@ -6,10 +6,8 @@ set -eu bash_source_dir="$(realpath "$(dirname "${BASH_SOURCE[0]}")")" # Read variable definitions output by _env.sh -source <("${bash_source_dir}/_env.sh") +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}" diff --git a/tests/bsim/bluetooth/host/security/bond_overwrite_allowed/test_scripts/_env.sh b/tests/bsim/bluetooth/host/security/bond_overwrite_allowed/test_scripts/_env.sh index f0005e331cc..102e63a5ef1 100755 --- a/tests/bsim/bluetooth/host/security/bond_overwrite_allowed/test_scripts/_env.sh +++ b/tests/bsim/bluetooth/host/security/bond_overwrite_allowed/test_scripts/_env.sh @@ -13,18 +13,3 @@ BOARD="${BOARD:-nrf52_bsim}" simulation_id="$test_name" central_exe="${bsim_bin}/bs_${BOARD}_tests_bsim_bluetooth_host_${test_name}_prj_conf" peripheral_exe="${central_exe}" - -function print_var { - # Print a shell-sourceable variable definition. - local var_name="$1" - local var_repr="${!var_name@Q}" - echo "$var_name=$var_repr" -} - -print_var test_name -print_var bsim_bin -print_var verbosity_level -print_var BOARD -print_var simulation_id -print_var central_exe -print_var peripheral_exe diff --git a/tests/bsim/bluetooth/host/security/bond_overwrite_allowed/test_scripts/run_test.sh b/tests/bsim/bluetooth/host/security/bond_overwrite_allowed/test_scripts/run_test.sh index fe5fcfdb194..3aecac00ee0 100755 --- a/tests/bsim/bluetooth/host/security/bond_overwrite_allowed/test_scripts/run_test.sh +++ b/tests/bsim/bluetooth/host/security/bond_overwrite_allowed/test_scripts/run_test.sh @@ -5,23 +5,10 @@ set -eu bash_source_dir="$(realpath "$(dirname "${BASH_SOURCE[0]}")")" -# Read variable definitions output by _env.sh -source <("${bash_source_dir}/_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 - timeout 30 $@ & - process_ids="$process_ids $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" +EXECUTE_TIMEOUT=30 cd ${BSIM_OUT_PATH}/bin @@ -34,7 +21,4 @@ Execute "$peripheral_exe" \ 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 -exit $exit_code #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/host/security/bond_overwrite_denied/test_scripts/_compile.sh b/tests/bsim/bluetooth/host/security/bond_overwrite_denied/test_scripts/_compile.sh index 33be3b19feb..2b722ca2a69 100755 --- a/tests/bsim/bluetooth/host/security/bond_overwrite_denied/test_scripts/_compile.sh +++ b/tests/bsim/bluetooth/host/security/bond_overwrite_denied/test_scripts/_compile.sh @@ -6,10 +6,8 @@ set -eu bash_source_dir="$(realpath "$(dirname "${BASH_SOURCE[0]}")")" # Read variable definitions output by _env.sh -source <("${bash_source_dir}/_env.sh") +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}" diff --git a/tests/bsim/bluetooth/host/security/bond_overwrite_denied/test_scripts/run_test.sh b/tests/bsim/bluetooth/host/security/bond_overwrite_denied/test_scripts/run_test.sh index fe5fcfdb194..6f00e23c70c 100755 --- a/tests/bsim/bluetooth/host/security/bond_overwrite_denied/test_scripts/run_test.sh +++ b/tests/bsim/bluetooth/host/security/bond_overwrite_denied/test_scripts/run_test.sh @@ -6,22 +6,10 @@ set -eu bash_source_dir="$(realpath "$(dirname "${BASH_SOURCE[0]}")")" # Read variable definitions output by _env.sh -source <("${bash_source_dir}/_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 - timeout 30 $@ & - process_ids="$process_ids $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" +EXECUTE_TIMEOUT=30 cd ${BSIM_OUT_PATH}/bin @@ -34,7 +22,4 @@ Execute "$peripheral_exe" \ 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 -exit $exit_code #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/ll/advx/tests_scripts/basic_advx.sh b/tests/bsim/bluetooth/ll/advx/tests_scripts/basic_advx.sh index 056378febf3..0fc0a93a112 100755 --- a/tests/bsim/bluetooth/ll/advx/tests_scripts/basic_advx.sh +++ b/tests/bsim/bluetooth/ll/advx/tests_scripts/basic_advx.sh @@ -2,25 +2,13 @@ # Copyright 2018 Oticon A/S # SPDX-License-Identifier: Apache-2.0 +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source + # Basic connection test: a central connects to a peripheral and expects a # notification, using the split controller (ULL LLL) simulation_id="basic_advx" verbosity_level=2 -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 120 $@ & process_ids="$process_ids $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" - -#Give a default value to BOARD if it does not have one yet: -BOARD="${BOARD:-nrf52_bsim}" +EXECUTE_TIMEOUT=120 cd ${BSIM_OUT_PATH}/bin @@ -33,7 +21,4 @@ Execute ./bs_${BOARD}_tests_bsim_bluetooth_ll_advx_prj_conf\ 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 -exit $exit_code #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/ll/compile.sh b/tests/bsim/bluetooth/ll/compile.sh index 8451406aa62..ff5b86d68c9 100755 --- a/tests/bsim/bluetooth/ll/compile.sh +++ b/tests/bsim/bluetooth/ll/compile.sh @@ -6,14 +6,12 @@ #set -x #uncomment this line for debugging set -ue - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" : "${BSIM_COMPONENTS_PATH:?BSIM_COMPONENTS_PATH must be defined}" : "${ZEPHYR_BASE:?ZEPHYR_BASE must be set to point to the zephyr root\ directory}" WORK_DIR="${WORK_DIR:-${ZEPHYR_BASE}/bsim_out}" -BOARD="${BOARD:-nrf52_bsim}" + BOARD_ROOT="${BOARD_ROOT:-${ZEPHYR_BASE}}" mkdir -p ${WORK_DIR} diff --git a/tests/bsim/bluetooth/ll/conn/tests_scripts/basic_conn_encrypted_split.sh b/tests/bsim/bluetooth/ll/conn/tests_scripts/basic_conn_encrypted_split.sh index c2bf39cac13..150b2fd2960 100755 --- a/tests/bsim/bluetooth/ll/conn/tests_scripts/basic_conn_encrypted_split.sh +++ b/tests/bsim/bluetooth/ll/conn/tests_scripts/basic_conn_encrypted_split.sh @@ -2,25 +2,13 @@ # Copyright 2018 Oticon A/S # SPDX-License-Identifier: Apache-2.0 +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source + # Basic connection test: a central connects to a peripheral and expects a # notification simulation_id="basic_conn_encr_split" verbosity_level=2 -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 5 $@ & process_ids="$process_ids $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" - -#Give a default value to BOARD if it does not have one yet: -BOARD="${BOARD:-nrf52_bsim}" +EXECUTE_TIMEOUT=5 cd ${BSIM_OUT_PATH}/bin @@ -35,7 +23,4 @@ Execute ./bs_${BOARD}_tests_bsim_bluetooth_ll_conn_prj_split_conf \ Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=${simulation_id} \ -D=2 -sim_length=20e6 $@ -for process_id in $process_ids; do - wait $process_id || let "exit_code=$?" -done -exit $exit_code #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/ll/conn/tests_scripts/basic_conn_encrypted_split_privacy.sh b/tests/bsim/bluetooth/ll/conn/tests_scripts/basic_conn_encrypted_split_privacy.sh index 7062aaeab47..53293f0bb12 100755 --- a/tests/bsim/bluetooth/ll/conn/tests_scripts/basic_conn_encrypted_split_privacy.sh +++ b/tests/bsim/bluetooth/ll/conn/tests_scripts/basic_conn_encrypted_split_privacy.sh @@ -2,25 +2,13 @@ # Copyright 2018 Oticon A/S # SPDX-License-Identifier: Apache-2.0 +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source + # Basic connection test: a central connects to a peripheral and expects a # notification simulation_id="basic_conn_encr_split_privacy" verbosity_level=2 -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 5 $@ & process_ids="$process_ids $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" - -#Give a default value to BOARD if it does not have one yet: -BOARD="${BOARD:-nrf52_bsim}" +EXECUTE_TIMEOUT=5 cd ${BSIM_OUT_PATH}/bin @@ -37,7 +25,4 @@ Execute \ Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=${simulation_id} \ -D=2 -sim_length=20e6 $@ -for process_id in $process_ids; do - wait $process_id || let "exit_code=$?" -done -exit $exit_code #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/ll/conn/tests_scripts/basic_conn_split.sh b/tests/bsim/bluetooth/ll/conn/tests_scripts/basic_conn_split.sh index 1106e44ca5c..621ab1d3720 100755 --- a/tests/bsim/bluetooth/ll/conn/tests_scripts/basic_conn_split.sh +++ b/tests/bsim/bluetooth/ll/conn/tests_scripts/basic_conn_split.sh @@ -2,25 +2,13 @@ # Copyright 2018 Oticon A/S # SPDX-License-Identifier: Apache-2.0 +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source + # Basic connection test: a central connects to a peripheral and expects a # notification, using the split controller (ULL LLL) simulation_id="basic_conn_split" verbosity_level=2 -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 5 $@ & process_ids="$process_ids $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" - -#Give a default value to BOARD if it does not have one yet: -BOARD="${BOARD:-nrf52_bsim}" +EXECUTE_TIMEOUT=5 cd ${BSIM_OUT_PATH}/bin @@ -35,7 +23,4 @@ Execute ./bs_${BOARD}_tests_bsim_bluetooth_ll_conn_prj_split_conf\ Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=${simulation_id} \ -D=2 -sim_length=20e6 $@ -for process_id in $process_ids; do - wait $process_id || let "exit_code=$?" -done -exit $exit_code #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/ll/conn/tests_scripts/basic_conn_split_low_lat.sh b/tests/bsim/bluetooth/ll/conn/tests_scripts/basic_conn_split_low_lat.sh index a3fa4abd146..4e7f993c456 100755 --- a/tests/bsim/bluetooth/ll/conn/tests_scripts/basic_conn_split_low_lat.sh +++ b/tests/bsim/bluetooth/ll/conn/tests_scripts/basic_conn_split_low_lat.sh @@ -2,25 +2,13 @@ # Copyright 2018 Oticon A/S # SPDX-License-Identifier: Apache-2.0 +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source + # Basic connection test: a central connects to a peripheral and expects a # notification, using the split controller (ULL LLL) in Low Latency Variant simulation_id="basic_conn_split_low_lat" verbosity_level=2 -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 5 $@ & process_ids="$process_ids $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" - -#Give a default value to BOARD if it does not have one yet: -BOARD="${BOARD:-nrf52_bsim}" +EXECUTE_TIMEOUT=5 cd ${BSIM_OUT_PATH}/bin @@ -37,7 +25,4 @@ Execute \ Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=${simulation_id} \ -D=2 -sim_length=20e6 $@ -for process_id in $process_ids; do - wait $process_id || let "exit_code=$?" -done -exit $exit_code #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/ll/edtt/tests_scripts/_controller_tests_inner.sh b/tests/bsim/bluetooth/ll/edtt/tests_scripts/_controller_tests_inner.sh index a7b0592b22a..e75f6ffbe35 100755 --- a/tests/bsim/bluetooth/ll/edtt/tests_scripts/_controller_tests_inner.sh +++ b/tests/bsim/bluetooth/ll/edtt/tests_scripts/_controller_tests_inner.sh @@ -44,9 +44,10 @@ VERBOSITY_LEVEL_DEVS=${VERBOSITY_LEVEL_DEVS:-${VERBOSITY_LEVEL}} VERBOSITY_LEVEL_DEV1=${VERBOSITY_LEVEL_1:-${VERBOSITY_LEVEL_DEVS}} VERBOSITY_LEVEL_DEV2=${VERBOSITY_LEVEL_2:-${VERBOSITY_LEVEL_DEVS}} -PROCESS_IDS=""; EXIT_CODE=0 -function Execute(){ +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source + +function _Execute(){ local rr= if [ "rr" = "$1" ]; then local devno=$2 @@ -56,19 +57,12 @@ function Execute(){ rm -rf ${out} rr="rr record -o ${out}" fi - 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 300 ${rr} $@ & PROCESS_IDS="$PROCESS_IDS $!" + check_program_exists $1 + run_in_background timeout 300 ${rr} $@ } -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" -: "${EDTT_PATH:?EDTT_PATH must be defined}" -#Give a default value to BOARD if it does not have one yet: -BOARD="${BOARD:-nrf52_bsim}" +: "${EDTT_PATH:?EDTT_PATH must be defined}" #Give a default value to PRJ_CONF_x if it does not have one yet: PRJ_CONF="${PRJ_CONF:-prj_dut_conf}" @@ -94,24 +88,21 @@ fi cd ${EDTT_PATH} -Execute ./src/edttool.py -s=${SIMULATION_ID} -d=2 --transport bsim \ +_Execute ./src/edttool.py -s=${SIMULATION_ID} -d=2 --transport bsim \ -T $TEST_MODULE -C $TEST_FILE -v=${VERBOSITY_LEVEL_EDTT} -S -l --low-level-device-nbr=3 \ -D=2 -devs 0 1 -RxWait=2.5e3 cd ${BSIM_OUT_PATH}/bin -Execute \ +_Execute \ ${RR_ARGS_1} ./bs_${BOARD}_tests_bsim_bluetooth_ll_edtt_hci_test_app_${PRJ_CONF_1}\ -s=${SIMULATION_ID} -d=0 -v=${VERBOSITY_LEVEL_DEV1} -RealEncryption=1 -Execute \ +_Execute \ ${RR_ARGS_2} ./bs_${BOARD}_tests_bsim_bluetooth_ll_edtt_hci_test_app_${PRJ_CONF_2}\ -s=${SIMULATION_ID} -d=1 -v=${VERBOSITY_LEVEL_DEV2} -RealEncryption=1 -Execute ./bs_2G4_phy_v1 -v=${VERBOSITY_LEVEL_PHY} -s=${SIMULATION_ID} \ +_Execute ./bs_2G4_phy_v1 -v=${VERBOSITY_LEVEL_PHY} -s=${SIMULATION_ID} \ -D=4 -sim_length=3600e6 -dump_imm $@ -for PROCESS_ID in $PROCESS_IDS; do - wait $PROCESS_ID || let "EXIT_CODE=$?" -done -exit $EXIT_CODE #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/ll/edtt/tests_scripts/gatt.llcp.sh b/tests/bsim/bluetooth/ll/edtt/tests_scripts/gatt.llcp.sh index f30f866923e..d16b743435d 100755 --- a/tests/bsim/bluetooth/ll/edtt/tests_scripts/gatt.llcp.sh +++ b/tests/bsim/bluetooth/ll/edtt/tests_scripts/gatt.llcp.sh @@ -2,27 +2,17 @@ # Copyright 2019 Oticon A/S # SPDX-License-Identifier: Apache-2.0 +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source + # GATT regression tests based on the EDTTool SIMULATION_ID="edtt_gatt_llcp" VERBOSITY_LEVEL=2 -PROCESS_IDS=""; EXIT_CODE=0 +EXECUTE_TIMEOUT=300 + CWD="$(cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P)" -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 300 $@ & PROCESS_IDS="$PROCESS_IDS $!" -} - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" : "${EDTT_PATH:?EDTT_PATH must be defined}" -#Give a default value to BOARD if it does not have one yet: -BOARD="${BOARD:-nrf52_bsim}" - cd ${EDTT_PATH} Execute ./src/edttool.py -s=${SIMULATION_ID} -d=0 --transport bsim \ @@ -42,7 +32,4 @@ Execute \ Execute ./bs_2G4_phy_v1 -v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} \ -D=3 -sim_length=3600e6 $@ -for PROCESS_ID in $PROCESS_IDS; do - wait $PROCESS_ID || let "EXIT_CODE=$?" -done -exit $EXIT_CODE #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/ll/iso/tests_scripts/broadcast_iso.sh b/tests/bsim/bluetooth/ll/iso/tests_scripts/broadcast_iso.sh index bbec1b2c712..2f9be4c3d8f 100755 --- a/tests/bsim/bluetooth/ll/iso/tests_scripts/broadcast_iso.sh +++ b/tests/bsim/bluetooth/ll/iso/tests_scripts/broadcast_iso.sh @@ -2,25 +2,13 @@ # Copyright 2020 Nordic Semiconductor ASA # SPDX-License-Identifier: Apache-2.0 +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source + # Basic ISO broadcast test: a broadcaster transmits a BIS and a receiver listens # to the BIS. simulation_id="broadcast_iso" verbosity_level=2 -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}" - -#Give a default value to BOARD if it does not have one yet: -BOARD="${BOARD:-nrf52_bsim}" +EXECUTE_TIMEOUT=30 cd ${BSIM_OUT_PATH}/bin @@ -33,7 +21,4 @@ Execute ./bs_${BOARD}_tests_bsim_bluetooth_ll_iso_prj_conf \ Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=${simulation_id} \ -D=2 -sim_length=30e6 $@ -for process_id in $process_ids; do - wait $process_id || let "exit_code=$?" -done -exit $exit_code #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/ll/iso/tests_scripts/broadcast_iso_vs_dp.sh b/tests/bsim/bluetooth/ll/iso/tests_scripts/broadcast_iso_vs_dp.sh index 62b73731467..1e1fde1247d 100755 --- a/tests/bsim/bluetooth/ll/iso/tests_scripts/broadcast_iso_vs_dp.sh +++ b/tests/bsim/bluetooth/ll/iso/tests_scripts/broadcast_iso_vs_dp.sh @@ -2,25 +2,13 @@ # Copyright 2020 Nordic Semiconductor ASA # SPDX-License-Identifier: Apache-2.0 +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source + # Basic ISO broadcast test: a broadcaster transmits a BIS and a receiver listens # to the BIS, and recevied SDUs are emitted via vendor data path implementation. simulation_id="broadcast_iso_vs_dp" verbosity_level=2 -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}" - -#Give a default value to BOARD if it does not have one yet: -BOARD="${BOARD:-nrf52_bsim}" +EXECUTE_TIMEOUT=30 cd ${BSIM_OUT_PATH}/bin @@ -33,7 +21,4 @@ Execute ./bs_${BOARD}_tests_bsim_bluetooth_ll_iso_prj_conf \ Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=${simulation_id} \ -D=2 -sim_length=30e6 $@ -for process_id in $process_ids; do - wait $process_id || let "exit_code=$?" -done -exit $exit_code #the last exit code != 0 +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/mesh/_mesh_test.sh b/tests/bsim/bluetooth/mesh/_mesh_test.sh index 0827585f3c9..2b2d0b4c52d 100755 --- a/tests/bsim/bluetooth/mesh/_mesh_test.sh +++ b/tests/bsim/bluetooth/mesh/_mesh_test.sh @@ -1,27 +1,9 @@ # Copyright 2021 Nordic Semiconductor # SPDX-License-Identifier: Apache-2.0 -process_ids=(); exit_code=0 +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source -trap ctrl_c INT - -function ctrl_c() { - echo "Aborted by CTRL-C" - conf=${conf:-prj_conf} - - for process_id in ${process_ids[@]}; do - kill -15 $process_id - done -} - -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 300 $@ & process_ids+=( $! ) -} +EXECUTE_TIMEOUT=300 function Skip(){ for i in "${SKIP[@]}" ; do @@ -86,16 +68,5 @@ function RunTest(){ Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=$s_id -D=$count -argschannel -at=35 - for process_id in ${process_ids[@]}; do - wait $process_id || let "exit_code=$?" - done - - if [ "$exit_code" != "0" ] ; then - exit $exit_code #the last exit code != 0 - fi + wait_for_background_jobs } - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" - -#Give a default value to BOARD if it does not have one yet: -BOARD="${BOARD:-nrf52_bsim}" diff --git a/tests/bsim/bluetooth/mesh/compile.sh b/tests/bsim/bluetooth/mesh/compile.sh index d0c3f91f4bb..c00048b4195 100755 --- a/tests/bsim/bluetooth/mesh/compile.sh +++ b/tests/bsim/bluetooth/mesh/compile.sh @@ -6,14 +6,11 @@ #set -x #uncomment this line for debugging set -ue - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" : "${BSIM_COMPONENTS_PATH:?BSIM_COMPONENTS_PATH must be defined}" : "${ZEPHYR_BASE:?ZEPHYR_BASE must be set to point to the zephyr root\ directory}" WORK_DIR="${WORK_DIR:-${ZEPHYR_BASE}/bsim_out}" -BOARD="${BOARD:-nrf52_bsim}" BOARD_ROOT="${BOARD_ROOT:-${ZEPHYR_BASE}}" mkdir -p ${WORK_DIR} diff --git a/tests/bsim/compile.sh b/tests/bsim/compile.sh index 39e07d1313d..beec89f937c 100755 --- a/tests/bsim/compile.sh +++ b/tests/bsim/compile.sh @@ -6,14 +6,12 @@ #set -x #uncomment this line for debugging set -ue - -: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" : "${BSIM_COMPONENTS_PATH:?BSIM_COMPONENTS_PATH must be defined}" : "${ZEPHYR_BASE:?ZEPHYR_BASE must be set to point to the zephyr root\ directory}" WORK_DIR="${WORK_DIR:-${ZEPHYR_BASE}/bsim_out}" -BOARD="${BOARD:-nrf52_bsim}" + BOARD_ROOT="${BOARD_ROOT:-${ZEPHYR_BASE}}" mkdir -p ${WORK_DIR} diff --git a/tests/bsim/sh_common.source b/tests/bsim/sh_common.source index 25c59d3f3c5..000ea36cd0c 100644 --- a/tests/bsim/sh_common.source +++ b/tests/bsim/sh_common.source @@ -3,6 +3,12 @@ _process_ids=""; +#All user scripts require these variable, let's check for them here already +: "${BSIM_OUT_PATH:?BSIM_OUT_PATH must be defined}" + +#Give a default value to BOARD if it does not have one yet: +BOARD="${BOARD:-nrf52_bsim}" + function run_in_background(){ $@ & _process_ids="$_process_ids $!" } @@ -12,5 +18,31 @@ function wait_for_background_jobs(){ for process_id in $_process_ids; do wait $process_id || let "exit_code=$?" done - exit $exit_code #the last exit code != 0 + [ $exit_code -eq 0 ] || exit $exit_code } + +trap ctrl_c INT + +function ctrl_c() { + echo "Aborted by CTRL-C" + + for process_id in $_process_ids; do + kill -15 $process_id + done +} + +function check_program_exists() { + 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 +} + +function Execute() { + EXECUTE_TIMEOUT="${EXECUTE_TIMEOUT:-30}" + + check_program_exists $1 + run_in_background timeout ${EXECUTE_TIMEOUT} $@ +} +