]> git.baikalelectronics.ru Git - uboot.git/commit
test: Make a copy of the device tree before running a test
authorSimon Glass <sjg@chromium.org>
Wed, 7 Sep 2022 02:27:05 +0000 (20:27 -0600)
committerTom Rini <trini@konsulko.com>
Thu, 29 Sep 2022 20:09:56 +0000 (16:09 -0400)
commit594ec5f4396fe933402a7987543c576c2ccec355
tree0d81dadb200fadc7a74a0d1cece914af244f4fa7
parent2d41b855f4eee7d79a4b1e6cca1962f835193464
test: Make a copy of the device tree before running a test

When the flat device tree changes it can mess up the live tree since that
uses the flat tree for its strings. This affects only a few sandbox tests
which modify the device tree, but the number will grow as ofnode support
for writing improves.

While the control FDT is not intended to change while U-Boot is running,
some tests do so. For example, the ofnode interface only supports
modifying properties in the control FDT, so tests must use that.

To solve this problem, keep a copy of the FDT and restore it as needed
when the test is finished. The copy only happens on sandbox (except SPL
builds), to reduce memory usage and because these tests are not useful on
other boards. For other boards, a checksum is taken to ensure that nothing
changes.

It would be possible to always checksum the FDT on sandbox and only
restore it if needed, but this is slightly slower than restoring it every
time, at least with crc8.

Move the code which checks for success to the very end, for clarity.

Signed-off-by: Simon Glass <sjg@chromium.org>
doc/develop/driver-model/livetree.rst
include/test/test.h
test/test-main.c