Files
openthread/tests/unit
Abtin Keshavarzian dd0d8311f8 [border-router] detect DHCPv6-PD prefix conflict with route prefixes (#12361)
This commit enhances the DHCPv6 PD prefix conflict detection logic
to check against Route Information Options (RIOs) present in received
Router Advertisements, in addition to the existing check against
on-link prefixes (PIOs).

The conflict detection behavior is event-driven to correctly handle
network propagation delays and valid advertisements:

1. On new prefix assignment (`kPdPrefixChanged`): A strict check is
   performed. If the prefix matches any existing RIO from another
   router, it is flagged as a conflict.

2. On RA table updates (`kRxRaPrefixTableChanged`): The check focuses
   on conflict resolution. Crucially, it ignores new RIO matches
   appearing after the prefix has been adopted. This is necessary
   because once the BR publishes the PD prefix in Thread Network
   Data as the OMR prefix, other BRs will naturally start
   advertising it as a RIO to announce reachability.

The unit test `TestDhcp6PdConflict` is updated to verify both the
detection of conflict, its resolution, and that the subsequent RIO
advertisements do not cause a conflict after PD prefix is published
as OMR.
2026-02-04 12:55:55 -08:00
..

OpenThread Unit Tests

This page describes how to build and run OpenThread unit tests. It will be helpful for developers to debug failed unit test cases if they got one in CI or to add some new test cases.

Build Simulation

The unit tests cannot be built solely without building the whole project. So first build OpenThread on the simulation platform, which will also build all unit tests:

# Go to the root directory of OpenThread
$ script/cmake-build simulation

List all tests

To see what tests are available in OpenThread:

# Make sure you are at the simulation build directory (build/simulation)
$ ctest -N

Run the Unit Tests

To run all the unit tests:

# Make sure you are at the simulation build directory (build/simulation)
$ ctest

To run a specific unit test, for example, ot-test-spinel:

# Make sure you are at the simulation build directory (build/simulation)
$ ctest -R ot-test-spinel

Update a Test Case

If you are developing a unit test case and have made some changes in the test source file, you will need rebuild the test before running it:

# Make sure you are at the simulation build directory (build/simulation)
$ ninja <test_name>

This will only build the test and take a short time.

If any changes or fixes were made to the OpenThread code, then you'll need to rebuild the entire project:

# Make sure you are at the simulation build directory (build/simulation)
$ ninja

This will build the updated OpenThread code as well as the test cases.