Skip to content

Commit

Permalink
selftests/cpu-hotplug: Use return instead of exit
Browse files Browse the repository at this point in the history
[ Upstream commit 972cf4c ]

Some cpus will be left in offline state when online
function exits in some error conditions. Use return
instead of exit to fix it.

Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Stable-dep-of: 51d4c85 ("selftests/cpu-hotplug: Reserve one cpu online at least")
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
zhaogongyi authored and gregkh committed Oct 21, 2022
1 parent 7308591 commit c5cc950
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
SYSFS=
# Kselftest framework requirement - SKIP code is 4.
ksft_skip=4
retval=0

prerequisite()
{
Expand Down Expand Up @@ -102,10 +103,10 @@ online_cpu_expect_success()

if ! online_cpu $cpu; then
echo $FUNCNAME $cpu: unexpected fail >&2
exit 1
retval=1
elif ! cpu_is_online $cpu; then
echo $FUNCNAME $cpu: unexpected offline >&2
exit 1
retval=1
fi
}

Expand All @@ -128,10 +129,10 @@ offline_cpu_expect_success()

if ! offline_cpu $cpu; then
echo $FUNCNAME $cpu: unexpected fail >&2
exit 1
retval=1
elif ! cpu_is_offline $cpu; then
echo $FUNCNAME $cpu: unexpected offline >&2
exit 1
retval=1
fi
}

Expand Down Expand Up @@ -201,7 +202,7 @@ if [ $allcpus -eq 0 ]; then
offline_cpu_expect_success $present_max
online_cpu $present_max
fi
exit 0
exit $retval
else
echo "Full scope test: all hotplug cpus"
echo -e "\t online all offline cpus"
Expand Down Expand Up @@ -291,3 +292,5 @@ done

echo 0 > $NOTIFIER_ERR_INJECT_DIR/actions/CPU_DOWN_PREPARE/error
/sbin/modprobe -q -r cpu-notifier-error-inject

exit $retval

0 comments on commit c5cc950

Please sign in to comment.