Skip to content

Commit 036c564

Browse files
bruce-richardsonferruhy
authored andcommitted
app/testpmd: show output of commands read from file
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 <[email protected]> Acked-by: Ferruh Yigit <[email protected]>
1 parent 126d4e2 commit 036c564

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

app/test-pmd/cmdline.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <ctype.h>
77
#include <stdarg.h>
88
#include <errno.h>
9+
#include <fcntl.h>
910
#include <stdio.h>
1011
#include <stdint.h>
1112
#include <stdlib.h>
@@ -13677,7 +13678,18 @@ cmdline_read_from_file(const char *filename)
1367713678
{
1367813679
struct cmdline *cl;
1367913680

13680-
cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
13681+
/* cmdline_file_new does not produce any output which is not ideal here.
13682+
* Much better to show output of the commands, so we open filename directly
13683+
* and then pass that to cmdline_new with stdout as the output path.
13684+
*/
13685+
int fd = open(filename, O_RDONLY);
13686+
if (fd < 0) {
13687+
fprintf(stderr, "Failed to open file %s: %s\n",
13688+
filename, strerror(errno));
13689+
return;
13690+
}
13691+
13692+
cl = cmdline_new(main_ctx, "testpmd> ", fd, STDOUT_FILENO);
1368113693
if (cl == NULL) {
1368213694
fprintf(stderr,
1368313695
"Failed to create file based cmdline context: %s\n",

0 commit comments

Comments
 (0)