Skip to content

Commit c01cad7

Browse files
authored
[nexus] migrate publish meshcop service cert test to nexus (openthread#13186)
This commit migrates the legacy Thread certification test 'test_publish_meshcop_service.py' to the C++ simulation test suite in the Nexus platform. To avoid redundancy and keep the test suite clean, the coverage is consolidated directly within 'tests/nexus/test_border_agent.cpp' instead of introducing a new redundant test file. Consolidated coverage and changes: - Extended the state bitmap parser and 'ValidateMeshCoPTxtData' in 'test_border_agent.cpp' to verify Backbone Router (BBR) active and primary flags (kFlagBbrIsActive, kFlagBbrIsPrimary) when OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE is enabled. - Added a new test block in 'TestBorderAgentServiceRegistration' to enable Backbone Router on node0, verify that BBR active and primary flags are dynamically advertised in the MeshCoP TXT record over mDNS, and verify that disabling BBR correctly updates the TXT record state bitmap. - Fully deleted the legacy Python certification script 'test_publish_meshcop_service.py' from 'thread-cert'.
1 parent 7ad13c8 commit c01cad7

2 files changed

Lines changed: 82 additions & 288 deletions

File tree

tests/nexus/test_border_agent.cpp

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,6 +1311,10 @@ void ValidateMeshCoPTxtData(TxtData &aTxtData, Node &aNode, bool aExpectVendorIn
13111311
static constexpr uint32_t kThreadRoleLeader = 3 << 9;
13121312
static constexpr uint32_t kFlagEpskcSupported = 1 << 11;
13131313
static constexpr uint32_t kFlagAdmitterSupported = 1 << 14;
1314+
#if OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE
1315+
static constexpr uint32_t kFlagBbrIsActive = 1 << 7;
1316+
static constexpr uint32_t kFlagBbrIsPrimary = 1 << 8;
1317+
#endif
13141318

13151319
MeshCoP::BorderAgent::Id id;
13161320
BaTxtData::Info info;
@@ -1449,6 +1453,35 @@ void ValidateMeshCoPTxtData(TxtData &aTxtData, Node &aNode, bool aExpectVendorIn
14491453
VerifyOrQuit(!info.mStateBitmap.mAdmitterSupported);
14501454
}
14511455

1456+
#if OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE
1457+
{
1458+
bool bbrEnabled = aNode.Get<Mle::Mle>().IsAttached() && aNode.Get<BackboneRouter::Local>().IsEnabled();
1459+
bool bbrPrimary = aNode.Get<Mle::Mle>().IsAttached() && aNode.Get<BackboneRouter::Local>().IsPrimary();
1460+
1461+
if (bbrEnabled)
1462+
{
1463+
VerifyOrQuit(stateBitmap & kFlagBbrIsActive);
1464+
VerifyOrQuit(info.mStateBitmap.mBbrIsActive);
1465+
}
1466+
else
1467+
{
1468+
VerifyOrQuit(!(stateBitmap & kFlagBbrIsActive));
1469+
VerifyOrQuit(!info.mStateBitmap.mBbrIsActive);
1470+
}
1471+
1472+
if (bbrPrimary)
1473+
{
1474+
VerifyOrQuit(stateBitmap & kFlagBbrIsPrimary);
1475+
VerifyOrQuit(info.mStateBitmap.mBbrIsPrimary);
1476+
}
1477+
else
1478+
{
1479+
VerifyOrQuit(!(stateBitmap & kFlagBbrIsPrimary));
1480+
VerifyOrQuit(!info.mStateBitmap.mBbrIsPrimary);
1481+
}
1482+
}
1483+
#endif
1484+
14521485
if (aExpectVendorInfo)
14531486
{
14541487
const char *expectedVendorName = (aVendorName != nullptr) ? aVendorName : aNode.Get<VendorInfo>().GetName();
@@ -2356,6 +2389,55 @@ void TestBorderAgentServiceRegistration(void)
23562389
VerifyOrQuit(foundService);
23572390

23582391
node0.Get<Dns::Multicast::Core>().FreeIterator(*iterator);
2392+
2393+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2394+
Log("Enable Backbone Router on node0 and validate state bitmap updates");
2395+
2396+
node0.Get<BorderRouter::InfraIf>().Init(kInfraIfIndex, true);
2397+
node0.Get<BorderRouter::RoutingManager>().Init();
2398+
SuccessOrQuit(node0.Get<BorderRouter::RoutingManager>().SetEnabled(true));
2399+
node0.Get<BackboneRouter::Local>().SetEnabled(true);
2400+
2401+
nexus.AdvanceTime(10 * Time::kOneSecondInMsec);
2402+
2403+
iterator = node0.Get<Dns::Multicast::Core>().AllocateIterator();
2404+
VerifyOrQuit(iterator != nullptr);
2405+
2406+
foundService = false;
2407+
while (node0.Get<Dns::Multicast::Core>().GetNextService(*iterator, service, entryState) == kErrorNone)
2408+
{
2409+
if (StringMatch(service.mServiceType, "_meshcop._udp"))
2410+
{
2411+
VerifyOrQuit(!foundService);
2412+
foundService = true;
2413+
ValidateRegisteredServiceData(service, node0);
2414+
}
2415+
}
2416+
VerifyOrQuit(foundService);
2417+
node0.Get<Dns::Multicast::Core>().FreeIterator(*iterator);
2418+
2419+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2420+
Log("Disable Backbone Router on node0 and validate state bitmap updates");
2421+
2422+
node0.Get<BackboneRouter::Local>().SetEnabled(false);
2423+
2424+
nexus.AdvanceTime(10 * Time::kOneSecondInMsec);
2425+
2426+
iterator = node0.Get<Dns::Multicast::Core>().AllocateIterator();
2427+
VerifyOrQuit(iterator != nullptr);
2428+
2429+
foundService = false;
2430+
while (node0.Get<Dns::Multicast::Core>().GetNextService(*iterator, service, entryState) == kErrorNone)
2431+
{
2432+
if (StringMatch(service.mServiceType, "_meshcop._udp"))
2433+
{
2434+
VerifyOrQuit(!foundService);
2435+
foundService = true;
2436+
ValidateRegisteredServiceData(service, node0);
2437+
}
2438+
}
2439+
VerifyOrQuit(foundService);
2440+
node0.Get<Dns::Multicast::Core>().FreeIterator(*iterator);
23592441
}
23602442

23612443
void TestBorderAgentServiceRegistrationRename(void)

tests/scripts/thread-cert/border_router/test_publish_meshcop_service.py

Lines changed: 0 additions & 288 deletions
This file was deleted.

0 commit comments

Comments
 (0)