forked from Semihalf/spectre-meltdown
-
Notifications
You must be signed in to change notification settings - Fork 2
/
regression.sh
executable file
·53 lines (42 loc) · 1.14 KB
/
regression.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
#!/bin/sh
TEST_RUNS="10"
OPTIONS="-Os -O0 -O1 -O2 -O3"
LOG="test.log"
EXPECTED_LOG_SIZE="2622"
EXPECTED_SPECTRE_LOG_SIZE="263"
POWER_MODES="powersave performance"
CFLAGS="-g -Wall -Werror"
SRC="$(ls *.c)"
SRC="${SRC%*.c}"
for POWER_MODE in ${POWER_MODES}; do
echo "===> Setting CPUs in ${POWER_MODE} mode..."
find '/sys/devices/system/cpu/' -name 'scaling_governor' \
| while read F; do
echo ${POWER_MODE} | sudo tee "${F}" > /dev/null
done
for SPECTRE in "" "0"; do
for OPT in ${OPTIONS}; do
if ! gcc ${OPT} -o ${SRC}${OPT} ${SRC}.c; then
exit 1
fi
count="0"
errors="0"
while [ "${count}" != "${TEST_RUNS}" ] ; do
count=$((${count} + 1))
./${SRC}${OPT} ${SPECTRE} > ${LOG}
fsize=$(stat -c "%s" ${LOG} )
if [ "x${fsize}" != "x${EXPECTED_LOG_SIZE}" -a \
"x${fsize}" != "x${EXPECTED_SPECTRE_LOG_SIZE}" ]; then
errors=$(($errors + 1))
fi
done
rm -f ${SRC}${OPT}
rm -f ${LOG}
if [ -n "${SPECTRE}" ]; then
echo "SPECTRE${OPT}: ${errors}/${count} = $((${errors}*1000/${count}))‰ errors"
else
echo "MELTDOWN${OPT}: ${errors}/${count} = $((${errors}*1000/${count}))‰ errors"
fi
done
done # SPECTRE
done # POWER_MODE