[LTP] [PATCH v3 0/2] Rewrite openposix clock_settime bugged tests inside LTP

Andrea Cervesato andrea.cervesato@suse.de
Thu Jul 17 11:41:56 CEST 2025


Both clock_settime_7-1 and clock_settime_8-1 are affected by the
same bug which is probably related to the way tests are written.

sleep() is used by the parent and is not reliable. It can oversleep
or undersleep according to system overload or signals which are
received. And we never check for its return value. Using
clock_nanosleep would make parent more reliable in this case.

At the same time, the test is taking for granted a certain
synchronization between child and parent, which is not always true
in case of system overload.

My suggestion is to rewrite the test using LTP, which has better
timing handling (see tst_timer.h).

Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
Changes in v3:
- remove checkpoints
- sleep with REALTIME only, but take time in MONOTONIC
- use only clock_settime variant
- Link to v2: https://lore.kernel.org/r/20250630-clock_nanosleep05-v2-0-15522d5551c6@suse.com

Changes in v2:
- add SAFE_CLOCK_NANOSLEEP
- move child to MONOTONIC clock
- simplify child_nanosleep by passing flags
- calculate delta by checking sleep() time between beginning and ending time
- keep variants only for child
- Link to v1: https://lore.kernel.org/r/20250627-clock_nanosleep05-v1-1-1357109a2c81@suse.com

---
Andrea Cervesato (2):
      Add SAFE_CLOCK_NANOSLEEP macro utility
      Add clock_settime04 test

 include/tst_safe_clocks.h                          |  23 ++++
 runtest/syscalls                                   |   1 +
 testcases/kernel/syscalls/clock_settime/.gitignore |   1 +
 .../syscalls/clock_settime/clock_settime04.c       | 140 +++++++++++++++++++++
 4 files changed, 165 insertions(+)
---
base-commit: 39072797fa63be2a5e85b1a79379b98a8bfa8d29
change-id: 20250620-clock_nanosleep05-60b3cfba52fe

Best regards,
-- 
Andrea Cervesato <andrea.cervesato@suse.com>



More information about the ltp mailing list