From dff0b609f61a6389f3dfe1f909fef8655de9f9fa Mon Sep 17 00:00:00 2001 From: Tom Henderson Date: Sat, 18 Jun 2022 08:21:00 -0700 Subject: [PATCH] wifi: Fix valgrind issue in ChannelAccessManager test --- src/wifi/test/channel-access-manager-test.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/wifi/test/channel-access-manager-test.cc b/src/wifi/test/channel-access-manager-test.cc index e243c4717..17facc521 100644 --- a/src/wifi/test/channel-access-manager-test.cc +++ b/src/wifi/test/channel-access-manager-test.cc @@ -1265,8 +1265,7 @@ private: }; LargestIdlePrimaryChannelTest::LargestIdlePrimaryChannelTest () - : TestCase ("Check calculation of the largest idle primary channel"), - m_cam (CreateObject ()) + : TestCase ("Check calculation of the largest idle primary channel") { } @@ -1401,6 +1400,7 @@ LargestIdlePrimaryChannelTest::RunOne (uint16_t chWidth, WifiChannelListType bus void LargestIdlePrimaryChannelTest::DoRun () { + m_cam = CreateObject (); uint16_t delay = 0; uint8_t channel = 0; std::list busyChannels; @@ -1415,7 +1415,11 @@ LargestIdlePrimaryChannelTest::DoRun () [this, chWidth, busyChannel]() { // reset PHY - m_cam->RemovePhyListener (m_phy); + if (m_phy) + { + m_cam->RemovePhyListener (m_phy); + m_phy->Dispose (); + } // create a new PHY operating on a channel of the current width m_phy = CreateObject (); m_phy->SetOperatingChannel (WifiPhy::ChannelTuple {0, chWidth, @@ -1433,6 +1437,9 @@ LargestIdlePrimaryChannelTest::DoRun () } Simulator::Run (); + m_cam->RemovePhyListener (m_phy); + m_phy->Dispose (); + m_cam->Dispose (); Simulator::Destroy (); }