"""Exercise the target file executable with its installed magic database.""" from pathlib import Path import subprocess program = "checked/usr/bin/file" magic = Path("checked/usr/share/misc/magic.mgc") if not magic.is_file(): raise SystemExit(f"installed magic database missing at {magic}") command = ["vinix-run", "--library-path", "checked/usr/lib", program, "-m", str(magic), "--brief", "--mime-type"] Path("plain.txt").write_text("Vinix package fixture\n") types = subprocess.check_output([*command, program, "plain.txt"], text=True).splitlines() if len(types) != 2 or types[0] not in ("application/x-executable", "application/x-pie-executable") or types[1] != "text/plain": raise SystemExit(f"unexpected target MIME types: {types}")