| 247 | |
| 248 | |
| 249 | def cmd_map(args) -> int: |
| 250 | data = json.load(open(MAP_FILE)) |
| 251 | platforms = data["platforms"] |
| 252 | bad = [] |
| 253 | for cls in data["classes"]: |
| 254 | cells = cls["cells"] |
| 255 | for plat in platforms: |
| 256 | cell = cells.get(plat) |
| 257 | if not cell: |
| 258 | bad.append(f"{cls['name']} / {plat}: missing") |
| 259 | elif cell.get("status") not in ("covered", "partial", "limit"): |
| 260 | bad.append(f"{cls['name']} / {plat}: status must be covered, partial or limit") |
| 261 | elif cell["status"] != "covered" and not cell.get("why"): |
| 262 | bad.append(f"{cls['name']} / {plat}: {cell['status']} needs a why") |
| 263 | if not args.quiet: |
| 264 | width = max(len(c["name"]) for c in data["classes"]) |
| 265 | print(f"{'defect class':<{width}} " + " ".join(f"{p:<14}" for p in platforms)) |
| 266 | for cls in data["classes"]: |
| 267 | row = [] |
| 268 | for plat in platforms: |
| 269 | cell = cls["cells"].get(plat, {}) |
| 270 | row.append(f"{cell.get('status', '?') + ':' + cell.get('lane', ''):<14}"[:14]) |
| 271 | print(f"{cls['name']:<{width}} " + " ".join(row)) |
| 272 | print() |
| 273 | for cls in data["classes"]: |
| 274 | for plat in platforms: |
| 275 | cell = cls["cells"].get(plat, {}) |
| 276 | if cell.get("status") in ("partial", "limit"): |
| 277 | print(f" {cell['status']:<7} {cls['name']} / {plat}: {cell.get('why', '')}") |
| 278 | for b in bad: |
| 279 | print(f"MAP DEFECT: {b}", file=sys.stderr) |
| 280 | return 1 if bad else 0 |
| 281 | |
| 282 | |
| 283 | def main() -> int: |