1#!/usr/bin/env bash 2# Copyright 2019 Oticon A/S 3# SPDX-License-Identifier: Apache-2.0 4 5# 6# ENVIRONMENT CONFIGURATION 7# ========================= 8# 9# This script can be configured with a number of environment variables. 10# Values in [] are the default unless overridden. 11# 12# PROJECT CONFIGURATION 13# --------------------- 14# PRJ_CONF: Default bsim device configuration [prj_dut_conf] 15# PRJ_CONF_1: bsim device 1 configuration [PRJ_CONF] 16# PRJ_CONF_2: bsim device 2 configuration [PRJ_CONF] 17# 18# VERBOSITY 19# --------- 20# VERBOSITY_LEVEL: Global verbosity [2] 21# VERBOSITY_LEVEL_EDTT: EDTT verbosity [VERBOSITY_LEVEL] 22# VERBOSITY_LEVEL_BRIDGE: EDTT bridge verbosity [VERBOSITY_LEVEL] 23# VERBOSITY_LEVEL_PHY: bsim phy verbosity [VERBOSITY_LEVEL] 24# VERBOSITY_LEVEL_DEVS: Global bsim device verbosity [VERBOSITY_LEVEL] 25# VERBOSITY_LEVEL_DEV1: bsim device 1 verbosity [VERBOSITY_LEVEL_DEVS] 26# VERBOSITY_LEVEL_DEV1: bsim device 2 verbosity [VERBOSITY_LEVEL_DEVS] 27# 28# RR DEBUG SUPPORT 29# ---------------- 30# RR: Default run bsim device under rr [0] 31# 0: disables; any other value enables. 32# RR_1: Run bsim device 1 under rr [RR] 33# RR_2: Run bsim device 2 under rr [RR] 34# 35 36 37# Common part of the test scripts for some of the EDTT tests 38# in which 2 controller only builds of the stack are run against each other 39VERBOSITY_LEVEL=${VERBOSITY_LEVEL:-2} 40VERBOSITY_LEVEL_EDTT=${VERBOSITY_LEVEL_EDTT:-${VERBOSITY_LEVEL}} 41VERBOSITY_LEVEL_BRIDGE=${VERBOSITY_LEVEL_BRIDGE:-${VERBOSITY_LEVEL}} 42VERBOSITY_LEVEL_PHY=${VERBOSITY_LEVEL_PHY:-${VERBOSITY_LEVEL}} 43VERBOSITY_LEVEL_DEVS=${VERBOSITY_LEVEL_DEVS:-${VERBOSITY_LEVEL}} 44VERBOSITY_LEVEL_DEV1=${VERBOSITY_LEVEL_1:-${VERBOSITY_LEVEL_DEVS}} 45VERBOSITY_LEVEL_DEV2=${VERBOSITY_LEVEL_2:-${VERBOSITY_LEVEL_DEVS}} 46 47 48source ${ZEPHYR_BASE}/tests/bsim/sh_common.source 49 50function _Execute(){ 51 local rr= 52 if [ "rr" = "$1" ]; then 53 local devno=$2 54 shift 2 55 local exe=$(basename $1) 56 local out=/tmp/rr/$$-${SIMULATION_ID}-${exe}-d_${devno} 57 rm -rf ${out} 58 rr="rr record -o ${out}" 59 fi 60 check_program_exists $1 61 run_in_background timeout --kill-after=5 -v 800 ${rr} $@ 62} 63 64 65: "${EDTT_PATH:?EDTT_PATH must be defined}" 66 67#Give a default value to PRJ_CONF_x if it does not have one yet: 68PRJ_CONF="${PRJ_CONF:-prj_dut_conf}" 69PRJ_CONF_1="${PRJ_CONF_1:-${PRJ_CONF}}" 70PRJ_CONF_2="${PRJ_CONF_2:-${PRJ_CONF}}" 71 72#Give default value to RR_x if it does not have one yet: 73RR="${RR:-0}" 74RR_1="${RR_1:-${RR}}" 75RR_2="${RR_2:-${RR}}" 76 77#Check if rr was requested and is available 78if [ "${RR_1}" != "0" -o "${RR_2}" != "0" ]; then 79 if [ ! -x "$(command -v rr)" ]; then 80 echo 'error: rr cannot be found in $PATH.' >&2 81 exit 1 82 fi 83 84 #Set RR_ARGS_x based on RR_x 85 [ "${RR_1}" != "0" ] && RR_ARGS_1="rr 1" 86 [ "${RR_2}" != "0" ] && RR_ARGS_2="rr 2" 87fi 88 89cd ${EDTT_PATH} 90 91_Execute ./src/edttool.py -s=${SIMULATION_ID} -d=2 --transport bsim \ 92 -T $TEST_MODULE -C $TEST_FILE -v=${VERBOSITY_LEVEL_EDTT} -S -l --low-level-device-nbr=3 \ 93 -D=2 -devs 0 1 -RxWait=2.5e3 94 95cd ${BSIM_OUT_PATH}/bin 96 97_Execute \ 98 ${RR_ARGS_1} ./bs_${BOARD_TS}_tests_bsim_bluetooth_ll_edtt_hci_test_app_${PRJ_CONF_1}\ 99 -s=${SIMULATION_ID} -d=0 -v=${VERBOSITY_LEVEL_DEV1} -RealEncryption=1 100 101_Execute \ 102 ${RR_ARGS_2} ./bs_${BOARD_TS}_tests_bsim_bluetooth_ll_edtt_hci_test_app_${PRJ_CONF_2}\ 103 -s=${SIMULATION_ID} -d=1 -v=${VERBOSITY_LEVEL_DEV2} -RealEncryption=1 104 105_Execute ./bs_2G4_phy_v1 -v=${VERBOSITY_LEVEL_PHY} -s=${SIMULATION_ID} \ 106 -D=4 -sim_length=3600e6 -dump_imm $@ 107 108wait_for_background_jobs 109