[LTP] [PATCH v2 2/2] ioctl_loop01.c: Update to new .needs_cmds struct
Wei Gao
wegao@suse.com
Mon Sep 29 01:26:58 CEST 2025
Suggested-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Wei Gao <wegao@suse.com>
---
.../kernel/syscalls/ioctl/ioctl_loop01.c | 23 ++++++++-----------
1 file changed, 9 insertions(+), 14 deletions(-)
diff --git a/testcases/kernel/syscalls/ioctl/ioctl_loop01.c b/testcases/kernel/syscalls/ioctl/ioctl_loop01.c
index c9137bf1e..70036d6ef 100644
--- a/testcases/kernel/syscalls/ioctl/ioctl_loop01.c
+++ b/testcases/kernel/syscalls/ioctl/ioctl_loop01.c
@@ -97,9 +97,10 @@ static void verify_ioctl_loop(void)
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};
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},
+ {}
+ },
.needs_tmpdir = 1,
};
--
2.51.0
More information about the ltp
mailing list