fxaudit-known.py 993 B

12345678910111213141516171819202122
  1. #!/usr/bin/env python3
  2. # Writes tests/FxAudit173dKnown.inc from a scripts/fxaudit.sh survey (--tsv): for every control the survey found
  3. # dependent-ok, the prerequisite that woke it up (the regression test tries it first, and searches only for the
  4. # controls it doesn't know). Usage: scripts/fxaudit-known.py survey.tsv > tests/FxAudit173dKnown.inc
  5. import csv
  6. import sys
  7. rows = []
  8. with open(sys.argv[1], newline="") as f:
  9. for r in csv.DictReader(f, delimiter="\t"):
  10. if r.get("status") == "dependent-ok" and r.get("key"):
  11. rows.append((r["effect"], r["control"], r["key"]))
  12. def q(s):
  13. return '"' + s.replace("\\", "\\\\").replace('"', '\\"') + '"'
  14. print("// Generated by scripts/fxaudit-known.py from a scripts/fxaudit.sh survey (round 173d): the prerequisite each")
  15. print("// dependent control needs (effect, control, key of fxaudit::prerequisite). Regenerate after a survey.")
  16. for e, c, k in sorted(set(rows)):
  17. print("{ %s, %s, %s }," % (q(e), q(c), q(k)))