forked from ehoutsma/StabilityTester
-
Notifications
You must be signed in to change notification settings - Fork 1
/
stabilityTester.sh
executable file
·129 lines (110 loc) · 4.05 KB
/
stabilityTester.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
#!/bin/bash
XHPLBINARY="xhpl64"
MINFREQUENCY=600000 #Only test frequencies from this point.
MAXFREQUENCY=2400000 #Only test frequencies upto this point.
COOLDOWNTEMP=50000 #Cool down after a test to mC degrees
COOLDOWNFREQ=600000 # Set to this speed when cooling down
CPUFREQ_HANDLER="/sys/devices/system/cpu/cpu0/cpufreq/";
SCALINGAVAILABLEFREQUENCIES="scaling_available_frequencies";
SCALINGMINFREQUENCY="scaling_min_freq";
SCALINGMAXFREQUENCY="scaling_max_freq";
SOCTEMPCMD="/sys/class/thermal/thermal_zone0/temp"
REGULATOR_HANDLER="/sys/class/regulator/regulator.2/"
REGULATOR_MICROVOLT="microvolts"
ROOT=$(pwd)
if [ -f /usr/bin/vcgencmd ]; then
USE_VCGENCMD=true
REGULATOR_MICROVOLT="millivolts"
[ -f /proc/device-tree/model ] && (cat /proc/device-tree/model ; echo)
vcgencmd get_config int | egrep "over_voltage|arm_freq|core_freq|dvs" | sort
echo
fi
declare -A VOLTAGES=()
# Make sure only root can run our script
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
trap "{ killall ${ROOT}/${XHPLBINARY}; exit 0; }" SIGINT SIGTERM
if [ ! -d "${ROOT}/results" ];
then
echo "Create";
mkdir ${ROOT}/results;
fi
if [ -f "/usr/lib/libmpich.so.12" -o "/usr/lib/aarch64-linux-gnu/libmpich.so.12" ]; then
:
else
echo "You need libmpich-dev to run xhpl"
echo "Install using sudo apt install libmpich-dev"
exit 1
fi
AVAILABLEFREQUENCIES=$(cat ${CPUFREQ_HANDLER}${SCALINGAVAILABLEFREQUENCIES})
for FREQUENCY in $AVAILABLEFREQUENCIES
do
if [ $FREQUENCY -ge $MINFREQUENCY ] && [ $FREQUENCY -le $MAXFREQUENCY ];
then
echo "Testing frequency ${FREQUENCY}";
if [ $FREQUENCY -gt $(cat ${CPUFREQ_HANDLER}${SCALINGMAXFREQUENCY}) ];
then
echo $FREQUENCY > ${CPUFREQ_HANDLER}${SCALINGMAXFREQUENCY}
echo $FREQUENCY > ${CPUFREQ_HANDLER}${SCALINGMINFREQUENCY}
else
echo $FREQUENCY > ${CPUFREQ_HANDLER}${SCALINGMINFREQUENCY}
echo $FREQUENCY > ${CPUFREQ_HANDLER}${SCALINGMAXFREQUENCY}
fi
${ROOT}/$XHPLBINARY > ${ROOT}/results/xhpl_${FREQUENCY}.log &
echo -n "Soc temp:"
while pgrep -x $XHPLBINARY > /dev/null
do
if [ ${USE_VCGENCMD} = true ] ; then
# On RPi we query ThreadX about clockspeed and VCore voltage
CURFREQ="$(/usr/bin/vcgencmd measure_clock arm | awk -F"=" '{printf ("%0.0f",$2/1000000); }' )000"
CURVOLT=$(/usr/bin/vcgencmd measure_volts | cut -f2 -d=)
else
CURFREQ=$(cat ${CPUFREQ_HANDLER}${SCALINGMINFREQUENCY})
CURVOLT=$(cat ${REGULATOR_HANDLER}${REGULATOR_MICROVOLT})
fi
SOCTEMP=$(cat ${SOCTEMPCMD})
echo -ne "\rSoc temp: ${SOCTEMP} \tCPU Freq: ${CURFREQ} \tCPU Core: ${CURVOLT} \t"
if [ $CURFREQ -eq $FREQUENCY ];
then
VOLTAGES[$FREQUENCY]=$CURVOLT
fi
sleep 1;
done
echo -ne "\r"
echo -n "Cooling down"
echo $COOLDOWNFREQ > ${CPUFREQ_HANDLER}${SCALINGMINFREQUENCY}
echo $COOLDOWNFREQ > ${CPUFREQ_HANDLER}${SCALINGMAXFREQUENCY}
while [ $SOCTEMP -gt $COOLDOWNTEMP ];
do
SOCTEMP=$(cat ${SOCTEMPCMD})
echo -ne "\rCooling down: ${SOCTEMP}"
sleep 1;
done
echo -ne "\n"
fi
done
echo -e "\nDone testing stability:"
for FREQUENCY in $AVAILABLEFREQUENCIES
do
if [ $FREQUENCY -ge $MINFREQUENCY ] && [ $FREQUENCY -le $MAXFREQUENCY ];
then
FINISHEDTEST=$(grep -Ec "PASSED|FAILED" ${ROOT}/results/xhpl_${FREQUENCY}.log )
SUCCESSTEST=$(grep -Ec "PASSED" ${ROOT}/results/xhpl_${FREQUENCY}.log )
DIFF=$(grep -E 'PASSED|FAILED' ${ROOT}/results/xhpl_${FREQUENCY}.log)
#echo $DIFF
DIFF="${DIFF#*=}"
DIFF="${DIFF#* }"
#echo $DIFF
RESULTTEST="${DIFF% .*}"
VOLTAGE=${VOLTAGES[$FREQUENCY]}
if [ $FINISHEDTEST -eq 1 ];
then
echo -ne "Frequency: ${FREQUENCY}\t"
echo -ne "Voltage: ${VOLTAGE}\t"
echo -ne "Success: ${SUCCESSTEST}\t"
echo -ne "Result: ${RESULTTEST}\n"
fi
fi
done