[LTP] [PATCH v3] ioctl_loop01.c: Use proper device for partitioning

Wei Gao wegao@suse.com
Wed Sep 10 03:35:17 CEST 2025


On Tue, Sep 09, 2025 at 01:50:30PM +0200, Cyril Hrubis wrote:
> Hi!
> >  .../kernel/syscalls/ioctl/ioctl_loop01.c      | 34 ++++++++-----------
> >  1 file changed, 15 insertions(+), 19 deletions(-)
> > 
> > diff --git a/testcases/kernel/syscalls/ioctl/ioctl_loop01.c b/testcases/kernel/syscalls/ioctl/ioctl_loop01.c
> > index c9137bf1e..b70e9fc22 100644
> > --- a/testcases/kernel/syscalls/ioctl/ioctl_loop01.c
> > +++ b/testcases/kernel/syscalls/ioctl/ioctl_loop01.c
> > @@ -78,7 +78,21 @@ static void check_loop_value(int set_flag, int get_flag, int autoclear_field)
> >  
> >  static void verify_ioctl_loop(void)
> >  {
> > +	int ret;
> > +	const char *const cmd_parted[] = {"parted", "-s", dev_path, "mklabel", "msdos", "mkpart",
> > +					"primary", "ext4", "1M", "10M", NULL};
> > +
> > +	tst_fill_file("test.img", 0, 1024 * 1024, 10);
> >  	tst_attach_device(dev_path, "test.img");
> > +
> > +	ret = tst_cmd(cmd_parted, NULL, NULL, TST_CMD_PASS_RETVAL);
> > +	if (!ret)
> > +		parted_sup = 1;
> > +	else if (ret == 255)
> > +		tst_res(TCONF, "parted binary not installed or failed");
> > +	else
> > +		tst_res(TCONF, "parted exited with %i", ret);
> 
> The test should have needs_cmds set to parted (we do that properly in
> ioctl09.c) then we do not have to handle the 255 exit code here since
> the test would be skipped if it's missing.

If we use needs_cmds all the check will be skipped in this case.

Current test case will still continue do some check even parted is
missing. Such as following test log:

tst_tmpdir.c:316: TINFO: Using /tmp/LTP_iocxxPKhg as tmpdir (ext2/ext3/ext4 filesystem)
tst_test.c:2004: TINFO: LTP version: 20250130-399-g47167e082
tst_test.c:2007: TINFO: Tested kernel: 6.11.0-1027-oem #27-Ubuntu SMP PREEMPT_DYNAMIC Tue Jul 22 06:12:35 UTC 2025 x86_64
tst_kconfig.c:88: TINFO: Parsing kernel config '/lib/modules/6.11.0-1027-oem/build/.config'
tst_test.c:1825: TINFO: Overall timeout per run is 0h 00m 31s
tst_device.c:98: TINFO: Found free device 14 '/dev/loop14'
tst_buffers.c:57: TINFO: Test is using guarded buffers
ioctl_loop01.c:92: TCONF: parted binary not installed or failed
ioctl_loop01.c:98: TPASS: /sys/block/loop14/loop/partscan = 0
ioctl_loop01.c:99: TPASS: /sys/block/loop14/loop/autoclear = 0
ioctl_loop01.c:100: TPASS: /sys/block/loop14/loop/backing_file = '/tmp/LTP_iocxxPKhg/test.img'
ioctl_loop01.c:56: TPASS: get expected lo_flag 12
ioctl_loop01.c:58: TPASS: /sys/block/loop14/loop/partscan = 1
ioctl_loop01.c:59: TPASS: /sys/block/loop14/loop/autoclear = 1
ioctl_loop01.c:62: TINFO: Current environment doesn't have parted disk, skip it
ioctl_loop01.c:104: TINFO: Test flag can be clear
ioctl_loop01.c:56: TPASS: get expected lo_flag 8
ioctl_loop01.c:58: TPASS: /sys/block/loop14/loop/partscan = 1
ioctl_loop01.c:59: TPASS: /sys/block/loop14/loop/autoclear = 0
ioctl_loop01.c:62: TINFO: Current environment doesn't have parted disk, skip it

Summary:
passed   9
failed   0
broken   0
skipped  1
warnings 0

> 
> -- 
> Cyril Hrubis
> chrubis@suse.cz


More information about the ltp mailing list