From 7eb0ec9fd66c471300f2e772941af0c66e41080a Mon Sep 17 00:00:00 2001 From: Pavel Moravec Date: Fri, 28 Jul 2023 10:43:00 +0200 Subject: [PATCH] [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 --- tests/sos_tests.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/sos_tests.py b/tests/sos_tests.py index 78c23e43af..d15395f035 100644 --- a/tests/sos_tests.py +++ b/tests/sos_tests.py @@ -390,11 +390,16 @@ def _decrypt_archive(self, archive): 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