From: Yi Zhao <yi.zhao@windriver.com>
To: <openembedded-core@lists.openembedded.org>
Subject: [PATCH 3/3] oeqa/runtime/parselogs: escape special character for grep
Date: Thu, 7 Jan 2016 11:29:54 +0800 [thread overview]
Message-ID: <1452137394-333-4-git-send-email-yi.zhao@windriver.com> (raw)
In-Reply-To: <1452137394-333-1-git-send-email-yi.zhao@windriver.com>
Sometimes the grep output is not correct if the log message contains
some special characters. Use re.escape to escape all non-alphanumerics
before grep
Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
---
meta/lib/oeqa/runtime/parselogs.py | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/meta/lib/oeqa/runtime/parselogs.py b/meta/lib/oeqa/runtime/parselogs.py
index fc2bc38..7fc7932 100644
--- a/meta/lib/oeqa/runtime/parselogs.py
+++ b/meta/lib/oeqa/runtime/parselogs.py
@@ -1,6 +1,7 @@
import os
import unittest
import subprocess
+import re
from oeqa.oetest import oeRuntimeTest
from oeqa.utils.decorators import *
@@ -50,7 +51,7 @@ x86_common = [
qemux86_common = [
'wrong ELF class',
"fail to add MMCONFIG information, can't access extended PCI configuration space under this bridge.",
- "can't claim BAR ",
+ "can\'t claim BAR ",
] + common_errors
ignore_errors = {
@@ -221,7 +222,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)
+ nxrez = re.escape(xrez)
+ command = "grep -E \""+str(nxrez)+"\" -B "+str(lines_before)+" -A "+str(lines_after)+" "+str(log)
try:
grep_output = subprocess.check_output(command, shell=True)
except:
--
1.7.9.5
next prev parent reply other threads:[~2016-01-07 3:30 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-07 3:29 [PATCH 0/3] oeqa/runtime: improve some test cases Yi Zhao
2016-01-07 3:29 ` [PATCH 1/3] oeqa/runtime/smart: fix hardcoded root directory Yi Zhao
2016-01-07 3:29 ` [PATCH 2/3] oeqa/runtime/logrotate: " Yi Zhao
2016-01-07 3:29 ` Yi Zhao [this message]
2016-01-07 12:21 ` [PATCH 3/3] oeqa/runtime/parselogs: escape special character for grep Burton, Ross
2016-01-08 8:44 ` Yi Zhao
2016-01-08 8:59 ` Burton, Ross
2016-01-12 1:51 ` Yi Zhao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1452137394-333-4-git-send-email-yi.zhao@windriver.com \
--to=yi.zhao@windriver.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.