Device Tree unittest

Revision as of 18:05, 10 February 2021 by Frowand (talk | contribs) (Expected Errors and Warnings: fix format error)
Jump to: navigation, search


Enable unit tests through config option CONFIG_OF_UNITTEST

  • Device Drivers ---> Device Tree and Open Firmware support ---> Device Tree runtime unit tests


The unit tests will be performed near the end of the boot sequence. The start of the tests is indicated by:

### dt-test ### start of unittest - you will see error messages

An example test result summary is:

### dt-test ### end of unittest - 148 passed, 0 failed

Expected Errors and Warnings

The actual test result is shown at the end of the test in the test result summary, which reports number of tests passed and number of tests failed.

The unittests invoke various devicetree functions, which may report warnings and/or errors to the console, even when a unittest passes. This has led to some confusion as to whether a unittest has unexpectedly triggered a kernel error and/or warning, or if the error and/or warning is an expected result.

Annotations where added by v5.7 commit 0ac174397940 ("of: unittest: annotate warnings triggered by unittest") to remove the confusion. One drawback of the annotations is added console verbosity and a need to interpret the expected errors and warnings vs expected errors and warnings.

A filter tool of_unittest_expect was written to filter the extra console messages. The tool is not yet in mainline, but can be downloaded from

Source Location

The unit tests are located in the Linux kernel source tree

  • drivers/of/unittest.c
  • drivers/of/unittest-data/