of: Add unit tests for applying overlays
Subsystems (2)
v3 cover of: Add unit tests for applying overlays
From: Frank Rowand <frank.rowand-7U/[email protected]>
Existing overlay unit tests examine individual pieces of the overlay code. The new tests target the entire process of applying an overlay.
Changes from v2:
- of_private.h: move __unflatten_device_tree() outside
#ifdef CONFIG_OF_UNITTEST
- unittest.c: move overlay declaration macros outside #ifdef CONFIG_OF_OVERLAY
- unittest.c: make overlay_info overlays[] static
- unittest.c: remove extra blank line
Changes from v1:
- Move overlay base dtb unflattening into unittest.c. Call from fdt.c.
- Clarify file and variable names, 'overlay_test_' instead of 'ot_'
- Use proper naming convention for node names.
- A few added comments.
- Improve error messages in the new tests.
Frank Rowand (2):
of: support dtc compiler flags for overlays
of: Add unit tests for applying overlays
drivers/of/fdt.c | 14 +- drivers/of/of_private.h | 12 + drivers/of/unittest-data/Makefile | 17 +- drivers/of/unittest-data/overlay.dts | 53 ++++ drivers/of/unittest-data/overlay_bad_phandle.dts | 20 ++ drivers/of/unittest-data/overlay_base.dts | 80 ++++++ drivers/of/unittest.c | 317 +++++++++++++++++++++++ scripts/Makefile.lib | 2 + 8 files changed, 507 insertions(+), 8 deletions(-) create mode 100644 drivers/of/unittest-data/overlay.dts create mode 100644 drivers/of/unittest-data/overlay_bad_phandle.dts create mode 100644 drivers/of/unittest-data/overlay_base.dts
Signature · 6 lines
Frank Rowand <frank.rowand-7U/[email protected]> -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v3 1/2 of: support dtc compiler flags for overlays
From: Frank Rowand <[email protected]>
The dtc compiler version that adds initial support was available in 4.11-rc1. Add the ability to set the dtc compiler flags needed by overlays.
--- scripts/Makefile.lib | 2 ++ 1 file changed, 2 insertions(+)
scripts/Makefile.lib +2 -0
@@ -283,6 +283,8 @@ ifeq ($(KBUILD_ENABLE_EXTRA_GCC_CHECKS),) DTC_FLAGS += -Wno-unit_address_vs_reg endif +DTC_FLAGS += $(DTC_FLAGS_$(basetarget)) + # Generate an assembly file to wrap the output of the device tree compiler quiet_cmd_dt_S_dtb= DTB $@ cmd_dt_S_dtb= \
Signature · 1 line
Frank Rowand <[email protected]>
PATCH v3 2/2 of: Add unit tests for applying overlays
In reply to [email protected]From: Frank Rowand <[email protected]>
Existing overlay unit tests examine individual pieces of the overlay code. The new tests target the entire process of applying an overlay.
---
There are checkpatch warnings. I have reviewed them and feel they can be ignored.
drivers/of/fdt.c | 14 +- drivers/of/of_private.h | 12 + drivers/of/unittest-data/Makefile | 17 +- drivers/of/unittest-data/overlay.dts | 53 ++++ drivers/of/unittest-data/overlay_bad_phandle.dts | 20 ++ drivers/of/unittest-data/overlay_base.dts | 80 ++++++ drivers/of/unittest.c | 317 +++++++++++++++++++++++ 7 files changed, 505 insertions(+), 8 deletions(-) create mode 100644 drivers/of/unittest-data/overlay.dts create mode 100644 drivers/of/unittest-data/overlay_bad_phandle.dts create mode 100644 drivers/of/unittest-data/overlay_base.dts
drivers/of/fdt.c +9 -5
@@ -31,6 +31,8 @@#include <asm/setup.h> /* for COMMAND_LINE_SIZE */ #include <asm/page.h> +#include "of_private.h" +/* * of_fdt_limit_memory - limit the number of regions in the /memory node * @limit: maximum entries
@@ -469,11 +471,11 @@ static int unflatten_dt_nodes(const void *blob,* Returns NULL on failure or the memory chunk containing the unflattened * device tree on success. */ -static void *__unflatten_device_tree (const void *blob, -struct device_node *dad, -struct device_node **mynodes, -void *(*dt_alloc)(u64 size,u64 align), -bool detached) +void *__unflatten_device_tree (const void *blob, +struct device_node *dad, +struct device_node **mynodes, +void *(*dt_alloc)(u64 size,u64 align), +bool detached) {int size;void *mem;
@@ -1261,6 +1263,8 @@ void __init unflatten_device_tree(void)/* Get pointer to "/chosen" and "/aliases" nodes for use everywhere */ of_alias_scan (early_init_dt_alloc_memory_arch); + +unittest_unflatten_overlay_base (); }/**
drivers/of/of_private.h +12 -0
@@ -55,6 +55,18 @@ static inline int of_property_notify(int action, struct device_node *np, }#endif /* CONFIG_OF_DYNAMIC */ +#ifdef CONFIG_OF_UNITTEST +extern void __init unittest_unflatten_overlay_base (void ); +#else +static inline void unittest_unflatten_overlay_base (void ) {}; +#endif + +extern void *__unflatten_device_tree (const void *blob, +struct device_node *dad, +struct device_node **mynodes, +void *(*dt_alloc)(u64 size,u64 align), +bool detached); +/** * General utilities for working with live trees. *
drivers/of/unittest-data/Makefile +14 -3
@@ -1,7 +1,18 @@ obj-y += testcases.dtb.o +obj-y += overlay.dtb.o +obj-y += overlay_bad_phandle.dtb.o +obj-y += overlay_base.dtb.o targets += testcases.dtb testcases.dtb.S +targets += overlay.dtb overlay.dtb.S +targets += overlay_bad_phandle.dtb overlay_bad_phandle.dtb.S +targets += overlay_base.dtb overlay_base.dtb.S -.SECONDARY: \ - $(obj)/testcases.dtb.S \ - $(obj)/testcases.dtb +.PRECIOUS: \ + $(obj)/%.dtb.S \ + $(obj)/%.dtb + +# enable creation of __symbols__ node +DTC_FLAGS_overlay := -@ +DTC_FLAGS_overlay_bad_phandle := -@ +DTC_FLAGS_overlay_base := -@
drivers/of/unittest-data/overlay.dts new file +53 -0
53 lines not on this page · raw message
drivers/of/unittest-data/overlay_bad_phandle.dts new file +20 -0
@@ -0,0 +1,20 @@ +/dts-v1/; +/plugin/; + +/ { + + fragment@0 { + target = <&electric_1>; + + __overlay__ { + + // This label should cause an error when the overlay + // is applied. There is already a phandle value + // in the base tree for motor-1. + spin_ctrl_1_conflict: motor-1 { + accelerate = < 3 >; + decelerate = < 5 >; + }; + }; + }; +};
drivers/of/unittest-data/overlay_base.dts new file +80 -0
80 lines not on this page · raw message
drivers/of/unittest.c +317 -0
335 lines not on this page · raw message
Signature · 1 line
Frank Rowand <[email protected]>