aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing
diff options
context:
space:
mode:
authorColin Ian King <colin.king@canonical.com>2019-01-10 07:38:02 -0500
committerShuah Khan <shuah@kernel.org>2019-01-25 16:57:45 -0500
commit2b531b6137834a55857a337ac17510d6436b6fbb (patch)
tree19a15bd955ef9927db0f893bb8d755d985712906 /tools/testing
parent3d244c192afeee7dd4f5fb1b916ea4e47420d401 (diff)
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: d89dffa976bc ("fault-injection: add selftests for cpu and memory hotplug") Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Shuah Khan <shuah@kernel.org>
Diffstat (limited to 'tools/testing')
-rwxr-xr-xtools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh13
1 files changed, 10 insertions, 3 deletions
diff --git a/tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh b/tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh
index bab13dd025a6..0d26b5e3f966 100755
--- a/tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh
+++ b/tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh
@@ -37,6 +37,10 @@ prerequisite()
37 exit $ksft_skip 37 exit $ksft_skip
38 fi 38 fi
39 39
40 present_cpus=`cat $SYSFS/devices/system/cpu/present`
41 present_max=${present_cpus##*-}
42 echo "present_cpus = $present_cpus present_max = $present_max"
43
40 echo -e "\t Cpus in online state: $online_cpus" 44 echo -e "\t Cpus in online state: $online_cpus"
41 45
42 offline_cpus=`cat $SYSFS/devices/system/cpu/offline` 46 offline_cpus=`cat $SYSFS/devices/system/cpu/offline`
@@ -151,6 +155,8 @@ online_cpus=0
151online_max=0 155online_max=0
152offline_cpus=0 156offline_cpus=0
153offline_max=0 157offline_max=0
158present_cpus=0
159present_max=0
154 160
155while getopts e:ahp: opt; do 161while getopts e:ahp: opt; do
156 case $opt in 162 case $opt in
@@ -190,9 +196,10 @@ if [ $allcpus -eq 0 ]; then
190 online_cpu_expect_success $online_max 196 online_cpu_expect_success $online_max
191 197
192 if [[ $offline_cpus -gt 0 ]]; then 198 if [[ $offline_cpus -gt 0 ]]; then
193 echo -e "\t offline to online to offline: cpu $offline_max" 199 echo -e "\t offline to online to offline: cpu $present_max"
194 online_cpu_expect_success $offline_max 200 online_cpu_expect_success $present_max
195 offline_cpu_expect_success $offline_max 201 offline_cpu_expect_success $present_max
202 online_cpu $present_max
196 fi 203 fi
197 exit 0 204 exit 0
198else 205else