* + selftests-ksft_exit_fail_perror-support-printf-style-arguments.patch added to mm-unstable branch
@ 2026-03-30 19:26 Andrew Morton
0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2026-03-30 19:26 UTC (permalink / raw)
To: mm-commits, chuhu, akpm
The patch titled
Subject: selftests: ksft_exit_fail_perror: support printf style arguments
has been added to the -mm mm-unstable branch. Its filename is
selftests-ksft_exit_fail_perror-support-printf-style-arguments.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/selftests-ksft_exit_fail_perror-support-printf-style-arguments.patch
This patch will later appear in the mm-unstable branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days
------------------------------------------------------
From: Chunyu Hu <chuhu@redhat.com>
Subject: selftests: ksft_exit_fail_perror: support printf style arguments
Date: Mon, 30 Mar 2026 23:15:00 +0800
The ksft_exit_fail_perror function previously only accepted a single string
argument, which limited its flexibility for providing specific context to
failure messages.
This change updates ksft_exit_fail_perror to support variable arguments,
similar to ksft_exit_fail_msg. Adding the __printf(1, 2) attribute enables
compile-time checking for format string correctness.
Link: https://lkml.kernel.org/r/20260330151503.670415-5-chuhu@redhat.com
Signed-off-by: Chunyu Hu <chuhu@redhat.com>
Cc: David Hildenbrand (Arm) <david@kernel.org>
Cc: Li Wang <liwang@redhat.com>
Cc: Lorenzo Stoakes (Oracle) <ljs@kernel.org>
Cc: Mike Rapoport (Microsoft) <rppt@kernel.org>
Cc: Zi Yan <ziy@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
tools/testing/selftests/kselftest.h | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
--- a/tools/testing/selftests/kselftest.h~selftests-ksft_exit_fail_perror-support-printf-style-arguments
+++ a/tools/testing/selftests/kselftest.h
@@ -43,7 +43,7 @@
* the program is aborting before finishing all tests):
*
* ksft_exit_fail_msg(fmt, ...);
- * ksft_exit_fail_perror(msg);
+ * ksft_exit_fail_perror(fmt, ...);
*
*/
#ifndef __KSELFTEST_H
@@ -417,9 +417,24 @@ static inline __noreturn __printf(1, 2)
exit(KSFT_FAIL);
}
-static inline __noreturn void ksft_exit_fail_perror(const char *msg)
+static inline __noreturn __printf(1, 2) void ksft_exit_fail_perror(const char *msg, ...)
{
- ksft_exit_fail_msg("%s: %s (%d)\n", msg, strerror(errno), errno);
+ va_list args;
+ char *buf = NULL;
+ int saved_errno = errno;
+
+ va_start(args, msg);
+ if (vasprintf(&buf, msg, args) == -1) {
+ va_end(args);
+ ksft_exit_fail_msg("vasprintf failed: %s (%d)\n", strerror(saved_errno),
+ saved_errno);
+ }
+ va_end(args);
+
+ errno = saved_errno;
+ ksft_exit_fail_msg("%s: %s (%d)\n", buf, strerror(errno), errno);
+
+ free(buf);
}
static inline __noreturn void ksft_exit_xfail(void)
_
Patches currently in -mm which might be from chuhu@redhat.com are
selftests-mm-guard-regions-skip-collapse-test-when-thp-not-enabled.patch
selftests-mm-soft-dirty-skip-two-tests-when-thp-is-not-available.patch
selftests-mm-move-write_file-helper-to-vm_util.patch
selftests-ksft_exit_fail_perror-support-printf-style-arguments.patch
selftests-mm-vm_util-robust-write_file.patch
selftests-mm-split_huge_page_test-skip-the-test-when-thp-is-not-available.patch
selftests-mm-transhuge_stress-skip-the-test-when-thp-not-available.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-03-30 19:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-30 19:26 + selftests-ksft_exit_fail_perror-support-printf-style-arguments.patch added to mm-unstable branch Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox