Skip to content

Commit

Permalink
[tests] search for fixed strings, not regexps, by default
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
pmoravec authored and TurboTurtle committed Aug 17, 2023
1 parent 7d5a2d9 commit e98e658
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tests/sos_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e98e658

Please sign in to comment.