Skip to content

Commit

Permalink
update test case to test comma sepparated list
Browse files Browse the repository at this point in the history
  • Loading branch information
ppham-nv committed Oct 9, 2024
1 parent f66f257 commit cc79c8a
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 31 deletions.
59 changes: 38 additions & 21 deletions tests/integration/test_manylinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,27 +329,44 @@ def test_repair_exclude(self, any_manylinux_container, io_folder):
orig_wheel = filenames[0]
assert "manylinux" not in orig_wheel

repair_command = [
f"LD_LIBRARY_PATH={test_path}/a:$LD_LIBRARY_PATH",
"auditwheel",
"repair",
f"--plat={policy}",
"--only-plat",
"-w",
"/io",
"--exclude=liba.so",
f"/io/{orig_wheel}",
]
output = docker_exec(manylinux_ctr, ["bash", "-c", " ".join(repair_command)])
assert "Excluding liba.so" in output
filenames = os.listdir(io_folder)
assert len(filenames) == 2
repaired_wheel = f"testrpath-0.0.1-{PYTHON_ABI}-{tag}.whl"
assert repaired_wheel in filenames

# Make sure we don't have liba.so & libb.so in the result
contents = zipfile.ZipFile(os.path.join(io_folder, repaired_wheel)).namelist()
assert not any(x for x in contents if "/liba" in x or "/libb" in x)
def run_repair_test(exclude_args, expected_exclusions):
repair_command = [
f"LD_LIBRARY_PATH={test_path}/a:$LD_LIBRARY_PATH",
"auditwheel",
"repair",
f"--plat={policy}",
"--only-plat",
"-w",
"/io",
] + exclude_args + [
f"/io/{orig_wheel}",
]
output = docker_exec(manylinux_ctr, ["bash", "-c", " ".join(repair_command)])

# Check for exclusions in the output
for arg in exclude_args:
if ',' in arg:
libs = arg.split('=')[1].split(',')
for lib in libs:
assert f"Excluding {lib}" in output
else:
lib = arg.split('=')[1]
assert f"Excluding {lib}" in output

filenames = os.listdir(io_folder)
assert len(filenames) == 2
repaired_wheel = f"testrpath-0.0.1-{PYTHON_ABI}-{tag}.whl"
assert repaired_wheel in filenames

# Make sure we don't have the excluded libraries in the result
contents = zipfile.ZipFile(os.path.join(io_folder, repaired_wheel)).namelist()
for lib in expected_exclusions:
assert not any(x for x in contents if f"/{lib}" in x)

# Test case 1: Exclude liba.so only - it will exclude libb.so as well due to indirect reference
run_repair_test(["--exclude=liba.so", "--exclude=libx.so"], ["liba.so", "libb.so", "libx.so"])
# Test case 2: Exclude liba.so and libx.so using comma separated
run_repair_test(["--exclude=liba.so,libx.so"], ["liba.so", "libb.so", "libx.so"])

def test_build_wheel_with_binary_executable(
self, any_manylinux_container, docker_python, io_folder
Expand Down
1 change: 0 additions & 1 deletion tests/integration/testrpath/c/c.h

This file was deleted.

16 changes: 10 additions & 6 deletions tests/integration/testrpath/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ def run(self) -> None:
cmd = "gcc -fPIC -shared -o b/libb.so b/b.c"
subprocess.check_call(cmd.split())

cmd = "gcc -fPIC -shared -o c/libc.so c/c.c"
cmd = "gcc -fPIC -shared -o x/libx.so x/x.c"
subprocess.check_call(cmd.split())

cmd = (
"gcc -fPIC -shared -o a/liba.so "
"-Wl,{dtags_flag} -Wl,-rpath=$ORIGIN/../b -Wl,-rpath=$ORIGIN/../c "
"-Ib a/a.c -Lb -Lc -lb -lc"
"-Wl,{dtags_flag} -Wl,-rpath=$ORIGIN/../b "
"-Ib a/a.c -Lb -lb"
).format(
dtags_flag=(
"--enable-new-dtags"
Expand All @@ -40,9 +40,13 @@ def run(self) -> None:
Extension(
"testrpath/testrpath",
sources=["src/testrpath/testrpath.c"],
include_dirs=["a", "c"],
libraries=["a", "c"],
library_dirs=["a", "c"],
include_dirs=["a", "x"],
libraries=["a", "x"],
library_dirs=["a", "x"],
extra_link_args=[
'-Wl,-rpath,$ORIGIN/../a',
'-Wl,-rpath,$ORIGIN/../x'
],
)
],
)
4 changes: 2 additions & 2 deletions tests/integration/testrpath/src/testrpath/testrpath.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <Python.h>
#include "a.h"
#include "c.h"
#include "x.h"

static PyObject *
func(PyObject *self, PyObject *args)
Expand All @@ -10,7 +10,7 @@ func(PyObject *self, PyObject *args)
(void)self;
(void)args;

res = fa() + fc();
res = fa() + fx();
return PyLong_FromLong(res);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
int fc(void) {
int fx(void) {
return 20;
}
1 change: 1 addition & 0 deletions tests/integration/testrpath/x/x.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
int fx(void);

0 comments on commit cc79c8a

Please sign in to comment.