Skip to content

Commit

Permalink
app/testpmd: show output of commands read from file
Browse files Browse the repository at this point in the history
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>
Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
  • Loading branch information
bruce-richardson authored and ferruhy committed Oct 8, 2024
1 parent 126d4e2 commit 036c564
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion app/test-pmd/cmdline.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -13677,7 +13678,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, STDOUT_FILENO);
if (cl == NULL) {
fprintf(stderr,
"Failed to create file based cmdline context: %s\n",
Expand Down

0 comments on commit 036c564

Please sign in to comment.