Runner for ESP32 QEMU emulation using Docker containers. Container Naming Convention: Simulator containers use platform-level naming with timestamps for uniqueness: - Pattern: fastled-simulator-{platform}-{timestamp} - Examples: - fastled-simulator-esp-xtensa
| 144 | |
| 145 | |
| 146 | class DockerQEMURunner: |
| 147 | """Runner for ESP32 QEMU emulation using Docker containers. |
| 148 | |
| 149 | Container Naming Convention: |
| 150 | Simulator containers use platform-level naming with timestamps for uniqueness: |
| 151 | - Pattern: fastled-simulator-{platform}-{timestamp} |
| 152 | - Examples: |
| 153 | - fastled-simulator-esp-xtensa-1234567890 (ESP32, ESP32-S2, ESP32-S3, ESP8266) |
| 154 | - fastled-simulator-esp-riscv-1234567890 (ESP32-C3, ESP32-C6, etc.) |
| 155 | - fastled-simulator-avr-1234567890 (Uno, ATtiny, etc.) |
| 156 | |
| 157 | Simulator containers are temporary (created/destroyed per test run) unlike |
| 158 | compiler containers which are persistent (paused/unpaused). |
| 159 | |
| 160 | Image Naming Convention: |
| 161 | - Registry images: niteris/fastled-simulator-{platform}:latest |
| 162 | - Local images: fastled-platformio-{board}-{hash} (for compatibility) |
| 163 | """ |
| 164 | |
| 165 | def __init__(self, docker_image: Optional[str] = None): |
| 166 | """Initialize Docker QEMU runner. |
| 167 | |
| 168 | Args: |
| 169 | docker_image: Docker image to use, defaults to espressif/idf |
| 170 | """ |
| 171 | self.docker_manager = DockerManager() |
| 172 | self.docker_image = docker_image or DEFAULT_DOCKER_IMAGE |
| 173 | self.container_name = None |
| 174 | # Use Linux-style paths for all containers since we're using Ubuntu/Alpine |
| 175 | self.firmware_mount_path = "/workspace/firmware" |
| 176 | |
| 177 | def check_docker_available(self) -> bool: |
| 178 | """Check if Docker is available and running.""" |
| 179 | try: |
| 180 | proc = RunningProcess( |
| 181 | ["docker", "version"], env=get_docker_env(), auto_run=True |
| 182 | ) |
| 183 | returncode = proc.wait(timeout=5) |
| 184 | return returncode == 0 |
| 185 | except KeyboardInterrupt as ki: |
| 186 | handle_keyboard_interrupt(ki) |
| 187 | raise |
| 188 | except (Exception, FileNotFoundError): |
| 189 | return False |
| 190 | |
| 191 | def check_image_exists(self, image_name: str) -> bool: |
| 192 | """Check if Docker image exists locally. |
| 193 | |
| 194 | Args: |
| 195 | image_name: Name of the Docker image to check |
| 196 | |
| 197 | Returns: |
| 198 | True if image exists, False otherwise |
| 199 | """ |
| 200 | try: |
| 201 | proc = RunningProcess( |
| 202 | ["docker", "images", "-q", image_name], |
| 203 | env=get_docker_env(), |
no outgoing calls