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

chninkel at users.sourceforge.net chninkel at users.sourceforge.net
Wed Jan 16 22:58:14 CET 2013


Revision: 20150
          http://gar.svn.sourceforge.net/gar/?rev=20150&view=rev
Author:   chninkel
Date:     2013-01-16 21:58:14 +0000 (Wed, 16 Jan 2013)
Log Message:
-----------
gar/v2: define elf test data outside functions to share them between tests

Modified Paths:
--------------
    csw/mgar/gar/v2/lib/python/inspective_package_test.py

Modified: csw/mgar/gar/v2/lib/python/inspective_package_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/inspective_package_test.py	2013-01-16 19:17:52 UTC (rev 20149)
+++ csw/mgar/gar/v2/lib/python/inspective_package_test.py	2013-01-16 21:58:14 UTC (rev 20150)
@@ -22,6 +22,70 @@
 \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)
 """
 
+ELFDUMP_OUTPUT = '''
+Version Definition Section:  .SUNW_version
+     index  version                     dependency
+       [1]  libssl.so.1.0.0                                  [ BASE ]
+       [2]  OPENSSL_1.0.0
+       [3]  OPENSSL_1.0.1               OPENSSL_1.0.0
+
+Version Needed Section:  .SUNW_version
+     index  file                        version
+       [4]  libcrypto.so.1.0.0          OPENSSL_1.0.0        [ INFO ]
+       [5]                              OPENSSL_1.0.1
+       [6]  libnsl.so.1                 SUNW_1.9.1
+
+Symbol Table Section:  .dynsym
+     index    value      size      type bind oth ver shndx          name
+       [0]  0x00000000 0x00000000  NOTY LOCL  D    0 UNDEF
+       [1]  0x00000000 0x00000000  FUNC GLOB  D    4 UNDEF          EVP_DigestSignFinal
+       [2]  0x0003ead4 0x000000dc  FUNC GLOB  P    2 .text          SSL_get_shared_ciphers
+       [3]  0x0004f8f8 0x00000014  FUNC GLOB  P    3 .text          SSL_CTX_set_srp_client_pwd_callback
+       [4]  0x00000000 0x00000000  FUNC GLOB  D    5 UNDEF          SRP_Calc_client_key
+       [5]  0x000661a0 0x00000000  OBJT GLOB  P    1 .got           _GLOBAL_OFFSET_TABLE_
+
+Syminfo Section:  .SUNW_syminfo
+     index  flags            bound to                 symbol
+       [1]  DBL          [1] libcrypto.so.1.0.0       EVP_DigestSignFinal
+       [2]  DB               <self>                   SSL_get_shared_ciphers
+       [3]  DB               <self>                   SSL_CTX_set_srp_client_pwd_callback
+       [4]  DBL          [1] libcrypto.so.1.0.0       SRP_Calc_client_key
+       [5]  DB               <self>                   _GLOBAL_OFFSET_TABLE_
+'''
+
+BINARY_ELFINFO = {'opt/csw/lib/libssl.so.1.0.0': {
+  'symbol table': [
+    {'shndx': 'UNDEF', 'soname': None, 'bind': 'LOCL',
+      'symbol': None, 'version': None, 'flags': None, 'type': 'NOTY'},
+    {'shndx': 'UNDEF', 'soname': 'libcrypto.so.1.0.0', 'bind': 'GLOB',
+      'symbol': 'EVP_DigestSignFinal', 'version': 'OPENSSL_1.0.0',
+      'flags': 'DBL', 'type': 'FUNC'},
+    {'shndx': 'UNDEF', 'soname': 'libcrypto.so.1.0.0', 'bind': 'GLOB',
+      'symbol': 'SRP_Calc_client_key', 'version': 'OPENSSL_1.0.1',
+      'flags': 'DBL', 'type': 'FUNC'},
+    {'shndx': '.text', 'soname': None, 'bind': 'GLOB',
+      'symbol': 'SSL_CTX_set_srp_client_pwd_callback',
+      'version': 'OPENSSL_1.0.1', 'flags': 'DB', 'type': 'FUNC'},
+    {'shndx': '.text', 'soname': None, 'bind': 'GLOB',
+      'symbol': 'SSL_get_shared_ciphers', 'version': 'OPENSSL_1.0.0',
+      'flags': 'DB', 'type': 'FUNC'},
+    {'shndx': '.got', 'soname': None, 'bind': 'GLOB',
+      'symbol': '_GLOBAL_OFFSET_TABLE_', 'version': None,
+      'flags': 'DB', 'type': 'OBJT'},
+    ],
+  'version definition': [
+    {'dependency': None, 'version': 'OPENSSL_1.0.0'},
+    {'dependency': 'OPENSSL_1.0.0', 'version': 'OPENSSL_1.0.1'},
+    ],
+  'version needed': [
+    {'version': 'OPENSSL_1.0.0', 'soname': 'libcrypto.so.1.0.0'},
+    {'version': 'OPENSSL_1.0.1', 'soname': 'libcrypto.so.1.0.0'},
+    {'version': 'SUNW_1.9.1', 'soname': 'libnsl.so.1'},
+    ]
+  }
+  }
+
+
 class InspectivePackageUnitTest(mox.MoxTestBase):
 
   def testListBinaries(self):
@@ -74,68 +138,7 @@
   def testGetBinaryElfInfo(self):
     fake_binary = 'opt/csw/lib/libssl.so.1.0.0'
     fake_package_path = '/fake/path/CSWfoo'
-    fake_elfdump_output = '''
-Version Definition Section:  .SUNW_version
-     index  version                     dependency
-       [1]  libssl.so.1.0.0                                  [ BASE ]
-       [2]  OPENSSL_1.0.0
-       [3]  OPENSSL_1.0.1               OPENSSL_1.0.0
 
-Version Needed Section:  .SUNW_version
-     index  file                        version
-       [4]  libcrypto.so.1.0.0          OPENSSL_1.0.0        [ INFO ]
-       [5]                              OPENSSL_1.0.1
-       [6]  libnsl.so.1                 SUNW_1.9.1
-
-Symbol Table Section:  .dynsym
-     index    value      size      type bind oth ver shndx          name
-       [0]  0x00000000 0x00000000  NOTY LOCL  D    0 UNDEF
-       [1]  0x00000000 0x00000000  FUNC GLOB  D    4 UNDEF          EVP_DigestSignFinal
-       [2]  0x0003ead4 0x000000dc  FUNC GLOB  P    2 .text          SSL_get_shared_ciphers
-       [3]  0x0004f8f8 0x00000014  FUNC GLOB  P    3 .text          SSL_CTX_set_srp_client_pwd_callback
-       [4]  0x00000000 0x00000000  FUNC GLOB  D    5 UNDEF          SRP_Calc_client_key
-       [5]  0x000661a0 0x00000000  OBJT GLOB  P    1 .got           _GLOBAL_OFFSET_TABLE_
-
-Syminfo Section:  .SUNW_syminfo
-     index  flags            bound to                 symbol
-       [1]  DBL          [1] libcrypto.so.1.0.0       EVP_DigestSignFinal
-       [2]  DB               <self>                   SSL_get_shared_ciphers
-       [3]  DB               <self>                   SSL_CTX_set_srp_client_pwd_callback
-       [4]  DBL          [1] libcrypto.so.1.0.0       SRP_Calc_client_key
-       [5]  DB               <self>                   _GLOBAL_OFFSET_TABLE_
-'''
-    fake_binary_elfinfo = {'opt/csw/lib/libssl.so.1.0.0': {
-      'symbol table': [
-        {'shndx': 'UNDEF', 'soname': None, 'bind': 'LOCL',
-          'symbol': None, 'version': None, 'flags': None, 'type': 'NOTY'},
-        {'shndx': 'UNDEF', 'soname': 'libcrypto.so.1.0.0', 'bind': 'GLOB',
-          'symbol': 'EVP_DigestSignFinal', 'version': 'OPENSSL_1.0.0',
-          'flags': 'DBL', 'type': 'FUNC'},
-        {'shndx': 'UNDEF', 'soname': 'libcrypto.so.1.0.0', 'bind': 'GLOB',
-          'symbol': 'SRP_Calc_client_key', 'version': 'OPENSSL_1.0.1',
-          'flags': 'DBL', 'type': 'FUNC'},
-        {'shndx': '.text', 'soname': None, 'bind': 'GLOB',
-          'symbol': 'SSL_CTX_set_srp_client_pwd_callback',
-          'version': 'OPENSSL_1.0.1', 'flags': 'DB', 'type': 'FUNC'},
-        {'shndx': '.text', 'soname': None, 'bind': 'GLOB',
-          'symbol': 'SSL_get_shared_ciphers', 'version': 'OPENSSL_1.0.0',
-          'flags': 'DB', 'type': 'FUNC'},
-        {'shndx': '.got', 'soname': None, 'bind': 'GLOB',
-          'symbol': '_GLOBAL_OFFSET_TABLE_', 'version': None,
-          'flags': 'DB', 'type': 'OBJT'},
-        ],
-      'version definition': [
-        {'dependency': None, 'version': 'OPENSSL_1.0.0'},
-        {'dependency': 'OPENSSL_1.0.0', 'version': 'OPENSSL_1.0.1'},
-        ],
-      'version needed': [
-        {'version': 'OPENSSL_1.0.0', 'soname': 'libcrypto.so.1.0.0'},
-        {'version': 'OPENSSL_1.0.1', 'soname': 'libcrypto.so.1.0.0'},
-        {'version': 'SUNW_1.9.1', 'soname': 'libnsl.so.1'},
-        ]
-      }
-    }
-
     ip = inspective_package.InspectivePackage(fake_package_path)
     self.mox.StubOutWithMock(ip, 'ListBinaries')
     ip.ListBinaries().AndReturn([fake_binary])
@@ -144,10 +147,10 @@
     args = [common_constants.ELFDUMP_BIN,
             '-svy',
             os.path.join(fake_package_path, "root", fake_binary)]
-    shell.ShellCommand(args).AndReturn((0, fake_elfdump_output, ""))
+    shell.ShellCommand(args).AndReturn((0, ELFDUMP_OUTPUT, ""))
     self.mox.ReplayAll()
 
-    self.assertEqual(fake_binary_elfinfo, ip.GetBinaryElfInfo())
+    self.assertEqual(BINARY_ELFINFO, ip.GetBinaryElfInfo())
 
   def testGetLddMinusRlinesRoot(self):
     ip = inspective_package.InspectivePackage("/tmp/CSWfake")

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