[csw-devel] SF.net SVN: gar:[20151] csw/mgar/gar/v2/lib/python

chninkel at users.sourceforge.net chninkel at users.sourceforge.net
Wed Jan 16 23:10:45 CET 2013


Revision: 20151
          http://gar.svn.sourceforge.net/gar/?rev=20151&view=rev
Author:   chninkel
Date:     2013-01-16 22:10:44 +0000 (Wed, 16 Jan 2013)
Log Message:
-----------
gar/v2: elf 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-16 21:58:14 UTC (rev 20150)
+++ csw/mgar/gar/v2/lib/python/inspective_package.py	2013-01-16 22:10:44 UTC (rev 20151)
@@ -250,9 +250,12 @@
     """
     binaries = self.ListBinaries()
     binaries_elf_info = {}
+    base_dir = self.GetBasedir()
 
     for binary in binaries:
       binary_abspath = os.path.join(self.directory, self.GetFilesDir(), binary)
+      if base_dir:
+        binary = os.path.join(base_dir, binary)
       # elfdump is the only tool that give us all informations
       args = [common_constants.ELFDUMP_BIN, "-svy", binary_abspath]
       retcode, stdout, stderr = shell.ShellCommand(args)

Modified: csw/mgar/gar/v2/lib/python/inspective_package_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/inspective_package_test.py	2013-01-16 21:58:14 UTC (rev 20150)
+++ csw/mgar/gar/v2/lib/python/inspective_package_test.py	2013-01-16 22:10:44 UTC (rev 20151)
@@ -135,13 +135,17 @@
     }
     self.assertEqual([u'foo-file'], ip.ListBinaries())
 
-  def testGetBinaryElfInfo(self):
+  def testGetBinaryElfInfoRoot(self):
     fake_binary = 'opt/csw/lib/libssl.so.1.0.0'
     fake_package_path = '/fake/path/CSWfoo'
 
     ip = inspective_package.InspectivePackage(fake_package_path)
     self.mox.StubOutWithMock(ip, 'ListBinaries')
+    self.mox.StubOutWithMock(ip, 'GetBasedir')
+    self.mox.StubOutWithMock(ip, 'GetFilesDir')
     ip.ListBinaries().AndReturn([fake_binary])
+    ip.GetBasedir().AndReturn('')
+    ip.GetFilesDir().AndReturn('root')
 
     self.mox.StubOutWithMock(shell, 'ShellCommand')
     args = [common_constants.ELFDUMP_BIN,
@@ -152,6 +156,27 @@
 
     self.assertEqual(BINARY_ELFINFO, ip.GetBinaryElfInfo())
 
+  def testGetBinaryElfInfoReloc(self):
+    fake_binary = 'lib/libssl.so.1.0.0'
+    fake_package_path = '/fake/path/CSWfoo'
+
+    ip = inspective_package.InspectivePackage(fake_package_path)
+    self.mox.StubOutWithMock(ip, 'ListBinaries')
+    self.mox.StubOutWithMock(ip, 'GetBasedir')
+    self.mox.StubOutWithMock(ip, 'GetFilesDir')
+    ip.ListBinaries().AndReturn([fake_binary])
+    ip.GetBasedir().AndReturn('opt/csw')
+    ip.GetFilesDir().AndReturn('reloc')
+
+    self.mox.StubOutWithMock(shell, 'ShellCommand')
+    args = [common_constants.ELFDUMP_BIN,
+            '-svy',
+            os.path.join(fake_package_path, "reloc", fake_binary)]
+    shell.ShellCommand(args).AndReturn((0, ELFDUMP_OUTPUT, ""))
+    self.mox.ReplayAll()
+
+    self.assertEqual(BINARY_ELFINFO, ip.GetBinaryElfInfo())
+
   def testGetLddMinusRlinesRoot(self):
     ip = inspective_package.InspectivePackage("/tmp/CSWfake")
     self.mox.StubOutWithMock(ip, 'GetBasedir')

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