Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

format_failure throws an error because of unexpanded tuple #137

Open
theasianpianist opened this issue Jul 19, 2021 · 0 comments
Open

format_failure throws an error because of unexpanded tuple #137

theasianpianist opened this issue Jul 19, 2021 · 0 comments

Comments

@theasianpianist
Copy link

Culprit:

failure_report = "\n".join([format_failure(f) for f in failures])

The format_failure function here always expects two arguments. However, the failure list which is used to store arguments for format_failure only ever has tuples appended to it, and the unexpected tuples are passed to format_failure as a single argument leading to the below error:

test = <tests.common.plugins.ptfadapter.ptfadapter.PtfTestAdapter testMethod=runTest>
pkt = <Ether  dst=5a:08:8c:93:f8:02 src=5e:43:11:39:4c:38 type=0x800 |<IP  tos=0x0 i...|<Raw  load='0000000000000000000000000000000000000000000000000000000000' |>>>>>, ports = [2]
device_number = 0

    def verify_packets_any(test, pkt, ports=[], device_number=0):
        """
        Check that a packet is received on _any_ of the specified ports belonging to
        the given device (default device_number is 0).

        Also verifies that the packet is not received on any other ports for this
        device, and that no other packets are received on the device (unless --relax
        is in effect).
        """
        received = False
        failures = []
        for device, port in ptf_ports():
            if device != device_number:
                continue
            if port in ports:
                logging.debug("Checking for pkt on device %d, port %d", device_number, port)
                result = dp_poll(test, device_number=device, port_number=port, exp_pkt=pkt)
                if isinstance(result, test.dataplane.PollSuccess):
                    received = True
                else:
                    failures.append((port, result))
            else:
                verify_no_packet(test, pkt, (device, port))
        verify_no_other_packets(test)

        if not received:
            def format_failure(port, failure):
                return "On port %d:\n%s" % (port, failure.format())
>           failure_report = "\n".join([format_failure(f) for f in failures])
E           TypeError: format_failure() takes exactly 2 arguments (1 given)

device     = 0
device_number = 0
f          = (2, PollResult(device=None, port=None, packet=None, time=None))
failures   = [(2, PollResult(device=None, port=None, packet=None, time=None))]
format_failure = <function format_failure at 0x7fa25903f450>
pkt        = <Ether  dst=5a:08:8c:93:f8:02 src=5e:43:11:39:4c:38 type=0x800 |<IP  tos=0x0 i...|<Raw  load='0000000000000000000000000000000000000000000000000000000000' |>>>>>
port       = 71
ports      = [2]
received   = False
result     = PollResult(device=None, port=None, packet=None, time=None)
test       = <tests.common.plugins.ptfadapter.ptfadapter.PtfTestAdapter testMethod=runTest>

/usr/lib/python2.7/dist-packages/ptf/testutils.py:2506: TypeError
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant