[LTP] [PATCH v2 2/2] ioctl_loop01.c: Update to new .needs_cmds struct

Petr Vorel pvorel@suse.cz
Tue Sep 30 15:12:50 CEST 2025


Hi Wei,

...
> +++ b/testcases/kernel/syscalls/ioctl/ioctl_loop01.c
> @@ -97,9 +97,10 @@ static void verify_ioctl_loop(void)

Patch does not apply, thus CI fail. Please always rebase before sending.

>  static void setup(void)
>  {
> -	int ret;
> +	parted_sup = tst_cmd_present("parted");
> +
>  	const char *const cmd_parted[] = {"parted", "-s", "test.img", "mklabel", "msdos", "mkpart",
> -	                                  "primary", "ext4", "1M", "10M", NULL};
> +					"primary", "ext4", "1M", "10M", NULL};

This change just changes whitespace. I would avoid it.

>  	dev_num = tst_find_free_loopdev(dev_path, sizeof(dev_path));
>  	if (dev_num < 0)
> @@ -107,18 +108,8 @@ static void setup(void)

>  	tst_fill_file("test.img", 0, 1024 * 1024, 10);

> -	ret = tst_cmd(cmd_parted, NULL, NULL, TST_CMD_PASS_RETVAL);
> -	switch (ret) {
> -	case 0:
> -		parted_sup = 1;
> -	break;
> -	case 255:
> -		tst_res(TCONF, "parted binary not installed or failed");
> -	break;
> -	default:
> -		tst_res(TCONF, "parted exited with %i", ret);
> -	break;
> -	}
> +	if (parted_sup)
> +		SAFE_CMD(cmd_parted, NULL, NULL);

>  	sprintf(partscan_path, "/sys/block/loop%d/loop/partscan", dev_num);
>  	sprintf(autoclear_path, "/sys/block/loop%d/loop/autoclear", dev_num);
> @@ -152,5 +143,9 @@ static struct tst_test test = {
>  		{"linux-git", "6ac92fb5cdff"},
>  		{}
>  	},
> +	.needs_cmds = (struct tst_cmd[]) {
> +		{.cmd = "parted", .optional = 1},
> +		{}
> +	},

Otherwise LGTM.

With above fixed:
Reviewed-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr


More information about the ltp mailing list