From: Bruce Richardson <bruce.richardson@intel.com>
To: dev@dpdk.org
Cc: Bruce Richardson <bruce.richardson@intel.com>
Subject: [PATCH] app/testpmd: show output of commands read from file
Date: Thu, 22 Aug 2024 11:36:04 +0100 [thread overview]
Message-ID: <20240822103604.113246-1-bruce.richardson@intel.com> (raw)
Testpmd supports the "--cmdline-file" parameter to read a set of initial
commands from a file. However, the only indication that this has been
done successfully on startup is a single-line message, no output from
the commands is seen.
To improve usability here, we can use cmdline_new rather than
cmdline_file_new and have the output from the various commands sent to
stdout, allowing the user to see better what is happening.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
app/test-pmd/cmdline.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index b7759e38a8..2a449b6b2f 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -6,6 +6,7 @@
#include <ctype.h>
#include <stdarg.h>
#include <errno.h>
+#include <fcntl.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
@@ -13431,7 +13432,18 @@ cmdline_read_from_file(const char *filename)
{
struct cmdline *cl;
- cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
+ /* cmdline_file_new does not produce any output which is not ideal here.
+ * Much better to show output of the commands, so we open filename directly
+ * and then pass that to cmdline_new with stdout as the output path.
+ */
+ int fd = open(filename, O_RDONLY);
+ if (fd < 0) {
+ fprintf(stderr, "Failed to open file %s: %s\n",
+ filename, strerror(errno));
+ return;
+ }
+
+ cl = cmdline_new(main_ctx, "testpmd> ", fd, 1);
if (cl == NULL) {
fprintf(stderr,
"Failed to create file based cmdline context: %s\n",
--
2.43.0
next reply other threads:[~2024-08-22 10:36 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-22 10:36 Bruce Richardson [this message]
2024-08-22 10:41 ` [PATCH v2] " Bruce Richardson
2024-08-22 16:53 ` Ferruh Yigit
2024-08-22 17:14 ` Bruce Richardson
2024-08-22 17:18 ` Bruce Richardson
2024-08-22 21:09 ` Ferruh Yigit
2024-08-23 9:12 ` Bruce Richardson
2024-10-04 4:56 ` Ferruh Yigit
2024-10-08 1:33 ` Ferruh Yigit
2024-10-10 8:56 ` David Marchand
2024-10-10 9:46 ` Bruce Richardson
2024-10-04 4:55 ` [PATCH] " Ferruh Yigit
2024-10-04 4:56 ` Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240822103604.113246-1-bruce.richardson@intel.com \
--to=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).