public inbox for live-patching@vger.kernel.org
 help / color / mirror / Atom feed
From: Petr Mladek <pmladek@suse.com>
To: Marcos Paulo de Souza <mpdesouza@suse.com>
Cc: Josh Poimboeuf <jpoimboe@kernel.org>,
	Jiri Kosina <jikos@kernel.org>, Miroslav Benes <mbenes@suse.cz>,
	Joe Lawrence <joe.lawrence@redhat.com>,
	Shuah Khan <shuah@kernel.org>,
	live-patching@vger.kernel.org, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 5/8] selftests: livepatch: sysfs: Split tests of replace attribute
Date: Fri, 20 Mar 2026 14:12:03 +0100	[thread overview]
Message-ID: <ab1Ho0jqOhFu3KZn@pathway.suse.cz> (raw)
In-Reply-To: <20260313-lp-tests-old-fixes-v1-5-71ac6dfb3253@suse.com>

On Fri 2026-03-13 17:58:36, Marcos Paulo de Souza wrote:
> In order to run the selftests on older kernels, split the sysfs tests to
> another file, making it able to skip the tests when the attributes
> don't exists.
> 
> No functional changes.
> 
> Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
> ---
>  tools/testing/selftests/livepatch/Makefile         |  1 +
>  .../selftests/livepatch/test-sysfs-replace-attr.sh | 75 ++++++++++++++++++++++
>  tools/testing/selftests/livepatch/test-sysfs.sh    | 48 --------------
>  3 files changed, 76 insertions(+), 48 deletions(-)
> 
> diff --git a/tools/testing/selftests/livepatch/Makefile b/tools/testing/selftests/livepatch/Makefile
> index a080eb54a215d..b95aa6e78a273 100644
> --- a/tools/testing/selftests/livepatch/Makefile
> +++ b/tools/testing/selftests/livepatch/Makefile
> @@ -10,6 +10,7 @@ TEST_PROGS := \
>  	test-state.sh \
>  	test-ftrace.sh \
>  	test-sysfs.sh \
> +	test-sysfs-replace-attr.sh \
>  	test-syscall.sh \
>  	test-kprobe.sh
>  
> diff --git a/tools/testing/selftests/livepatch/test-sysfs-replace-attr.sh b/tools/testing/selftests/livepatch/test-sysfs-replace-attr.sh
> new file mode 100755
> index 0000000000000..d1051211fe320
> --- /dev/null
> +++ b/tools/testing/selftests/livepatch/test-sysfs-replace-attr.sh
> @@ -0,0 +1,75 @@
> +#!/bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (C) 2022 Song Liu <song@kernel.org>
> +
> +. $(dirname $0)/functions.sh
> +
> +MOD_LIVEPATCH=test_klp_livepatch
> +
> +setup_config
> +
> +# - load a livepatch and verifies the sysfs replace attribute exists
> +
> +start_test "check sysfs replace attribute"
> +
> +load_lp $MOD_LIVEPATCH
> +
> +check_sysfs_exists "$MOD_LIVEPATCH" "replace"
> +file_exists=$?
> +
> +disable_lp $MOD_LIVEPATCH
> +
> +unload_lp $MOD_LIVEPATCH
> +
> +if [[ "$file_exists" == "0" ]]; then
> +	skip "sysfs attribute doesn't exists."

Nit: I would write "is not supported by this kernel version"
     instead of "doesn't exist".

     I think that it better describes the situation.
     "doesn't exist" sounds more like an error description.

> +fi

This extra code is repeated in 6th and 7th patch as well.
It would be nice to hide it into some helper function
so that we could use here something like:

	check_sysfs_attr_or_skip "replace"

or

	if has_klp_sysfs_attr "replace" ; then
		skip "sysfs \"replace\" attribute is not supported"
	fi

Best Regards,
Petr

  parent reply	other threads:[~2026-03-20 13:12 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-13 20:58 [PATCH 0/8] kselftests: livepatch: Adapt tests to be executed on 4.12 kernels Marcos Paulo de Souza
2026-03-13 20:58 ` [PATCH 1/8] selftests: livepatch: test-syscall: Check for ARCH_HAS_SYSCALL_WRAPPER Marcos Paulo de Souza
2026-03-16 20:12   ` Joe Lawrence
2026-03-19 12:54     ` Miroslav Benes
2026-03-19 14:11       ` Marcos Paulo de Souza
2026-03-20 10:45         ` Miroslav Benes
2026-03-27 13:24           ` Marcos Paulo de Souza
2026-03-27 13:16     ` Marcos Paulo de Souza
2026-03-13 20:58 ` [PATCH 2/8] selftests: livepatch: test-kprobe: Replace true/false mod param by 1/0 Marcos Paulo de Souza
2026-03-19 13:03   ` Miroslav Benes
2026-03-19 14:16     ` Marcos Paulo de Souza
2026-03-20 11:18       ` Miroslav Benes
2026-03-13 20:58 ` [PATCH 3/8] selftests: livepatch: test-kprobe: Check if kprobes can work with livepatches Marcos Paulo de Souza
2026-03-16 20:38   ` Joe Lawrence
2026-03-19 14:35     ` Marcos Paulo de Souza
2026-03-20 11:33       ` Petr Mladek
2026-03-27 13:43         ` Marcos Paulo de Souza
2026-03-13 20:58 ` [PATCH 4/8] selftests: livepatch: functions: Introduce check_sysfs_exists Marcos Paulo de Souza
2026-03-16 20:47   ` Joe Lawrence
2026-03-13 20:58 ` [PATCH 5/8] selftests: livepatch: sysfs: Split tests of replace attribute Marcos Paulo de Souza
2026-03-20 13:03   ` Miroslav Benes
2026-03-20 13:12   ` Petr Mladek [this message]
2026-03-13 20:58 ` [PATCH 6/8] selftests: livepatch: sysfs: Split tests of stack_order attribute Marcos Paulo de Souza
2026-03-13 20:58 ` [PATCH 7/8] selftests: livepatch: sysfs: Split tests of patched attribute Marcos Paulo de Souza
2026-03-13 20:58 ` [PATCH 8/8] selftests: livepatch: functions.sh: Extend check for taint flag kernel message Marcos Paulo de Souza
2026-03-20 13:04   ` Miroslav Benes
2026-03-20 13:26   ` Petr Mladek
2026-03-20 13:41     ` Marcos Paulo de Souza
2026-03-20 13:31 ` [PATCH 0/8] kselftests: livepatch: Adapt tests to be executed on 4.12 kernels Petr Mladek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ab1Ho0jqOhFu3KZn@pathway.suse.cz \
    --to=pmladek@suse.com \
    --cc=jikos@kernel.org \
    --cc=joe.lawrence@redhat.com \
    --cc=jpoimboe@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=live-patching@vger.kernel.org \
    --cc=mbenes@suse.cz \
    --cc=mpdesouza@suse.com \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox