| 433 | |
| 434 | |
| 435 | class Client(Runnable): |
| 436 | def __init__(self, test_env, extra_args=[]): # noqa: B006 mutable-default-arguments |
| 437 | name = f"client{test_env.num_clients}" |
| 438 | self.fifo_name, self.fifo_path = fifo_name_path(test_env, name) |
| 439 | # Delay opening the FIFO until the client has started, because it will |
| 440 | # block. |
| 441 | self.fifo = None |
| 442 | super().__init__( |
| 443 | test_env, |
| 444 | name, |
| 445 | [ |
| 446 | test_env.ddnet, |
| 447 | f"cl_input_fifo {self.fifo_name}", |
| 448 | "gfx_fullscreen 0", |
| 449 | "cl_save_settings 0", |
| 450 | ] |
| 451 | + extra_args, |
| 452 | ) |
| 453 | test_env.num_clients += 1 |
| 454 | |
| 455 | def command(self, command): |
| 456 | if self.fifo is None: |
| 457 | self.fifo = open_fifo(self.fifo_path) |
| 458 | self.fifo.write(f"{command}\n") |
| 459 | |
| 460 | def exit(self): |
| 461 | self.command("quit") |
| 462 | |
| 463 | def wait_for_startup(self, timeout=15): |
| 464 | self.wait_for_log_prefix("client: version", timeout=timeout) |
| 465 | |
| 466 | |
| 467 | class Server(Runnable): |