Re: [PATCH v4 2/6] kselftest: Add test runner creation script

From: Kees Cook
Date: Wed Oct 30 2019 - 15:16:44 EST


On Wed, Oct 30, 2019 at 06:15:22PM +0530, Naresh Kamboju wrote:
> Hi Tobin,
>
> On Fri, 5 Apr 2019 at 07:30, Tobin C. Harding <tobin@xxxxxxxxxx> wrote:
> >
> > Currently if we wish to use kselftest to run tests within a kernel
> > module we write a small script to load/unload and do error reporting.
> > There are a bunch of these under tools/testing/selftests/lib/ that are
> > all identical except for the test name. We can reduce code duplication
> > and improve maintainability if we have one version of this. However
> > kselftest requires an executable for each test. We can move all the
> > script logic to a central script then have each individual test script
> > call the main script.
> >
> > Oneliner to call kselftest_module.sh courtesy of Kees, thanks!
> >
> > Add test runner creation script. Convert
> > tools/testing/selftests/lib/*.sh to use new test creation script.
> >
> > Testing
> > -------
> >
> > Configure kselftests for lib/ then build and boot kernel. Then run
> > kselftests as follows:
> >
> > $ cd /path/to/kernel/tree
> > $ sudo make O=$output_path -C tools/testing/selftests TARGETS="lib" run_tests
>
> We are missing "kselftest_module.sh" file when we do "make install"
> and followed by generating a tar file "gen_kselftest_tar.sh" and
> copying that on to target device and running tests by using
> "run_kselftest.sh" script file on the target.

Yikes -- there's a problem with gen_kselftest_tar.sh using the wrong
directory. I'll send a patch...

-Kees

>
> Could you install the supporting script file "kselftest_module.sh" ?
>
> Error log,
> -------------
> # selftests lib printf.sh
> lib: printf.sh_ #
> # ./printf.sh line 4 ./../kselftest_module.sh No such file or directory
> line: 4_./../kselftest_module.sh #
> [FAIL] 1 selftests lib printf.sh # exit=127
> selftests: lib_printf.sh [FAIL]
> # selftests lib bitmap.sh
> lib: bitmap.sh_ #
> # ./bitmap.sh line 3 ./../kselftest_module.sh No such file or directory
> line: 3_./../kselftest_module.sh #
> [FAIL] 2 selftests lib bitmap.sh # exit=127
> selftests: lib_bitmap.sh [FAIL]
> # selftests lib prime_numbers.sh
> lib: prime_numbers.sh_ #
> # ./prime_numbers.sh line 4 ./../kselftest_module.sh No such file or directory
> line: 4_./../kselftest_module.sh #
> [FAIL] 3 selftests lib prime_numbers.sh # exit=127
> selftests: lib_prime_numbers.sh [FAIL]
> # selftests lib strscpy.sh
> lib: strscpy.sh_ #
> # ./strscpy.sh line 3 ./../kselftest_module.sh No such file or directory
> line: 3_./../kselftest_module.sh #
> [FAIL] 4 selftests lib strscpy.sh # exit=127
> selftests: lib_strscpy.sh [FAIL]
>
> - Naresh

--
Kees Cook