Skip to content

Commit

Permalink
TST: Use different library file for link test
Browse files Browse the repository at this point in the history
The old test seemed to pick up the 32-bit library, not the 64-bit one.
The new test should pick up the 64-bit one consistently when relevant.
  • Loading branch information
DWesl committed Jun 28, 2024
1 parent 19ea50b commit 9d45f13
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions distutils/tests/test_build_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import re
import shutil
import site
import subprocess
import sys
import tempfile
import textwrap
Expand Down Expand Up @@ -112,8 +113,8 @@ def test_build_ext(self, copy_so):
)
elif sys.platform == 'linux':
libz_so = glob.glob('/usr/lib*/libz.so*')
shutil.copyfile(libz_so[0], '/tmp/libxx_z.so')
shutil.copyfile(libz_so[-1], '/tmp/libxx_z.so')

xx_ext = Extension(
'xx',
[xx_c],
Expand All @@ -140,7 +141,7 @@ def test_build_ext(self, copy_so):

with safe_extension_import('xx', self.tmp_dir):
self._test_xx(copy_so)

if sys.platform == 'linux' and copy_so:
os.unlink('/tmp/libxx_z.so')

Expand All @@ -159,9 +160,11 @@ def _test_xx(copy_so):
assert xx.__doc__ == doc
assert isinstance(xx.Null(), xx.Null)
assert isinstance(xx.Str(), xx.Str)

if sys.platform == 'linux':
so_headers = subprocess.check_output(["readelf", "-d", xx.__file__], universal_newlines=True)
so_headers = subprocess.check_output(
["readelf", "-d", xx.__file__], universal_newlines=True
)
if not copy_so:
# Linked against a library in /usr/lib{,64}
assert 'RPATH' not in so_headers and 'RUNPATH' not in so_headers
Expand Down

0 comments on commit 9d45f13

Please sign in to comment.