Skip to content

Commit f4f13b6

Browse files
authored
[nexus] add test for OT_MLE_LONG_ROUTES feature (openthread#12956)
This commit adds a new Nexus test to verify the functionality of the MLE long routes experimental feature, which allows path costs to exceed the standard limit of 15. The new test `TestLongRoutes` in `test_long_routes.cpp` forms a topology consisting of a leader and a chain of 25 routers. It then validates that the path cost from the last router in the chain to the leader is correctly reported as 25 using `GetPathCostToLeader()`. Supporting changes include: - Updating `build.sh` to support a `long_routes` build target that enables `OT_MLE_LONG_ROUTES`. - Adding the `long_routes` test to `CMakeLists.txt` with the appropriate labels. - Introducing a new GitHub workflow job `nexus-long-routes-tests` in `nexus.yml` to automate the execution of this test.
1 parent 5340cfa commit f4f13b6

4 files changed

Lines changed: 135 additions & 0 deletions

File tree

.github/workflows/nexus.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,35 @@ jobs:
107107
run: |
108108
cd build/nexus && ctest -L trel --output-on-failure
109109
110+
nexus-long-routes-tests:
111+
name: nexus-long-routes-tests
112+
runs-on: ubuntu-24.04
113+
steps:
114+
- name: Harden Runner
115+
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
116+
with:
117+
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
118+
119+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
120+
with:
121+
submodules: recursive
122+
123+
- name: Bootstrap
124+
env:
125+
PR_BODY: "${{ github.event.pull_request.body }}"
126+
run: |
127+
sudo apt-get update
128+
sudo apt-get --no-install-recommends install -y ninja-build lcov
129+
130+
- name: Build Nexus
131+
run: |
132+
mkdir -p build/nexus
133+
top_builddir=build/nexus ./tests/nexus/build.sh long_routes
134+
135+
- name: Run LONG_ROUTES Tests
136+
run: |
137+
cd build/nexus && ctest -L long_routes --output-on-failure
138+
110139
nexus-grpc-tests:
111140
name: nexus-grpc-tests
112141
runs-on: ubuntu-24.04

tests/nexus/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,9 @@ ot_nexus_test(zero_len_external_route "core;nexus")
423423
# Trel
424424
ot_nexus_test(trel "trel;nexus")
425425

426+
# Long-routes
427+
ot_nexus_test(long_routes "long_routes;nexus")
428+
426429
# Grpc
427430
if(OT_NEXUS_GRPC)
428431
ot_nexus_test(grpc "core;nexus")

tests/nexus/build.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ else
4444
top_builddir=.
4545
fi
4646

47+
long_routes=OFF
48+
4749
case $1 in
4850
trel)
4951
fifteenfour=OFF
@@ -53,6 +55,11 @@ case $1 in
5355
fifteenfour=ON
5456
wasm=ON
5557
;;
58+
long_routes)
59+
fifteenfour=ON
60+
wasm=OFF
61+
long_routes=ON
62+
;;
5663
*)
5764
fifteenfour=ON
5865
wasm=OFF
@@ -73,6 +80,7 @@ CMAKE_ARGS=(
7380
-DOT_APP_NCP=OFF
7481
-DOT_APP_RCP=OFF
7582
-DOT_15_4="${fifteenfour}"
83+
-DOT_MLE_LONG_ROUTES="${long_routes}"
7684
-DOT_PROJECT_CONFIG="${top_srcdir}/tests/nexus/openthread-core-nexus-config.h"
7785
)
7886

tests/nexus/test_long_routes.cpp

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/*
2+
* Copyright (c) 2026, The OpenThread Authors.
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
* 1. Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* 2. Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
* 3. Neither the name of the copyright holder nor the
13+
* names of its contributors may be used to endorse or promote products
14+
* derived from this software without specific prior written permission.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26+
* POSSIBILITY OF SUCH DAMAGE.
27+
*/
28+
29+
#include <stdarg.h>
30+
#include <stdio.h>
31+
#include <string.h>
32+
33+
#include "platform/nexus_core.hpp"
34+
#include "platform/nexus_node.hpp"
35+
36+
namespace ot {
37+
namespace Nexus {
38+
39+
#if OPENTHREAD_CONFIG_MLE_LONG_ROUTES_ENABLE
40+
41+
void TestLongRoutes(void)
42+
{
43+
static constexpr uint16_t kNumRouters = 25;
44+
45+
Core nexus;
46+
Node &leader = nexus.CreateNode();
47+
Node *routers[kNumRouters];
48+
49+
Log("---------------------------------------------------------------------------------------");
50+
Log("TestLongRoutes");
51+
52+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
53+
Log("Form topology - long chain of routers");
54+
55+
leader.Form();
56+
nexus.AdvanceTime(100 * 1000);
57+
VerifyOrQuit(leader.Get<Mle::Mle>().IsLeader());
58+
59+
routers[0] = &nexus.CreateNode();
60+
AllowLinkBetween(leader, *routers[0]);
61+
routers[0]->Join(leader, Node::kAsFtd);
62+
63+
for (uint16_t i = 1; i < kNumRouters; i++)
64+
{
65+
Log("Router %u", i);
66+
67+
routers[i] = &nexus.CreateNode();
68+
AllowLinkBetween(*routers[i], *routers[i - 1]);
69+
routers[i]->Join(*routers[i - 1], Node::kAsFtd);
70+
nexus.AdvanceTime(20 * 1000);
71+
72+
VerifyOrQuit(routers[i - 1]->Get<Mle::Mle>().IsRouter());
73+
}
74+
75+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
76+
Log("Check the path cost from last router to leader");
77+
78+
VerifyOrQuit(routers[kNumRouters - 1]->Get<RouterTable>().GetPathCostToLeader() == kNumRouters);
79+
}
80+
81+
#endif // OPENTHREAD_CONFIG_MLE_LONG_ROUTES_ENABLE
82+
83+
} // namespace Nexus
84+
} // namespace ot
85+
86+
int main(void)
87+
{
88+
#if OPENTHREAD_CONFIG_MLE_LONG_ROUTES_ENABLE
89+
ot::Nexus::TestLongRoutes();
90+
printf("All tests passed\n");
91+
#else
92+
printf("OPENTHREAD_CONFIG_MLE_LONG_ROUTES_ENABLE is not enabled, test is skipped\n");
93+
#endif
94+
return 0;
95+
}

0 commit comments

Comments
 (0)