diff --git a/tests/test_termux_python_linkage.py b/tests/test_termux_python_linkage.py index 11c76e1e73..37c19d27a0 100644 --- a/tests/test_termux_python_linkage.py +++ b/tests/test_termux_python_linkage.py @@ -14,11 +14,11 @@ from scripts.termux import python_linkage @pytest.mark.platforms("linux") def test_python_symbols_gain_an_explicit_library_dependency(tmp_path): - import _ctypes + import _cffi_backend library = Path(sysconfig.get_config_var("LIBDIR")) / sysconfig.get_config_var("LDLIBRARY") - extension = tmp_path / Path(_ctypes.__file__).name - shutil.copy2(_ctypes.__file__, extension) + extension = tmp_path / Path(_cffi_backend.__file__).name + shutil.copy2(_cffi_backend.__file__, extension) original = subprocess.check_output(["patchelf", "--print-needed", str(extension)], text=True).splitlines() for name in original: if name.startswith("libpython"): @@ -29,7 +29,7 @@ def test_python_symbols_gain_an_explicit_library_dependency(tmp_path): assert soname in needed assert not python_linkage.link_extension(extension, library), "a second pass must not edit a correct extension" subprocess.run( - [sys.executable, "-c", "import _ctypes; print(_ctypes.__file__)"], + [sys.executable, "-c", "import _cffi_backend; print(_cffi_backend.__file__)"], cwd=tmp_path, check=True, ) diff --git a/tests/test_termux_runtime_libs.py b/tests/test_termux_runtime_libs.py index 63e42bfa10..24718dc14c 100644 --- a/tests/test_termux_runtime_libs.py +++ b/tests/test_termux_runtime_libs.py @@ -160,8 +160,6 @@ def test_stage_cache_correctness(tmp_path, lib_source, corruption): # True cache hit: source deleted, no downloads possible. server.stop() - for p in (tmp_path / "payload" / ".work").rglob("*"): - pass import shutil shutil.rmtree(tmp_path / "payload" / ".work") assert srl.stage(tmp_path / "payload", table) == out @@ -207,9 +205,12 @@ def test_collision_identical_ok_conflicting_raises(tmp_path, lib_source): srl.stage(tmp_path / "payload", table) -def test_main_thin_caller(tmp_path): - """main() is a thin wrapper over stage() reading runtime_libs.json.""" - import importlib - mod = importlib.reload(srl) - assert callable(mod.stage) - assert callable(mod.main) +def test_stale_scratch_cannot_poison_a_rebuilt_cache(tmp_path, lib_source): + _, table = lib_source + out = _stage(tmp_path, table) + expected = (out / "liba.so").read_bytes() + scratch = tmp_path / "payload/.work/runtime-libs/extract/liba" / PREFIX / "lib/liba.so" + scratch.write_bytes(b"corrupted scratch bytes") + (out / "liba.so").unlink() + srl.stage(tmp_path / "payload", table) + assert (out / "liba.so").read_bytes() == expected