Re: [PATCH v6 2/3] livepatch: Move tests from lib/livepatch to selftests/livepatch

mpdesouza
2024-01-18T01:53:00Z

On Wed, 2024-01-17 at 16:40 +0100, Alexander Gordeev wrote:
> On Fri, Jan 12, 2024 at 02:43:51PM -0300, Marcos Paulo de Souza
> wrote:
>
> Hi Marcos!

Hello!

>
> > Having the modules being built as out-of-modules requires changing
> > the
> > currently used 'modprobe' by 'insmod' and adapt the test scripts
> > that
> > check for the kernel message buffer.
>
> Please, correct me if I am wrong, but with this change one would
> require a configured build environment and kernel tree that matches
> running kernel in order to run tests. Is that correct?

You don't need a kernel tree in order to run the tests, you can build
the modules and use gen_tar to pack them, setting KDIR to the currently
built kernel:
make KDIR=$(pwd) TARGETS=livepatch -C
tools/testing/selftests

This can be used when packaging the tests, like Joe showed when
reviewing the v4:

mkdir /tmp/test-install
make KDIR=$(pwd) INSTALL_PATH=/tmp/test-install
TARGETS=livepatch -C tools/testing/selftests install

In this case /tmp/test-install will contain the scripts and the modules
compiled targeting the same kernel version from the kernel built from
the kernel tree.

You can also run the tests from the kernel tree but targeting your
currently running system.
Using this approach you can run the tests on machines without kernel
tree and without build environment.

You can also pick the kernel source and run
make kselftest TARGETS=livepatch

As KDIR wasn't set it builds the livepatch test modules targeting
/lib/modules/<current kernel version/build, and so you can run the
tests against your currently running kernel. This would require kernel-
devel package and gcc.

I hope this answer your question, and provides some info about how to
run the tests on different environments!

Thanks,
Marcos

>
> Thanks!