From ff07007796a9777e345992a1fe63c6e6d0e24a69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dirk=20M=C3=BCller?= Date: Mon, 7 Jul 2025 12:08:06 +0200 Subject: [PATCH] Check for leftover files in the container --- tests/test_all.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/test_all.py b/tests/test_all.py index 5e8fe4a5..4ae5fdd9 100644 --- a/tests/test_all.py +++ b/tests/test_all.py @@ -875,3 +875,34 @@ def test_uids_stable( assert gid == expected_gid, ( f"Expected user {name} to have gid {expected_gid} but got {gid}" ) + + +@pytest.mark.skipif(True, reason="not yet deleted") +def test_no_ldconfig_cache(auto_container): + """Ensure that there are no leftover backup files in /var/tmp and other locations.""" + + assert not auto_container.connection.file( + "/var/cache/ldconfig/aux-cache" + ).exists, ( + "machine-specific /var/cache/ldconfig/aux-cache still exists in container" + ) + + +def test_no_shadow_backup(auto_container): + """Ensure that there are no leftover backup files of /etc/shadow.""" + + auto_container.connection.check_output("ls -1 /var/tmp").strip() == "" + assert not auto_container.connection.file("/etc/shadow-").exists, ( + "backup file of /etc/shadow found" + ) + + +@pytest.mark.parametrize("container", CONTAINERS_WITHOUT_ZYPPER, indirect=True) +def test_no_zypper_leftover_files( + container: ContainerData, +) -> None: + """Ensure that there are no leftover files that only zypper needs.""" + + assert not container.connection.file( + "/var/lib/zypp/AnonymousUniqueId" + ).exists