From 6cbe62b8580f982f09be4cdd6f693dc159978fb3 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 5 Mar 2020 17:16:24 +0100 Subject: [PATCH] MINOR: debug: add CLI command "debug dev write" to write an arbitrary size This command is used to produce an arbitrary amount of data on the output. It can be used to test the CLI's state machine as well as the internal parts related to applets an I/O. A typical test consists in asking for all sizes from 0 to 16384: $ (echo "prompt;expert-mode on";for i in {0..16384}; do echo "debug dev write $i"; done) | socat - /tmp/sock1 | wc -c 134258738 A better test would consist in first waiting for the response before sending a new request. This command is not restricted to the admin since it's harmless. --- src/debug.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/debug.c b/src/debug.c index c01f794..a3b208a 100644 --- a/src/debug.c +++ b/src/debug.c @@ -497,6 +497,29 @@ static int debug_parse_cli_tkill(char **args, char *payload, struct appctx *appc return 1; } +/* parse a "debug dev write" command. It always returns 1. */ +static int debug_parse_cli_write(char **args, char *payload, struct appctx *appctx, void *private) +{ + unsigned long len; + + if (!*args[3]) + return cli_err(appctx, "Missing output size.\n"); + + len = strtoul(args[3], NULL, 0); + if (len >= trash.size) + return cli_err(appctx, "Output too large, must be ] [strm.f[{+-=}]] [txn.f[{+-=}]] \ @@ -795,6 +818,7 @@ static struct cli_kw_list cli_kws = {{ },{ {{ "debug", "dev", "panic", NULL }, "debug dev panic : immediately trigger a panic", debug_parse_cli_panic, NULL, NULL, NULL, ACCESS_EXPERT }, {{ "debug", "dev", "stream",NULL }, "debug dev stream ... : show/manipulate stream flags", debug_parse_cli_stream,NULL, NULL, NULL, ACCESS_EXPERT }, {{ "debug", "dev", "tkill", NULL }, "debug dev tkill [thr] [sig] : send signal to thread", debug_parse_cli_tkill, NULL, NULL, NULL, ACCESS_EXPERT }, + {{ "debug", "dev", "write", NULL }, "debug dev write [size] : write that many bytes", debug_parse_cli_write, NULL, NULL, NULL, ACCESS_EXPERT }, {{ "show", "threads", NULL, NULL }, "show threads : show some threads debugging information", NULL, cli_io_handler_show_threads, NULL }, {{},} }}; -- 1.7.10.4