"""Live local protocol, concurrency, deadlines and bulk-output regression tests.""" import concurrent.futures import json import struct import subprocess import time from pathlib import Path ROOT = Path(__file__).resolve().parents[1] EXE = ROOT / "build/bin/Release/locate.exe" MAGIC = 0x31434C57 checks = [] def run(*args): return subprocess.run([str(EXE), *args], capture_output=True, timeout=30) def exact(pipe, size): data = b"" while len(data) < size: chunk = pipe.read(size - len(data)) assert chunk, "truncated reply" data += chunk return data def malformed(**changes): fields = dict(magic=MAGIC, size=0, operation=0, flags=0, limit=10, offset=0, sort=0, descending=0, timeout=1000, reserved=0) fields.update(changes) with open(r"\\.\pipe\WLocate.Search.v1", "r+b", buffering=0) as pipe: pipe.write(struct.pack("