aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tools
diff options
context:
space:
mode:
authorMing Lei <ming.lei@redhat.com>2025-03-03 20:43:13 +0800
committerJens Axboe <axboe@kernel.dk>2025-03-10 09:17:13 -0600
commit2ecdcdfee58c028c15ed00b691104249370db075 (patch)
treeebba8083161693b09420c631f5e7508c3aeeb1da /tools
parentselftests: ublk: fix build failure (diff)
downloadwireguard-linux-2ecdcdfee58c028c15ed00b691104249370db075.tar.xz
wireguard-linux-2ecdcdfee58c028c15ed00b691104249370db075.zip
selftests: ublk: add --foreground command line
Add --foreground command for helping to debug. Signed-off-by: Ming Lei <ming.lei@redhat.com> Reviewed-by: Keith Busch <kbusch@kernel.org> Link: https://lore.kernel.org/r/20250303124324.3563605-4-ming.lei@redhat.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'tools')
-rw-r--r--tools/testing/selftests/ublk/kublk.c17
-rw-r--r--tools/testing/selftests/ublk/kublk.h1
2 files changed, 14 insertions, 4 deletions
diff --git a/tools/testing/selftests/ublk/kublk.c b/tools/testing/selftests/ublk/kublk.c
index 2072d880fdc4..24557a3e5508 100644
--- a/tools/testing/selftests/ublk/kublk.c
+++ b/tools/testing/selftests/ublk/kublk.c
@@ -679,7 +679,10 @@ static int ublk_start_daemon(const struct dev_ctx *ctx, struct ublk_dev *dev)
}
ublk_ctrl_get_info(dev);
- ublk_send_dev_event(ctx, dev->dev_info.dev_id);
+ if (ctx->fg)
+ ublk_ctrl_dump(dev);
+ else
+ ublk_send_dev_event(ctx, dev->dev_info.dev_id);
/* wait until we are terminated */
for (i = 0; i < dinfo->nr_hw_queues; i++)
@@ -867,6 +870,9 @@ static int cmd_dev_add(struct dev_ctx *ctx)
{
int res;
+ if (ctx->fg)
+ goto run;
+
ctx->_evtfd = eventfd(0, 0);
if (ctx->_evtfd < 0) {
ublk_err("%s: failed to create eventfd %s\n", __func__, strerror(errno));
@@ -876,8 +882,9 @@ static int cmd_dev_add(struct dev_ctx *ctx)
setsid();
res = fork();
if (res == 0) {
- __cmd_dev_add(ctx);
- exit(EXIT_SUCCESS);
+run:
+ res = __cmd_dev_add(ctx);
+ return res;
} else if (res > 0) {
uint64_t id;
@@ -1044,6 +1051,7 @@ int main(int argc, char *argv[])
{ "debug_mask", 1, NULL, 0 },
{ "quiet", 0, NULL, 0 },
{ "zero_copy", 1, NULL, 'z' },
+ { "foreground", 0, NULL, 0 },
{ 0, 0, 0, 0 }
};
int option_idx, opt;
@@ -1087,7 +1095,8 @@ int main(int argc, char *argv[])
ublk_dbg_mask = strtol(optarg, NULL, 16);
if (!strcmp(longopts[option_idx].name, "quiet"))
ublk_dbg_mask = 0;
- break;
+ if (!strcmp(longopts[option_idx].name, "foreground"))
+ ctx.fg = 1;
}
}
diff --git a/tools/testing/selftests/ublk/kublk.h b/tools/testing/selftests/ublk/kublk.h
index 8f48eb8568ab..26d9aa9c5ca2 100644
--- a/tools/testing/selftests/ublk/kublk.h
+++ b/tools/testing/selftests/ublk/kublk.h
@@ -67,6 +67,7 @@ struct dev_ctx {
char *files[MAX_BACK_FILES];
unsigned int logging:1;
unsigned int all:1;
+ unsigned int fg:1;
int _evtfd;
};