[PATCH v2 1/1] dts: add send_packets to test suites and rework packet addressing
Juraj Linkeš
juraj.linkes at pantheon.tech
Thu Sep 26 12:13:15 CEST 2024
>>> diff --git a/dts/framework/test_suite.py b/dts/framework/test_suite.py
>>
>>> @@ -243,41 +255,74 @@ def get_expected_packet(self, packet: Packet) -> Packet:
>>> Returns:
>>> `packet` with injected L2/L3 addresses.
>>> """
>>> - return self._adjust_addresses(packet, expected=True)
>>> + return self._adjust_addresses([packet], expected=True)[0]
>>>
>>> - def _adjust_addresses(self, packet: Packet, expected: bool = False) -> Packet:
>>> + def _adjust_addresses(self, packets: list[Packet], expected: bool = False) -> list[Packet]:
>>> """L2 and L3 address additions in both directions.
>>>
>>> + Packets in `packets` will be directly modified in this method. The returned list of packets
>>> + however will be copies of the modified packets in order to keep the two lists distinct.
>>> +
>>
>> Do we need to do this? I guess you needed this in a test suite - what is
>> the reason?
>
> This is actually just me documenting something that was already
> happening behind the scenes in this method that I thought would be
> helpful for people to know. Right now this method ends in
> `Ether(packet.build())` which essentially just copies the packet, but
> it does so after the modifications were made. I think there is some
> logical reason to do this
Ah, ok, this only documents what already existed. I think this was here
because packet.build() doesn't return a Packet so a conversion is
needed. The intention is not to keep the two lists distinct.
> which is this method is called internally in
> the framework, so it allows the send methods where these packets are
> used to essentially modify the list and do whatever they want to/need
> to to get the packets sent
There are two usages for this method:
1. To update the packet before it's sent out (so that the proper
addresses are used),
2. To update a packet, constructed in a test case, that we expect to
receive, so as to compare with actual received packets. This is used in
the OS UDP test case which checks that the MAC addresses are updated
properly (and IP addresses stay the same).
> and the only change that is reflected on
> the user is the addresses are added.
>
More information about the dev
mailing list