[LTP] [PATCH v4] Migrating the libhugetlbfs/testcases/truncate.c test

Petr Vorel pvorel@suse.cz
Fri Mar 22 07:02:45 CET 2024


Hi,

> Test Description: Test is used to verify the correct functionality
nit: I would remove "Test Description: " and instead point out the link from
which test originated.

...
> +static void run_test(void)
> +{
> +	void *p;
> +	volatile unsigned int *q;
> +
> +	sigbus_count = 0;
> +	test_pass = 0;
> +
> +	struct sigaction my_sigaction;
> +
> +	my_sigaction.sa_handler = sigbus_handler;
> +	p = SAFE_MMAP(NULL, hpage_size, PROT_READ|PROT_WRITE, MAP_SHARED,
> +			fd, 0);
> +	q = p;
> +	*q = 0;
> +	SAFE_SIGACTION(SIGBUS, &my_sigaction, NULL);
> +	SAFE_FTRUNCATE(fd, 0);
If any of these 2 SAFE_*() fails, we don't call SAFE_MUNMAP(), right?
But at least in hugemmap27.c it's happily ignored, I guess it can stay.

The rest LGTM.

Kind regards,
Petr

> +
> +	if (sigsetjmp(sig_escape, 1) == 0)
> +		*q;
> +	else
> +		sigbus_count++;
> +
> +	if (sigbus_count != 1)
> +		tst_res(TFAIL, "Didn't SIGBUS");
> +
> +	if (test_pass == 1)
> +		tst_res(TPASS, "Expected SIGBUS triggered");
> +
> +	SAFE_MUNMAP(p, hpage_size);
> +}


More information about the ltp mailing list