summaryrefslogtreecommitdiff
path: root/bin
diff options
authorJeff Lane <jeffrey.lane@canonical.com>2016-09-13 17:21:57 +0000
committerSylvain Pineau <>2016-09-13 17:21:57 +0000
commit4b906c261bedcb2693ff3835227ec6e8ed4d7dbb (patch)
tree0e10242dcacdedb8d9e9e0e07d5dba985bfa5480 /bin
parenta1e847809cc863b331f6fb52afef0939b87bb01f (diff)
parentab8e82749b0ee4b651c1f6c7406d1d0dec10a876 (diff)
"automatic merge of lp:~bladernr/checkbox/1614671-quiet-cpu_offlining/ by tarmac [r=sylvain-pineau][bug=1614671][author=bladernr]"
Diffstat (limited to 'bin')
-rwxr-xr-xbin/cpu_offlining32
1 files changed, 19 insertions, 13 deletions
diff --git a/bin/cpu_offlining b/bin/cpu_offlining
index 0e88af1..7f1095a 100755
--- a/bin/cpu_offlining
+++ b/bin/cpu_offlining
@@ -1,22 +1,24 @@
#!/bin/bash
-echo "Beginning CPU Offlining Test" 1>&2
-
result=0
cpu_count=0
+offline_fails="Offline Failed:"
+online_fails="Online Failed:"
+exitcode=0
# Turn CPU cores off
for cpu_num in `ls /sys/devices/system/cpu | grep -o cpu[0-9]*`; do
if [ -f /sys/devices/system/cpu/$cpu_num/online ]; then
if [ "$cpu_num" != "cpu0" ]; then
((cpu_count++))
- echo "Offlining $cpu_num" 1>&2
echo 0 > /sys/devices/system/cpu/$cpu_num/online
-
- grep -w -i -q $cpu_num /proc/interrupts
- if [ $? -eq 0 ]; then
+ sleep 0.5
+ output=`grep -w -i $cpu_num /proc/interrupts`
+ result=$?
+ if [ $result -eq 0 ]; then
echo "ERROR: Failed to offline $cpu_num" 1>&2
- result=1
+ offline_fails="$offline_fails $cpu_num"
+ exitcode=1
fi
fi
fi
@@ -26,21 +28,25 @@ done
for cpu_num in `ls /sys/devices/system/cpu | grep -o cpu[0-9]*`; do
if [ -f /sys/devices/system/cpu/$cpu_num/online ]; then
if [ "$cpu_num" != "cpu0" ]; then
- echo "Onlining $cpu_num" 1>&2
echo 1 > /sys/devices/system/cpu/$cpu_num/online
- grep -w -i -q $cpu_num /proc/interrupts
- if [ $? -eq 1 ]; then
+ sleep 0.5
+ output=`grep -w -i $cpu_num /proc/interrupts`
+ result=$?
+ if [ $result -eq 1 ]; then
echo "ERROR: Failed to online $cpu_num" 1>&2
- result=1
+ online_fails="$online_fails $cpu_num"
+ exitcode=1
fi
fi
fi
done
-if [ $result -eq 0 ]; then
+if [ $exitcode -eq 0 ]; then
echo "Successfully turned $cpu_count cores off and back on"
else
echo "Error with offlining one or more cores. CPU offline may not work if this is an ARM system." 1>&2
+ echo $offline_fails 1>&2
+ echo $online_fails 1>&2
fi
-exit $result
+exit $exitcode