[LTP] [PATCH v2 2/2] lib: moves test infrastructure states into a shared context structure

Li Wang liwang@redhat.com
Thu Jun 5 14:20:12 CEST 2025


 Li Wang via ltp <ltp@lists.linux.it> wrote:


> +               size_t futexes_offset = offsetof(struct ipc_region,
> futexes);
> +               tst_max_futexes = (size - futexes_offset) /
> sizeof(futex_t);
>

I suddenly realized that Cyril's meant:
  tst_max_futexes = (size - offsetof(struct ipc_region, futexes)) /
sizeof(futex_t);

Okay, we can refine this before the patch merging (or in patch v3 if
needed).


@@ -178,12 +198,22 @@ void tst_reinit(void)
>                 tst_brk(TBROK, "File %s does not exist!", path);
>
>         fd = SAFE_OPEN(path, O_RDWR);
> +       ipc = SAFE_MMAP(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED,
> fd, 0);
> +       SAFE_CLOSE(fd);
>
> -       results = SAFE_MMAP(NULL, size, PROT_READ | PROT_WRITE,
> MAP_SHARED, fd, 0);
> -       tst_futexes = (char *)results + sizeof(struct results);
> -       tst_max_futexes = (size - sizeof(struct results))/sizeof(futex_t);
> +       if (ipc->magic != LTP_MAGIC)
> +               tst_brk(TBROK, "Invalid shared memory region (bad magic)");
>
> -       SAFE_CLOSE(fd);
> +       /* Restore the parent context from IPC region */
> +       context = &ipc->context;
> +       results = &ipc->results;
> +
> +       tst_futexes = ipc->futexes;
> +       size_t futexes_offset = offsetof(struct ipc_region, futexes);
> +       tst_max_futexes = (size - futexes_offset) / sizeof(futex_t);
>

tst_max_futexes = (size - offsetof(struct ipc_region, futexes)) /
sizeof(futex_t);


-- 
Regards,
Li Wang


More information about the ltp mailing list