CLI interface for testing
()
| 256 | |
| 257 | |
| 258 | def main() -> None: |
| 259 | """CLI interface for testing""" |
| 260 | if len(sys.argv) < 2: |
| 261 | print("Usage: python avr8js_docker.py <firmware.elf> [timeout]") |
| 262 | print() |
| 263 | print("Example:") |
| 264 | print(" python avr8js_docker.py .build/pio/uno/.pio/build/uno/firmware.elf 30") |
| 265 | sys.exit(1) |
| 266 | |
| 267 | firmware_path = Path(sys.argv[1]) |
| 268 | timeout = int(sys.argv[2]) if len(sys.argv) > 2 else 30 |
| 269 | |
| 270 | try: |
| 271 | runner = DockerAVR8jsRunner() |
| 272 | |
| 273 | # Ensure Docker is available |
| 274 | if not runner.check_docker_available(): |
| 275 | print("❌ Docker is not available") |
| 276 | sys.exit(1) |
| 277 | |
| 278 | # Ensure image exists |
| 279 | if not runner.ensure_image_available(): |
| 280 | print("❌ Failed to prepare Docker image") |
| 281 | sys.exit(1) |
| 282 | |
| 283 | # Run tests |
| 284 | returncode = runner.run( |
| 285 | elf_path=firmware_path, |
| 286 | mcu="atmega328p", |
| 287 | frequency=16000000, |
| 288 | timeout=timeout, |
| 289 | ) |
| 290 | |
| 291 | sys.exit(returncode) |
| 292 | |
| 293 | except KeyboardInterrupt as ki: |
| 294 | handle_keyboard_interrupt(ki) |
| 295 | raise |
| 296 | except Exception as e: |
| 297 | print(f"❌ Error: {e}") |
| 298 | sys.exit(1) |
| 299 | |
| 300 | |
| 301 | if __name__ == "__main__": |
no test coverage detected