public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
* [PATCH v2] oeqa/runtime/parselogs: use -F to search fixed strings for grep
@ 2016-01-14  7:08 Yi Zhao
  0 siblings, 0 replies; only message in thread
From: Yi Zhao @ 2016-01-14  7:08 UTC (permalink / raw)
  To: openembedded-core

The grep output is not correct if the log message contains special
characters. Use -F which tells grep to search for fixed strings, not
expressions and pass lists instead of strings to subprocess.

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
---
 meta/lib/oeqa/runtime/parselogs.py |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/meta/lib/oeqa/runtime/parselogs.py b/meta/lib/oeqa/runtime/parselogs.py
index fc2bc38..5a2d50f 100644
--- a/meta/lib/oeqa/runtime/parselogs.py
+++ b/meta/lib/oeqa/runtime/parselogs.py
@@ -221,9 +221,8 @@ class ParseLogsTest(oeRuntimeTest):
                 results[log.replace('target_logs/','')] = {}
                 rez = result.splitlines()
                 for xrez in rez:
-                    command = "grep \"\\"+str(xrez)+"\" -B "+str(lines_before)+" -A "+str(lines_after)+" "+str(log)
                     try:
-                        grep_output = subprocess.check_output(command, shell=True)
+                        grep_output = subprocess.check_output(['grep', '-F', xrez, '-B', str(lines_before), '-A', str(lines_after), log])
                     except:
                         pass
                     results[log.replace('target_logs/','')][xrez]=grep_output
-- 
1.7.9.5



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-01-14  7:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-14  7:08 [PATCH v2] oeqa/runtime/parselogs: use -F to search fixed strings for grep Yi Zhao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox