Re: [PATCH v14 11/11] selftests/livepatch: introduce tests

From: Alice Ferrazzi
Date: Sat Dec 08 2018 - 11:54:22 EST


On 29-11-2018 10:44, Petr Mladek wrote:
> From: Joe Lawrence <joe.lawrence@xxxxxxxxxx>
>
> Add a few livepatch modules and simple target modules that the included
> regression suite can run tests against:
>
> - basic livepatching (multiple patches, atomic replace)
> - pre/post (un)patch callbacks
> - shadow variable API
>
> Signed-off-by: Joe Lawrence <joe.lawrence@xxxxxxxxxx>
> Signed-off-by: Petr Mladek <pmladek@xxxxxxxx>
> ---
> Documentation/livepatch/callbacks.txt | 489 +----------------
> MAINTAINERS | 1 +
> lib/Kconfig.debug | 21 +
> lib/Makefile | 2 +
> lib/livepatch/Makefile | 15 +
> lib/livepatch/test_klp_atomic_replace.c | 57 ++
> lib/livepatch/test_klp_callbacks_busy.c | 43 ++
> lib/livepatch/test_klp_callbacks_demo.c | 121 +++++
> lib/livepatch/test_klp_callbacks_demo2.c | 93 ++++
> lib/livepatch/test_klp_callbacks_mod.c | 24 +
> lib/livepatch/test_klp_livepatch.c | 51 ++
> lib/livepatch/test_klp_shadow_vars.c | 236 +++++++++
> tools/testing/selftests/Makefile | 1 +
> tools/testing/selftests/livepatch/Makefile | 8 +
> tools/testing/selftests/livepatch/README | 43 ++
> tools/testing/selftests/livepatch/config | 1 +
> tools/testing/selftests/livepatch/functions.sh | 203 +++++++
> .../testing/selftests/livepatch/test-callbacks.sh | 587 +++++++++++++++++++++
> .../testing/selftests/livepatch/test-livepatch.sh | 168 ++++++
> .../selftests/livepatch/test-shadow-vars.sh | 60 +++
> 20 files changed, 1740 insertions(+), 484 deletions(-)
> create mode 100644 lib/livepatch/Makefile
> create mode 100644 lib/livepatch/test_klp_atomic_replace.c
> create mode 100644 lib/livepatch/test_klp_callbacks_busy.c
> create mode 100644 lib/livepatch/test_klp_callbacks_demo.c
> create mode 100644 lib/livepatch/test_klp_callbacks_demo2.c
> create mode 100644 lib/livepatch/test_klp_callbacks_mod.c
> create mode 100644 lib/livepatch/test_klp_livepatch.c
> create mode 100644 lib/livepatch/test_klp_shadow_vars.c
> create mode 100644 tools/testing/selftests/livepatch/Makefile
> create mode 100644 tools/testing/selftests/livepatch/README
> create mode 100644 tools/testing/selftests/livepatch/config
> create mode 100644 tools/testing/selftests/livepatch/functions.sh
> create mode 100755 tools/testing/selftests/livepatch/test-callbacks.sh
> create mode 100755 tools/testing/selftests/livepatch/test-livepatch.sh
> create mode 100755 tools/testing/selftests/livepatch/test-shadow-vars.sh

I tested the livepatch selftest and it works for me:

```
gentoo_07 linux-dev (alice/livepatch) # make -C tools/testing/selftests
TARGETS=livepatch run_tests
make: Entering directory '/root/linux-dev/tools/testing/selftests'
make[1]: Entering directory
'/root/linux-dev/tools/testing/selftests/livepatch'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory
'/root/linux-dev/tools/testing/selftests/livepatch'
make[1]: Entering directory
'/root/linux-dev/tools/testing/selftests/livepatch'
TAP version 13
selftests: livepatch: test-livepatch.sh
========================================
TEST: basic function patching ... ok
TEST: multiple livepatches ... ok
TEST: atomic replace livepatch ... ok
ok 1..1 selftests: livepatch: test-livepatch.sh [PASS]
selftests: livepatch: test-callbacks.sh
========================================
TEST: target module before livepatch ... ok
TEST: module_coming notifier ... ok
TEST: module_going notifier ... ok
TEST: module_coming and module_going notifiers ... ok
TEST: target module not present ... ok
TEST: pre-patch callback -ENODEV ... ok
TEST: module_coming + pre-patch callback -ENODEV ... ok
TEST: multiple target modules ... ok
TEST: busy target module ... ok
TEST: multiple livepatches ... ok
TEST: atomic replace ... ok
ok 1..2 selftests: livepatch: test-callbacks.sh [PASS]
selftests: livepatch: test-shadow-vars.sh
========================================
TEST: basic shadow variable API ... ok
ok 1..3 selftests: livepatch: test-shadow-vars.sh [PASS]
make[1]: Leaving directory
'/root/linux-dev/tools/testing/selftests/livepatch'
make: Leaving directory '/root/linux-dev/tools/testing/selftests'
```

Tested-by: Alice Ferrazzi <alice.ferrazzi@xxxxxxxxx>