Skip to contentSkip to conversation

oeqa/runtime/parselogs: use -F to search fixed strings for grep

PATCH New Yi Zhao 1 participant 1 message Jan 14, 2016

lore
Share & tools
lore

Yi Zhao

author
#0 lore raw

PATCH v2 1/1 oeqa/runtime/parselogs: use -F to search fixed strings for grep

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.

---
 meta/lib/oeqa/runtime/parselogs.py |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
meta/lib/oeqa/runtime/parselogs.py +1 -2
index fc2bc38..5a2d50f 100644
@@ -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
Signature · 1 line
1.7.9.5