]> code.ossystems Code Review - openembedded-core.git/commitdiff
oeqa/runtime/parselogs: use -F to search fixed strings for grep
authorYi Zhao <yi.zhao@windriver.com>
Thu, 14 Jan 2016 07:08:37 +0000 (15:08 +0800)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 19 Jan 2016 17:37:23 +0000 (17:37 +0000)
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>
Signed-off-by: Ross Burton <ross.burton@intel.com>
meta/lib/oeqa/runtime/parselogs.py

index fc2bc389350ab76c801485d64c268537d0082722..5a2d50f0a3f1415749e0e7afada952be38f734e4 100644 (file)
@@ -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