[LTP] [PATCH v7 3/4] ioctl_loop01.c: Add new support .needs_cmds

Li Wang liwang@redhat.com
Fri Jan 16 14:25:05 CET 2026


>         TST_ASSERT_INT(partscan_path, 0);
>         TST_ASSERT_INT(autoclear_path, 0);
>         TST_ASSERT_STR(backing_path, backing_file_path);
> @@ -114,10 +97,23 @@ static void verify_ioctl_loop(void)
>
>  static void setup(void)
>  {
> +       parted_sup = tst_cmd_present("parted");


In the logic of tst_test.c, there already did check and store the
value in tst_test->needs_cmds.present, so why here do the check
seperately again?

+               struct tst_cmd *pcmd = tst_test->needs_cmds;
+               while (pcmd->cmd) {
+                       pcmd->present = tst_check_cmd(pcmd->cmd,
!pcmd->optional) ? 1 : 0;
+                       pcmd++;
+               }


> +       const char *const cmd_parted[] = {"parted", "-s", dev_path, "mklabel", "msdos", "mkpart",
> +                                         "primary", "ext4", "1M", "10M", NULL};
> +
>         dev_num = tst_find_free_loopdev(dev_path, sizeof(dev_path));
>         if (dev_num < 0)
>                 tst_brk(TBROK, "Failed to find free loop device");
>
> +       tst_fill_file("test.img", 0, 1024 * 1024, 10);
> +
> +       tst_attach_device(dev_path, "test.img");
> +       attach_flag = 1;
> +
> +       if (parted_sup)

Can we just reuse the 'tst_test->needs_cmds.present' result?

> +               SAFE_CMD(cmd_parted, NULL, NULL);


-- 
Regards,
Li Wang



More information about the ltp mailing list