Debian Codegraph @

debian/tests/import

raw
1 #!/bin/sh
2 set -e
3
4 # CRITICAL: leave source tree
5 cd /
6
7 # Force use of installed package
8 unset PYTHONPATH
9
10 for py in $(py3versions -s); do
11 echo "=== Testing with $py ==="
12
13 $py - <<'EOF'
14 import ptufile
15 import numpy
16 import tempfile
17 import os
18 import subprocess
19
20 print("✔ Imported ptufile")
21
22 # Check where the Python module is loaded from
23 print("ptufile module:", ptufile.__file__)
24 assert ptufile.__file__ is not None
25
26 # Ensure the C extension is present and loaded
27 try:
28 import ptufile._ptufile as ext
29 except ImportError as e:
30 raise AssertionError("C extension ptufile not found") from e
31
32 print("✔ C extension loaded:", ext.__file__)
33 assert "dist-packages" in ptufile.__file__, ptufile.__file__
34 assert ext.__file__.endswith(".so"), ext.__file__
35
36 # Verify shared library dependencies using ldd
37 print("Running ldd on:", ext.__file__)
38 out = subprocess.check_output(["ldd", ext.__file__], text=True)
39 print(out)
40
41 # Ensure libc is linked and no dependencies are missing
42 assert "libc.so.6" in out, "libc missing in ldd output"
43 assert "not found" not in out, "Missing shared library detected"
44
45 # Minimal functional test using the C extension
46 data = numpy.zeros((2, 2, 4), dtype=numpy.uint32)
47
48 tmp = tempfile.NamedTemporaryFile(suffix=".bin", delete=False)
49 tmp.close()
50
51 try:
52 # Call a core function to ensure runtime correctness
53 ptufile.binwrite(tmp.name, data, 1e-9, pixel_resolution=1.0)
54 print("✔ binwrite OK")
55
56 # Verify output file was created and is not empty
57 assert os.path.exists(tmp.name), "Output file missing"
58 assert os.path.getsize(tmp.name) > 0, "Output file is empty"
59
60 print("✔ File write OK")
61
62 finally:
63 os.unlink(tmp.name)
64
65 print("✔ All checks passed")
66
67 EOF
68 done
69
70 echo "=== All Python versions passed ==="