* [PATCH 0/3] oeqa/runtime: improve some test cases
@ 2016-01-07 3:29 Yi Zhao
2016-01-07 3:29 ` [PATCH 1/3] oeqa/runtime/smart: fix hardcoded root directory Yi Zhao
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Yi Zhao @ 2016-01-07 3:29 UTC (permalink / raw)
To: openembedded-core
Yi Zhao (3):
oeqa/runtime/smart: fix hardcoded root directory
oeqa/runtime/logrotate: fix hardcoded root directory
oeqa/runtime/parselogs: escape special character for grep
meta/lib/oeqa/runtime/logrotate.py | 8 ++++----
meta/lib/oeqa/runtime/parselogs.py | 6 ++++--
meta/lib/oeqa/runtime/smart.py | 4 ++--
3 files changed, 10 insertions(+), 8 deletions(-)
--
1.7.9.5
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/3] oeqa/runtime/smart: fix hardcoded root directory
2016-01-07 3:29 [PATCH 0/3] oeqa/runtime: improve some test cases Yi Zhao
@ 2016-01-07 3:29 ` Yi Zhao
2016-01-07 3:29 ` [PATCH 2/3] oeqa/runtime/logrotate: " Yi Zhao
2016-01-07 3:29 ` [PATCH 3/3] oeqa/runtime/parselogs: escape special character for grep Yi Zhao
2 siblings, 0 replies; 8+ messages in thread
From: Yi Zhao @ 2016-01-07 3:29 UTC (permalink / raw)
To: openembedded-core
Use $HOME instead of /home/root in case user changes the default root
directory by ROOT_HOME
Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
---
meta/lib/oeqa/runtime/smart.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/meta/lib/oeqa/runtime/smart.py b/meta/lib/oeqa/runtime/smart.py
index e41668d..126d614 100644
--- a/meta/lib/oeqa/runtime/smart.py
+++ b/meta/lib/oeqa/runtime/smart.py
@@ -147,7 +147,7 @@ class SmartRepoTest(SmartTest):
for i in output.split("\n"):
if ("rpmsys" != str(i)) and ("myrpmdir" != str(i)):
self.smart('channel --disable '+str(i))
- self.target.run('cd /home/root')
+ self.target.run('cd $HOME')
self.smart('install psplash')
for i in output.split("\n"):
if ("rpmsys" != str(i)) and ("myrpmdir" != str(i)):
@@ -172,4 +172,4 @@ class SmartRepoTest(SmartTest):
@skipUnlessPassed('test_smart_channel_add')
def test_smart_remove_package(self):
self.smart('install -y psplash')
- self.smart('remove -y psplash')
\ No newline at end of file
+ self.smart('remove -y psplash')
--
1.7.9.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/3] oeqa/runtime/logrotate: fix hardcoded root directory
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 ` Yi Zhao
2016-01-07 3:29 ` [PATCH 3/3] oeqa/runtime/parselogs: escape special character for grep Yi Zhao
2 siblings, 0 replies; 8+ messages in thread
From: Yi Zhao @ 2016-01-07 3:29 UTC (permalink / raw)
To: openembedded-core
Use $HOME instead of /home/root in case user changes the default root
directory by ROOT_HOME
Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
---
meta/lib/oeqa/runtime/logrotate.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/meta/lib/oeqa/runtime/logrotate.py b/meta/lib/oeqa/runtime/logrotate.py
index 86d791c..de300bf 100644
--- a/meta/lib/oeqa/runtime/logrotate.py
+++ b/meta/lib/oeqa/runtime/logrotate.py
@@ -14,9 +14,9 @@ class LogrotateTest(oeRuntimeTest):
@skipUnlessPassed("test_ssh")
def test_1_logrotate_setup(self):
- (status, output) = self.target.run('mkdir /home/root/logrotate_dir')
+ (status, output) = self.target.run('mkdir $HOME/logrotate_dir')
self.assertEqual(status, 0, msg = "Could not create logrotate_dir. Output: %s" % output)
- (status, output) = self.target.run("sed -i 's#wtmp {#wtmp {\\n olddir /home/root/logrotate_dir#' /etc/logrotate.conf")
+ (status, output) = self.target.run("sed -i \"s#wtmp {#wtmp {\\n olddir $HOME/logrotate_dir#\" /etc/logrotate.conf")
self.assertEqual(status, 0, msg = "Could not write to logrotate.conf file. Status and output: %s and %s)" % (status, output))
@testcase(289)
@@ -24,5 +24,5 @@ class LogrotateTest(oeRuntimeTest):
def test_2_logrotate(self):
(status, output) = self.target.run('logrotate -f /etc/logrotate.conf')
self.assertEqual(status, 0, msg = "logrotate service could not be reloaded. Status and output: %s and %s" % (status, output))
- output = self.target.run('ls -la /home/root/logrotate_dir/ | wc -l')[1]
- self.assertTrue(int(output)>=3, msg = "new logfile could not be created. List of files within log directory: %s" %(self.target.run('ls -la /home/root/logrotate_dir')[1]))
+ output = self.target.run('ls -la $HOME/logrotate_dir/ | wc -l')[1]
+ self.assertTrue(int(output)>=3, msg = "new logfile could not be created. List of files within log directory: %s" %(self.target.run('ls -la $HOME/logrotate_dir')[1]))
--
1.7.9.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/3] oeqa/runtime/parselogs: escape special character for grep
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
2016-01-07 12:21 ` Burton, Ross
2 siblings, 1 reply; 8+ messages in thread
From: Yi Zhao @ 2016-01-07 3:29 UTC (permalink / raw)
To: openembedded-core
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
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3] oeqa/runtime/parselogs: escape special character for grep
2016-01-07 3:29 ` [PATCH 3/3] oeqa/runtime/parselogs: escape special character for grep Yi Zhao
@ 2016-01-07 12:21 ` Burton, Ross
2016-01-08 8:44 ` Yi Zhao
0 siblings, 1 reply; 8+ messages in thread
From: Burton, Ross @ 2016-01-07 12:21 UTC (permalink / raw)
To: Yi Zhao; +Cc: OE-core
[-- Attachment #1: Type: text/plain, Size: 466 bytes --]
On 7 January 2016 at 03:29, Yi Zhao <yi.zhao@windriver.com> wrote:
> 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
>
If we're going to insist that the strings are literal then instead of
telling grep to use extended regexp's and passing escaped regexs, why not
just use -F which tells grep to search for fixed strings, not expressions.
Ross
[-- Attachment #2: Type: text/html, Size: 884 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3] oeqa/runtime/parselogs: escape special character for grep
2016-01-07 12:21 ` Burton, Ross
@ 2016-01-08 8:44 ` Yi Zhao
2016-01-08 8:59 ` Burton, Ross
0 siblings, 1 reply; 8+ messages in thread
From: Yi Zhao @ 2016-01-08 8:44 UTC (permalink / raw)
To: Burton, Ross; +Cc: OE-core
[-- Attachment #1: Type: text/plain, Size: 862 bytes --]
在 2016年01月07日 20:21, Burton, Ross 写道:
>
> On 7 January 2016 at 03:29, Yi Zhao <yi.zhao@windriver.com
> <mailto:yi.zhao@windriver.com>> wrote:
>
> 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
>
>
> If we're going to insist that the strings are literal then instead of
> telling grep to use extended regexp's and passing escaped regexs, why
> not just use -F which tells grep to search for fixed strings, not
> expressions.
Hi Ross,
It still need to escape quotation marks if using -F option.
Consider the following log:
[521514.737] (EE) evdev: Qemu Tablet: Unable to open evdev device
"/dev/input/touchscreen0".
We still need an extra step to replace " with \" before grep
Yi
>
> Ross
[-- Attachment #2: Type: text/html, Size: 2270 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3] oeqa/runtime/parselogs: escape special character for grep
2016-01-08 8:44 ` Yi Zhao
@ 2016-01-08 8:59 ` Burton, Ross
2016-01-12 1:51 ` Yi Zhao
0 siblings, 1 reply; 8+ messages in thread
From: Burton, Ross @ 2016-01-08 8:59 UTC (permalink / raw)
To: Yi Zhao; +Cc: OE-core
[-- Attachment #1: Type: text/plain, Size: 654 bytes --]
On 8 January 2016 at 08:44, Yi Zhao <yi.zhao@windriver.com> wrote:
> It still need to escape quotation marks if using -F option.
> Consider the following log:
> [521514.737] (EE) evdev: Qemu Tablet: Unable to open evdev device
> "/dev/input/touchscreen0".
>
> We still need an extra step to replace " with \" before grep
>
Actually that's only true as the grep command is passed to
subproces.check_output() as a string. If it was constructed as a list the
shell wouldn't be parsing it and you wouldn't have to worry about quoting
at all.
(always pass lists instead of strings to subprocess, it makes everything a
lot easier)
Ross
[-- Attachment #2: Type: text/html, Size: 1164 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3] oeqa/runtime/parselogs: escape special character for grep
2016-01-08 8:59 ` Burton, Ross
@ 2016-01-12 1:51 ` Yi Zhao
0 siblings, 0 replies; 8+ messages in thread
From: Yi Zhao @ 2016-01-12 1:51 UTC (permalink / raw)
To: Burton, Ross; +Cc: OE-core
[-- Attachment #1: Type: text/plain, Size: 855 bytes --]
在 2016年01月08日 16:59, Burton, Ross 写道:
>
> On 8 January 2016 at 08:44, Yi Zhao <yi.zhao@windriver.com
> <mailto:yi.zhao@windriver.com>> wrote:
>
> It still need to escape quotation marks if using -F option.
> Consider the following log:
> [521514.737] (EE) evdev: Qemu Tablet: Unable to open evdev device
> "/dev/input/touchscreen0".
>
> We still need an extra step to replace " with \" before grep
>
>
> Actually that's only true as the grep command is passed to
> subproces.check_output() as a string. If it was constructed as a list
> the shell wouldn't be parsing it and you wouldn't have to worry about
> quoting at all.
>
> (always pass lists instead of strings to subprocess, it makes
> everything a lot easier)
>
> Ross
Thanks, Ross.
I will test it and send the v2 patch.
Yi
[-- Attachment #2: Type: text/html, Size: 2136 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2016-01-12 1:51 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 3/3] oeqa/runtime/parselogs: escape special character for grep Yi Zhao
2016-01-07 12:21 ` Burton, Ross
2016-01-08 8:44 ` Yi Zhao
2016-01-08 8:59 ` Burton, Ross
2016-01-12 1:51 ` Yi Zhao
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.