From bc124ba8c76b93a6d29ca7b80b7d7cf8b1457c65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Nowak?= <luke@nexedi.com> Date: Tue, 9 Nov 2010 12:43:51 +0000 Subject: [PATCH] - start to use readelf to check ELF files git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@40092 20353a03-c40f-0410-a6d1-a30d3c3de9de --- buildout/tests/assertSoftware.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/buildout/tests/assertSoftware.py b/buildout/tests/assertSoftware.py index ff2ffa97d0..d341b8fb76 100644 --- a/buildout/tests/assertSoftware.py +++ b/buildout/tests/assertSoftware.py @@ -12,6 +12,27 @@ def createCleanList(s): """ return sorted([q.strip() for q in s.split() if len(q.strip()) > 0]) +def readElfAsDict(f): + """Reads ELF information from file""" + popen = subprocess.Popen(['readelf', '-d', f], stdout=subprocess.PIPE, + stderr=subprocess.STDOUT) + result = popen.communicate()[0] + if popen.returncode != 0: + return False + library_list = [] + for l in result.split('\n'): + if '(NEEDED)' in l: + library_list.append(l.split(':')[1].strip(' []')) + elif '(RPATH)' in l: + rpath_list = l.split(':',1)[1].strip(' []').split(':') + elif '(RUNPATH)' in l: + runpath_list = l.split(':',1)[1].strip(' []').split(':') + return dict( + library_list=library_list, + rpath_list=rpath_list, + runpath_list=runpath_list + ) + class AssertPythonSoftware(unittest.TestCase): """Asserts that python related software is in good shape.""" @@ -186,6 +207,14 @@ class AssertMysql50Tritonn(unittest.TestCase): class AssertApache(unittest.TestCase): """Tests for built apache""" + def test_ld_libaprutil1(self): + """Checks proper linking""" + elf_dict = readElfAsDict('parts/apache/lib/libaprutil-1.so') + for lib in ['libexpat', 'libapr-1', 'librt', + 'libcrypt', 'libpthread', 'libdl', 'libc']: + self.assertEqual(1, len([q for q in elf_dict['library_list'] if + q.startswith(lib+'.')]), 'No %r found' % lib) + def test_modules(self): """Checks for availability of apache modules""" required_module_list = createCleanList(""" -- 2.30.9