[LTP] [PATCH 0/3] checkpoint: Refactor and unify shell/C reinit support
Cyril Hrubis
chrubis@suse.cz
Fri Jun 27 09:49:40 CEST 2025
Hi!
> > I think that the root of the problem is that the shell function
> > _tst_init_checkpoints() does not create the IPC region with the magic.
> >
> > What about this patch:
> >
> > diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
> > index c32bd8b19..a310d3922 100644
> > --- a/testcases/lib/tst_test.sh
> > +++ b/testcases/lib/tst_test.sh
> > @@ -627,6 +627,7 @@ _tst_init_checkpoints()
> > tst_brk TBROK "tst_getconf PAGESIZE failed"
> > fi
> > ROD_SILENT dd if=/dev/zero of="$LTP_IPC_PATH" bs="$pagesize"
> > count=1
> > + ROD_SILENT printf LTPM | dd of="$LTP_IPC_PATH" bs=1 seek=0
> > conv=notrunc
> >
>
> No, I'm afraid this won't work as expected.
>
> The PEC failure wasn't caused by the shell checkpoint missing the "LTPM"
> magic. Instead, the root cause was that the reinitialization logic
> (tst_reinit())
> expected a different IPC format.
I do not think so, both the PEC C helpers and the tst_checkpoint.c call
tst_reinit() so as long as the function succeeds the memory layout will
be the same. The checkpoints will start at some offset in the page of
the IPC memory, but that was always the case.
And it turns out that the patch I've send yesterday does not work
because of endianity. The magic in the IPC region is MPTL on little
endian.
This patch actually works:
diff --git a/lib/tst_test.c b/lib/tst_test.c
index 495e022f7..17ce91932 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -52,7 +52,13 @@ const char *TCID __attribute__((weak));
#define CVE_DB_URL "https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-"
#define DEFAULT_TIMEOUT 30
-#define LTP_MAGIC 0x4C54504D /* Magic number is "LTPM" */
+
+/* Magic number is "LTPM" */
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+# define LTP_MAGIC 0x4C54504D
+#else
+# define LTP_MAGIC 0x4D50544C
+#endif
struct tst_test *tst_test;
diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index c32bd8b19..4be10a4f9 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -627,6 +627,7 @@ _tst_init_checkpoints()
tst_brk TBROK "tst_getconf PAGESIZE failed"
fi
ROD_SILENT dd if=/dev/zero of="$LTP_IPC_PATH" bs="$pagesize" count=1
+ ROD_SILENT "printf LTPM | dd of="$LTP_IPC_PATH" bs=1 seek=0 conv=notrunc"
ROD_SILENT chmod 600 "$LTP_IPC_PATH"
export LTP_IPC_PATH
}
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list