Skip to content

Commit 3d9bb59

Browse files
committed
chore: add test for glibcxx 3.4.25 symbol
1 parent 946303a commit 3d9bb59

File tree

3 files changed

+82
-0
lines changed

3 files changed

+82
-0
lines changed

Diff for: tests/integration/test_glibcxx_3_4_25/setup.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from setuptools import Extension, setup
2+
3+
setup(
4+
name="testentropy",
5+
version="0.0.1",
6+
ext_modules=[
7+
Extension(
8+
"testentropy",
9+
language="c++",
10+
sources=["testentropy.cpp"],
11+
extra_compile_args=["-std=c++11"],
12+
),
13+
],
14+
)
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include <Python.h>
2+
#include <random>
3+
4+
static PyObject *
5+
run(PyObject *self, PyObject *args)
6+
{
7+
(void)self;
8+
(void)args;
9+
std::random_device rd;
10+
return PyLong_FromLong(rd.entropy() >= 0.0 ? 0 : -1);
11+
}
12+
13+
/* Module initialization */
14+
PyMODINIT_FUNC PyInit_testentropy(void)
15+
{
16+
static PyMethodDef module_methods[] = {
17+
{"run", (PyCFunction)run, METH_NOARGS, "run."},
18+
{NULL} /* Sentinel */
19+
};
20+
static struct PyModuleDef moduledef = {
21+
PyModuleDef_HEAD_INIT,
22+
"testentropy",
23+
"testentropy module",
24+
-1,
25+
module_methods,
26+
};
27+
return PyModule_Create(&moduledef);
28+
}

Diff for: tests/integration/test_manylinux.py

+40
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,46 @@ def test_nonpy_rpath(self, any_manylinux_container, docker_python, io_folder):
693693
],
694694
)
695695

696+
def test_glibcxx_3_4_25(self, any_manylinux_container, docker_python, io_folder):
697+
policy, tag, manylinux_ctr = any_manylinux_container
698+
docker_exec(
699+
manylinux_ctr,
700+
[
701+
"bash",
702+
"-c",
703+
"cd /auditwheel_src/tests/integration/test_glibcxx_3_4_25 && "
704+
"if [ -d ./build ]; then rm -rf ./build ./*.egg-info; fi && "
705+
"python -m pip wheel --no-deps -w /io .",
706+
],
707+
)
708+
709+
orig_wheel, *_ = os.listdir(io_folder)
710+
assert orig_wheel.startswith("testentropy-0.0.1")
711+
712+
# Repair the wheel using the appropriate manylinux container
713+
repair_command = f"auditwheel repair --plat {policy} -w /io /io/{orig_wheel}"
714+
if policy.startswith("manylinux_2_28_"):
715+
with pytest.raises(CalledProcessError):
716+
docker_exec(manylinux_ctr, repair_command)
717+
# TODO if a "permissive" mode is implemented, add the relevant flag to the
718+
# repair_command here and drop the return statement below
719+
return
720+
721+
docker_exec(manylinux_ctr, repair_command)
722+
723+
repaired_wheel, *_ = glob.glob(f"{io_folder}/*{policy}*.whl")
724+
repaired_wheel = os.path.basename(repaired_wheel)
725+
726+
docker_exec(docker_python, "pip install /io/" + repaired_wheel)
727+
docker_exec(
728+
docker_python,
729+
[
730+
"python",
731+
"-c",
732+
"from testentropy import run; exit(run())",
733+
],
734+
)
735+
696736

697737
class TestManylinux(Anylinux):
698738
@pytest.fixture(scope="session")

0 commit comments

Comments
 (0)