[csw-devel] SF.net SVN: gar:[20136] csw/mgar/gar/v2/lib/python
chninkel at users.sourceforge.net
chninkel at users.sourceforge.net
Mon Jan 14 22:32:01 CET 2013
Revision: 20136
http://gar.svn.sourceforge.net/gar/?rev=20136&view=rev
Author: chninkel
Date: 2013-01-14 21:32:00 +0000 (Mon, 14 Jan 2013)
Log Message:
-----------
gar/v2: ldd info extraction: bugfix and unit test for relocatable packages
Modified Paths:
--------------
csw/mgar/gar/v2/lib/python/inspective_package.py
csw/mgar/gar/v2/lib/python/inspective_package_test.py
Modified: csw/mgar/gar/v2/lib/python/inspective_package.py
===================================================================
--- csw/mgar/gar/v2/lib/python/inspective_package.py 2013-01-14 20:38:30 UTC (rev 20135)
+++ csw/mgar/gar/v2/lib/python/inspective_package.py 2013-01-14 21:32:00 UTC (rev 20136)
@@ -349,9 +349,13 @@
def GetLddMinusRlines(self):
"""Returns ldd -r output."""
binaries = self.ListBinaries()
+ base_dir = self.GetBasedir()
ldd_output = {}
for binary in binaries:
binary_abspath = os.path.join(self.directory, self.GetFilesDir(), binary)
+ if base_dir:
+ binary = os.path.join(base_dir, binary)
+
# this could be potentially moved into the DirectoryFormatPackage class.
# ldd needs the binary to be executable
os.chmod(binary_abspath, 0755)
Modified: csw/mgar/gar/v2/lib/python/inspective_package_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/inspective_package_test.py 2013-01-14 20:38:30 UTC (rev 20135)
+++ csw/mgar/gar/v2/lib/python/inspective_package_test.py 2013-01-14 21:32:00 UTC (rev 20136)
@@ -149,32 +149,59 @@
self.assertEqual(fake_binary_elfinfo, ip.GetBinaryElfInfo())
- def testGetLddMinusRlines(self):
+ def testGetLddMinusRlinesRoot(self):
ip = inspective_package.InspectivePackage("/tmp/CSWfake")
+ self.mox.StubOutWithMock(ip, 'GetBasedir')
self.mox.StubOutWithMock(ip, 'ListBinaries')
+ self.mox.StubOutWithMock(ip, 'GetFilesDir')
self.mox.StubOutWithMock(os, 'chmod')
self.mox.StubOutWithMock(os, 'uname')
- os.chmod('/tmp/CSWfake/root/bin/foo', 0755)
+ ip.GetBasedir().AndReturn('/')
+ os.chmod('/tmp/CSWfake/root/opt/csw/bin/foo', 0755)
+ ip.ListBinaries().AndReturn(['opt/csw/bin/foo'])
+ ip.GetFilesDir().AndReturn('root')
+ self.mox.StubOutWithMock(shell, 'ShellCommand')
+ shell.ShellCommand(
+ ['ldd', '-Ur', '/tmp/CSWfake/root/opt/csw/bin/foo'],
+ timeout=10).AndReturn((0, "", ""))
+ self.mox.StubOutWithMock(ip, '_ParseLddDashRline')
+ self.mox.ReplayAll()
+ self.assertEqual({'/opt/csw/bin/foo': []}, ip.GetLddMinusRlines())
+
+ def testGetLddMinusRlinesReloc(self):
+ ip = inspective_package.InspectivePackage("/tmp/CSWfake")
+ self.mox.StubOutWithMock(ip, 'GetBasedir')
+ self.mox.StubOutWithMock(ip, 'ListBinaries')
+ self.mox.StubOutWithMock(ip, 'GetFilesDir')
+ self.mox.StubOutWithMock(os, 'chmod')
+ self.mox.StubOutWithMock(os, 'uname')
+ ip.GetBasedir().AndReturn('/opt/csw')
+ os.chmod('/tmp/CSWfake/reloc/bin/foo', 0755)
ip.ListBinaries().AndReturn(['bin/foo'])
+ ip.GetFilesDir().AndReturn('reloc')
self.mox.StubOutWithMock(shell, 'ShellCommand')
shell.ShellCommand(
- ['ldd', '-Ur', '/tmp/CSWfake/root/bin/foo'],
+ ['ldd', '-Ur', '/tmp/CSWfake/reloc/bin/foo'],
timeout=10).AndReturn((0, "", ""))
self.mox.StubOutWithMock(ip, '_ParseLddDashRline')
self.mox.ReplayAll()
- self.assertEqual({'bin/foo': []}, ip.GetLddMinusRlines())
+ self.assertEqual({'/opt/csw/bin/foo': []}, ip.GetLddMinusRlines())
def testGetLddMinusRlinesThrows(self):
ip = inspective_package.InspectivePackage("/tmp/CSWfake")
+ self.mox.StubOutWithMock(ip, 'GetBasedir')
self.mox.StubOutWithMock(ip, 'ListBinaries')
+ self.mox.StubOutWithMock(ip, 'GetFilesDir')
self.mox.StubOutWithMock(os, 'chmod')
self.mox.StubOutWithMock(os, 'uname')
- os.chmod('/tmp/CSWfake/root/bin/foo', 0755)
+ ip.GetBasedir().AndReturn('/')
+ os.chmod('/tmp/CSWfake/root/opt/csw/bin/foo', 0755)
os.uname().AndReturn('i86pc')
- ip.ListBinaries().AndReturn(['bin/foo'])
+ ip.GetFilesDir().AndReturn('root')
+ ip.ListBinaries().AndReturn(['opt/csw/bin/foo'])
self.mox.StubOutWithMock(shell, 'ShellCommand')
shell.ShellCommand(
- ['ldd', '-Ur', '/tmp/CSWfake/root/bin/foo'],
+ ['ldd', '-Ur', '/tmp/CSWfake/root/opt/csw/bin/foo'],
timeout=10).AndReturn((1, "", "boo"))
self.mox.StubOutWithMock(ip, '_ParseLddDashRline')
self.mox.ReplayAll()
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