Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 81d0848f authored by Frank Rowand's avatar Frank Rowand Committed by Rob Herring
Browse files

of: Add unit tests for applying overlays



Existing overlay unit tests examine individual pieces of the overlay
code.  The new tests target the entire process of applying an overlay.

Signed-off-by: default avatarFrank Rowand <frank.rowand@sony.com>
Signed-off-by: default avatarRob Herring <robh@kernel.org>
parent 331f7416
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -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,7 +471,7 @@ 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,
void *__unflatten_device_tree(const void *blob,
			      struct device_node *dad,
			      struct device_node **mynodes,
			      void *(*dt_alloc)(u64 size, u64 align),
@@ -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();
}

/**
+12 −0
Original line number Diff line number Diff line
@@ -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.
 *
+14 −3
Original line number Diff line number Diff line
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 := -@
+53 −0
Original line number Diff line number Diff line
/dts-v1/;
/plugin/;

/ {

	fragment@0 {
		target = <&electric_1>;

		__overlay__ {
			status = "ok";

			hvac_2: hvac-large-1 {
				compatible = "ot,hvac-large";
				heat-range = < 40 75 >;
				cool-range = < 65 80 >;
			};
		};
	};

	fragment@1 {
		target = <&rides_1>;

		__overlay__ {
			#address-cells = <1>;
			#size-cells = <1>;
			status = "ok";

			ride@200 {
				compatible = "ot,ferris-wheel";
				reg = < 0x00000200 0x100 >;
				hvac-provider = < &hvac_2 >;
				hvac-thermostat = < 27 32 > ;
				hvac-zones = < 12 5 >;
				hvac-zone-names = "operator", "snack-bar";
				spin-controller = < &spin_ctrl_1 3 >;
				spin-rph = < 30 >;
				gondolas = < 16 >;
				gondola-capacity = < 6 >;
			};
		};
	};

	fragment@2 {
		target = <&lights_2>;

		__overlay__ {
			status = "ok";
			color = "purple", "white", "red", "green";
			rate = < 3 256 >;
		};
	};

};
+20 −0
Original line number Diff line number Diff line
/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 >;
			};
		};
	};
};
Loading