Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 82337406 authored by Shuah Khan (Samsung OSG)'s avatar Shuah Khan (Samsung OSG)
Browse files

selftests: kmod: return Kselftest Skip code for skipped tests



When kmod test is skipped because of unmet dependencies and/or unsupported
configuration, it returns 0 which is treated as a pass by the Kselftest
framework. This leads to false positive result even when the test could
not be run. It returns fail in some cases when test is skipped. Either way,
it is incorrect and incosnistent reporting.

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>
Reviewed-by: default avatarLuis R. Rodriguez <mcgrof@kernel.org>
Signed-off-by: default avatarShuah Khan (Samsung OSG) <shuah@kernel.org>
parent 6004881f
Loading
Loading
Loading
Loading
+8 −5
Original line number Original line Diff line number Diff line
@@ -62,13 +62,16 @@ ALL_TESTS="$ALL_TESTS 0007:5:1"
ALL_TESTS="$ALL_TESTS 0008:150:1"
ALL_TESTS="$ALL_TESTS 0008:150:1"
ALL_TESTS="$ALL_TESTS 0009:150:1"
ALL_TESTS="$ALL_TESTS 0009:150:1"


# Kselftest framework requirement - SKIP code is 4.
ksft_skip=4

test_modprobe()
test_modprobe()
{
{
       if [ ! -d $DIR ]; then
       if [ ! -d $DIR ]; then
               echo "$0: $DIR not present" >&2
               echo "$0: $DIR not present" >&2
               echo "You must have the following enabled in your kernel:" >&2
               echo "You must have the following enabled in your kernel:" >&2
               cat $TEST_DIR/config >&2
               cat $TEST_DIR/config >&2
               exit 1
               exit $ksft_skip
       fi
       fi
}
}


@@ -105,12 +108,12 @@ test_reqs()
{
{
	if ! which modprobe 2> /dev/null > /dev/null; then
	if ! which modprobe 2> /dev/null > /dev/null; then
		echo "$0: You need modprobe installed" >&2
		echo "$0: You need modprobe installed" >&2
		exit 1
		exit $ksft_skip
	fi
	fi


	if ! which kmod 2> /dev/null > /dev/null; then
	if ! which kmod 2> /dev/null > /dev/null; then
		echo "$0: You need kmod installed" >&2
		echo "$0: You need kmod installed" >&2
		exit 1
		exit $ksft_skip
	fi
	fi


	# kmod 19 has a bad bug where it returns 0 when modprobe
	# kmod 19 has a bad bug where it returns 0 when modprobe
@@ -124,13 +127,13 @@ test_reqs()
		echo "$0: You need at least kmod 20" >&2
		echo "$0: You need at least kmod 20" >&2
		echo "kmod <= 19 is buggy, for details see:" >&2
		echo "kmod <= 19 is buggy, for details see:" >&2
		echo "http://git.kernel.org/cgit/utils/kernel/kmod/kmod.git/commit/libkmod/libkmod-module.c?id=fd44a98ae2eb5eb32161088954ab21e58e19dfc4" >&2
		echo "http://git.kernel.org/cgit/utils/kernel/kmod/kmod.git/commit/libkmod/libkmod-module.c?id=fd44a98ae2eb5eb32161088954ab21e58e19dfc4" >&2
		exit 1
		exit $ksft_skip
	fi
	fi


	uid=$(id -u)
	uid=$(id -u)
	if [ $uid -ne 0 ]; then
	if [ $uid -ne 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
}
}