From 08236466c5b2871d860b0bbfdfa6a0774bda2e6f Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Thu, 24 Jul 2025 15:00:36 +0200 Subject: [PATCH] wifi: Make EMLSR link switch test more robust Wait for one additional TimeStep before checking which link the main PHY is switching to. We were waiting for a PHY slot to account for backoff slot alignment, but this is not sufficient when channel access is delayed by a whole PHY slot because the check is performed before channel access is granted and the main PHY starts switching. --- src/wifi/test/wifi-emlsr-link-switch-test.cc | 24 +++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/wifi/test/wifi-emlsr-link-switch-test.cc b/src/wifi/test/wifi-emlsr-link-switch-test.cc index f0b33865d..297923ca2 100644 --- a/src/wifi/test/wifi-emlsr-link-switch-test.cc +++ b/src/wifi/test/wifi-emlsr-link-switch-test.cc @@ -1677,18 +1677,20 @@ EmlsrSwitchMainPhyBackTest::MainPhySwitchInfoCallback(std::size_t index, m_staMacs[0]->GetDevice()->GetNode()->AddApplication( GetApplication(UPLINK, 0, 1, 500, 4)); // channel access can be obtained within a slot due to slot alignment - Simulator::Schedule(m_apMac->GetWifiPhy(m_linkIdForTid4)->GetSlot(), [=, this]() { - auto advEmlsrMgr = - DynamicCast(m_staMacs[0]->GetEmlsrManager()); + Simulator::Schedule( + m_apMac->GetWifiPhy(m_linkIdForTid4)->GetSlot() + TimeStep(1), + [=, this]() { + auto advEmlsrMgr = + DynamicCast(m_staMacs[0]->GetEmlsrManager()); - NS_TEST_EXPECT_MSG_EQ(advEmlsrMgr->m_mainPhySwitchInfo.disconnected, - true, - "Expected the main PHY to be switching"); - NS_TEST_EXPECT_MSG_EQ( - +advEmlsrMgr->m_mainPhySwitchInfo.to, - +(advEmlsrMgr->m_interruptSwitching ? m_linkIdForTid4 : m_mainPhyId), - "Main PHY is switching to wrong link"); - }); + NS_TEST_EXPECT_MSG_EQ(advEmlsrMgr->m_mainPhySwitchInfo.disconnected, + true, + "Expected the main PHY to be switching"); + NS_TEST_EXPECT_MSG_EQ( + +advEmlsrMgr->m_mainPhySwitchInfo.to, + +(advEmlsrMgr->m_interruptSwitching ? m_linkIdForTid4 : m_mainPhyId), + "Test index " << +m_testIndex << ": Main PHY is switching to wrong link"); + }); }); InsertEventsForQosTid4(); };