-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathutils.sh
167 lines (140 loc) · 3.17 KB
/
utils.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
#!/bin/bash
A7_FREQS="350000 400000 500000 600000 700000 800000 900000 1000000"
A15_FREQS="500000 600000 700000 800000 900000 1000000 1100000 1200000"
ALL_MASK="0 1 2 3 4"
A7_MASK="2 3 4"
A15_MASK="0 1"
ONE_A7_ONE_A15_NMASK="2 3 4"
TRACE_CMD="trace-cmd"
tracing=0
rt_runtime=-1
print_test_info() {
if [ -n "$TDESC" ]; then
echo "$TDESC"
else
echo "Test has no description."
fi
}
trace_start() {
if [[ -n "$TRACE" && ${TRACE} -eq 1 ]]; then
tracing=1
events=""
for e in ${EVENTS}; do
events+="-e ${e} "
done
${TRACE_CMD} start ${events} >${TNAME}.out 2>&1
echo "tracing started"
fi
}
trace_stop() {
if [ ${tracing} -eq 1 ]; then
${TRACE_CMD} stop >>${TNAME}.out 2>&1
echo "tracing stopped"
fi
}
trace_extract() {
if [ ${tracing} -eq 1 ]; then
${TRACE_CMD} extract -o ${TNAME}.dat >>${TNAME}.out 2>&1
echo "trace available: ${TNAME}.dat"
fi
tracing=0
}
trace_write() {
echo $1
if [ ${tracing} -eq 1 ]; then
echo $1 > /sys/kernel/debug/tracing/trace_marker
fi
}
dump_on_oops() {
echo 50000 > /sys/kernel/debug/tracing/buffer_size_kb
echo 1 > /proc/sys/kernel/ftrace_dump_on_oops
}
test_failed() {
echo "TEST_FAILED"
trace_write "TEST_FAILED"
trace_stop
trace_extract
exit 1
}
test_passed() {
echo "TEST_PASSED"
trace_write "TEST_PASSED"
}
disable_ac() {
echo "disabling admission control"
echo -1 > /proc/sys/kernel/sched_rt_runtime_us
}
enable_ac() {
echo "enabling admission control"
echo 950000 > /proc/sys/kernel/sched_rt_runtime_us
}
set_cpufreq() {
if [ -z "$3" ]; then
echo "setting CPU$1 to $2 governor"
trace_write "setting CPU$1 to $2 governor"
else
echo "setting CPU$1 to $2 governor at $3 MHz"
trace_write "setting CPU$1 to $2 governor at $3 MHz"
fi
echo $2 > /sys/devices/system/cpu/cpu$1/cpufreq/scaling_governor
if [ ! -z "$3" ]; then
echo $3 > /sys/devices/system/cpu/cpu$1/cpufreq/scaling_setspeed
fi
}
set_runtime_freq_inv() {
echo "enabling runtime frequency invariance"
#echo DL_RUNTIME_FI > /sys/kernel/debug/sched_features
echo ENERGY_AWARE > /sys/kernel/debug/sched_features
}
clear_runtime_freq_inv() {
echo "disabling runtime frequency invariance"
#echo NO_DL_RUNTIME_FI > /sys/kernel/debug/sched_features
echo NO_ENERGY_AWARE > /sys/kernel/debug/sched_features
}
turn_off_cpu() {
echo "turning off CPU$1"
trace_write "turning off CPU$1"
echo 0 > /sys/devices/system/cpu/cpu$1/online
}
turn_on_cpu() {
echo "turning on CPU$1"
trace_write "turning on CPU$1"
echo 1 > /sys/devices/system/cpu/cpu$1/online
}
log() {
echo $1
trace_write $1
}
random() {
local min=${1-1}
local max=${2-100}
echo $(( (RANDOM % max) + min))
}
# Written by Locutus for bash demonstration.
# Found at http://it.toolbox.com/blogs/locutus/bash-bits-nibbles-and-bytes-a-rotating-cursor-while-you-wait-22867
rotateCursor()
{
case $toggle
in
1)
echo -n $1" \ "
echo -ne "\r"
toggle="2"
;;
2)
echo -n $1" | "
echo -ne "\r"
toggle="3"
;;
3)
echo -n $1" / "
echo -ne "\r"
toggle="4"
;;
*)
echo -n $1" - "
echo -ne "\r"
toggle="1"
;;
esac
}