[csw-devel] SF.net SVN: gar:[8750] csw/mgar/gar/v2/lib/python
wahwah at users.sourceforge.net
wahwah at users.sourceforge.net
Mon Feb 22 19:27:29 CET 2010
Revision: 8750
http://gar.svn.sourceforge.net/gar/?rev=8750&view=rev
Author: wahwah
Date: 2010-02-22 18:27:29 +0000 (Mon, 22 Feb 2010)
Log Message:
-----------
mGAR v2: checkpkg, ldd -r line parser and a unit test for it. It's not plugged in anywhere yet.
Modified Paths:
--------------
csw/mgar/gar/v2/lib/python/checkpkg.py
csw/mgar/gar/v2/lib/python/checkpkg_test.py
Modified: csw/mgar/gar/v2/lib/python/checkpkg.py
===================================================================
--- csw/mgar/gar/v2/lib/python/checkpkg.py 2010-02-22 18:19:43 UTC (rev 8749)
+++ csw/mgar/gar/v2/lib/python/checkpkg.py 2010-02-22 18:27:29 UTC (rev 8750)
@@ -1105,3 +1105,28 @@
for name in self.STAT_FILES:
all_stats[name] = self.ReadObject(name)
return all_stats
+
+ def _ParseLddDashRline(self, line):
+ found_re = r"^\t(?P<soname>\S+)\s+=>\s+(?P<path_found>\S+)"
+ symbol_not_found_re = r"^\tsymbol not found:\s(?P<symbol>\S+)\s+\((?P<path_not_found>\S+)\)"
+ common_re = r"(%s|%s)" % (found_re, symbol_not_found_re)
+ m = re.match(common_re, line)
+ response = {}
+ if m:
+ d = m.groupdict()
+ if "soname" in d and d["soname"]:
+ # it was found
+ response["state"] = "OK"
+ response["soname"] = d["soname"]
+ response["path"] = d["path_found"]
+ response["symbol"] = None
+ elif "symbol" in d:
+ response["state"] = "symbol-not-found"
+ response["soname"] = None
+ response["path"] = d["path_not_found"]
+ response["symbol"] = d["symbol"]
+ else:
+ raise StdoutSyntaxError("Could not parse %s" % repr(line))
+ else:
+ raise StdoutSyntaxError("Could not parse %s" % repr(line))
+ return response
Modified: csw/mgar/gar/v2/lib/python/checkpkg_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/checkpkg_test.py 2010-02-22 18:19:43 UTC (rev 8749)
+++ csw/mgar/gar/v2/lib/python/checkpkg_test.py 2010-02-22 18:27:29 UTC (rev 8750)
@@ -762,6 +762,9 @@
class PackageStatsUnitTest(unittest.TestCase):
+ def setUp(self):
+ self.pkgstats = checkpkg.PackageStats(None)
+
def test_ParseNmSymLineGoodLine(self):
line = '0000097616 T aliases_lookup'
expected = {
@@ -769,14 +772,33 @@
'type': 'T',
'name': 'aliases_lookup',
}
- pkgstats = checkpkg.PackageStats(None)
- self.assertEqual(expected, pkgstats._ParseNmSymLine(line))
+ self.assertEqual(expected, self.pkgstats._ParseNmSymLine(line))
def test_ParseNmSymLineBadLine(self):
line = 'foo'
- pkgstats = checkpkg.PackageStats(None)
- self.assertEqual(None, pkgstats._ParseNmSymLine(line))
+ self.assertEqual(None, self.pkgstats._ParseNmSymLine(line))
+ def test_ParseLddDashRlineFound(self):
+ line = '\tlibc.so.1 => /lib/libc.so.1'
+ expected = {
+ 'state': 'OK',
+ 'soname': 'libc.so.1',
+ 'path': '/lib/libc.so.1',
+ 'symbol': None,
+ }
+ self.assertEqual(expected, self.pkgstats._ParseLddDashRline(line))
+ def test_ParseLddDashRlineSymbolMissing(self):
+ line = ('\tsymbol not found: check_encoding_conversion_args '
+ '(/opt/csw/lib/postgresql/8.4/utf8_and_gbk.so)')
+ expected = {
+ 'state': 'symbol-not-found',
+ 'soname': None,
+ 'path': '/opt/csw/lib/postgresql/8.4/utf8_and_gbk.so',
+ 'symbol': 'check_encoding_conversion_args',
+ }
+ self.assertEqual(expected, self.pkgstats._ParseLddDashRline(line))
+
+
if __name__ == '__main__':
unittest.main()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the devel
mailing list