lib/checkpoint: remove deprecated tst_checkpoint_init() and legacy macro
PATCH 1/1 lib/checkpoint: remove deprecated tst_checkpoint_init() and legacy macro
The function tst_checkpoint_init() and macro TST_CHECKPOINT_INIT were used by old library tests for setting up checkpoint futex memory.
These APIs have been fully replaced by tst_reinit() and in the new checkpoint infrastructure.
So let's get rid of them and rewrite the checkpoint tests in newlib_tests/.
--- include/old/old_checkpoint.h | 8 -- include/tst_checkpoint_fn.h | 8 -- lib/newlib_tests/.gitignore | 3 + lib/newlib_tests/tst_checkpoint.c | 114 ++++++++++++++++++ .../tst_checkpoint_wait_timeout.c | 42 +++++++ .../tst_checkpoint_wake_timeout.c | 29 +++++ lib/tests/.gitignore | 3 - lib/tests/tst_checkpoint.c | 59 --------- lib/tests/tst_checkpoint_wait_timeout.c | 58 --------- lib/tests/tst_checkpoint_wake_timeout.c | 41 ------- lib/tst_checkpoint.c | 51 +------- 11 files changed, 194 insertions(+), 222 deletions(-) create mode 100644 lib/newlib_tests/tst_checkpoint.c create mode 100644 lib/newlib_tests/tst_checkpoint_wait_timeout.c create mode 100644 lib/newlib_tests/tst_checkpoint_wake_timeout.c delete mode 100644 lib/tests/tst_checkpoint.c delete mode 100644 lib/tests/tst_checkpoint_wait_timeout.c delete mode 100644 lib/tests/tst_checkpoint_wake_timeout.c
include/old/old_checkpoint.h +0 -8
@@ -32,14 +32,6 @@#include "test.h" #include "tst_checkpoint_fn.h" -/* -* Checkpoint initializaton, must be done first. -* -* NOTE: tst_tmpdir() must be called beforehand. -*/ -#define TST_CHECKPOINT_INIT (cleanup_fn) \ - tst_checkpoint_init(__FILE__, __LINE__, cleanup_fn) -#define TST_SAFE_CHECKPOINT_WAIT (cleanup_fn, id) \ tst_safe_checkpoint_wait(__FILE__, __LINE__, cleanup_fn, id, 0);
include/tst_checkpoint_fn.h +0 -8
@@ -5,14 +5,6 @@#ifndef TST_CHECKPOINT_FN__ #define TST_CHECKPOINT_FN__ -/* -* Checkpoint initializaton, must be done first. -* -* NOTE: tst_tmpdir() must be called beforehand. -*/ -void tst_checkpoint_init (const char *file,const int lineno, -void (*cleanup_fn)(void )); -/* * Waits for wakeup. *
lib/newlib_tests/.gitignore +3 -0
@@ -15,6 +15,9 @@ tst_capability01 tst_capability02 tst_cgroup01 tst_cgroup02 +tst_checkpoint +tst_checkpoint_wait_timeout +tst_checkpoint_wake_timeout tst_device tst_safe_fileops tst_res_hexd
lib/newlib_tests/tst_checkpoint.c new file +114 -0
114 lines not on this page · raw message
lib/newlib_tests/tst_checkpoint_wait_timeout.c new file +42 -0
42 lines not on this page · raw message
lib/newlib_tests/tst_checkpoint_wake_timeout.c new file +29 -0
@@ -0,0 +1,29 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Test: checkpoint wake without matching wait. +* Expected: wake completes with ETIMEDOUT errno as expected. +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include "tst_test.h" +#include "tst_checkpoint.h" + +static void run (void ) +{ +int ret =tst_checkpoint_wake (0 ,1 ,1000 ); + +if (ret ==-1 && errno ==ETIMEDOUT ) +tst_res (TPASS ,"checkpoint wake timed out as expected" ); +else +tst_brk (TBROK |TERRNO ,"checkpoint wake failed" ); + +return ; +} + +static struct tst_test test = { + .test_all = run, + .needs_checkpoints =1 , +};
lib/tests/.gitignore +0 -3
@@ -1,7 +1,4 @@ /tst_tmpdir_test -/tst_checkpoint -/tst_checkpoint_wait_timeout -/tst_checkpoint_wake_timeout /tst_process_state /tst_cleanup_once /tst_safe_macros
lib/tests/tst_checkpoint.c deleted +0 -59
59 lines not on this page · raw message
lib/tests/tst_checkpoint_wait_timeout.c deleted +0 -58
58 lines not on this page · raw message
lib/tests/tst_checkpoint_wake_timeout.c deleted +0 -41
41 lines not on this page · raw message
lib/tst_checkpoint.c +6 -45
60 lines not on this page · raw message
Signature · 5 lines
2.50.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 8 lines · Li Wang via ltp
The function
tst_checkpoint_init()and macroTST_CHECKPOINT_INITwere used by old library tests for setting up checkpoint futex memory.These APIs have been fully replaced by
tst_reinit()and in the new checkpoint infrastructure.So let's get rid of them and rewrite the checkpoint tests in newlib_tests/.
Seems tst_ipc_path should be deleted as well:
include/tst_checkpoint.h +0 -2
@@ -86,6 +86,4 @@tst_safe_checkpoint_wait (__FILE__, __LINE__,NULL , id,0 ); \ } while (0) -extern const char *tst_ipc_path; -#endif /* TST_CHECKPOINT__ */
lib/tst_test.c +0 -1
@@ -108,7 +108,6 @@ extern unsigned int tst_max_futexes;static int ipc_fd;static char ipc_path[1064 ]; -const char *tst_ipc_path = ipc_path;static char shm_path[1024 ];
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Yes please.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 1/1 checkpoint: add test for child reinitializing checkpoint region
In reply to Li Wang via ltpThis adds a pair of tests that verify checkpoint synchronization across a parent and a re-exec'd child. The child process uses tst_reinit() to reconnect to the shared checkpoint memory region established by the parent.
The parent waits on checkpoint 0, while the child wakes it after verifying CLI arguments and reinitializing the IPC region.
Follow-up: https://lists.linux.it/pipermail/ltp/2025-June/044063.html
--- lib/newlib_tests/.gitignore | 2 ++ lib/newlib_tests/runtest.sh | 4 +++ lib/newlib_tests/tst_checkpoint_child.c | 27 +++++++++++++++++ lib/newlib_tests/tst_checkpoint_parent.c | 38 ++++++++++++++++++++++++ 4 files changed, 71 insertions(+) create mode 100644 lib/newlib_tests/tst_checkpoint_child.c create mode 100644 lib/newlib_tests/tst_checkpoint_parent.c
lib/newlib_tests/.gitignore +2 -0
@@ -16,6 +16,8 @@ tst_capability02 tst_cgroup01 tst_cgroup02 tst_checkpoint +tst_checkpoint_parent +tst_checkpoint_child tst_checkpoint_wait_timeout tst_checkpoint_wake_timeout tst_device
lib/newlib_tests/runtest.sh +4 -0
@@ -18,6 +18,10 @@ test1[59] test2[04] tst_bool_expr tst_capability02 +tst_checkpoint +tst_checkpoint_parent +tst_checkpoint_wait_timeout +tst_checkpoint_wake_timeout tst_device tst_expiration_timer tst_fuzzy_sync0[1-3]
lib/newlib_tests/tst_checkpoint_child.c new file +27 -0
@@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Child process: this binary is expected to be exec'd by the parent. +* +* It reinitializes the shared memory region using tst_reinit(), +* verifies the command-line argument, and signals checkpoint 0. +*/ + +#define TST_NO_DEFAULT_MAIN +#include "tst_test.h" +#include "tst_checkpoint.h" + +int main (int argc,char *argv[]) +{ +tst_reinit (); + +if (argc !=2 ) +tst_brk (TFAIL ,"argc is %d, expected 2" , argc); + +if (strcmp (argv[1 ],"canary" )) +tst_brk (TFAIL ,"argv[1] is %s, expected 'canary'" , argv[1 ]); + +tst_res (TINFO ,"Child: signaling checkpoint" ); +TST_CHECKPOINT_WAKE (0 ); + +return 0 ; +}
lib/newlib_tests/tst_checkpoint_parent.c new file +38 -0
@@ -0,0 +1,38 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Parent process: spawns a child which reinitializes checkpoint region +* using tst_reinit(). Waits for a checkpoint signal from the child. +*/ + +#include <errno.h> +#include <signal.h> +#include <stdlib.h> +#include <sys/types.h> +#include <sys/wait.h> + +#include "tst_test.h" +#include "tst_checkpoint.h" + +static void run (void ) +{ +pid_t pid =SAFE_FORK (); + +if (pid ==0 ) { +TEST (execlp ("tst_checkpoint_child" ,"tst_checkpoint_child" ,"canary" ,NULL )); +tst_brk (TFAIL |TTERRNO ,"Failed to execute tst_checkpoint_child" ); + } + +TST_CHECKPOINT_WAIT (0 ); +tst_res (TPASS ,"Parent: checkpoint reached" ); + +SAFE_WAITPID (pid,NULL ,0 ); + +return ; +} + +static struct tst_test test = { + .forks_child =1 , + .needs_checkpoints =1 , + .child_needs_reinit =1 , + .test_all = run, +};
Signature · 5 lines
2.50.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH] checkpoint: add test for child reinitializing checkpoint region
Hi!
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 2 lines
Reviewed-by Cyril Hrubis <[email protected]>
Patchset pushed with minor adjustments (GPL License update, tst_ipc_path drop).
Thanks for the review!
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp