Files
slocker-lite/tests/run_test.py
T
ceamac d2d631117d Drop -m/-u/-c short options for --mount/--umount/--cleanup
Now that -r/--run and -x/--exec cover normal use, --mount/--umount/--cleanup
are debug-only escape hatches not worth a short letter. Reassigned their
long_options codes to long-option-only constants (options::mount/umount/
cleanup) and dropped m:/u:/c: from getopt_long's own short-options string.

Updated the fixture smoke test (tests/run_test.py) and docs, which invoked
-m/-u/-c directly.
2026-09-05 08:43:58 +00:00

40 lines
1.1 KiB
Python

#!/usr/bin/env python3
"""Runs the mount -> umount -> cleanup cycle against the fixture image and checks
that every step succeeds, so `meson test` doesn't leak a layer on every run.
"""
import re
import subprocess
import sys
def run(slocker_lite: str, *args: str) -> subprocess.CompletedProcess:
return subprocess.run([slocker_lite, *args], capture_output=True, text=True)
def main() -> int:
slocker_lite, fixture_tar = sys.argv[1], sys.argv[2]
mount = run(slocker_lite, "--mount", fixture_tar)
if mount.returncode != 0:
print(mount.stderr, file=sys.stderr)
return mount.returncode
match = re.search(r"\(layer (\S+)\)", mount.stdout)
if not match:
print(f"could not find layer ID in mount output: {mount.stdout!r}", file=sys.stderr)
return 1
layer_id = match.group(1)
for args in (("--umount", layer_id), ("--cleanup", layer_id)):
result = run(slocker_lite, *args)
if result.returncode != 0:
print(result.stderr, file=sys.stderr)
return result.returncode
return 0
if __name__ == "__main__":
sys.exit(main())