aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShuah Khan (Samsung OSG) <shuah@kernel.org>2018-05-03 21:38:41 -0400
committerShuah Khan (Samsung OSG) <shuah@kernel.org>2018-05-30 17:21:53 -0400
commit82337406d10bf48aa7cb356dafbd056edab09843 (patch)
tree47e70ba2d606dc9aaabb68e75586c60ebcfb0c40
parent6004881fa0730fed08a2a719a81efba6003d9d36 (diff)
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: Shuah Khan (Samsung OSG) <shuah@kernel.org> Reviewed-by: Luis R. Rodriguez <mcgrof@kernel.org> Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>
-rwxr-xr-xtools/testing/selftests/kmod/kmod.sh13
1 files changed, 8 insertions, 5 deletions
diff --git a/tools/testing/selftests/kmod/kmod.sh b/tools/testing/selftests/kmod/kmod.sh
index 7956ea3be667..0a76314b4414 100755
--- a/tools/testing/selftests/kmod/kmod.sh
+++ b/tools/testing/selftests/kmod/kmod.sh
@@ -62,13 +62,16 @@ ALL_TESTS="$ALL_TESTS 0007:5:1"
62ALL_TESTS="$ALL_TESTS 0008:150:1" 62ALL_TESTS="$ALL_TESTS 0008:150:1"
63ALL_TESTS="$ALL_TESTS 0009:150:1" 63ALL_TESTS="$ALL_TESTS 0009:150:1"
64 64
65# Kselftest framework requirement - SKIP code is 4.
66ksft_skip=4
67
65test_modprobe() 68test_modprobe()
66{ 69{
67 if [ ! -d $DIR ]; then 70 if [ ! -d $DIR ]; then
68 echo "$0: $DIR not present" >&2 71 echo "$0: $DIR not present" >&2
69 echo "You must have the following enabled in your kernel:" >&2 72 echo "You must have the following enabled in your kernel:" >&2
70 cat $TEST_DIR/config >&2 73 cat $TEST_DIR/config >&2
71 exit 1 74 exit $ksft_skip
72 fi 75 fi
73} 76}
74 77
@@ -105,12 +108,12 @@ test_reqs()
105{ 108{
106 if ! which modprobe 2> /dev/null > /dev/null; then 109 if ! which modprobe 2> /dev/null > /dev/null; then
107 echo "$0: You need modprobe installed" >&2 110 echo "$0: You need modprobe installed" >&2
108 exit 1 111 exit $ksft_skip
109 fi 112 fi
110 113
111 if ! which kmod 2> /dev/null > /dev/null; then 114 if ! which kmod 2> /dev/null > /dev/null; then
112 echo "$0: You need kmod installed" >&2 115 echo "$0: You need kmod installed" >&2
113 exit 1 116 exit $ksft_skip
114 fi 117 fi
115 118
116 # kmod 19 has a bad bug where it returns 0 when modprobe 119 # kmod 19 has a bad bug where it returns 0 when modprobe
@@ -124,13 +127,13 @@ test_reqs()
124 echo "$0: You need at least kmod 20" >&2 127 echo "$0: You need at least kmod 20" >&2
125 echo "kmod <= 19 is buggy, for details see:" >&2 128 echo "kmod <= 19 is buggy, for details see:" >&2
126 echo "http://git.kernel.org/cgit/utils/kernel/kmod/kmod.git/commit/libkmod/libkmod-module.c?id=fd44a98ae2eb5eb32161088954ab21e58e19dfc4" >&2 129 echo "http://git.kernel.org/cgit/utils/kernel/kmod/kmod.git/commit/libkmod/libkmod-module.c?id=fd44a98ae2eb5eb32161088954ab21e58e19dfc4" >&2
127 exit 1 130 exit $ksft_skip
128 fi 131 fi
129 132
130 uid=$(id -u) 133 uid=$(id -u)
131 if [ $uid -ne 0 ]; then 134 if [ $uid -ne 0 ]; then
132 echo $msg must be run as root >&2 135 echo $msg must be run as root >&2
133 exit 0 136 exit $ksft_skip
134 fi 137 fi
135} 138}
136 139