mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3 00/15] selftests/futex: Refactor tests to use kselftest_harness.h
@ 2025-09-17 21:21 André Almeida
  2025-09-17 21:21 ` [PATCH v3 01/15] selftests: kselftest: Create ksft_print_dbg_msg() André Almeida
                   ` (14 more replies)
  0 siblings, 15 replies; 41+ messages in thread
From: André Almeida @ 2025-09-17 21:21 UTC (permalink / raw)
  To: Shuah Khan, Thomas Gleixner, Ingo Molnar, Peter Zijlstra,
	Darren Hart, Davidlohr Bueso, Sebastian Andrzej Siewior
  Cc: linux-kselftest, linux-kernel, kernel-dev, André Almeida

This patch series refactors all futex selftests to use
kselftest_harness.h instead of futex's logging.h, as discussed here [1].

This allows to remove a lot of boilerplate code and to simplify some
parts of the test logic, mainly when the test needs to exit early. The
result of this is more than 500 lines removed from
tools/testing/selftests/futex/. Also, this enables new tests to use
kselftest.h features like ASSERT_s and such.

There are some caveats around this refactor:
 - logging.h had verbosity levels, while kselftest_harness.h doesn't. I
   created a new print function called ksft_print_dbg_msg() that prints
   the message if the user uses the -d flag, so now there's an
   equivalent of this feature.
 - futex_requeue_pi test accepted command line arguments to be used as
   test parameters (e.g. ./futex_requeue_pi -b -l -t 500000). This
   doesn't work with kselftest_harness.h because there's no
   straightforward way to send command line arguments to the test.
   I used FIXTURE_VARIANT() to achieve the same result, but now the
   parameters live inside of the test file, instead of on
   functional/run.sh. This increased a little bit the number of test
   cases for futex_requeue_pi, from 22 to 24.

Although there are a lot of patches, they follow a simple pattern:
 - The usage() function, options parsing, kseftest setup
   (ksft_print_header(), ksft_set_plan(), ksft_print_cnts()), are all
   gone
 - info() is replaced with ksft_print_dbg_msg()
 - Exit on error paths are replaced with ksft_exit_fail_msg()
 - fail/pass replaced with their ksft_ equivalents.

I have compared the results of run.sh before and after this patchset and
didn't find any regression from the test results.

Thanks,
	André

[1] https://lore.kernel.org/lkml/87ecv6p364.ffs@tglx/

---
Changes in v3:
- Rebased on top of tip/locking/futex
- Link to v2: https://lore.kernel.org/r/20250720-tonyk-robust_test_cleanup-v2-0-1f9bcb5b7294@igalia.com

Changes in v2:
- Rebased on top of tip/master
- Dropped priv_hash global test variant now that this feature was
  dropped
- Added include <stdbool.h> in the first patch
- Link to v1: https://lore.kernel.org/r/20250704-tonyk-robust_test_cleanup-v1-0-c0ff4f24c4e1@igalia.com

---
André Almeida (15):
      selftests: kselftest: Create ksft_print_dbg_msg()
      selftests/futex: Refactor futex_requeue_pi with kselftest_harness.h
      selftests/futex: Refactor futex_requeue_pi_mismatched_ops with kselftest_harness.h
      selftests/futex: Refactor futex_requeue_pi_signal_restart with kselftest_harness.h
      selftests/futex: Refactor futex_wait_timeout with kselftest_harness.h
      selftests/futex: Refactor futex_wait_wouldblock with kselftest_harness.h
      selftests/futex: Refactor futex_wait_unitialized_heap with kselftest_harness.h
      selftests/futex: Refactor futex_wait_private_mapped_file with kselftest_harness.h
      selftests/futex: Refactor futex_wait with kselftest_harness.h
      selftests/futex: Refactor futex_requeue with kselftest_harness.h
      selftests/futex: Refactor futex_waitv with kselftest_harness.h
      selftests/futex: Refactor futex_priv_hash with kselftest_harness.h
      selftests/futex: Refactor futex_numa_mpol with kselftest_harness.h
      selftests/futex: Drop logging.h include from futex_numa
      selftests/futex: Remove logging.h file

 tools/testing/selftests/futex/functional/Makefile  |   3 +-
 .../selftests/futex/functional/futex_numa.c        |   3 +-
 .../selftests/futex/functional/futex_numa_mpol.c   |  39 +--
 .../selftests/futex/functional/futex_priv_hash.c   |  48 +---
 .../selftests/futex/functional/futex_requeue.c     |  76 ++----
 .../selftests/futex/functional/futex_requeue_pi.c  | 261 ++++++++++-----------
 .../functional/futex_requeue_pi_mismatched_ops.c   |  86 ++-----
 .../functional/futex_requeue_pi_signal_restart.c   | 129 +++-------
 .../selftests/futex/functional/futex_wait.c        | 103 +++-----
 .../functional/futex_wait_private_mapped_file.c    |  83 ++-----
 .../futex/functional/futex_wait_timeout.c          | 139 +++++------
 .../functional/futex_wait_uninitialized_heap.c     |  76 ++----
 .../futex/functional/futex_wait_wouldblock.c       |  75 ++----
 .../selftests/futex/functional/futex_waitv.c       |  98 ++++----
 tools/testing/selftests/futex/functional/run.sh    |  61 +----
 tools/testing/selftests/futex/include/logging.h    | 148 ------------
 tools/testing/selftests/kselftest.h                |  14 ++
 tools/testing/selftests/kselftest_harness.h        |  13 +-
 18 files changed, 456 insertions(+), 999 deletions(-)
