Skip to content
Snippets Groups Projects
Commit 304660a5 authored by Chris Lamb's avatar Chris Lamb :eyes:
Browse files

tests.comparators.test_elf: Return "unknown" if we can't parse the readelf...

tests.comparators.test_elf: Return "unknown" if we can't parse the readelf version number eg. for FreeBSD. We don't skip those tests; as they should still run. (Closes: #886963)
parent b5ba6a92
No related branches found
No related tags found
No related merge requests found
......@@ -17,6 +17,7 @@
# You should have received a copy of the GNU General Public License
# along with diffoscope. If not, see <https://www.gnu.org/licenses/>.
import re
import pytest
import os.path
import subprocess
......@@ -43,7 +44,17 @@ def readelf_version():
out = subprocess.check_output(['readelf', '--version'])
except subprocess.CalledProcessError as e:
out = e.output
return out.decode('UTF-8').splitlines()[0].split()[-1].strip()
# Only match GNU readelf; we only need to match some versions
m = re.match(
r'^GNU readelf .* (?P<version>[\d.]+)\n',
out.decode('utf-8'),
)
if m is None:
return 'unknown'
return m.group('version')
def test_obj_identification(obj1):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment