Commit 2b531b61 authored by Colin Ian King's avatar Colin Ian King Committed by Shuah Khan

selftests: cpu-hotplug: fix case where CPUs offline > CPUs present

The cpu-hotplug test assumes that we can offline the maximum CPU as
described by /sys/devices/system/cpu/offline.  However, in the case
where the number of CPUs exceeds like kernel configuration then
the offline count can be greater than the present count and we end
up trying to test the offlining of a CPU that is not available to
offline.  Fix this by testing the maximum present CPU instead.

Also, the test currently offlines the CPU and does not online it,
so fix this by onlining the CPU after the test.

Fixes: d89dffa9 ("fault-injection: add selftests for cpu and memory hotplug")
Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
Signed-off-by: default avatarShuah Khan <shuah@kernel.org>
parent 3d244c19
...@@ -37,6 +37,10 @@ prerequisite() ...@@ -37,6 +37,10 @@ prerequisite()
exit $ksft_skip exit $ksft_skip
fi fi
present_cpus=`cat $SYSFS/devices/system/cpu/present`
present_max=${present_cpus##*-}
echo "present_cpus = $present_cpus present_max = $present_max"
echo -e "\t Cpus in online state: $online_cpus" echo -e "\t Cpus in online state: $online_cpus"
offline_cpus=`cat $SYSFS/devices/system/cpu/offline` offline_cpus=`cat $SYSFS/devices/system/cpu/offline`
...@@ -151,6 +155,8 @@ online_cpus=0 ...@@ -151,6 +155,8 @@ online_cpus=0
online_max=0 online_max=0
offline_cpus=0 offline_cpus=0
offline_max=0 offline_max=0
present_cpus=0
present_max=0
while getopts e:ahp: opt; do while getopts e:ahp: opt; do
case $opt in case $opt in
...@@ -190,9 +196,10 @@ if [ $allcpus -eq 0 ]; then ...@@ -190,9 +196,10 @@ if [ $allcpus -eq 0 ]; then
online_cpu_expect_success $online_max online_cpu_expect_success $online_max
if [[ $offline_cpus -gt 0 ]]; then if [[ $offline_cpus -gt 0 ]]; then
echo -e "\t offline to online to offline: cpu $offline_max" echo -e "\t offline to online to offline: cpu $present_max"
online_cpu_expect_success $offline_max online_cpu_expect_success $present_max
offline_cpu_expect_success $offline_max offline_cpu_expect_success $present_max
online_cpu $present_max
fi fi
exit 0 exit 0
else else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment