aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPavel Moravec <pmoravec@redhat.com>2023-07-28 10:43:00 +0200
committerJake Hunsaker <jacob.r.hunsaker@gmail.com>2023-08-17 10:20:44 -0400
commite98e658ed7fdb782f24bf8f337d4218621763ecf (patch)
tree2cc790bf5166888cd8547fa5cf8551747806a567 /tests
parent7d5a2d9f762263f9c2c978f792febdf54d5a51a0 (diff)
downloadsos-e98e658ed7fdb782f24bf8f337d4218621763ecf.tar.gz
[tests] search for fixed strings, not regexps, by default
Change grep_for_content to grep for a fixed string by default. The reason is tests would match 1a2b3c4 as IP address 1.2.3.4 (which it is not). Add regexp option to grep_for_content, to allow the default "grep" search. Resolves: #3320 Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/sos_tests.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/tests/sos_tests.py b/tests/sos_tests.py
index 78c23e43..d15395f0 100644
--- a/tests/sos_tests.py
+++ b/tests/sos_tests.py
@@ -390,11 +390,16 @@ class BaseSoSReportTest(BaseSoSTest):
raise
return _archive
- def grep_for_content(self, search):
+ def grep_for_content(self, search, regexp=False):
"""Call out to grep for finding a specific string 'search' in any place
in the archive
+
+ :param search: string to search
+ :param regexp: use regular expression search (default False
+ means "grep -F")
"""
- cmd = "grep -ril '%s' %s" % (search, self.archive_path)
+ fixed_opt = "" if regexp else "F"
+ cmd = "grep -ril%s '%s' %s" % (fixed_opt, search, self.archive_path)
try:
out = process.run(cmd)
rc = out.exit_status