Volkov: добавить Sprinter Commander
Реализовать двухпанельный Commander от платформенного PoC до этапов P6-P20: EMM-каталог, сортировку и выбор, операции с файлами и деревьями, транзакционное копирование, метаданные, политику конфликтов и предварительную проверку свободного места. Добавить проектную документацию, HDD/MAME-сценарии и проверенные артефакты. Расширить libc операцией bank_write_page, исправлением режима O_RDONLY и связанными регрессионными проверками.
This commit is contained in:
+72
@@ -0,0 +1,72 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Создаёт и проверяет HDD-fixture рекурсивного F5 одного каталога."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
|
||||
def payload(size: int, seed: int) -> bytes:
|
||||
return bytes(((index * 53 + seed) & 0xFF) for index in range(size))
|
||||
|
||||
|
||||
def create(root: pathlib.Path) -> None:
|
||||
tree = root / "SRC" / "TREE"
|
||||
(root / "DST").mkdir(parents=True)
|
||||
(tree / "EMPTY").mkdir(parents=True)
|
||||
(tree / "ROOT.TXT").write_bytes(b"recursive root\r\n")
|
||||
sub = tree / "SUB"
|
||||
sub.mkdir()
|
||||
(sub / "A.BIN").write_bytes(payload(4097, 7))
|
||||
(sub / "ZERO.DAT").write_bytes(b"")
|
||||
|
||||
deep = sub
|
||||
for level in range(1, 17):
|
||||
deep = deep / f"L{level:02d}"
|
||||
deep.mkdir()
|
||||
(deep / "BOTTOM.TXT").write_bytes(b"depth sixteen\r\n")
|
||||
|
||||
|
||||
def tree_snapshot(root: pathlib.Path) -> dict[str, bytes | None]:
|
||||
result: dict[str, bytes | None] = {}
|
||||
for path in sorted(root.rglob("*")):
|
||||
relative = path.relative_to(root).as_posix().upper()
|
||||
result[relative] = None if path.is_dir() else path.read_bytes()
|
||||
return result
|
||||
|
||||
|
||||
def verify(root: pathlib.Path) -> None:
|
||||
source = root / "SRC" / "TREE"
|
||||
target = root / "DST" / "TREE"
|
||||
failures: list[str] = []
|
||||
|
||||
if not source.is_dir() or not target.is_dir():
|
||||
failures.append("source или target TREE отсутствует")
|
||||
elif tree_snapshot(source) != tree_snapshot(target):
|
||||
failures.append("рекурсивное дерево target не совпадает с source")
|
||||
|
||||
temporary = [path.as_posix() for path in (root / "DST").rglob("*")
|
||||
if path.name.upper().endswith(".TMP")]
|
||||
if temporary:
|
||||
failures.append(f"остались temp: {temporary}")
|
||||
|
||||
if failures:
|
||||
for failure in failures:
|
||||
print(f"FAIL: {failure}")
|
||||
raise SystemExit(1)
|
||||
print("PASS: recursive tree copied exactly; depth=16; no temp.")
|
||||
|
||||
|
||||
def main() -> None:
|
||||
if len(sys.argv) != 3 or sys.argv[1] not in {"create", "verify"}:
|
||||
raise SystemExit(f"usage: {sys.argv[0]} create|verify DIR")
|
||||
root = pathlib.Path(sys.argv[2])
|
||||
if sys.argv[1] == "create":
|
||||
create(root)
|
||||
else:
|
||||
verify(root)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user