-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_mesh_test.sh
More file actions
executable file
·148 lines (116 loc) · 3.34 KB
/
_mesh_test.sh
File metadata and controls
executable file
·148 lines (116 loc) · 3.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# Copyright 2021 Nordic Semiconductor
# SPDX-License-Identifier: Apache-2.0
source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
EXECUTE_TIMEOUT=8000
function Skip(){
for i in "${SKIP[@]}" ; do
if [ "$i" == "$1" ] ; then
return 0
fi
done
return 1
}
function RunTest(){
# Set default values
arg_ch=""
arg_file=""
use_nodump=""
# Parse optional arguments
while [[ "$1" == arg_ch=* || "$1" == arg_file=* || "$1" == nodump ]]; do
case "$1" in
arg_ch=*) arg_ch="${1#arg_ch=}" ;;
arg_file=*) arg_file="${1#arg_file=}" ;;
nodump) use_nodump="-nodump" ;;
esac
shift
done
# Error checking for arg_ch/arg_file
if [[ "$arg_ch" == "multiatt" ]]; then
if [[ -z "$arg_file" ]]; then
echo "Error: When arg_ch is 'multiatt', arg_file must also be provided." >&2
exit 1
fi
elif [[ -n "$arg_ch" || -n "$arg_file" ]]; then
echo "Error: arg_ch and arg_file must both be set together (with arg_ch='multiatt'), or both be unset." >&2
exit 1
fi
# print source files directory name relative to zephyr base without leading slash and with slashes replaced by underscores
SCRIPT_PATH="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)/$(basename -- "${BASH_SOURCE[0]}")"
APP_DIR="$(dirname "$SCRIPT_PATH")"
APP_DIR="${APP_DIR/${ZEPHYR_BASE}/}"
APP_DIR="${APP_DIR//\//_}" # Replace slashes with underscores
# Now $1, $2, ... are the positional arguments
echo "arg_ch: $arg_ch"
echo "arg_file: $arg_file"
echo "Positional args: $@"
verbosity_level=${verbosity_level:-2}
extra_devs=${EXTRA_DEVS:-0}
cd ${BSIM_OUT_PATH}/bin
idx=0
s_id=$1
shift 1
declare -A testids
testid=""
testid_in_order=()
for arg in $@ ; do
if [ "$arg" == "--" ]; then
shift 1
break
fi
if [[ "$arg" == "-"* ]]; then
testids["${testid}"]+="$arg "
else
testid=$arg
testid_in_order+=($testid)
testids["${testid}"]=""
fi
shift 1
done
test_options=$@
for testid in ${testid_in_order[@]}; do
if Skip $testid; then
echo "Skipping $testid (device #$idx)"
let idx=idx+1
continue
fi
echo "Starting $testid as device #$idx"
conf=${conf:-prj_conf}
if [ ${overlay} ]; then
exe_name=./bs_${BOARD_TS}_${APP_DIR}_${conf}_${overlay}
else
exe_name=./bs_${BOARD_TS}_${APP_DIR}_${conf}
fi
Execute \
${exe_name} \
-v=${verbosity_level} -s=$s_id -d=$idx -sync_preboot -RealEncryption=1 \
-testid=$testid ${testids["${testid}"]} ${test_options}
let idx=idx+1
done
count=$(expr $idx + $extra_devs)
echo "Starting phy with $count devices"
if [[ "$arg_ch" == "multiatt" ]]; then
Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=$s_id -D=$count $use_nodump -defmodem=BLE_simple -channel=$arg_ch -argschannel -at=100 -atextra=0 -file=$arg_file
else
Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=$s_id -D=$count $use_nodump -argschannel -at=35
fi
wait_for_background_jobs
}
function RunTestFlash(){
s_id=$1
ext_arg="${s_id} "
idx=0
shift 1
for arg in $@ ; do
if [ "$arg" == "--" ]; then
ext_arg+=$@
break
fi
ext_arg+="$arg "
if [[ "$arg" != "-"* ]]; then
ext_arg+="-flash=../results/${s_id}/${s_id}_${idx}.bin "
let idx=idx+1
fi
shift 1
done
RunTest ${ext_arg}
}