tests: Check for duplication in __local_fixups__ and __fixups__

Typically the info contained in __local_fixups__ and __fixups__ is
autogenerated from phandles used in the tree. However before commit
915daadbb6 ("Start with empty __local_fixups__ and __fixups__ nodes")
compiling a dts that has both the __local_fixups__ and/or __fixups__ and
phandles that result in entries in these nodes, the fixups were
duplicated:

	$ cat test.dts
	/dts-v1/;
	/plugin/;

	/ {
		important: node {
			property = <&somenode>, "string";
			phandle = <0x01>;
			self = <&important>;
		};

		__fixups__ {
			somenode = "/node:property:0";
		};

		__local_fixups__ {
			node {
				self = <0x00>;
			};
		};

		__symbols__ {
			important = "/node";
		};
	};

	$ dtc -v
	Version: DTC 1.7.2

	$ dtc -O dts test2.dts
	/dts-v1/;

	/ {

		important: node {
			property = <&somenode>, "string";
			phandle = <0x01>;
			self = <&important>;
		};

		__fixups__ {
			somenode = "/node:property:0", "/node:property:0";
		};

		__local_fixups__ {

			node {
				self = <0x00>, <0x00>;
			};
		};

		__symbols__ {
			important = "/node";
		};
	};

Add a test that ensures this issue isn't reintroduced later.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
This commit is contained in:
Uwe Kleine-König 2025-01-14 09:40:10 +01:00
parent a9b9a47857
commit 4d12fac793
2 changed files with 27 additions and 0 deletions

23
tests/over-determined.dts Normal file
View file

@ -0,0 +1,23 @@
/dts-v1/;
/plugin/;
/ {
labelfornodea: nodea {
property = <&labelfornodea>;
};
nodeb {
property = <&nonexisting>;
};
__fixups__ {
nonexisting = "/nodeb:property:0";
};
__local_fixups__ {
nodea {
property = <0>;
};
};
};

View file

@ -570,6 +570,10 @@ dtc_tests () {
run_dtc_test -I dts -O dtb -o dtc_sized_cells.test.dtb "$SRCDIR/sized_cells.dts"
run_test sized_cells dtc_sized_cells.test.dtb
run_dtc_test -I dts -O dts -o over-determined-once.test.dts "$SRCDIR/over-determined.dts"
run_dtc_test -I dts -O dts -o over-determined-twice.test.dts "over-determined-once.test.dts"
run_wrap_test cmp over-determined-once.test.dts over-determined-twice.test.dts
run_dtc_test -I dts -O dtb -o dtc_extra-terminating-null.test.dtb "$SRCDIR/extra-terminating-null.dts"
run_test extra-terminating-null dtc_extra-terminating-null.test.dtb