fix nostestest3 run error case 16/292416/1
authorwang biao <biao716.wang@samsung.com>
Sat, 6 May 2023 06:36:22 +0000 (14:36 +0800)
committerwang biao <biao716.wang@samsung.com>
Sat, 6 May 2023 06:36:22 +0000 (14:36 +0800)
Change-Id: Ifb252ddccfb5fac27ad481f803a368b0aa62aea3
Signed-off-by: wang biao <biao716.wang@samsung.com>
mic/utils/runner.py

index e22d734547cd619687390e2998f110c18a177883..c06dd4ed1081aed947bdd78a11dae57878fc9054 100644 (file)
@@ -46,25 +46,22 @@ def runtool(cmdln_or_args, catch=1):
         cmd = shlex.split(cmdln_or_args)[0]
         shell = True
 
-    if catch != 3:
-        dev_null = os.open("/dev/null", os.O_WRONLY)
-
     if catch == 0:
-        sout = dev_null
-        serr = dev_null
+        sout = subprocess.DEVNULL
+        serr = subprocess.DEVNULL
     elif catch == 1:
         sout = subprocess.PIPE
-        serr = dev_null
+        serr = subprocess.DEVNULL
     elif catch == 2:
-        sout = dev_null
+        sout = subprocess.DEVNULL
         serr = subprocess.PIPE
     elif catch == 3:
         sout = subprocess.PIPE
         serr = subprocess.STDOUT
 
     try:
-        p = subprocess.Popen(cmdln_or_args, stdout=subprocess.PIPE,
-                             stderr=subprocess.PIPE, shell=shell, universal_newlines=True)
+        p = subprocess.Popen(cmdln_or_args, stdout=sout,
+                             stderr=serr, shell=shell, universal_newlines=True)
         (sout, serr) = p.communicate()
         # combine stdout and stderr, filter None out
         out = ''.join([_f for _f in [sout, serr] if _f])