---
base-commit: ed323aeda5e09fa1ab95946673939c8c425c329c
change-id: 20250703-tonyk-robust_test_cleanup-d1f3406365d9

Best regards,
-- 
André Almeida <andrealmeid@igalia.com>


^ permalink raw reply	[flat|nested] 41+ messages in thread

end of thread, other threads:[~2025-09-25 16:50 UTC | newest]

Thread overview: 41+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-17 21:21 [PATCH v3 00/15] selftests/futex: Refactor tests to use kselftest_harness.h André Almeida
2025-09-17 21:21 ` [PATCH v3 01/15] selftests: kselftest: Create ksft_print_dbg_msg() André Almeida
2025-09-20 16:27   ` [tip: locking/futex] " tip-bot2 for André Almeida
2025-09-25 11:47     ` Mark Brown
2025-09-25 14:14       ` [PATCH] tools/nolibc: Add stdbool.h to nolibc includes André Almeida
2025-09-25 14:24         ` Mark Brown
2025-09-25 14:37           ` André Almeida
2025-09-25 14:45             ` Mark Brown
2025-09-25 14:48               ` Thomas Weißschuh
2025-09-25 14:46             ` Thomas Weißschuh
2025-09-25 16:15         ` Thomas Weißschuh
2025-09-25 16:24           ` Mark Brown
2025-09-25 16:49             ` Thomas Weißschuh
2025-09-17 21:21 ` [PATCH v3 02/15] selftests/futex: Refactor futex_requeue_pi with kselftest_harness.h André Almeida
2025-09-20 16:27   ` [tip: locking/futex] " tip-bot2 for André Almeida
2025-09-17 21:21 ` [PATCH v3 03/15] selftests/futex: Refactor futex_requeue_pi_mismatched_ops " André Almeida
2025-09-20 16:27   ` [tip: locking/futex] " tip-bot2 for André Almeida
2025-09-17 21:21 ` [PATCH v3 04/15] selftests/futex: Refactor futex_requeue_pi_signal_restart " André Almeida
2025-09-20 16:27   ` [tip: locking/futex] " tip-bot2 for André Almeida
2025-09-17 21:21 ` [PATCH v3 05/15] selftests/futex: Refactor futex_wait_timeout " André Almeida
2025-09-20 16:27   ` [tip: locking/futex] " tip-bot2 for André Almeida
2025-09-17 21:21 ` [PATCH v3 06/15] selftests/futex: Refactor futex_wait_wouldblock " André Almeida
2025-09-20 16:27   ` [tip: locking/futex] " tip-bot2 for André Almeida
2025-09-17 21:21 ` [PATCH v3 07/15] selftests/futex: Refactor futex_wait_unitialized_heap " André Almeida
2025-09-20 16:27   ` [tip: locking/futex] " tip-bot2 for André Almeida
2025-09-17 21:21 ` [PATCH v3 08/15] selftests/futex: Refactor futex_wait_private_mapped_file " André Almeida
2025-09-20 16:27   ` [tip: locking/futex] " tip-bot2 for André Almeida
2025-09-17 21:21 ` [PATCH v3 09/15] selftests/futex: Refactor futex_wait " André Almeida
2025-09-20 16:27   ` [tip: locking/futex] " tip-bot2 for André Almeida
2025-09-17 21:21 ` [PATCH v3 10/15] selftests/futex: Refactor futex_requeue " André Almeida
2025-09-20 16:27   ` [tip: locking/futex] " tip-bot2 for André Almeida
2025-09-17 21:21 ` [PATCH v3 11/15] selftests/futex: Refactor futex_waitv " André Almeida
2025-09-20 16:27   ` [tip: locking/futex] " tip-bot2 for André Almeida
2025-09-17 21:21 ` [PATCH v3 12/15] selftests/futex: Refactor futex_priv_hash " André Almeida
2025-09-20 16:27   ` [tip: locking/futex] " tip-bot2 for André Almeida
2025-09-17 21:21 ` [PATCH v3 13/15] selftests/futex: Refactor futex_numa_mpol " André Almeida
2025-09-20 16:27   ` [tip: locking/futex] " tip-bot2 for André Almeida
2025-09-17 21:21 ` [PATCH v3 14/15] selftests/futex: Drop logging.h include from futex_numa André Almeida
2025-09-20 16:27   ` [tip: locking/futex] " tip-bot2 for André Almeida
2025-09-17 21:21 ` [PATCH v3 15/15] selftests/futex: Remove logging.h file André Almeida
2025-09-20 16:27   ` [tip: locking/futex] " tip-bot2 for André Almeida

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®