[LTP] [RFC] .all_filesystems imply .needs_root? [was Re: [PATCH] open14: Rewrite to new API]

Petr Vorel pvorel@suse.cz
Tue Jul 22 10:03:22 CEST 2025


Hi all,

...
> > +static struct tst_test test = {
> > +	.setup = setup,
> > +	.test_all = run,
> > +	.cleanup = cleanup,
> > +	.mntpoint = MNTPOINT,
> > +	.all_filesystems = 1
> We need .needs_root if we acquire a device.

We LTP library allows to run test under non-root user with rw permissions to
/dev/loop-control:

tst_device.c:110: TINFO: Not allowed to open /dev/loop-control. Are you root?: EACCES (13)
tst_device.c:149: TINFO: No free devices found
tst_device.c:362: TBROK: Failed to acquire device

In openSUSE that would be to run tests with user which is in disk group.
Although this should theoretically work, root is often required for something
else:

$ open14
...
tst_supported_fs_types.c:49: TINFO: mkfs is not needed for tmpfs
tst_test.c:1938: TINFO: === Testing on ext2 ===
...
open14.c:141: TINFO: Closing temporary files
open14.c:146: TPASS: Multiple files test passed
open14.c:168: TINFO: Testing linked temp files access mode
open14.c:186: TFAIL: Unexpected access mode: 1755 != 7755
open14.c:186: TFAIL: Unexpected access mode: 1755 != 7755
open14.c:186: TFAIL: Unexpected access mode: 1755 != 7755
open14.c:186: TFAIL: Unexpected access mode: 1755 != 7755
open14.c:186: TFAIL: Unexpected access mode: 1755 != 7755

Obviously with root everything works:
...
open14.c:193: TPASS: File access modes are correct

Also I'm not sure if anybody would bother with configuring group for a test
user. I suppose most of testers run LTP under root.

Also, not all tests define needs_device for these tests:

$ git grep -l -e needs_device -e all_filesystems testcases/ | wc -l
121

$ git grep -l needs_root $(git grep -l -e needs_device -e all_filesystems testcases/) | wc -l
108

Therefore I wonder if we should just imply .needs_root on .all_filesystems (and
other flags). Also doc could be tweaked to show .needs_root in the test catalog
for these tests [1].

And there are other flags which effectively enforce root, e.g. .mount_device
(mount() requires CAP_SYS_ADMIN). Here IMHO implying root makes even more sense.

Kind regards,
Petr

[1] https://linux-test-project.readthedocs.io/en/latest/users/test_catalog.html

> > +};
...

> - Andrea


More information about the ltp mailing list