tree: 8365aded2f5a74c2590aa783228eb56df5d4cfb1 [path history] [tgz]
  1. CMakeLists.txt
  2. README.md
  3. test_address_sanitizer.cpp
  4. test_aes.cpp
  5. test_array.cpp
  6. test_binary_search.cpp
  7. test_checksum.cpp
  8. test_child.cpp
  9. test_child_table.cpp
  10. test_cmd_line_parser.cpp
  11. test_data.cpp
  12. test_dns.cpp
  13. test_dns_client.cpp
  14. test_dso.cpp
  15. test_ecdsa.cpp
  16. test_flash.cpp
  17. test_frame_builder.cpp
  18. test_hdlc.cpp
  19. test_heap.cpp
  20. test_heap_array.cpp
  21. test_heap_string.cpp
  22. test_hkdf_sha256.cpp
  23. test_hmac_sha256.cpp
  24. test_ip4_header.cpp
  25. test_ip6_header.cpp
  26. test_ip_address.cpp
  27. test_link_metrics_manager.cpp
  28. test_link_quality.cpp
  29. test_linked_list.cpp
  30. test_lowpan.cpp
  31. test_lowpan.hpp
  32. test_mac_frame.cpp
  33. test_macros.cpp
  34. test_meshcop.cpp
  35. test_message.cpp
  36. test_message_queue.cpp
  37. test_mle.cpp
  38. test_multicast_listeners_table.cpp
  39. test_multipan_rcp_instances.cpp
  40. test_nat64.cpp
  41. test_ndproxy_table.cpp
  42. test_netif.cpp
  43. test_network_data.cpp
  44. test_network_name.cpp
  45. test_platform.cpp
  46. test_platform.h
  47. test_pool.cpp
  48. test_power_calibration.cpp
  49. test_priority_queue.cpp
  50. test_pskc.cpp
  51. test_routing_manager.cpp
  52. test_serial_number.cpp
  53. test_smart_ptrs.cpp
  54. test_spinel_buffer.cpp
  55. test_spinel_decoder.cpp
  56. test_spinel_encoder.cpp
  57. test_srp_adv_proxy.cpp
  58. test_srp_server.cpp
  59. test_string.cpp
  60. test_timer.cpp
  61. test_tlv.cpp
  62. test_toolchain.cpp
  63. test_toolchain_c.c
  64. test_trickle_timer.cpp
  65. test_url.cpp
  66. test_util.cpp
  67. test_util.h
  68. test_util.hpp
tests/unit/README.md

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.