summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2010-02-23 19:56:41 +1100
committerJon Loeliger <jdl@jdl.com>2010-02-23 09:04:48 -0600
commit329055dbbc3c09e21386ceae788256991f4c8aec (patch)
tree92d2c0fee03699a262080183cc2f4c756972a24e /tests
parent15ad6d862ec7f66dc00783798705a8db1c5d9aca (diff)
downloaddtc-329055dbbc3c09e21386ceae788256991f4c8aec.tar.gz
Disallow re-use of the same label within a dts file
Currently, nothing will stop you from re-using the same label string multiple times in a dts, e.g.: / { samelabel: prop1 = "foo"; samelabel: prop2 = "bar"; }; or / { samelabel: prop1 = "foo"; samelabel: subnode { }; }; When using node references by label, this could lead to confusing results (with no warning), and in -Oasm mode will result in output which the assembler will complain about (since it too will have duplicate labels). This patch, therefore, adds code to checks.c to give errors if you attempt to re-use the same label. It treats all labels (node, property, and value) as residing in the same namespace, since the assembler will treat them so for -Oasm mode. Testcases for the new code are also added. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'tests')
-rw-r--r--tests/reuse-label.dts15
-rw-r--r--tests/reuse-label1.dts10
-rw-r--r--tests/reuse-label2.dts6
-rw-r--r--tests/reuse-label3.dts9
-rw-r--r--tests/reuse-label4.dts5
-rw-r--r--tests/reuse-label5.dts6
-rw-r--r--tests/reuse-label6.dts6
-rwxr-xr-xtests/run_tests.sh7
8 files changed, 64 insertions, 0 deletions
diff --git a/tests/reuse-label.dts b/tests/reuse-label.dts
new file mode 100644
index 0000000..98b5ca9
--- /dev/null
+++ b/tests/reuse-label.dts
@@ -0,0 +1,15 @@
+/dts-v1/;
+
+/ {
+ label: property1 = "foo";
+ label: property2 = "bar";
+
+ test1 = &label;
+
+ label: node1 {
+ prop = "foo";
+ };
+ label: node2 {
+ prop = "bar";
+ };
+};
diff --git a/tests/reuse-label1.dts b/tests/reuse-label1.dts
new file mode 100644
index 0000000..f229569
--- /dev/null
+++ b/tests/reuse-label1.dts
@@ -0,0 +1,10 @@
+/dts-v1/;
+
+/ {
+ label: node1 {
+ prop = "foo";
+ };
+ label: node2 {
+ prop = "bar";
+ };
+};
diff --git a/tests/reuse-label2.dts b/tests/reuse-label2.dts
new file mode 100644
index 0000000..01ea6b2
--- /dev/null
+++ b/tests/reuse-label2.dts
@@ -0,0 +1,6 @@
+/dts-v1/;
+
+/ {
+ label: property1 = "foo";
+ label: property2 = "bar";
+};
diff --git a/tests/reuse-label3.dts b/tests/reuse-label3.dts
new file mode 100644
index 0000000..fa3d2c7
--- /dev/null
+++ b/tests/reuse-label3.dts
@@ -0,0 +1,9 @@
+/dts-v1/;
+
+/ {
+ label: property = "foo";
+
+ label: node {
+ property = "foo";
+ };
+};
diff --git a/tests/reuse-label4.dts b/tests/reuse-label4.dts
new file mode 100644
index 0000000..6805de3
--- /dev/null
+++ b/tests/reuse-label4.dts
@@ -0,0 +1,5 @@
+/dts-v1/;
+
+/ {
+ property = label: "foo" label:;
+};
diff --git a/tests/reuse-label5.dts b/tests/reuse-label5.dts
new file mode 100644
index 0000000..b7238e6
--- /dev/null
+++ b/tests/reuse-label5.dts
@@ -0,0 +1,6 @@
+/dts-v1/;
+
+/ {
+ prop1 = label: "foo";
+ prop2 = "bar" label:;
+};
diff --git a/tests/reuse-label6.dts b/tests/reuse-label6.dts
new file mode 100644
index 0000000..f5d507c
--- /dev/null
+++ b/tests/reuse-label6.dts
@@ -0,0 +1,6 @@
+/dts-v1/;
+
+/ {
+ label: prop1 = "foo";
+ prop2 = "bar" label:;
+};
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index ca46051..eb46819 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -318,6 +318,13 @@ dtc_tests () {
run_sh_test dtc-checkfails.sh node_name_format -- -I dtb -O dtb bad_node_format.dtb
run_sh_test dtc-checkfails.sh prop_name_chars -- -I dtb -O dtb bad_prop_char.dtb
+ run_sh_test dtc-checkfails.sh duplicate_label -- -I dts -O dtb reuse-label1.dts
+ run_sh_test dtc-checkfails.sh duplicate_label -- -I dts -O dtb reuse-label2.dts
+ run_sh_test dtc-checkfails.sh duplicate_label -- -I dts -O dtb reuse-label3.dts
+ run_sh_test dtc-checkfails.sh duplicate_label -- -I dts -O dtb reuse-label4.dts
+ run_sh_test dtc-checkfails.sh duplicate_label -- -I dts -O dtb reuse-label5.dts
+ run_sh_test dtc-checkfails.sh duplicate_label -- -I dts -O dtb reuse-label6.dts
+
# Check for proper behaviour reading from stdin
run_dtc_test -I dts -O dtb -o stdin_dtc_tree1.test.dtb - < test_tree1.dts
run_wrap_test cmp stdin_dtc_tree1.test.dtb dtc_tree1.test.dtb