vinix-ports / ports / file / check.py
14 lines · 13 sloc · 758 bytes · c33d8afc2906b8dd9a8b905224eccd49a44f7ad5
Raw
1"""Exercise the target file executable with its installed magic database."""
2from pathlib import Path
3import subprocess
4
5program = "checked/usr/bin/file"
6magic = Path("checked/usr/share/misc/magic.mgc")
7if not magic.is_file():
8 raise SystemExit(f"installed magic database missing at {magic}")
9command = ["vinix-run", "--library-path", "checked/usr/lib", program,
10 "-m", str(magic), "--brief", "--mime-type"]
11Path("plain.txt").write_text("Vinix package fixture\n")
12types = subprocess.check_output([*command, program, "plain.txt"], text=True).splitlines()
13if 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