1# Copyright 2021 Nordic Semiconductor
2# SPDX-License-Identifier: Apache-2.0
3
4source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
5
6EXECUTE_TIMEOUT=300
7
8function Skip(){
9  for i in "${SKIP[@]}" ; do
10    if [ "$i" == "$1" ] ; then
11      return 0
12    fi
13  done
14
15  return 1
16}
17
18function RunTest(){
19  verbosity_level=${verbosity_level:-2}
20  extra_devs=${EXTRA_DEVS:-0}
21
22  cd ${BSIM_OUT_PATH}/bin
23
24  idx=0
25
26  s_id=$1
27  shift 1
28
29  testids=()
30  for testid in $@ ; do
31    if [ "$testid" == "--" ]; then
32      shift 1
33      break
34    fi
35
36    testids+=( $testid )
37    shift 1
38  done
39
40  test_options=$@
41
42  for testid in ${testids[@]} ; do
43    if Skip $testid; then
44      echo "Skipping $testid (device #$idx)"
45      let idx=idx+1
46      continue
47    fi
48
49    echo "Starting $testid as device #$idx"
50    conf=${conf:-prj_conf}
51
52    if [ ${overlay} ]; then
53        exe_name=./bs_${BOARD}_tests_bsim_bluetooth_mesh_${conf}_${overlay}
54    else
55        exe_name=./bs_${BOARD}_tests_bsim_bluetooth_mesh_${conf}
56    fi
57
58    Execute \
59      ${exe_name} \
60      -v=${verbosity_level} -s=$s_id -d=$idx -sync_preboot -RealEncryption=1 \
61      -testid=$testid ${test_options}
62    let idx=idx+1
63  done
64
65  count=$(expr $idx + $extra_devs)
66
67  echo "Starting phy with $count devices"
68
69  Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=$s_id -D=$count -argschannel -at=35
70
71  wait_for_background_jobs
72}
73