-
Notifications
You must be signed in to change notification settings - Fork 3
/
Hikey-Demo.sh
306 lines (248 loc) · 7.26 KB
/
Hikey-Demo.sh
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
#!/bin/bash
# Copyright (C) 2017 Luca Miccio <lucmiccio@gmail.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# This demo tests the Hikey "LeMaker" Board using the Hikey-Tester script suite
# Main variables
script_name="Hikey-Tester-Demo"
test_script="Hikey-Tester.sh"
lat_workloads=( "" "-r 3" "-r 2 -w 1")
thr_workloads=( "-r 3" "-r 2 -w 1")
schedulers=(noop bfq)
video=file:///sdcard/Hikey-Tester/demo.mp4
my_pid_file=Hikey-Tester-Pid.txt
run_all=1
run_thr=0
run_video=0
run_lat=0
run_update=0
enable_pause=0
debug=0
results_dir="Results-Demo"
# Utility functions
show_help () {
local help_message="
$script_name
The demo must be run using the Hikey LeMaker Board to properly work cause it
makes use of the Hikey-Tester script suite, which works only with this board.
USAGE:
sh $script_name.sh [options ...]
Options:
-all (default): run all the tests
-latency: run the latency test only
-throughput: run the throughput test only
-video : run the video playing test only
-update : run the update test only
-enable_pause: enable a \"[Enter] to start\" step every test
-help| -h : display this message
Advanced options:
-debug: enable verbose output
Example:
sh demo.sh -video -latency
This command will run the video playing test first, then the latency
test.
Author: Luca Miccio <lucmiccio@gmail.com>
"
clear
echo "$help_message"
}
# Handle -h and --help options
if [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then
show_help
exit 0
fi
pause () {
local phrase=$1
local start=0
echo "\n$phrase"
read -n1 -s key
echo
while [ "$key" != '' ]; do
echo "\n$phrase"
read -n 1 -s key
echo
done
}
start_latency_test () {
local scheduler=$1
local background_io=$2
local time_test=30
local low_latency_enabled=""
if [ "$scheduler" == 'bfq' ]; then
low_latency_enabled="-low_lat"
fi
if [ "$background_io" == "" ]; then
time_test=15
fi
if [ $debug -eq 1 ]; then
echo -n "sh $test_script -sched $scheduler -time $time_test $scheduler $background_io $low_latency_enabled\n"
fi
sh $test_script -sched $scheduler -time $time_test $background_io $low_latency_enabled
}
start_thr_test () {
local scheduler=$1
local background_io=$2
if [ $debug -eq 1 ]; then
echo -n "sh $test_script -sched $scheduler $background_io -thr -time 35\n"
fi
sh $test_script -sched $scheduler $background_io -thr -time 35
local workload="$(echo -e $background_io | sed 's/ //g')"
mv outfile.txt $results_dir/"outfile-$scheduler$workload.txt"
}
start_video_test () {
local scheduler=$1
local background_io=$2
local low_latency_enabled=""
if [ "$scheduler" == 'bfq' ]; then
low_latency_enabled="-low_lat"
fi
if [ $debug -eq 1 ]; then
echo -n "sh $test_script -sched $scheduler $background_io -video $video $low_latency_enabled\n"
fi
sh $test_script -sched $scheduler $background_io -video $video $low_latency_enabled
}
# Multipurose function that runs a test
run_test () {
local test_function=$1
local test_type=$2
local test_workload_name=$3
local test_workload
if [ "$test_workload_name" == "lat_workloads" ]; then
test_workload=("${lat_workloads[@]}")
else
test_workload=("${thr_workloads[@]}")
fi
if [ $debug -eq 1 ]; then
echo "Current workload items:"
for work in "${test_workload[@]}"; do
echo "Work:$work"
done
fi
echo "Starting $test_type test..."
if [ "$test_workload_name" == "update" ]; then
local workload="-update"
for i in ${schedulers[@]}; do
local message_param="Starting the $test_type test with the following parameters:\n- scheduler: $i\n- workload: $workload"
echo "\n$message_param"
if [[ $enable_pause -eq 1 ]]; then
message_pause="Press [Enter] to start..."
pause "$message_pause"
fi
sleep 1
$test_function $i "$workload"
sleep 3
done
return 0
fi
for k in "${test_workload[@]}"; do
local workload
if [ "$k" == "" ]; then
workload="no workload"
else
workload=$k
fi
for i in ${schedulers[@]}; do
local message_param="Starting the $test_type test with the following parameters:\n- scheduler: $i\n- workload: $workload"
echo "\n$message_param"
if [[ $enable_pause -eq 1 ]]; then
message_pause="Press [Enter] to start..."
pause "$message_pause"
fi
sleep 1
$test_function $i "$k"
sleep 3
done
done
}
close_current_test () {
echo -n "Continue? [Yy/Nn]: "
read -n1 -s key
if [[ "$key" == "N" || "$key" == "n" ]]; then
echo
exit 1
fi
}
trap 'echo Interrupting test; close_current_test;' SIGKILL SIGTERM SIGINT
########################## Handle multiple options ############################
while :
do
case "$1" in
-enable_pause)
enable_pause=1
shift
;;
-all)
run_all=1
break
;;
-video)
run_video=1
run_all=0
shift
;;
-throughput)
run_thr=1
run_all=0
shift
;;
-latency)
run_lat=1
run_all=0
shift
;;
-update)
run_update=1
run_all=0
shift
;;
-debug)
debug=1
shift
;;
-*)
echo "ERROR: Unknown option: $1" >&2
exit 1
;;
*) # No more options
break
;;
esac
done
sleep 1
################MAIN#################
echo "Hikey Tester Demo"
# First of all we have to check if the user has root privileges
USER=$(whoami)
if [[ "$USER" != 'root' ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
# Execute only the test choosen
if [[ $run_all -eq 1 || $run_lat -eq 1 ]]; then
run_test "start_latency_test" "latency" "lat_workloads"
sleep 2
fi
if [[ $run_all -eq 1 || $run_thr -eq 1 ]]; then
mkdir $results_dir 2>/dev/null
run_test "start_thr_test" "throughput" "thr_workloads"
sleep 2
fi
if [[ $run_all -eq 1 || $run_video -eq 1 ]]; then
run_test "start_video_test" "video playing" "lat_workloads"
sleep 2
fi
if [[ $run_all -eq 1 || $run_update -eq 1 ]]; then
run_test "start_latency_test" "update test" "update"
sleep 2
fi
echo "Demo ended"
exit 0