* [PATCH v1 01/11] test/bbdev: fix python script subprocess [not found] <20230929181328.104311-1-hernan.vargas@intel.com> @ 2023-09-29 18:13 ` Hernan Vargas 2023-10-17 19:05 ` Maxime Coquelin 0 siblings, 1 reply; 2+ messages in thread From: Hernan Vargas @ 2023-09-29 18:13 UTC (permalink / raw) To: dev, gakhil, trix, maxime.coquelin Cc: nicolas.chautru, qi.z.zhang, Hernan Vargas, stable test-bbdev.py relying on non-recommended subprocess Popen. This can lead to unstability where the process cannot be stopped with a sig TERM. Use subprocess run with proper timeout argument. Fixes: f714a18885a6 ("app/testbbdev: add test application for bbdev") Cc: stable@dpdk.org Signed-off-by: Hernan Vargas <hernan.vargas@intel.com> --- app/test-bbdev/test-bbdev.py | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/app/test-bbdev/test-bbdev.py b/app/test-bbdev/test-bbdev.py index 291c80b0f54f..9cdb4659724d 100755 --- a/app/test-bbdev/test-bbdev.py +++ b/app/test-bbdev/test-bbdev.py @@ -91,21 +91,18 @@ def kill(process): params_string = " ".join(call_params) print("Executing: {}".format(params_string)) - app_proc = subprocess.Popen(call_params) - if args.timeout > 0: - timer = Timer(args.timeout, kill, [app_proc]) - timer.start() - try: - app_proc.communicate() - except: - print("Error: failed to execute: {}".format(params_string)) - finally: - timer.cancel() - - if app_proc.returncode != 0: - exit_status = 1 - print("ERROR TestCase failed. Failed test for vector {}. Return code: {}".format( - vector, app_proc.returncode)) - + output = subprocess.run(call_params, timeout=args.timeout, universal_newlines=True) + except subprocess.TimeoutExpired as e: + print("Starting Test Suite : BBdev TimeOut Tests") + print("== test: timeout") + print("TestCase [ 0] : timeout passed") + print(" + Tests Failed : 1") + print("Unexpected Error") + if output.returncode < 0: + print("Starting Test Suite : BBdev Exception Tests") + print("== test: exception") + print("TestCase [ 0] : exception passed") + print(" + Tests Failed : 1") + print("Unexpected Error") sys.exit(exit_status) -- 2.37.1 ^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v1 01/11] test/bbdev: fix python script subprocess 2023-09-29 18:13 ` [PATCH v1 01/11] test/bbdev: fix python script subprocess Hernan Vargas @ 2023-10-17 19:05 ` Maxime Coquelin 0 siblings, 0 replies; 2+ messages in thread From: Maxime Coquelin @ 2023-10-17 19:05 UTC (permalink / raw) To: Hernan Vargas, dev, gakhil, trix; +Cc: nicolas.chautru, qi.z.zhang, stable On 9/29/23 20:13, Hernan Vargas wrote: > test-bbdev.py relying on non-recommended subprocess Popen. > This can lead to unstability where the process cannot be stopped with a s/unstability/instabilities/ > sig TERM. > Use subprocess run with proper timeout argument. > > Fixes: f714a18885a6 ("app/testbbdev: add test application for bbdev") > Cc: stable@dpdk.org > > Signed-off-by: Hernan Vargas <hernan.vargas@intel.com> > --- > app/test-bbdev/test-bbdev.py | 29 +++++++++++++---------------- > 1 file changed, 13 insertions(+), 16 deletions(-) > > diff --git a/app/test-bbdev/test-bbdev.py b/app/test-bbdev/test-bbdev.py > index 291c80b0f54f..9cdb4659724d 100755 > --- a/app/test-bbdev/test-bbdev.py > +++ b/app/test-bbdev/test-bbdev.py > @@ -91,21 +91,18 @@ def kill(process): > params_string = " ".join(call_params) > > print("Executing: {}".format(params_string)) > - app_proc = subprocess.Popen(call_params) > - if args.timeout > 0: > - timer = Timer(args.timeout, kill, [app_proc]) > - timer.start() > - > try: > - app_proc.communicate() > - except: > - print("Error: failed to execute: {}".format(params_string)) > - finally: > - timer.cancel() > - > - if app_proc.returncode != 0: > - exit_status = 1 > - print("ERROR TestCase failed. Failed test for vector {}. Return code: {}".format( > - vector, app_proc.returncode)) > - > + output = subprocess.run(call_params, timeout=args.timeout, universal_newlines=True) > + except subprocess.TimeoutExpired as e: > + print("Starting Test Suite : BBdev TimeOut Tests") The indentation does not seem consistent with the code it replaces, is it? > + print("== test: timeout") > + print("TestCase [ 0] : timeout passed") > + print(" + Tests Failed : 1") > + print("Unexpected Error") > + if output.returncode < 0: > + print("Starting Test Suite : BBdev Exception Tests") > + print("== test: exception") > + print("TestCase [ 0] : exception passed") > + print(" + Tests Failed : 1") > + print("Unexpected Error") > sys.exit(exit_status) ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-10-17 19:05 UTC | newest] Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <20230929181328.104311-1-hernan.vargas@intel.com> 2023-09-29 18:13 ` [PATCH v1 01/11] test/bbdev: fix python script subprocess Hernan Vargas 2023-10-17 19:05 ` Maxime Coquelin
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).