Skip to contentSkip to conversation

selftest: don't offline the last CPU in cpu hotplug test

PATCH New Lai Jiangshan 1 participant 2 messages Dec 17, 2020 Kselftest

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 selftest: don't offline the last CPU in cpu hotplug test

From: Lai Jiangshan <[email protected]>

In my box, all CPUs are allowed to be offline. The test tries to offline all offline-able CPUs and causes fail on the last one. We should just skip offlining the last CPU

---
 tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh | 5 +++++
 1 file changed, 5 insertions(+)
tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh +5 -0
index 0d26b5e3f966..5cdef96326a7 100755
@@ -126,6 +126,11 @@ offline_cpu_expect_success()
 {
 	local cpu=$1
 
+	# don't offline the last CPU if all CPUs are offline-able
+	if [[ a$cpu = a`cat $SYSFS/devices/system/cpu/online` ]]; then
+		return
+	fi
+
 	if ! offline_cpu $cpu; then
 		echo $FUNCNAME $cpu: unexpected fail >&2
 		exit 1
Signature · 1 line
2.19.1.6.gb485710b
#1 lore raw

PATCH 2/2 selftest: parse the max cpu corretly from cpu list string

From: Lai Jiangshan <[email protected]>

"," is allowed in cpu list strings, such as "0-3,5". We need to handle these cases.

---
 tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh +3 -3
index 5cdef96326a7..ac37bd54ea1c 100755
@@ -30,7 +30,7 @@ prerequisite()
 
 	echo "CPU online/offline summary:"
 	online_cpus=`cat $SYSFS/devices/system/cpu/online`
-	online_max=${online_cpus##*-}
+	online_max=${online_cpus##*[-|,]}
 
 	if [[ "$online_cpus" = "$online_max" ]]; then
 		echo "$msg: since there is only one cpu: $online_cpus"
@@ -38,7 +38,7 @@ prerequisite()
 	fi
 
 	present_cpus=`cat $SYSFS/devices/system/cpu/present`
-	present_max=${present_cpus##*-}
+	present_max=${present_cpus##*[-|,]}
 	echo "present_cpus = $present_cpus present_max = $present_max"
 
 	echo -e "\t Cpus in online state: $online_cpus"
@@ -47,7 +47,7 @@ prerequisite()
 	if [[ "a$offline_cpus" = "a" ]]; then
 		offline_cpus=0
 	else
-		offline_max=${offline_cpus##*-}
+		offline_max=${offline_cpus##*[-|,]}
 	fi
 	echo -e "\t Cpus in offline state: $offline_cpus"
 }
Signature · 1 line
2.19.1.6.gb485710b