forked from EpiSci/oai-lte-5g-multi-ue-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_proxy_num_ues
executable file
·102 lines (86 loc) · 2.22 KB
/
run_proxy_num_ues
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
#!/bin/bash
#
# Run the proxy test script for a scenario of a specifed number of UEs.
# See `--help` for more information.
#
this_script=${0##*/}
this_dir=$(dirname "$0")
proxy_testscript=$this_dir/proxy_testscript.py
validate=true
num_runs=1
log_dir=.
while (( $# > 0 )) && [[ $1 = -* ]]; do
arg=$1; shift
case "$arg" in
(--validate=*)
validate=${arg#*=}
;;
(--log-dir=*)
log_dir=${arg#*=}
;;
(--repeat=*)
num_runs=${arg#*=}
if ! (( num_runs > 0 )); then
echo >&2 "$this_script: invalid repeat count '$arg'"
exit 1
fi
;;
(--help)
cat <<EOF
Usage: $this_script [options] NUM-UES [proxy_testscript args]"
NUM-UES Number of UEs
options:
--repeat=N Run the test this many times (default: 1)
--log-dir=DIR Where to store the logs. Default is \$HOME
--validate=CMD Invoke CMD after each test iteration. If CMD
fails (e.g., exit 1), stop immediately
See also: $proxy_testscript --help
EOF
exit 0
;;
(*)
echo >&2 "$this_script: unknown option '$arg', try --help"
exit 1
;;
esac
done
if (( $# < 1 )); then
echo >&2 "$this_script: wrong usage, try --help"
exit 1
fi
num_ues=$1; shift
if ! (( num_ues > 0 )); then
echo >&2 "$this_script: Invalid number of UEs '$num_ues'"
exit 1
fi
log_base=$log_dir/logs-$(date +%Y-%m-%d-%H%M%S)
mkdir -p "$log_base" || exit
echo "Logs: $log_base"
ln -nsf "${log_base##*/}" "$log_dir/latest"
num_pass=0
num_fail=0
for i in $(seq $num_runs); do
echo "------------------------- RUN $i of $num_runs -------------------------"
log_dir=$log_base/$(printf "%04d" $i)
mkdir "$log_dir" || exit
run_cmd=(
"$proxy_testscript"
-u $num_ues
--log-dir="$log_dir"
"$@"
)
if "${run_cmd[@]}"; then
(( num_pass += 1 ))
else
(( num_fail += 1 ))
fi
echo "run: $i, pass: $num_pass, fail: $num_fail"
if ! $validate "$log_dir"; then
echo "*** Validation failed, stopping"
exit 1
fi
done
if (( num_fail != 0 )); then
exit 1
fi
exit 0