Re: [LTP] [PATCH v3] Migrating the libhugetlbfs/testcases/truncate.c test

Petr Vorel
2023-11-28T11:23:55Z

Hi,

...
> +static void sigbus_handler(int signum)
> +{
> + test_pass = 1;
> + siglongjmp(sig_escape, 17);
What 17 stands for? Is there any constant which could be used? Or can you define
something (the name of the constant would be self-describing).
> +}
> +
> +static void run_test(void)
> +{
> + void *p;
> + volatile unsigned int *q;
> +
> + sigbus_count = 0;
> + test_pass = 0;
> + int err;
> +
> + p = SAFE_MMAP(NULL, hpage_size, PROT_READ|PROT_WRITE, MAP_SHARED,
> + fd, 0);
> + q = p;
> + *q = 0;
> + err = ftruncate(fd, 0);
> + if (err)
> + tst_res(TFAIL, "ftruncate failed");
We have SAFE_FTRUNCATE(), error check is not needed.