Browse Source

Improve tests for dtc overlay generation

So far, the tests for generating runtime overlays with dtc weren't checking
the syntactic sugar.  This adds such a test.

Furthermore the existing tests were only minimally testing dtc's output
for the overlay.  This adds a test comparing the dtc output with the
more or less manually constructed overlays we already have for testing
libfdt's overlay application code.  This does require some minor changes
to that manually constructed overlay which don't change the sematics but
re-order / rename things to match the way dtc does it.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
main
David Gibson 7 years ago
parent
commit
119e273003
  1. 50
      tests/overlay_overlay.dts
  2. 34
      tests/overlay_overlay_manual_fixups.dts
  3. 86
      tests/overlay_overlay_nosugar.dts
  4. 13
      tests/run_tests.sh

50
tests/overlay_overlay.dts

@ -9,78 +9,44 @@ @@ -9,78 +9,44 @@
/dts-v1/;
/plugin/;

/ {
/* Test that we can change an int by another */
fragment@0 {
target = <&test>;

__overlay__ {
&test {
test-int-property = <43>;
};
};

/* Test that we can replace a string by a longer one */
fragment@1 {
target = <&test>;

__overlay__ {
&test {
test-str-property = "foobar";
};
};

/* Test that we add a new property */
fragment@2 {
target = <&test>;

__overlay__ {
&test {
test-str-property-2 = "foobar2";
};
};

/* Test that we add a new node (by phandle) */
fragment@3 {
target = <&test>;

__overlay__ {
&test {
new-node {
new-property;
};
};
};

fragment@5 {
target = <&test>;

__overlay__ {
&test {
local: new-local-node {
new-property;
};
};
};

fragment@6 {
target = <&test>;

__overlay__ {
&test {
test-phandle = <&test>, <&local>;
};
};

fragment@7 {
target = <&test>;

__overlay__ {
&test {
test-several-phandle = <&local>, <&local>;
};
};

fragment@8 {
target = <&test>;

__overlay__ {
&test {
sub-test-node {
new-sub-test-property;
};
};
};
};

34
tests/overlay_overlay_manual_fixups.dts

@ -50,7 +50,7 @@ @@ -50,7 +50,7 @@
};
};

fragment@5 {
fragment@4 {
target = <0xffffffff /*&test*/>;

__overlay__ {
@ -60,7 +60,7 @@ @@ -60,7 +60,7 @@
};
};

fragment@6 {
fragment@5 {
target = <0xffffffff /*&test*/>;

__overlay__ {
@ -68,7 +68,7 @@ @@ -68,7 +68,7 @@
};
};

fragment@7 {
fragment@6 {
target = <0xffffffff /*&test*/>;

__overlay__ {
@ -76,7 +76,7 @@ @@ -76,7 +76,7 @@
};
};

fragment@8 {
fragment@7 {
target = <0xffffffff /*&test*/>;

__overlay__ {
@ -86,27 +86,27 @@ @@ -86,27 +86,27 @@
};
};

__fixups__ {
test = "/fragment@0:target:0",
"/fragment@1:target:0",
"/fragment@2:target:0",
"/fragment@3:target:0",
"/fragment@4:target:0",
"/fragment@5:target:0",
"/fragment@5/__overlay__:test-phandle:0",
"/fragment@6:target:0",
"/fragment@7:target:0";
};
__local_fixups__ {
fragment@6 {
fragment@5 {
__overlay__ {
test-phandle = <4>;
};
};
fragment@7 {
fragment@6 {
__overlay__ {
test-several-phandle = <0 4>;
};
};
};
__fixups__ {
test = "/fragment@0:target:0",
"/fragment@1:target:0",
"/fragment@2:target:0",
"/fragment@3:target:0",
"/fragment@5:target:0",
"/fragment@6:target:0",
"/fragment@6/__overlay__:test-phandle:0",
"/fragment@7:target:0",
"/fragment@8:target:0";
};
};

86
tests/overlay_overlay_nosugar.dts

@ -0,0 +1,86 @@ @@ -0,0 +1,86 @@
/*
* Copyright (c) 2016 NextThing Co
* Copyright (c) 2016 Free Electrons
* Copyright (c) 2016 Konsulko Inc.
*
* SPDX-License-Identifier: GPL-2.0+
*/

/dts-v1/;
/plugin/;

/ {
/* Test that we can change an int by another */
fragment@0 {
target = <&test>;

__overlay__ {
test-int-property = <43>;
};
};

/* Test that we can replace a string by a longer one */
fragment@1 {
target = <&test>;

__overlay__ {
test-str-property = "foobar";
};
};

/* Test that we add a new property */
fragment@2 {
target = <&test>;

__overlay__ {
test-str-property-2 = "foobar2";
};
};

/* Test that we add a new node (by phandle) */
fragment@3 {
target = <&test>;

__overlay__ {
new-node {
new-property;
};
};
};

fragment@5 {
target = <&test>;

__overlay__ {
local: new-local-node {
new-property;
};
};
};

fragment@6 {
target = <&test>;

__overlay__ {
test-phandle = <&test>, <&local>;
};
};

fragment@7 {
target = <&test>;

__overlay__ {
test-several-phandle = <&local>, <&local>;
};
};

fragment@8 {
target = <&test>;

__overlay__ {
sub-test-node {
new-sub-test-property;
};
};
};
};

13
tests/run_tests.sh

@ -239,11 +239,24 @@ dtc_overlay_tests () { @@ -239,11 +239,24 @@ dtc_overlay_tests () {
run_test check_path overlay_base.test.dtb not-exists "/__fixups__"
run_test check_path overlay_base.test.dtb not-exists "/__local_fixups__"

# With syntactic sugar
run_dtc_test -I dts -O dtb -o overlay_overlay.test.dtb overlay_overlay.dts
run_test check_path overlay_overlay.test.dtb not-exists "/__symbols__"
run_test check_path overlay_overlay.test.dtb exists "/__fixups__"
run_test check_path overlay_overlay.test.dtb exists "/__local_fixups__"

# Without syntactic sugar
run_dtc_test -I dts -O dtb -o overlay_overlay_nosugar.test.dtb overlay_overlay.dts
run_test check_path overlay_overlay_nosugar.test.dtb not-exists "/__symbols__"
run_test check_path overlay_overlay_nosugar.test.dtb exists "/__fixups__"
run_test check_path overlay_overlay_nosugar.test.dtb exists "/__local_fixups__"

# Check building works the same as manual constructions
run_test dtbs_equal_ordered overlay_overlay.test.dtb overlay_overlay_nosugar.test.dtb

run_dtc_test -I dts -O dtb -o overlay_overlay_manual_fixups.test.dtb overlay_overlay_manual_fixups.dts
run_test dtbs_equal_ordered overlay_overlay.test.dtb overlay_overlay_manual_fixups.test.dtb

run_test overlay overlay_base.test.dtb overlay_overlay.test.dtb

# test plugin source to dtb and back

Loading…
Cancel
Save