selftests: memory-hotplug: return Kselftest Skip code for skipped tests

When memory-hotplug test is skipped because of unmet dependencies and/or
unsupported configuration, it returns non-zero value hich is treated as a
fail by the Kselftest framework. This leads to false negative result even
when the test could not be run.

Change it to return kselftest skip code when a test gets skipped to
clearly report that the test could not be run.

Kselftest framework SKIP code is 4 and the framework prints appropriate
messages to indicate that the test is skipped.
Signed-off-by: default avatarShuah Khan (Samsung OSG) <shuah@kernel.org>
parent b27f0259
...@@ -3,30 +3,33 @@ ...@@ -3,30 +3,33 @@
SYSFS= SYSFS=
# Kselftest framework requirement - SKIP code is 4.
ksft_skip=4
prerequisite() prerequisite()
{ {
msg="skip all tests:" msg="skip all tests:"
if [ $UID != 0 ]; then if [ $UID != 0 ]; then
echo $msg must be run as root >&2 echo $msg must be run as root >&2
exit 0 exit $ksft_skip
fi fi
SYSFS=`mount -t sysfs | head -1 | awk '{ print $3 }'` SYSFS=`mount -t sysfs | head -1 | awk '{ print $3 }'`
if [ ! -d "$SYSFS" ]; then if [ ! -d "$SYSFS" ]; then
echo $msg sysfs is not mounted >&2 echo $msg sysfs is not mounted >&2
exit 0 exit $ksft_skip
fi fi
if ! ls $SYSFS/devices/system/memory/memory* > /dev/null 2>&1; then if ! ls $SYSFS/devices/system/memory/memory* > /dev/null 2>&1; then
echo $msg memory hotplug is not supported >&2 echo $msg memory hotplug is not supported >&2
exit 0 exit $ksft_skip
fi fi
if ! grep -q 1 $SYSFS/devices/system/memory/memory*/removable; then if ! grep -q 1 $SYSFS/devices/system/memory/memory*/removable; then
echo $msg no hot-pluggable memory >&2 echo $msg no hot-pluggable memory >&2
exit 0 exit $ksft_skip
fi fi
} }
......
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