| 134 | |
| 135 | |
| 136 | def evaluate(case: TestCase, parsed: dict[str, int]) -> tuple[bool, str]: |
| 137 | success = parsed.get("success", 0) |
| 138 | num_leds = parsed.get("num_leds", 0) |
| 139 | exp_bytes = parsed.get("exp_bytes", 0) |
| 140 | dec_bytes = parsed.get("dec_bytes", 0) |
| 141 | matched = parsed.get("matched", 0) |
| 142 | mismatched = parsed.get("mismatched", 0) |
| 143 | edges = parsed.get("edges", 0) |
| 144 | |
| 145 | if num_leds != case.num_leds: |
| 146 | return False, ( |
| 147 | f"firmware reported num_leds={num_leds}, expected {case.num_leds} — " |
| 148 | "test case mismatch" |
| 149 | ) |
| 150 | if exp_bytes != case.num_leds * 3: |
| 151 | return False, ( |
| 152 | f"firmware expected_bytes={exp_bytes}, expected {case.num_leds * 3}" |
| 153 | ) |
| 154 | |
| 155 | msg = ( |
| 156 | f"num_leds={num_leds}, exp_bytes={exp_bytes}, dec_bytes={dec_bytes}, " |
| 157 | f"matched={matched}, mismatched={mismatched}, edges={edges}" |
| 158 | ) |
| 159 | if not success or mismatched > 0: |
| 160 | return False, msg |
| 161 | return True, msg |
| 162 | |
| 163 | |
| 164 | def main() -> int: |