Skip to content

Commit 36df2d2

Browse files
Merge branch 'fix/multicast_filter_test_v6.0' into 'release/v6.0'
fix(esp_eth): maked esp_eth_test_l2 more robust (v6.0) See merge request espressif/esp-idf!43483
2 parents f229575 + 30919c1 commit 36df2d2

File tree

2 files changed

+17
-23
lines changed

2 files changed

+17
-23
lines changed

components/esp_eth/test_apps/main/esp_eth_test_l2.c

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,15 @@ TEST_CASE("ethernet recv_pkt", "[ethernet_l2]")
220220

221221
TEST_ESP_OK(esp_eth_update_input_path(eth_handle, l2_packet_txrx_test_cb, &s_recv_info));
222222

223+
TEST_ESP_OK(esp_eth_start(eth_handle)); // start Ethernet driver state machine
224+
225+
EventBits_t bits = 0;
226+
bits = xEventGroupWaitBits(eth_event_state_group, ETH_CONNECT_BIT, true, true, pdMS_TO_TICKS(WAIT_FOR_CONN_TMO_MS));
227+
TEST_ASSERT((bits & ETH_CONNECT_BIT) == ETH_CONNECT_BIT);
228+
// if DUT is connected in network with switch: even if link is indicated up, it may take some time the switch
229+
// starts switching the associated port (e.g. it runs RSTP at first)
230+
poke_and_wait(eth_handle, NULL, 0, NULL, eth_event_rx_group);
231+
223232
// ---------------------------------------
224233
printf("Enable receive all multicast\n");
225234
// ---------------------------------------
@@ -231,18 +240,9 @@ TEST_CASE("ethernet recv_pkt", "[ethernet_l2]")
231240
s_recv_info.brdcast_rx_cnt = 0;
232241
bool all_multicast = true;
233242
TEST_ESP_OK(esp_eth_ioctl(eth_handle, ETH_CMD_S_ALL_MULTICAST, &all_multicast));
234-
235-
TEST_ESP_OK(esp_eth_start(eth_handle)); // start Ethernet driver state machine
236-
237-
EventBits_t bits = 0;
238-
bits = xEventGroupWaitBits(eth_event_state_group, ETH_CONNECT_BIT, true, true, pdMS_TO_TICKS(WAIT_FOR_CONN_TMO_MS));
239-
TEST_ASSERT((bits & ETH_CONNECT_BIT) == ETH_CONNECT_BIT);
240-
// if DUT is connected in network with switch: even if link is indicated up, it may take some time the switch
241-
// starts switching the associated port (e.g. it runs RSTP at first)
242-
poke_and_wait(eth_handle, NULL, 0, NULL, eth_event_rx_group);
243-
244243
bits = 0;
245244
xEventGroupClearBits(eth_event_rx_group, ETH_BROADCAST_RECV_BIT | ETH_MULTICAST_RECV_BIT | ETH_UNICAST_RECV_BIT);
245+
printf("Filter configured\n");
246246
bits = xEventGroupWaitBits(eth_event_rx_group, ETH_BROADCAST_RECV_BIT | ETH_MULTICAST_RECV_BIT | ETH_UNICAST_RECV_BIT,
247247
true, true, pdMS_TO_TICKS(1000));
248248
printf("bits = 0x%" PRIu32 "\n", (uint32_t)bits & (ETH_BROADCAST_RECV_BIT | ETH_MULTICAST_RECV_BIT | ETH_UNICAST_RECV_BIT));
@@ -270,11 +270,9 @@ TEST_CASE("ethernet recv_pkt", "[ethernet_l2]")
270270
s_recv_info.brdcast_rx_cnt = 0;
271271
all_multicast = false;
272272
TEST_ESP_OK(esp_eth_ioctl(eth_handle, ETH_CMD_S_ALL_MULTICAST, &all_multicast));
273-
// send POKE to indicate that the DUT reconfigured the filter
274-
poke_and_wait(eth_handle, NULL, 0, NULL, eth_event_rx_group);
275-
276273
bits = 0;
277274
xEventGroupClearBits(eth_event_rx_group, ETH_BROADCAST_RECV_BIT | ETH_MULTICAST_RECV_BIT | ETH_UNICAST_RECV_BIT);
275+
printf("Filter configured\n");
278276
bits = xEventGroupWaitBits(eth_event_rx_group, ETH_BROADCAST_RECV_BIT | ETH_MULTICAST_RECV_BIT | ETH_UNICAST_RECV_BIT,
279277
true, true, pdMS_TO_TICKS(1000));
280278
printf("bits = 0x%" PRIu32 "\n", (uint32_t)bits & (ETH_BROADCAST_RECV_BIT | ETH_MULTICAST_RECV_BIT | ETH_UNICAST_RECV_BIT));
@@ -297,10 +295,9 @@ TEST_CASE("ethernet recv_pkt", "[ethernet_l2]")
297295
TEST_ESP_OK(esp_eth_ioctl(eth_handle, ETH_CMD_ADD_MAC_FILTER, multicast_addr_ip4));
298296
uint8_t multicast_addr_ip6[ETH_ADDR_LEN] = {0x33, 0x33, 0x00, 0x00, 0x00, 0x00};
299297
TEST_ESP_OK(esp_eth_ioctl(eth_handle, ETH_CMD_ADD_MAC_FILTER, multicast_addr_ip6));
300-
// send POKE to indicate that the DUT reconfigured the filter
301-
poke_and_wait(eth_handle, NULL, 0, NULL, eth_event_rx_group);
302298
bits = 0;
303299
xEventGroupClearBits(eth_event_rx_group, ETH_BROADCAST_RECV_BIT | ETH_MULTICAST_RECV_BIT | ETH_UNICAST_RECV_BIT);
300+
printf("Filter configured\n");
304301
bits = xEventGroupWaitBits(eth_event_rx_group, ETH_BROADCAST_RECV_BIT | ETH_MULTICAST_RECV_BIT | ETH_UNICAST_RECV_BIT,
305302
true, true, pdMS_TO_TICKS(1000));
306303
printf("bits = 0x%" PRIu32 "\n", (uint32_t)bits & (ETH_BROADCAST_RECV_BIT | ETH_MULTICAST_RECV_BIT | ETH_UNICAST_RECV_BIT));
@@ -319,10 +316,9 @@ TEST_CASE("ethernet recv_pkt", "[ethernet_l2]")
319316
s_recv_info.multicast_rx_cnt = 0;
320317
s_recv_info.brdcast_rx_cnt = 0;
321318
TEST_ESP_OK(esp_eth_ioctl(eth_handle, ETH_CMD_DEL_MAC_FILTER, multicast_addr_ip4));
322-
// send POKE to indicate that the DUT reconfigured the filter
323-
poke_and_wait(eth_handle, NULL, 0, NULL, eth_event_rx_group);
324319
bits = 0;
325320
xEventGroupClearBits(eth_event_rx_group, ETH_BROADCAST_RECV_BIT | ETH_MULTICAST_RECV_BIT | ETH_UNICAST_RECV_BIT);
321+
printf("Filter configured\n");
326322
bits = xEventGroupWaitBits(eth_event_rx_group, ETH_BROADCAST_RECV_BIT | ETH_MULTICAST_RECV_BIT | ETH_UNICAST_RECV_BIT,
327323
true, true, pdMS_TO_TICKS(1000));
328324
printf("bits = 0x%" PRIu32 "\n", (uint32_t)bits & (ETH_BROADCAST_RECV_BIT | ETH_MULTICAST_RECV_BIT | ETH_UNICAST_RECV_BIT));
@@ -355,10 +351,9 @@ TEST_CASE("ethernet recv_pkt", "[ethernet_l2]")
355351
#else
356352
TEST_ESP_OK(esp_eth_ioctl(eth_handle, ETH_CMD_DEL_MAC_FILTER, multicast_addr_ip6));
357353
#endif
358-
// send POKE to indicate that the DUT reconfigured the filter
359-
poke_and_wait(eth_handle, NULL, 0, NULL, eth_event_rx_group);
360354
bits = 0;
361355
xEventGroupClearBits(eth_event_rx_group, ETH_BROADCAST_RECV_BIT | ETH_MULTICAST_RECV_BIT | ETH_UNICAST_RECV_BIT);
356+
printf("Filter configured\n");
362357
bits = xEventGroupWaitBits(eth_event_rx_group, ETH_BROADCAST_RECV_BIT | ETH_MULTICAST_RECV_BIT | ETH_UNICAST_RECV_BIT,
363358
true, true, pdMS_TO_TICKS(1000));
364359
printf("bits = 0x%" PRIu32 "\n", (uint32_t)bits & (ETH_BROADCAST_RECV_BIT | ETH_MULTICAST_RECV_BIT | ETH_UNICAST_RECV_BIT));

components/esp_eth/test_apps/pytest_esp_eth.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,10 @@ def ethernet_l2_test(dut: IdfDut) -> None:
169169
r'DUT MAC: ([0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2})'
170170
)
171171
dut_mac = res.group(1).decode('utf-8')
172+
target_if.recv_resp_poke(mac=dut_mac)
172173
for _ in range(5):
173-
# wait for POKE msg to be sure the switch already started forwarding the port's traffic
174-
# (there might be slight delay due to the RSTP execution)
175-
# or wait for next POKE msg to be sure the DUT reconfigured the filter
176-
target_if.recv_resp_poke(mac=dut_mac)
174+
# wait to be sure the DUT reconfigured the filter
175+
dut.expect_exact('Filter configured')
177176
target_if.send_eth_packet('ff:ff:ff:ff:ff:ff') # broadcast frame
178177
target_if.send_eth_packet('01:00:5e:00:00:00') # IPv4 multicast frame
179178
target_if.send_eth_packet('33:33:00:00:00:00') # IPv6 multicast frame

0 commit comments

Comments
 (0)