All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/15] selftests/futex: Refactor tests to use kselftest_harness.h
@ 2025-07-04 15:05 André Almeida
  2025-07-04 15:05 ` [PATCH 01/15] selftests: kselftest: Create ksft_print_dbg_msg() André Almeida
                   ` (14 more replies)
  0 siblings, 15 replies; 18+ messages in thread
From: André Almeida @ 2025-07-04 15:05 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.
 - test_harness_run() calls mmap(MAP_SHARED) before running the test and
   this has caused a side effect on test futex_numa_mpol.c. This test
   also calls mmap() and then try to access an address out of
   boundaries of this mapped memory for a "Memory out of range" subtest,
   where the kernel should return -EACCESS. After the refactor, the test
   address might be fall inside the first memory mapped region, thus
   being a valid address and succeeding the syscall, making the test
   fail. To fix that, I created a small "buffer zone" with
   mmap(PROT_NONE) between both mmaps.

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/

---
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   |  57 ++---
 .../selftests/futex/functional/futex_priv_hash.c   |  79 +++----
 .../selftests/futex/functional/futex_requeue.c     |  76 ++----
 .../selftests/futex/functional/futex_requeue_pi.c  | 261 ++++++++++-----------
 .../functional/futex_requeue_pi_mismatched_ops.c   |  80 ++-----
 .../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    |  62 +----
 tools/testing/selftests/futex/include/logging.h    | 148 ------------
 tools/testing/selftests/kselftest.h                |  13 +
 tools/testing/selftests/kselftest_harness.h        |  13 +-
 18 files changed, 491 insertions(+), 1007 deletions(-)
---
base-commit: a24cc6ce1933eade12aa2b9859de0fcd2dac2c06
change-id: 20250703-tonyk-robust_test_cleanup-d1f3406365d9

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


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

end of thread, other threads:[~2025-07-15  7:23 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-04 15:05 [PATCH 00/15] selftests/futex: Refactor tests to use kselftest_harness.h André Almeida
2025-07-04 15:05 ` [PATCH 01/15] selftests: kselftest: Create ksft_print_dbg_msg() André Almeida
2025-07-06  3:05   ` kernel test robot
2025-07-15  7:23   ` kernel test robot
2025-07-04 15:05 ` [PATCH 02/15] selftests/futex: Refactor futex_requeue_pi with kselftest_harness.h André Almeida
2025-07-04 15:05 ` [PATCH 03/15] selftests/futex: Refactor futex_requeue_pi_mismatched_ops " André Almeida
2025-07-04 15:05 ` [PATCH 04/15] selftests/futex: Refactor futex_requeue_pi_signal_restart " André Almeida
2025-07-04 15:05 ` [PATCH 05/15] selftests/futex: Refactor futex_wait_timeout " André Almeida
2025-07-04 15:05 ` [PATCH 06/15] selftests/futex: Refactor futex_wait_wouldblock " André Almeida
2025-07-04 15:05 ` [PATCH 07/15] selftests/futex: Refactor futex_wait_unitialized_heap " André Almeida
2025-07-04 15:05 ` [PATCH 08/15] selftests/futex: Refactor futex_wait_private_mapped_file " André Almeida
2025-07-04 15:05 ` [PATCH 09/15] selftests/futex: Refactor futex_wait " André Almeida
2025-07-04 15:05 ` [PATCH 10/15] selftests/futex: Refactor futex_requeue " André Almeida
2025-07-04 15:05 ` [PATCH 11/15] selftests/futex: Refactor futex_waitv " André Almeida
2025-07-04 15:05 ` [PATCH 12/15] selftests/futex: Refactor futex_priv_hash " André Almeida
2025-07-04 15:05 ` [PATCH 13/15] selftests/futex: Refactor futex_numa_mpol " André Almeida
2025-07-04 15:05 ` [PATCH 14/15] selftests/futex: Drop logging.h include from futex_numa André Almeida
2025-07-04 15:05 ` [PATCH 15/15] selftests/futex: Remove logging.h file André Almeida

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.