On Tue, Mar 18, 2025 at 06:20:36PM -0300, Filipe Xavier wrote: > This new test makes sure that ftrace can trace a > function that was introduced by a livepatch. > > Signed-off-by: Filipe Xavier <felipeagg...@gmail.com> > --- > tools/testing/selftests/livepatch/test-ftrace.sh | 34 > ++++++++++++++++++++++++ > 1 file changed, 34 insertions(+) > > diff --git a/tools/testing/selftests/livepatch/test-ftrace.sh > b/tools/testing/selftests/livepatch/test-ftrace.sh > index > fe14f248913acbec46fb6c0fec38a2fc84209d39..4937c74de0e4d34e4e692f20ee2bbe3cd6f5a232 > 100755 > --- a/tools/testing/selftests/livepatch/test-ftrace.sh > +++ b/tools/testing/selftests/livepatch/test-ftrace.sh > @@ -61,4 +61,38 @@ livepatch: '$MOD_LIVEPATCH': unpatching complete > % rmmod $MOD_LIVEPATCH" > > > +# - verify livepatch can load > +# - check if traces have a patched function > +# - reset trace and unload livepatch > + > +start_test "trace livepatched function and check that the live patch remains > in effect" > + > +FUNCTION_NAME="livepatch_cmdline_proc_show" > + > +load_lp $MOD_LIVEPATCH > +trace_function "$FUNCTION_NAME" > + > +if [[ "$(cat /proc/cmdline)" == "$MOD_LIVEPATCH: this has been live patched" > ]] ; then > + log "livepatch: ok" > +fi > + > +check_traced_functions "$FUNCTION_NAME" > + > +disable_lp $MOD_LIVEPATCH > +unload_lp $MOD_LIVEPATCH > + > +check_result "% insmod test_modules/$MOD_LIVEPATCH.ko > +livepatch: enabling patch '$MOD_LIVEPATCH' > +livepatch: '$MOD_LIVEPATCH': initializing patching transition > +livepatch: '$MOD_LIVEPATCH': starting patching transition > +livepatch: '$MOD_LIVEPATCH': completing patching transition > +livepatch: '$MOD_LIVEPATCH': patching complete > +livepatch: ok > +% echo 0 > /sys/kernel/livepatch/$MOD_LIVEPATCH/enabled
A few months ago, 637c730998b8 ("selftests: livepatch: rename KLP_SYSFS_DIR to SYSFS_KLP_DIR") tweaked the functions.sh::SYSFS_KLP_DIR and then updated all of the test-*.sh scripts to use the variable instead of the spelled out "/sys/kernel/livepatch" string. So if there if there is another patchset version, s/\/sys\/kernel\/livepatch/$SYSFS_KLP_DIR/g -- Joe