| 585 | self.compare_stats_with_snapshot(stats_diff, stats_snapshot) |
| 586 | |
| 587 | def send_and_expect_multi( |
| 588 | self, |
| 589 | send: list[Send], |
| 590 | expect: list[Expect], |
| 591 | trace: bool = True, |
| 592 | log_packets: bool = True, |
| 593 | msg: str | None = None, |
| 594 | stats_diff: StatsDiff | None = None, |
| 595 | timeout: float | None = None, |
| 596 | assert_nothing_captured: list[VppPGInterface] | None = None, |
| 597 | ) -> list[Capture]: |
| 598 | if stats_diff: |
| 599 | stats_snapshot = self.snapshot_stats(stats_diff) |
| 600 | |
| 601 | for s in send: |
| 602 | s.interface.add_stream(s.packets, worker=s.worker) |
| 603 | if log_packets: |
| 604 | self.logger.debug( |
| 605 | ppc(f"Adding stream '{msg}' to worker {s.worker}:", s.packets) |
| 606 | ) |
| 607 | |
| 608 | self.pg_enable_capture(self.pg_interfaces) |
| 609 | self.pg_start(trace=trace) |
| 610 | |
| 611 | if timeout is not None: |
| 612 | deadline = time.time() + timeout |
| 613 | |
| 614 | if expect: |
| 615 | capture = [ |
| 616 | Capture( |
| 617 | interface=e.interface, |
| 618 | packets=e.interface.get_capture( |
| 619 | expected_count=e.expected_count, |
| 620 | timeout=None if timeout is None else deadline - time.time(), |
| 621 | filter_out_fn=e.filter_out_fn, |
| 622 | ), |
| 623 | ) |
| 624 | for e in expect |
| 625 | ] |
| 626 | else: |
| 627 | capture = [] |
| 628 | |
| 629 | if assert_nothing_captured is None: |
| 630 | assert_nothing_captured = self.pg_interfaces |
| 631 | expect_intfs = {e.interface for e in expect} if expect else set() |
| 632 | for i in assert_nothing_captured: |
| 633 | if i not in expect_intfs: |
| 634 | i.assert_nothing_captured( |
| 635 | timeout=None if timeout is None else deadline - time.time() |
| 636 | ) |
| 637 | |
| 638 | if trace: |
| 639 | if msg: |
| 640 | self.logger.debug(f"send_and_expect: {msg}") |
| 641 | self.logger.debug(self.vapi.cli("show trace")) |
| 642 | |
| 643 | if stats_diff: |
| 644 | self.compare_stats_with_snapshot(stats_diff, stats_snapshot) |