[csw-devel] SF.net SVN: gar:[12092] csw/mgar/gar/v2/lib/python
wahwah at users.sourceforge.net
wahwah at users.sourceforge.net
Mon Dec 27 13:24:39 CET 2010
Revision: 12092
http://gar.svn.sourceforge.net/gar/?rev=12092&view=rev
Author: wahwah
Date: 2010-12-27 12:24:38 +0000 (Mon, 27 Dec 2010)
Log Message:
-----------
checkpkg: Moving functions to InspectivePackage
Part of cleanup. Functions interacting with the OS should be in the
InspectivePackage class.
Modified Paths:
--------------
csw/mgar/gar/v2/lib/python/inspective_package.py
csw/mgar/gar/v2/lib/python/inspective_package_test.py
csw/mgar/gar/v2/lib/python/package_stats.py
csw/mgar/gar/v2/lib/python/package_stats_test.py
Modified: csw/mgar/gar/v2/lib/python/inspective_package.py
===================================================================
--- csw/mgar/gar/v2/lib/python/inspective_package.py 2010-12-27 12:24:11 UTC (rev 12091)
+++ csw/mgar/gar/v2/lib/python/inspective_package.py 2010-12-27 12:24:38 UTC (rev 12092)
@@ -133,7 +133,154 @@
binaries_dump_info.append(binary_data)
return binaries_dump_info
+ def GetDefinedSymbols(self):
+ """Returns text symbols (i.e. defined functions) for packaged ELF objects
+ To do this we parse output lines from nm similar to the following. "T"s are
+ the definitions which we are after.
+
+ 0000104000 D _lib_version
+ 0000986980 D _libiconv_version
+ 0000000000 U abort
+ 0000097616 T aliases_lookup
+ """
+ binaries = self.ListBinaries()
+ defined_symbols = {}
+
+ for binary in binaries:
+ binary_abspath = os.path.join(self.directory, "root", binary)
+ # Get parsable, ld.so.1 relevant SHT_DYNSYM symbol information
+ args = ["/usr/ccs/bin/nm", "-p", "-D", binary_abspath]
+ nm_proc = subprocess.Popen(
+ args,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ stdout, stderr = nm_proc.communicate()
+ retcode = nm_proc.wait()
+ if retcode:
+ logging.error("%s returned an error: %s", args, stderr)
+ continue
+ nm_out = stdout.splitlines()
+
+ defined_symbols[binary] = []
+ for line in nm_out:
+ sym = self._ParseNmSymLine(line)
+ if not sym:
+ continue
+ if sym['type'] not in ("T", "D", "B"):
+ continue
+ defined_symbols[binary].append(sym['name'])
+
+ return defined_symbols
+
+ def GetLddMinusRlines(self):
+ """Returns ldd -r output."""
+ dir_pkg = self.GetInspectivePkg()
+ binaries = dir_pkg.ListBinaries()
+ ldd_output = {}
+ for binary in binaries:
+ binary_abspath = os.path.join(dir_pkg.directory, "root", binary)
+ # this could be potentially moved into the DirectoryFormatPackage class.
+ # ldd needs the binary to be executable
+ os.chmod(binary_abspath, 0755)
+ args = ["ldd", "-r", binary_abspath]
+ ldd_proc = subprocess.Popen(
+ args,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ stdout, stderr = ldd_proc.communicate()
+ retcode = ldd_proc.wait()
+ if retcode:
+ logging.error("%s returned an error: %s", args, stderr)
+ ldd_info = []
+ for line in stdout.splitlines():
+ ldd_info.append(self._ParseLddDashRline(line))
+ ldd_output[binary] = ldd_info
+ return ldd_output
+
+ def _ParseNmSymLine(self, line):
+ re_defined_symbol = re.compile('[0-9]+ [ABDFNSTU] \S+')
+ m = re_defined_symbol.match(line)
+ if not m:
+ return None
+ fields = line.split()
+ sym = { 'address': fields[0], 'type': fields[1], 'name': fields[2] }
+ return sym
+
+ 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+"
+ r"\((?P<path_not_found>\S+)\)")
+ only_so = r"^\t(?P<path_only>\S+)$"
+ version_so = (r'^\t(?P<soname_version_not_found>\S+) '
+ r'\((?P<lib_name>\S+)\) =>\t \(version not found\)')
+ stv_protected = (r'^\trelocation \S+ symbol: (?P<relocation_symbol>\S+): '
+ r'file (?P<relocation_path>\S+): '
+ r'relocation bound to a symbol '
+ r'with STV_PROTECTED visibility$')
+ sizes_differ = (r'^\trelocation \S+ sizes differ: '
+ r'(?P<sizes_differ_symbol>\S+)$')
+ sizes_info = (r'^\t\t\(file (?P<sizediff_file1>\S+) size=(?P<size1>0x\w+); '
+ r'file (?P<sizediff_file2>\S+) size=(?P<size2>0x\w+)\)$')
+ sizes_one_used = (r'^\t\t(?P<sizediffused_file>\S+) size used; '
+ r'possible insufficient data copied$')
+ common_re = (r"(%s|%s|%s|%s|%s|%s|%s|%s)"
+ % (found_re, symbol_not_found_re, only_so, version_so,
+ stv_protected, sizes_differ, sizes_info, sizes_one_used))
+ 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 and d["symbol"]:
+ response["state"] = "symbol-not-found"
+ response["soname"] = None
+ response["path"] = d["path_not_found"]
+ response["symbol"] = d["symbol"]
+ elif d["path_only"]:
+ response["state"] = "OK"
+ response["soname"] = None
+ response["path"] = d["path_only"]
+ response["symbol"] = None
+ elif d["soname_version_not_found"]:
+ response["state"] = "version-not-found"
+ response["soname"] = d["soname_version_not_found"]
+ response["path"] = None
+ response["symbol"] = None
+ elif d["relocation_symbol"]:
+ response["state"] = 'relocation-bound-to-a-symbol-with-STV_PROTECTED-visibility'
+ response["soname"] = None
+ response["path"] = d["relocation_path"]
+ response["symbol"] = d["relocation_symbol"]
+ elif d["sizes_differ_symbol"]:
+ response["state"] = 'sizes-differ'
+ response["soname"] = None
+ response["path"] = None
+ response["symbol"] = d["sizes_differ_symbol"]
+ elif d["sizediff_file1"]:
+ response["state"] = 'sizes-diff-info'
+ response["soname"] = None
+ response["path"] = "%s %s" % (d["sizediff_file1"], d["sizediff_file2"])
+ response["symbol"] = None
+ elif d["sizediffused_file"]:
+ response["state"] = 'sizes-diff-one-used'
+ response["soname"] = None
+ response["path"] = "%s" % (d["sizediffused_file"])
+ response["symbol"] = None
+ else:
+ raise StdoutSyntaxError("Could not parse %s with %s"
+ % (repr(line), common_re))
+ else:
+ raise StdoutSyntaxError("Could not parse %s with %s"
+ % (repr(line), common_re))
+ return response
+
+
class FileMagic(object):
"""Libmagic sometimes returns None, which I think is a bug.
Trying to come up with a way to work around that. It might not even be
Modified: csw/mgar/gar/v2/lib/python/inspective_package_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/inspective_package_test.py 2010-12-27 12:24:11 UTC (rev 12091)
+++ csw/mgar/gar/v2/lib/python/inspective_package_test.py 2010-12-27 12:24:38 UTC (rev 12092)
@@ -7,6 +7,18 @@
import magic
import os
+LDD_R_OUTPUT_1 = """\tlibc.so.1 => /lib/libc.so.1
+\tsymbol not found: check_encoding_conversion_args (/opt/csw/lib/postgresql/8.4/utf8_and_gbk.so)
+\tsymbol not found: LocalToUtf (/opt/csw/lib/postgresql/8.4/utf8_and_gbk.so)
+\tsymbol not found: UtfToLocal (/opt/csw/lib/postgresql/8.4/utf8_and_gbk.so)
+\tlibm.so.2 => /lib/libm.so.2
+\t/usr/lib/secure/s8_preload.so.1
+\tlibXext.so.0 (SUNW_1.1) =>\t (version not found)
+\trelocation R_SPARC_COPY symbol: ASN1_OCTET_STRING_it: file /opt/csw/lib/sparcv8plus+vis/libcrypto.so.0.9.8: relocation bound to a symbol with STV_PROTECTED visibility
+\trelocation R_SPARC_COPY sizes differ: _ZTI7QWidget
+\t\t(file /tmp/pkg_GqCk0P/CSWkdeartworkgcc/root/opt/csw/kde-gcc/bin/kslideshow.kss size=0x28; file /opt/csw/kde-gcc/lib/libqt-mt.so.3 size=0x20)
+"""
+
class InspectivePackageUnitTest(mox.MoxTestBase):
def testOne(self):
@@ -44,5 +56,115 @@
self.assertEqual(["foo-file"], ip.ListBinaries())
+class PackageStatsUnitTest(unittest.TestCase):
+
+ def setUp(self):
+ self.ip = inspective_package.InspectivePackage("/fake/path/CSWfoo")
+
+ def test_ParseNmSymLineGoodLine(self):
+ line = '0000097616 T aliases_lookup'
+ expected = {
+ 'address': '0000097616',
+ 'type': 'T',
+ 'name': 'aliases_lookup',
+ }
+ self.assertEqual(expected, self.ip._ParseNmSymLine(line))
+
+ def test_ParseNmSymLineBadLine(self):
+ line = 'foo'
+ self.assertEqual(None, self.ip._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.ip._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.ip._ParseLddDashRline(line))
+
+ def test_ParseLddDashRlineFound(self):
+ line = '\t/usr/lib/secure/s8_preload.so.1'
+ expected = {
+ 'state': 'OK',
+ 'soname': None,
+ 'path': '/usr/lib/secure/s8_preload.so.1',
+ 'symbol': None,
+ }
+ self.assertEqual(expected, self.ip._ParseLddDashRline(line))
+
+ def test_ParseLdd_VersionNotFound(self):
+ line = '\tlibXext.so.0 (SUNW_1.1) =>\t (version not found)'
+ expected = {
+ 'symbol': None,
+ 'soname': 'libXext.so.0',
+ 'path': None,
+ 'state': 'version-not-found',
+ }
+ self.assertEqual(expected, self.ip._ParseLddDashRline(line))
+
+ def test_ParseLdd_StvProtectedVisibility(self):
+ line = ('\trelocation R_SPARC_COPY symbol: ASN1_OCTET_STRING_it: '
+ 'file /opt/csw/lib/sparcv8plus+vis/libcrypto.so.0.9.8: '
+ 'relocation bound to a symbol with STV_PROTECTED visibility')
+ expected = {
+ 'symbol': 'ASN1_OCTET_STRING_it',
+ 'soname': None,
+ 'path': '/opt/csw/lib/sparcv8plus+vis/libcrypto.so.0.9.8',
+ 'state': 'relocation-bound-to-a-symbol-with-STV_PROTECTED-visibility',
+ }
+ self.assertEqual(expected, self.ip._ParseLddDashRline(line))
+
+ def test_ParseLdd_SizesDiffer(self):
+ line = '\trelocation R_SPARC_COPY sizes differ: _ZTI7QWidget'
+ expected = {
+ 'symbol': '_ZTI7QWidget',
+ 'soname': None,
+ 'path': None,
+ 'state': 'sizes-differ',
+ }
+ self.assertEqual(expected, self.ip._ParseLddDashRline(line))
+
+ def test_ParseLdd_SizesDifferInfo(self):
+ line = ('\t\t(file /tmp/pkg_GqCk0P/CSWkdeartworkgcc/root/opt/csw/kde-gcc/bin/'
+ 'kslideshow.kss size=0x28; '
+ 'file /opt/csw/kde-gcc/lib/libqt-mt.so.3 size=0x20)')
+ expected = {
+ 'symbol': None,
+ 'path': ('/tmp/pkg_GqCk0P/CSWkdeartworkgcc/root/opt/csw/kde-gcc/'
+ 'bin/kslideshow.kss /opt/csw/kde-gcc/lib/libqt-mt.so.3'),
+ 'state': 'sizes-diff-info',
+ 'soname': None,
+ }
+ self.assertEqual(expected, self.ip._ParseLddDashRline(line))
+
+ def test_ParseLdd_SizesDifferOneUsed(self):
+ line = ('\t\t/opt/csw/kde-gcc/lib/libqt-mt.so.3 size used; '
+ 'possible insufficient data copied')
+ expected = {
+ 'symbol': None,
+ 'path': '/opt/csw/kde-gcc/lib/libqt-mt.so.3',
+ 'state': 'sizes-diff-one-used',
+ 'soname': None,
+ }
+ self.assertEqual(expected, self.ip._ParseLddDashRline(line))
+
+ def test_ParseLddDashRlineManyLines(self):
+ for line in LDD_R_OUTPUT_1.splitlines():
+ parsed = self.ip._ParseLddDashRline(line)
+
+
if __name__ == '__main__':
unittest.main()
Modified: csw/mgar/gar/v2/lib/python/package_stats.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_stats.py 2010-12-27 12:24:11 UTC (rev 12091)
+++ csw/mgar/gar/v2/lib/python/package_stats.py 2010-12-27 12:24:38 UTC (rev 12092)
@@ -8,7 +8,6 @@
import progressbar
import re
import sqlobject
-import subprocess
import catalog
import checkpkg
@@ -156,81 +155,6 @@
overrides_simple = [OverrideToDict(x) for x in override_list]
return overrides_simple
- def GetLddMinusRlines(self):
- """Returns ldd -r output."""
- dir_pkg = self.GetInspectivePkg()
- binaries = dir_pkg.ListBinaries()
- ldd_output = {}
- for binary in binaries:
- binary_abspath = os.path.join(dir_pkg.directory, "root", binary)
- # this could be potentially moved into the DirectoryFormatPackage class.
- # ldd needs the binary to be executable
- os.chmod(binary_abspath, 0755)
- args = ["ldd", "-r", binary_abspath]
- ldd_proc = subprocess.Popen(
- args,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
- stdout, stderr = ldd_proc.communicate()
- retcode = ldd_proc.wait()
- if retcode:
- logging.error("%s returned an error: %s", args, stderr)
- ldd_info = []
- for line in stdout.splitlines():
- ldd_info.append(self._ParseLddDashRline(line))
- ldd_output[binary] = ldd_info
- return ldd_output
-
- def GetDefinedSymbols(self):
- """Returns text symbols (i.e. defined functions) for packaged ELF objects
-
- To do this we parse output lines from nm similar to the following. "T"s are
- the definitions which we are after.
-
- 0000104000 D _lib_version
- 0000986980 D _libiconv_version
- 0000000000 U abort
- 0000097616 T aliases_lookup
- """
- dir_pkg = self.GetInspectivePkg()
- binaries = dir_pkg.ListBinaries()
- defined_symbols = {}
-
- for binary in binaries:
- binary_abspath = os.path.join(dir_pkg.directory, "root", binary)
- # Get parsable, ld.so.1 relevant SHT_DYNSYM symbol information
- args = ["/usr/ccs/bin/nm", "-p", "-D", binary_abspath]
- nm_proc = subprocess.Popen(
- args,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
- stdout, stderr = nm_proc.communicate()
- retcode = nm_proc.wait()
- if retcode:
- logging.error("%s returned an error: %s", args, stderr)
- continue
- nm_out = stdout.splitlines()
-
- defined_symbols[binary] = []
- for line in nm_out:
- sym = self._ParseNmSymLine(line)
- if not sym:
- continue
- if sym['type'] not in ("T", "D", "B"):
- continue
- defined_symbols[binary].append(sym['name'])
-
- return defined_symbols
-
- def _ParseNmSymLine(self, line):
- re_defined_symbol = re.compile('[0-9]+ [ABDFNSTU] \S+')
- m = re_defined_symbol.match(line)
- if not m:
- return None
- fields = line.split()
- sym = { 'address': fields[0], 'type': fields[1], 'name': fields[2] }
- return sym
-
def CollectStats(self, force=False, register_files=False):
"""Lazy stats collection."""
if force or not self.StatsExist():
@@ -465,80 +389,7 @@
self.all_stats = cPickle.loads(str(res.getOne().data_obj.pickle))
return self.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+"
- r"\((?P<path_not_found>\S+)\)")
- only_so = r"^\t(?P<path_only>\S+)$"
- version_so = (r'^\t(?P<soname_version_not_found>\S+) '
- r'\((?P<lib_name>\S+)\) =>\t \(version not found\)')
- stv_protected = (r'^\trelocation \S+ symbol: (?P<relocation_symbol>\S+): '
- r'file (?P<relocation_path>\S+): '
- r'relocation bound to a symbol '
- r'with STV_PROTECTED visibility$')
- sizes_differ = (r'^\trelocation \S+ sizes differ: '
- r'(?P<sizes_differ_symbol>\S+)$')
- sizes_info = (r'^\t\t\(file (?P<sizediff_file1>\S+) size=(?P<size1>0x\w+); '
- r'file (?P<sizediff_file2>\S+) size=(?P<size2>0x\w+)\)$')
- sizes_one_used = (r'^\t\t(?P<sizediffused_file>\S+) size used; '
- r'possible insufficient data copied$')
- common_re = (r"(%s|%s|%s|%s|%s|%s|%s|%s)"
- % (found_re, symbol_not_found_re, only_so, version_so,
- stv_protected, sizes_differ, sizes_info, sizes_one_used))
- 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 and d["symbol"]:
- response["state"] = "symbol-not-found"
- response["soname"] = None
- response["path"] = d["path_not_found"]
- response["symbol"] = d["symbol"]
- elif d["path_only"]:
- response["state"] = "OK"
- response["soname"] = None
- response["path"] = d["path_only"]
- response["symbol"] = None
- elif d["soname_version_not_found"]:
- response["state"] = "version-not-found"
- response["soname"] = d["soname_version_not_found"]
- response["path"] = None
- response["symbol"] = None
- elif d["relocation_symbol"]:
- response["state"] = 'relocation-bound-to-a-symbol-with-STV_PROTECTED-visibility'
- response["soname"] = None
- response["path"] = d["relocation_path"]
- response["symbol"] = d["relocation_symbol"]
- elif d["sizes_differ_symbol"]:
- response["state"] = 'sizes-differ'
- response["soname"] = None
- response["path"] = None
- response["symbol"] = d["sizes_differ_symbol"]
- elif d["sizediff_file1"]:
- response["state"] = 'sizes-diff-info'
- response["soname"] = None
- response["path"] = "%s %s" % (d["sizediff_file1"], d["sizediff_file2"])
- response["symbol"] = None
- elif d["sizediffused_file"]:
- response["state"] = 'sizes-diff-one-used'
- response["soname"] = None
- response["path"] = "%s" % (d["sizediffused_file"])
- response["symbol"] = None
- else:
- raise StdoutSyntaxError("Could not parse %s with %s"
- % (repr(line), common_re))
- else:
- raise StdoutSyntaxError("Could not parse %s with %s"
- % (repr(line), common_re))
- return response
-
def StatsListFromCatalog(file_name_list, catalog_file_name=None, debug=False):
packages = [inspective_package.InspectiveCswSrv4File(x, debug) for x in file_name_list]
if catalog_file_name:
Modified: csw/mgar/gar/v2/lib/python/package_stats_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_stats_test.py 2010-12-27 12:24:11 UTC (rev 12091)
+++ csw/mgar/gar/v2/lib/python/package_stats_test.py 2010-12-27 12:24:38 UTC (rev 12092)
@@ -17,128 +17,7 @@
from testdata.tree_stats import pkgstats as tree_stats
from testdata.neon_stats import pkgstats as neon_stats
-LDD_R_OUTPUT_1 = """\tlibc.so.1 => /lib/libc.so.1
-\tsymbol not found: check_encoding_conversion_args (/opt/csw/lib/postgresql/8.4/utf8_and_gbk.so)
-\tsymbol not found: LocalToUtf (/opt/csw/lib/postgresql/8.4/utf8_and_gbk.so)
-\tsymbol not found: UtfToLocal (/opt/csw/lib/postgresql/8.4/utf8_and_gbk.so)
-\tlibm.so.2 => /lib/libm.so.2
-\t/usr/lib/secure/s8_preload.so.1
-\tlibXext.so.0 (SUNW_1.1) =>\t (version not found)
-\trelocation R_SPARC_COPY symbol: ASN1_OCTET_STRING_it: file /opt/csw/lib/sparcv8plus+vis/libcrypto.so.0.9.8: relocation bound to a symbol with STV_PROTECTED visibility
-\trelocation R_SPARC_COPY sizes differ: _ZTI7QWidget
-\t\t(file /tmp/pkg_GqCk0P/CSWkdeartworkgcc/root/opt/csw/kde-gcc/bin/kslideshow.kss size=0x28; file /opt/csw/kde-gcc/lib/libqt-mt.so.3 size=0x20)
-"""
-class PackageStatsUnitTest(unittest.TestCase):
-
- def setUp(self):
- self.pkgstats = package_stats.PackageStats(None)
-
- def test_ParseNmSymLineGoodLine(self):
- line = '0000097616 T aliases_lookup'
- expected = {
- 'address': '0000097616',
- 'type': 'T',
- 'name': 'aliases_lookup',
- }
- self.assertEqual(expected, self.pkgstats._ParseNmSymLine(line))
-
- def test_ParseNmSymLineBadLine(self):
- line = 'foo'
- 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))
-
- def test_ParseLddDashRlineFound(self):
- line = '\t/usr/lib/secure/s8_preload.so.1'
- expected = {
- 'state': 'OK',
- 'soname': None,
- 'path': '/usr/lib/secure/s8_preload.so.1',
- 'symbol': None,
- }
- self.assertEqual(expected, self.pkgstats._ParseLddDashRline(line))
-
- def test_ParseLdd_VersionNotFound(self):
- line = '\tlibXext.so.0 (SUNW_1.1) =>\t (version not found)'
- expected = {
- 'symbol': None,
- 'soname': 'libXext.so.0',
- 'path': None,
- 'state': 'version-not-found',
- }
- self.assertEqual(expected, self.pkgstats._ParseLddDashRline(line))
-
- def test_ParseLdd_StvProtectedVisibility(self):
- line = ('\trelocation R_SPARC_COPY symbol: ASN1_OCTET_STRING_it: '
- 'file /opt/csw/lib/sparcv8plus+vis/libcrypto.so.0.9.8: '
- 'relocation bound to a symbol with STV_PROTECTED visibility')
- expected = {
- 'symbol': 'ASN1_OCTET_STRING_it',
- 'soname': None,
- 'path': '/opt/csw/lib/sparcv8plus+vis/libcrypto.so.0.9.8',
- 'state': 'relocation-bound-to-a-symbol-with-STV_PROTECTED-visibility',
- }
- self.assertEqual(expected, self.pkgstats._ParseLddDashRline(line))
-
- def test_ParseLdd_SizesDiffer(self):
- line = '\trelocation R_SPARC_COPY sizes differ: _ZTI7QWidget'
- expected = {
- 'symbol': '_ZTI7QWidget',
- 'soname': None,
- 'path': None,
- 'state': 'sizes-differ',
- }
- self.assertEqual(expected, self.pkgstats._ParseLddDashRline(line))
-
- def test_ParseLdd_SizesDifferInfo(self):
- line = ('\t\t(file /tmp/pkg_GqCk0P/CSWkdeartworkgcc/root/opt/csw/kde-gcc/bin/'
- 'kslideshow.kss size=0x28; '
- 'file /opt/csw/kde-gcc/lib/libqt-mt.so.3 size=0x20)')
- expected = {
- 'symbol': None,
- 'path': ('/tmp/pkg_GqCk0P/CSWkdeartworkgcc/root/opt/csw/kde-gcc/'
- 'bin/kslideshow.kss /opt/csw/kde-gcc/lib/libqt-mt.so.3'),
- 'state': 'sizes-diff-info',
- 'soname': None,
- }
- self.assertEqual(expected, self.pkgstats._ParseLddDashRline(line))
-
- def test_ParseLdd_SizesDifferOneUsed(self):
- line = ('\t\t/opt/csw/kde-gcc/lib/libqt-mt.so.3 size used; '
- 'possible insufficient data copied')
- expected = {
- 'symbol': None,
- 'path': '/opt/csw/kde-gcc/lib/libqt-mt.so.3',
- 'state': 'sizes-diff-one-used',
- 'soname': None,
- }
- self.assertEqual(expected, self.pkgstats._ParseLddDashRline(line))
-
- def test_ParseLddDashRlineManyLines(self):
- for line in LDD_R_OUTPUT_1.splitlines():
- parsed = self.pkgstats._ParseLddDashRline(line)
-
-
class PackageStatsWithDbUnitTest(test_base.SqlObjectTestMixin,
unittest.TestCase):
@@ -167,7 +46,7 @@
mock_srv4.GetMd5sum().AndReturn("mock md5sum")
mock_srv4.GetSize().AndReturn(42)
mock_dirpkg.ListBinaries().AndReturn([])
- mock_dirpkg.ListBinaries().AndReturn([])
+ mock_dirpkg.GetBinaryDumpInfo().AndReturn([])
mock_dirpkg.GetDependencies().AndReturn([])
mock_srv4.GetPkgchkOutput().AndReturn((0, "", ""))
mock_dirpkg.GetParsedPkginfo().AndReturn({
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