test: don't break terminal settings when running tests
PATCH 1/1 test: don't break terminal settings when running tests
When running one test (via DPDK_TEST) the test program would leave the terminal in raw mode. This was because it was setting up cmdline to do interactive input.
The fix is to use cmdline_new() for the interactive case.
This also fixes a memory leak because the test runner was never calling cmdline_free().
revise test bugfix
--- app/test/test.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-)
app/test/test.c +20 -11
@@ -164,29 +164,38 @@ main(int argc, char **argv)#ifdef RTE_LIB_CMDLINE - cl =cmdline_stdin_new (main_ctx,"RTE>>" ); -if (cl ==NULL ) { - ret =-1 ; - goto out; - } -char *dpdk_test =getenv ("DPDK_TEST" );if (dpdk_test &&strlen (dpdk_test)) {char buf[1024 ]; + + cl =cmdline_new (main_ctx,"RTE>>" ,0 ,1 ); +if (cl ==NULL ) { + ret =-1 ; + goto out; + } +snprintf (buf,sizeof (buf),"%s\n" , dpdk_test);if (cmdline_in (cl, buf,strlen (buf)) <0 ) {printf ("error on cmdline input\n" ); + + ret =-1 ; + }else { + ret = last_test_result; + } +cmdline_free (cl); + goto out; + }else { +/* if no DPDK_TEST env variable, go interactive */ + cl =cmdline_stdin_new (main_ctx,"RTE>>" ); +if (cl ==NULL ) { ret =-1 ; goto out; } +cmdline_interact (cl);cmdline_stdin_exit (cl); - ret = last_test_result; - goto out; +cmdline_free (cl); } -/* if no DPDK_TEST env variable, go interactive */ -cmdline_interact (cl); -cmdline_stdin_exit (cl);#endif ret =0 ;
Signature · 1 line
2.29.2
Quoted 16 lines
From: Stephen Hemminger <[email protected]>
Sent: Thursday, January 14, 2021 4:46 PM
To: Richardson, Bruce <[email protected]>; Van Haaren, Harry <[email protected]>; De Lara Guarch, Pablo <[email protected]>
Cc: [email protected]; [email protected]; Stephen Hemminger <[email protected]>
Subject: [PATCH] test: don't break terminal settings when running testsWhen running one test (via
DPDK_TEST) the test program would leave the terminal in raw mode. This was because it was setting up cmdline to do interactive input.The fix is to use
cmdline_new()for the interactive case.
Quoted 6 lines
This also fixes a memory leak because the test runner was never calling
cmdline_free().Fixes 9b848774a5dc ("test: use env variable to run tests")Signed-off-by Stephen Hemminger <[email protected]>
Thomas Monjalon
Applied14/01/2021 18:01, Van Haaren, Harry:
Quoted 16 lines
Quoted 16 lines
From: Stephen Hemminger <[email protected]>
Sent: Thursday, January 14, 2021 4:46 PM
To: Richardson, Bruce <[email protected]>; Van Haaren, Harry <[email protected]>; De Lara Guarch, Pablo <[email protected]>
Cc: [email protected]; [email protected]; Stephen Hemminger <[email protected]>
Subject: [PATCH] test: don't break terminal settings when running testsWhen running one test (via
DPDK_TEST) the test program would leave the terminal in raw mode. This was because it was setting up cmdline to do interactive input.The fix is to use
cmdline_new()for the interactive case.
Quoted 8 lines
Quoted 6 lines
This also fixes a memory leak because the test runner was never calling
cmdline_free().Fixes 9b848774a5dc ("test: use env variable to run tests")Signed-off-by Stephen Hemminger <[email protected]>Tested-by Harry van Haaren <[email protected]>
Applied, thanks