From d1cc563ccfb5cd053d33d996ff6a7fbb7bb94011 Mon Sep 17 00:00:00 2001 From: Antonio Galea Date: Thu, 10 Oct 2019 14:56:58 +0200 Subject: [PATCH] USBUS CDC ACM STDIO: test for the buffering code fixes #12384 --- tests/usbus_cdc_acm_stdio/main.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/tests/usbus_cdc_acm_stdio/main.c b/tests/usbus_cdc_acm_stdio/main.c index e342013afd..c41f763540 100644 --- a/tests/usbus_cdc_acm_stdio/main.c +++ b/tests/usbus_cdc_acm_stdio/main.c @@ -18,16 +18,46 @@ */ #include +#include #include "shell.h" #include "shell_commands.h" +static int cmd_text(int argc, char **argv) +{ + char *usage = "text [length]\n"; + if (argc != 2) { + puts(usage); + return -1; + } + int n = atoi(argv[1]); + if (n <= 0) { + puts(usage); + return -1; + } + for (int i=0; i < n; i++) { + if (i && (i % 80 == 0)) { + puts(""); + } + putc('0' + (i % 10), stdout); + } + puts(""); + return 0; +} + + +static const shell_command_t shell_commands[] = { + { "text", "Generates long text for testing stdio buffer", cmd_text }, + { NULL, NULL, NULL } +}; + + int main(void) { (void) puts("RIOT USB CDC ACM shell test"); char line_buf[SHELL_DEFAULT_BUFSIZE]; - shell_run(NULL, line_buf, SHELL_DEFAULT_BUFSIZE); + shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE); return 0; }