aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2014-01-27 06:22:54 +0000
committerWarner Losh <imp@FreeBSD.org>2014-01-27 06:22:54 +0000
commitb903311b940763cafe4fb3d8ab3da9c135c17b0c (patch)
treedff3470181b322b8d9012f7f1626284a52c14145 /tests
parent939bdb9f6a0dad490702c3009bb8714579e1e765 (diff)
downloadsrc-b903311b940763cafe4fb3d8ab3da9c135c17b0c.tar.gz
src-b903311b940763cafe4fb3d8ab3da9c135c17b0c.zip
Add files for 6a15eb2350426d285130e4c9d84c0bdb6575547a importvendor/dtc/dtc-6a15eb23
Notes
Notes: svn path=/vendor/dtc/dist/; revision=261203 svn path=/vendor/dtc/dtc-6a15eb23/; revision=261204; tag=vendor/dtc/dtc-6a15eb23
Diffstat (limited to 'tests')
-rw-r--r--tests/delete_reinstate_multilabel.dts37
-rw-r--r--tests/delete_reinstate_multilabel_ref.dts9
-rw-r--r--tests/line_directives.dts21
-rw-r--r--tests/propname_escapes.c42
-rw-r--r--tests/propname_escapes.dts6
-rw-r--r--tests/subnode_iterate.c94
-rw-r--r--tests/subnode_iterate.dts44
-rw-r--r--tests/sw_tree1.supp18
-rw-r--r--tests/test_tree1_body.dtsi43
-rw-r--r--tests/test_tree1_delete.dts68
10 files changed, 382 insertions, 0 deletions
diff --git a/tests/delete_reinstate_multilabel.dts b/tests/delete_reinstate_multilabel.dts
new file mode 100644
index 000000000000..281a6b28962e
--- /dev/null
+++ b/tests/delete_reinstate_multilabel.dts
@@ -0,0 +1,37 @@
+/dts-v1/;
+
+/* Create some nodes and properties with multiple labels */
+
+/ {
+ label1: label2: prop = "value";
+
+ label3: label4: node {
+ label5: label6: prop = "value";
+ };
+};
+
+/* Delete them, and everything that's part of them, i.e. the labels */
+
+/ {
+ /delete-property/ prop;
+ /delete-node/ node;
+};
+
+/*
+ * Re-instate them. None of the old labels should come back
+ *
+ * Note: Do not add any new/extra labels here. As of the time of writing,
+ * when dtc adds labels to an object, they are added to the head of the list
+ * of labels, and this test is specifically about ensuring the correct
+ * handling of lists of labels where the first label in the list is marked as
+ * deleted. Failure to observe this note may result in the test passing when
+ * it should not.
+ */
+
+/ {
+ prop = "value";
+
+ node {
+ prop = "value";
+ };
+};
diff --git a/tests/delete_reinstate_multilabel_ref.dts b/tests/delete_reinstate_multilabel_ref.dts
new file mode 100644
index 000000000000..28fa1174fe2c
--- /dev/null
+++ b/tests/delete_reinstate_multilabel_ref.dts
@@ -0,0 +1,9 @@
+/dts-v1/;
+
+/ {
+ prop = "value";
+
+ node {
+ prop = "value";
+ };
+};
diff --git a/tests/line_directives.dts b/tests/line_directives.dts
new file mode 100644
index 000000000000..046ef3715ad6
--- /dev/null
+++ b/tests/line_directives.dts
@@ -0,0 +1,21 @@
+/dts-v1/;
+
+/* common format */
+#line 3 "foo.dts"
+/* newer gcc format */
+# 9 "baz.dts" 1
+/* flags are optional */
+# 6 "bar.dts"
+
+/ {
+/*
+ * Make sure optional flags don't consume integer data on next line. The issue
+ * was that the {WS} in the trailing ({WS}+[0-9]+)? could cross the * line-
+ * break, and consume the leading "0" of the hex constant, leaving "x12345678"
+ * to be parsed as a number, which is invalid syntax.
+ */
+ prop1 = <
+# 10 "qux.dts"
+ 0x12345678
+ >;
+};
diff --git a/tests/propname_escapes.c b/tests/propname_escapes.c
new file mode 100644
index 000000000000..e91bd9944de0
--- /dev/null
+++ b/tests/propname_escapes.c
@@ -0,0 +1,42 @@
+/*
+ * libfdt - Flat Device Tree manipulation
+ * Testcase for fdt_getprop()
+ * Copyright (C) 2006 David Gibson, IBM Corporation.
+ * Copyright (C) 2012 NVIDIA CORPORATION. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdint.h>
+
+#include <libfdt.h>
+
+#include "tests.h"
+
+int main(int argc, char *argv[])
+{
+ void *fdt;
+
+ test_init(argc, argv);
+ fdt = load_blob_arg(argc, argv);
+
+ check_getprop_cell(fdt, 0, "#address-cells", 1);
+ check_getprop_cell(fdt, 0, "#gpio-cells", 2);
+
+ PASS();
+}
diff --git a/tests/propname_escapes.dts b/tests/propname_escapes.dts
new file mode 100644
index 000000000000..9f70618b9150
--- /dev/null
+++ b/tests/propname_escapes.dts
@@ -0,0 +1,6 @@
+/dts-v1/;
+
+/ {
+ #address-cells = <1>;
+ \#gpio-cells = <2>;
+};
diff --git a/tests/subnode_iterate.c b/tests/subnode_iterate.c
new file mode 100644
index 000000000000..b9f379d5963c
--- /dev/null
+++ b/tests/subnode_iterate.c
@@ -0,0 +1,94 @@
+/*
+ * libfdt - Flat Device Tree manipulation
+ * Tests that fdt_next_subnode() works as expected
+ *
+ * Copyright (C) 2013 Google, Inc
+ *
+ * Copyright (C) 2007 David Gibson, IBM Corporation.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdint.h>
+
+#include <libfdt.h>
+
+#include "tests.h"
+#include "testdata.h"
+
+static void test_node(void *fdt, int parent_offset)
+{
+ fdt32_t subnodes;
+ const fdt32_t *prop;
+ int offset;
+ int count;
+ int len;
+
+ /* This property indicates the number of subnodes to expect */
+ prop = fdt_getprop(fdt, parent_offset, "subnodes", &len);
+ if (!prop || len != sizeof(fdt32_t)) {
+ FAIL("Missing/invalid subnodes property at '%s'",
+ fdt_get_name(fdt, parent_offset, NULL));
+ }
+ subnodes = cpu_to_fdt32(*prop);
+
+ count = 0;
+ for (offset = fdt_first_subnode(fdt, parent_offset);
+ offset >= 0;
+ offset = fdt_next_subnode(fdt, offset))
+ count++;
+
+ if (count != subnodes) {
+ FAIL("Node '%s': Expected %d subnodes, got %d\n",
+ fdt_get_name(fdt, parent_offset, NULL), subnodes,
+ count);
+ }
+}
+
+static void check_fdt_next_subnode(void *fdt)
+{
+ int offset;
+ int count = 0;
+
+ for (offset = fdt_first_subnode(fdt, 0);
+ offset >= 0;
+ offset = fdt_next_subnode(fdt, offset)) {
+ test_node(fdt, offset);
+ count++;
+ }
+
+ if (count != 2)
+ FAIL("Expected %d tests, got %d\n", 2, count);
+}
+
+int main(int argc, char *argv[])
+{
+ void *fdt;
+
+ test_init(argc, argv);
+ if (argc != 2)
+ CONFIG("Usage: %s <dtb file>", argv[0]);
+
+ fdt = load_blob(argv[1]);
+ if (!fdt)
+ FAIL("No device tree available");
+
+ check_fdt_next_subnode(fdt);
+
+ PASS();
+}
diff --git a/tests/subnode_iterate.dts b/tests/subnode_iterate.dts
new file mode 100644
index 000000000000..14a0d3aba1fb
--- /dev/null
+++ b/tests/subnode_iterate.dts
@@ -0,0 +1,44 @@
+/dts-v1/;
+
+/ {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ test1 {
+ subnodes = <2>;
+ linux,phandle = <0x1>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ PowerPC,970@0 {
+ name = "PowerPC,970";
+ device_type = "cpu";
+ reg = <0x00000000>;
+ clock-frequency = <1600000000>;
+ timebase-frequency = <33333333>;
+ linux,boot-cpu;
+ i-cache-size = <65536>;
+ d-cache-size = <32768>;
+ another-sub-node {
+ should-be-ignored;
+ yet-another {
+ should-also-be-ignored;
+ };
+ };
+ };
+
+ PowerPC,970@1 {
+ name = "PowerPC,970";
+ device_type = "cpu";
+ reg = <0x00000001>;
+ clock-frequency = <1600000000>;
+ timebase-frequency = <33333333>;
+ i-cache-size = <65536>;
+ d-cache-size = <32768>;
+ };
+ };
+
+ test2 {
+ subnodes = <0>;
+ };
+};
+
diff --git a/tests/sw_tree1.supp b/tests/sw_tree1.supp
new file mode 100644
index 000000000000..279f9e55054c
--- /dev/null
+++ b/tests/sw_tree1.supp
@@ -0,0 +1,18 @@
+{
+ allocation methods causes uninitialized data in alignment gap
+ Memcheck:Param
+ write(buf)
+ fun:__write_nocancel
+ fun:utilfdt_write_err
+ fun:save_blob
+ fun:main
+}
+{
+ allocation methods causes uninitialized data in alignment gap
+ Memcheck:Param
+ write(buf)
+ fun:__write_nocancel
+ fun:utilfdt_write_err
+ fun:save_blob
+ fun:main
+}
diff --git a/tests/test_tree1_body.dtsi b/tests/test_tree1_body.dtsi
new file mode 100644
index 000000000000..24a5e1ee35d0
--- /dev/null
+++ b/tests/test_tree1_body.dtsi
@@ -0,0 +1,43 @@
+/memreserve/ 0xdeadbeef00000000 0x100000;
+/memreserve/ 123456789 010000;
+
+/ {
+ compatible = "test_tree1";
+ prop-int = <0xdeadbeef>;
+ prop-int64 = /bits/ 64 <0xdeadbeef01abcdef>;
+ prop-str = "hello world";
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ subnode@1 {
+ compatible = "subnode1";
+ reg = <1>;
+ prop-int = [deadbeef];
+
+ subsubnode {
+ compatible = "subsubnode1", "subsubnode";
+ prop-int = <0xdeadbeef>;
+ };
+
+ ss1 {
+ };
+ };
+
+ subnode@2 {
+ reg = <2>;
+ linux,phandle = <0x2000>;
+ prop-int = <123456789>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ ssn0: subsubnode@0 {
+ reg = <0>;
+ phandle = <0x2001>;
+ compatible = "subsubnode2", "subsubnode";
+ prop-int = <0726746425>;
+ };
+
+ ss2 {
+ };
+ };
+};
diff --git a/tests/test_tree1_delete.dts b/tests/test_tree1_delete.dts
new file mode 100644
index 000000000000..a2f1bfdc51c9
--- /dev/null
+++ b/tests/test_tree1_delete.dts
@@ -0,0 +1,68 @@
+/dts-v1/;
+
+/include/ "test_tree1_body.dtsi"
+
+/ {
+ nonexistant-property = <0xdeadbeef>;
+
+ nonexistant-subnode {
+ prop-int = <1>;
+ };
+
+ dellabel: deleted-by-label {
+ prop-int = <1>;
+ };
+
+ subnode@1 {
+ delete-this-str = "deadbeef";
+ };
+
+};
+
+/ {
+ /delete-property/ nonexistant-property;
+
+ /delete-node/ nonexistant-subnode;
+
+ subnode@1 {
+ /delete-property/ delete-this-str;
+ };
+};
+
+/delete-node/ &dellabel;
+
+/ {
+ /delete-property/ prop-str;
+};
+
+/ {
+ prop-str = "hello world";
+};
+
+/ {
+ subnode@1 {
+ /delete-node/ ss1;
+ };
+};
+
+/ {
+ subnode@1 {
+ ss1 {
+ };
+ };
+};
+
+/{
+ duplabel1: foo1 = "bar";
+ duplabel2: foo2 = "bar";
+};
+
+/{
+ duplabel1: baz1 = "qux";
+ duplabel2: baz2 = "qux";
+};
+
+/{
+ /delete-property/ foo1;
+ /delete-property/ baz2;
+};