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