test: dm: eth, dsa: update tests for NET_LWIP
authorJerome Forissier <jerome.forissier@linaro.org>
Tue, 15 Apr 2025 21:17:43 +0000 (23:17 +0200)
committerJerome Forissier <jerome.forissier@linaro.org>
Wed, 23 Apr 2025 08:02:49 +0000 (10:02 +0200)
commit58ea7c3b507d2544f9dfe1712fe0fdb73086c733
tree1a86384d151c62c11967d61fc1a600d956d1535c
parent1f907e559d5d29f7824115e47c9771595fdf5819
test: dm: eth, dsa: update tests for NET_LWIP

Convert the tests to use the do_ping() interface which is now
common to NET and NET_LWIP. This allows running most network test with
SANDBOX and NET_LWIP. A few things to note though:

1. The ARP and IPv6 tests are enabled for NET only

2. The net_retry test is modified to use eth0 (eth@10002000) as the
active (but disabled) interface, and therefore we expect eth1
(eth@10003000) to be the fallback when "netretry" is "yes". This is in
replacement of eth7 (lan1) and eth0 (eth@10002000) respectively.
Indeed, it seems eth7 works with NET by chance and it certainly does not
work with NET_LWIP. I observed that even with NET,
sandbox_eth_disable_response(1, true) has no effect: remove it and
the test still passes. The interface ID is not correct to begin with; 1
corresponds to eth1 (eth@10003000) as shown by debug traces, it is not
eth7 (lan1). And using index 7 causes a SEGV.  In fact, it is not the
call to sandbox_eth_disable_response() that prevents the stack from
processing the ICMP reply but the timeout caused by the call to
sandbox_eth_skip_timeout(). Here is what happens when trying to ping
using the eth7 (lan1) interface with NET:

 do_ping(...)
     net_loop(PING)
         ping_start()
         eth_rx()
             sb_eth_recv()
                 time_test_add_offset(11000UL);
         if (get_timer(0) - time_start > time_delta)
             ping_timeout_handler()  // ping error, as expected

And the same with NET_LWIP:

 do_ping(...)
     ping_loop(...)
         sys_check_timeouts()
         net_lwip_rx(...)
             sb_eth_recv()
                 time_test_add_offset(11000UL);
             netif->input(...)  // the packet is processed succesfully

By choosing eth0 and sandbox_eth_disable_response(0, true), the incoming
packet is indeed discarded and things work as expected with both network
stacks.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
test/dm/Makefile
test/dm/dsa.c
test/dm/eth.c