[LTP] [PATCH v3 2/2] swapon03: Try to swapon() as many files until it fails

Petr Vorel pvorel@suse.cz
Tue Nov 18 16:04:10 CET 2025


Hi,

> Previously tst_max_swapfiles() had fine tuning for a specific kernel
> version which was fragile due various backports in enterprise kernels.

> Let's try to create and use as many swap files until swapon() fails.
> Then check for expected EPERM.

> Also test swapon() 2x, first in the setup() when first failure happen,
> then in the test function (easier than propagate errno from fork to the
> main function). Therefore add -i2 into runtest/syscalls.

> It was required to increase cmd_buffer size to avoid directive output
> may be truncated warning.

...
> -	/* Determine how many more files are to be created */
> -	max_swapfiles = tst_max_swapfiles();
>  	used_swapfiles = tst_count_swaps();
> -	swapfiles = max_swapfiles - used_swapfiles;
> -	if (swapfiles > max_swapfiles)
> -		swapfiles = max_swapfiles;
> +	expected_swapfiles = NUM_SWAP_FILES - used_swapfiles;

And merging this should be followed with removing tst_max_swapfiles()

https://lore.kernel.org/ltp/20251106163500.1063704-5-pvorel@suse.cz/
https://patchwork.ozlabs.org/project/ltp/patch/20251106163500.1063704-5-pvorel@suse.cz/

I forget to add it to v3, therefore I keep this patch opened in patchwork.
I'm sorry for the noise.

Kind regards,
Petr


More information about the ltp mailing list