selftests: lib: Skip tests on missing test modules
PATCH v2 1/2 selftests: lib: Skip tests on missing test modules
With older kernels, printf.sh and bitmap.sh fail because they can't find the respective test modules they are looking for.
Add the skip portion on missing the respective test_XXX module. Error out with the same error code as prime_numbers.sh.
v2: Per Shuah's review, search for the module rather than do modprobe.
--- tools/testing/selftests/lib/bitmap.sh | 6 ++++++ tools/testing/selftests/lib/printf.sh | 6 ++++++ 2 files changed, 12 insertions(+)
tools/testing/selftests/lib/bitmap.sh +6 -0
@@ -1,6 +1,12 @@ #!/bin/sh # Runs bitmap infrastructure tests using test_bitmap kernel module +if ! find /lib/modules/$(uname -r) -type f -name test_bitmap.ko | grep -q .; +then + echo "bitmap: test_bitmap.ko not found [SKIP]" + exit 77 +fi + if /sbin/modprobe -q test_bitmap; then /sbin/modprobe -q -r test_bitmap echo "bitmap: ok"
tools/testing/selftests/lib/printf.sh +6 -0
@@ -1,6 +1,12 @@ #!/bin/sh # Runs printf infrastructure using test_printf kernel module +if ! find /lib/modules/$(uname -r) -type f -name test_printf.ko | grep -q .; +then + echo "printf: test_printf.ko not found [SKIP]" + exit 77 +fi + if /sbin/modprobe -q test_printf; then /sbin/modprobe -q -r test_printf echo "printf: ok"
Signature · 1 line
2.7.4
Quoted 38 lines · Sumit Semwal
With older kernels,
printf.shandbitmap.shfail because they can't find the respective test modules they are looking for.Add the skip portion on missing the respective
test_XXXmodule. Error out with the same error code asprime_numbers.sh.v2: Per Shuah's review, search for the module rather than do modprobe.
Signed-off-by Sumit Semwal <[email protected]>--- tools/testing/selftests/lib/bitmap.sh | 6 ++++++ tools/testing/selftests/lib/printf.sh | 6 ++++++ 2 files changed, 12 insertions(+)tools/testing/selftests/lib/bitmap.sh +6
-0@@ -1,6 +1,12 @@ #!/bin/sh # Runs bitmap infrastructure tests using test_bitmap kernel module +if ! find /lib/modules/$(uname -r) -type f -name test_bitmap.ko | grep -q .; +then + echo "bitmap: test_bitmap.ko not found [SKIP]" + exit 77 +fi + if /sbin/modprobe -q test_bitmap; then /sbin/modprobe -q -r test_bitmap echo "bitmap: ok"tools/testing/selftests/lib/printf.sh +0
-0@@ -1,6 +1,12 @@ #!/bin/sh # Runs printf infrastructure using test_printf kernel module
tools/testing/selftests/lib/printf.sh line 12
Quoted 10 lines
tools/testing/selftests/lib/printf.sh +6
-0+if ! find /lib/modules/$(uname -r) -type f -name test_printf.ko | grep -q .; +then + echo "printf: test_printf.ko not found [SKIP]" + exit 77 +fi + if /sbin/modprobe -q test_printf; then /sbin/modprobe -q -r test_printf echo "printf: ok"
This doesn't seem right to me. Can't these be built-ins too?
-Kees
Signature · 2 lines
Kees Cook Pixel Security
Hi Kees,
Quoted 40 lines · Kees Cook
Quoted 39 lines · Sumit Semwal
With older kernels,
printf.shandbitmap.shfail because they can't find the respective test modules they are looking for.Add the skip portion on missing the respective
test_XXXmodule. Error out with the same error code asprime_numbers.sh.v2: Per Shuah's review, search for the module rather than do modprobe.
Signed-off-by Sumit Semwal <[email protected]>--- tools/testing/selftests/lib/bitmap.sh | 6 ++++++ tools/testing/selftests/lib/printf.sh | 6 ++++++ 2 files changed, 12 insertions(+)tools/testing/selftests/lib/bitmap.sh +6
-0@@ -1,6 +1,12 @@ #!/bin/sh # Runs bitmap infrastructure tests using test_bitmap kernel module +if ! find /lib/modules/$(uname -r) -type f -name test_bitmap.ko | grep -q .; +then + echo "bitmap: test_bitmap.ko not found [SKIP]" + exit 77 +fi + if /sbin/modprobe -q test_bitmap; then /sbin/modprobe -q -r test_bitmap echo "bitmap: ok"tools/testing/selftests/lib/printf.sh +0
-0@@ -1,6 +1,12 @@ #!/bin/sh # Runs printf infrastructure using test_printf kernel module
Quoted 12 lines
tools/testing/selftests/lib/printf.sh line 12
Quoted 9 lines
tools/testing/selftests/lib/printf.sh +6
-0+if ! find /lib/modules/$(uname -r) -type f -name test_printf.ko | grep -q .; +then + echo "printf: test_printf.ko not found [SKIP]" + exit 77 +fi + if /sbin/modprobe -q test_printf; then /sbin/modprobe -q -r test_printf echo "printf: ok"This doesn't seem right to me. Can't these be built-ins too?
Yes, it can be. I'm running test right now to check presence of module with -q -n; that should take care of builtin as well. will send an updated patch soon.
Quoted 5 lines
-Kees
--
Kees Cook
Pixel Security
Best,
Sumit.