def testMergeCopyAndLink(self): for arch in [Architecture.X86, Architecture.X86_64]: file1 = os.path.join(self.tmp, arch, 'share', 'test1') file2 = os.path.join(self.tmp, arch, 'share', 'test2') with open(file1, 'w') as f: f.write("test") os.symlink(file1, file2) gen = OSXUniversalGenerator( os.path.join(self.tmp, Architecture.UNIVERSAL)) gen.merge_dirs([ os.path.join(self.tmp, Architecture.X86), os.path.join(self.tmp, Architecture.X86_64)]) file1 = os.path.join(self.tmp, Architecture.UNIVERSAL, 'share', 'test1') file2 = os.path.join(self.tmp, Architecture.UNIVERSAL, 'share', 'test2') self.assertTrue(os.path.exists(file1)) self.assertTrue(os.path.exists(file2)) self.assertEqual(os.readlink(file2), file1)
def testMergedLibraryPaths(self): def check_prefix(path): if self.tmp not in path: return self.assertTrue(uni_prefix in path) self.assertTrue(x86_prefix not in path) self.assertTrue(x86_64_prefix not in path) self._compile(Architecture.X86) self._compile(Architecture.X86_64) self._check_compiled_files() uni_prefix = os.path.join(self.tmp, Architecture.UNIVERSAL) x86_prefix = os.path.join(self.tmp, Architecture.X86) x86_64_prefix = os.path.join(self.tmp, Architecture.X86_64) gen = OSXUniversalGenerator(uni_prefix) gen.merge_dirs([x86_prefix, x86_64_prefix]) libfoo = os.path.join(self.tmp, Architecture.UNIVERSAL, 'lib', 'libfoo.so') libname = OSXRelocator.library_id_name(libfoo) check_prefix(libname) for p in OSXRelocator.list_shared_libraries(libfoo): check_prefix(p)
def testMergedLibraryPaths(self): def check_prefix(path): if self.tmp not in path: return self.assertTrue(uni_prefix in path) self.assertTrue(x86_prefix not in path) self.assertTrue(x86_64_prefix not in path) self._compile(Architecture.X86) self._compile(Architecture.X86_64) self._check_compiled_files() uni_prefix = os.path.join(self.tmp, Architecture.UNIVERSAL) x86_prefix = os.path.join(self.tmp, Architecture.X86) x86_64_prefix = os.path.join(self.tmp, Architecture.X86_64) gen = OSXUniversalGenerator(uni_prefix) gen.merge_dirs([x86_prefix, x86_64_prefix]) libfoo = os.path.join(self.tmp, Architecture.UNIVERSAL, 'lib', 'libfoo.so') libname = OSXRelocator.library_id_name(libfoo) check_prefix(libname) for p in OSXRelocator.list_shared_libraries(libfoo): check_prefix(p)
def testMergeDirs(self): self._compile(Architecture.X86) self._compile(Architecture.X86_64) self._check_compiled_files() gen = OSXUniversalGenerator( os.path.join(self.tmp, Architecture.UNIVERSAL)) gen.merge_dirs([ os.path.join(self.tmp, Architecture.X86), os.path.join(self.tmp, Architecture.X86_64)]) # bash-3.2$ file libfoo.so # libfoo.so: Mach-O universal binary with 2 architectures # libfoo.so (for architecture i386): Mach-O dynamically linked shared library i386 # libfoo.so (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64 ftype = self._get_file_type(os.path.join(self.tmp, Architecture.UNIVERSAL, 'lib', 'libfoo.so')) for arch in [Architecture.X86, Architecture.X86_64]: self.assertTrue(SHARED_LIBRARY[arch] in ftype) ftype = self._get_file_type(os.path.join(self.tmp, Architecture.UNIVERSAL, 'bin', 'test_app')) for arch in [Architecture.X86, Architecture.X86_64]: self.assertTrue(EXECUTABLE[arch] in ftype)
def testMergeCopyAndLink(self): for arch in [Architecture.X86, Architecture.X86_64]: file1 = os.path.join(self.tmp, arch, 'share', 'test1') file2 = os.path.join(self.tmp, arch, 'share', 'test2') with open(file1, 'w') as f: f.write("test") os.symlink(file1, file2) gen = OSXUniversalGenerator( os.path.join(self.tmp, Architecture.UNIVERSAL)) gen.merge_dirs([ os.path.join(self.tmp, Architecture.X86), os.path.join(self.tmp, Architecture.X86_64) ]) file1 = os.path.join(self.tmp, Architecture.UNIVERSAL, 'share', 'test1') file2 = os.path.join(self.tmp, Architecture.UNIVERSAL, 'share', 'test2') self.assertTrue(os.path.exists(file1)) self.assertTrue(os.path.exists(file2)) self.assertEquals(os.readlink(file2), file1)
def testMergeDirs(self): self._compile(Architecture.X86) self._compile(Architecture.X86_64) self._check_compiled_files() gen = OSXUniversalGenerator( os.path.join(self.tmp, Architecture.UNIVERSAL)) gen.merge_dirs([ os.path.join(self.tmp, Architecture.X86), os.path.join(self.tmp, Architecture.X86_64) ]) # bash-3.2$ file libfoo.so # libfoo.so: Mach-O universal binary with 2 architectures # libfoo.so (for architecture i386): Mach-O dynamically linked shared library i386 # libfoo.so (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64 ftype = self._get_file_type( os.path.join(self.tmp, Architecture.UNIVERSAL, 'lib', 'libfoo.so')) for arch in [Architecture.X86, Architecture.X86_64]: self.assertTrue(SHARED_LIBRARY[arch] in ftype) ftype = self._get_file_type( os.path.join(self.tmp, Architecture.UNIVERSAL, 'bin', 'test_app')) for arch in [Architecture.X86, Architecture.X86_64]: self.assertTrue(EXECUTABLE[arch] in ftype)