aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKyle Evans <kevans@FreeBSD.org>2018-01-12 21:44:53 +0000
committerKyle Evans <kevans@FreeBSD.org>2018-01-12 21:44:53 +0000
commit2f36e4ecd0f0c04781c752e5382906a43feaf4e3 (patch)
tree27f6eba9c66c680c931ce0562e2586cc9a3c07de /tests
parentf059bd1ebfc4cf2e96c4639ad7fa6cf3a3198a2f (diff)
downloadsrc-vendor/dtc.tar.gz
src-vendor/dtc.zip
Notes
Notes: svn path=/vendor/dtc/dist/; revision=327893 svn path=/vendor/dtc/1.4.6/; revision=327894; tag=vendor/dtc/1.4.6
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.tests6
-rw-r--r--tests/bad-chosen.dts10
-rw-r--r--tests/bad-gpio.dts13
-rw-r--r--tests/bad-interrupt-cells.dts12
-rw-r--r--tests/bad-phandle-cells.dts11
-rw-r--r--tests/bad-string-props.dts7
-rw-r--r--tests/char_literal.c2
-rw-r--r--tests/dtbs_equal_ordered.c2
-rw-r--r--tests/dtbs_equal_unordered.c10
-rw-r--r--tests/dumptrees.c4
-rwxr-xr-xtests/fdtoverlay-runtest.sh40
-rw-r--r--tests/include7.dts1
-rw-r--r--tests/integer-expressions.c4
-rw-r--r--tests/node_check_compatible.c19
-rw-r--r--tests/node_offset_by_prop_value.c2
-rw-r--r--tests/nopulate.c2
-rw-r--r--tests/path-references.c12
-rw-r--r--tests/path-references.dts13
-rw-r--r--tests/pci-bridge-bad1.dts16
-rw-r--r--tests/pci-bridge-bad2.dts16
-rw-r--r--tests/pci-bridge-ok.dts25
-rw-r--r--tests/property_iterate.c4
-rw-r--r--tests/pylibfdt_tests.py334
-rw-r--r--tests/references.c4
-rwxr-xr-xtests/run_tests.sh109
-rw-r--r--tests/sized_cells.c6
-rw-r--r--tests/stacked_overlay_bar.dts13
-rw-r--r--tests/stacked_overlay_base.dts6
-rw-r--r--tests/stacked_overlay_baz.dts13
-rw-r--r--tests/stringlist.c9
-rw-r--r--tests/subnode_iterate.c4
-rw-r--r--tests/sw_tree1.c11
-rw-r--r--tests/test_tree1.dts1
-rw-r--r--tests/test_tree1_label_noderef.dts1
-rw-r--r--tests/testdata.h32
-rw-r--r--tests/tests.h12
-rwxr-xr-xtests/tests.sh1
-rw-r--r--tests/trees.S41
-rw-r--r--tests/truncated_property.c2
-rw-r--r--tests/unit-addr-leading-0s.dts12
-rw-r--r--tests/unit-addr-leading-0x.dts12
-rw-r--r--tests/value-labels.c6
42 files changed, 775 insertions, 85 deletions
diff --git a/tests/Makefile.tests b/tests/Makefile.tests
index 3d7a4f82f067..22581359623c 100644
--- a/tests/Makefile.tests
+++ b/tests/Makefile.tests
@@ -72,13 +72,13 @@ tests_clean:
rm -f $(STD_CLEANFILES:%=$(TESTS_PREFIX)%)
rm -f $(TESTS_CLEANFILES)
-check: tests ${TESTS_BIN}
+check: tests ${TESTS_BIN} $(TESTS_PYLIBFDT)
cd $(TESTS_PREFIX); ./run_tests.sh
-checkm: tests ${TESTS_BIN}
+checkm: tests ${TESTS_BIN} $(TESTS_PYLIBFDT)
cd $(TESTS_PREFIX); ./run_tests.sh -m 2>&1 | tee vglog.$$$$
-checkv: tests ${TESTS_BIN}
+checkv: tests ${TESTS_BIN} $(TESTS_PYLIBFDT)
cd $(TESTS_PREFIX); ./run_tests.sh -v
ifneq ($(DEPTARGETS),)
diff --git a/tests/bad-chosen.dts b/tests/bad-chosen.dts
new file mode 100644
index 000000000000..d6f53c68ddd9
--- /dev/null
+++ b/tests/bad-chosen.dts
@@ -0,0 +1,10 @@
+/dts-v1/;
+
+/ {
+ node2 {
+ chosen {
+ bootargs = <0xdeadbeef>;
+ stdout-path = <1>;
+ };
+ };
+};
diff --git a/tests/bad-gpio.dts b/tests/bad-gpio.dts
new file mode 100644
index 000000000000..6b77be447b82
--- /dev/null
+++ b/tests/bad-gpio.dts
@@ -0,0 +1,13 @@
+/dts-v1/;
+
+/ {
+ gpio: gpio-controller {
+ #gpio-cells = <3>;
+ };
+
+ node {
+ nr-gpios = <1>;
+ foo-gpios = <&gpio>;
+ bar-gpio = <&gpio 1 2 3>;
+ };
+};
diff --git a/tests/bad-interrupt-cells.dts b/tests/bad-interrupt-cells.dts
new file mode 100644
index 000000000000..39fc78fdc11d
--- /dev/null
+++ b/tests/bad-interrupt-cells.dts
@@ -0,0 +1,12 @@
+/dts-v1/;
+
+/ {
+ interrupt-parent = <&intc>;
+ intc: interrupt-controller {
+ #interrupt-cells = <3>;
+ };
+
+ node {
+ interrupts = <1>;
+ };
+};
diff --git a/tests/bad-phandle-cells.dts b/tests/bad-phandle-cells.dts
new file mode 100644
index 000000000000..7f7c6a25fd25
--- /dev/null
+++ b/tests/bad-phandle-cells.dts
@@ -0,0 +1,11 @@
+/dts-v1/;
+
+/ {
+ intc: interrupt-controller {
+ #interrupt-cells = <3>;
+ };
+
+ node {
+ interrupts-extended = <&intc>;
+ };
+};
diff --git a/tests/bad-string-props.dts b/tests/bad-string-props.dts
index 396f82069cf7..6694704a5fc2 100644
--- a/tests/bad-string-props.dts
+++ b/tests/bad-string-props.dts
@@ -4,4 +4,11 @@
device_type = <0xdeadbeef>;
model = <0xdeadbeef>;
status = <0xdeadbeef>;
+ label = <0xdeadbeef>;
+
+ foobar-names = "foo", <1>;
+
+ node {
+ compatible = "good", <0xdeadbeef>;
+ };
};
diff --git a/tests/char_literal.c b/tests/char_literal.c
index d7a4773419a0..da1f964d85fa 100644
--- a/tests/char_literal.c
+++ b/tests/char_literal.c
@@ -31,7 +31,7 @@
int main(int argc, char *argv[])
{
void *fdt;
- uint32_t expected_cells[5];
+ fdt32_t expected_cells[5];
expected_cells[0] = cpu_to_fdt32((unsigned char)TEST_CHAR1);
expected_cells[1] = cpu_to_fdt32((unsigned char)TEST_CHAR2);
diff --git a/tests/dtbs_equal_ordered.c b/tests/dtbs_equal_ordered.c
index 12495dea483e..98bf0e712805 100644
--- a/tests/dtbs_equal_ordered.c
+++ b/tests/dtbs_equal_ordered.c
@@ -28,7 +28,7 @@
#include "tests.h"
#include "testdata.h"
-int notequal; /* = 0 */
+static int notequal; /* = 0 */
#define MISMATCH(fmt, ...) \
do { \
diff --git a/tests/dtbs_equal_unordered.c b/tests/dtbs_equal_unordered.c
index 20b4356f92f6..baf2ae7826a1 100644
--- a/tests/dtbs_equal_unordered.c
+++ b/tests/dtbs_equal_unordered.c
@@ -29,7 +29,7 @@
#include "tests.h"
#include "testdata.h"
-int notequal; /* = 0 */
+static int notequal; /* = 0 */
#define MISMATCH(fmt, ...) \
do { \
@@ -59,14 +59,14 @@ static int mem_rsv_cmp(const void *p1, const void *p2)
const struct fdt_reserve_entry *re1 = p1;
const struct fdt_reserve_entry *re2 = p2;
- if (re1->address < re2->address)
+ if (fdt64_to_cpu(re1->address) < fdt64_to_cpu(re2->address))
return -1;
- else if (re1->address > re2->address)
+ else if (fdt64_to_cpu(re1->address) > fdt64_to_cpu(re2->address))
return 1;
- if (re1->size < re2->size)
+ if (fdt64_to_cpu(re1->size) < fdt64_to_cpu(re2->size))
return -1;
- else if (re1->size > re2->size)
+ else if (fdt64_to_cpu(re1->size) > fdt64_to_cpu(re2->size))
return 1;
return 0;
diff --git a/tests/dumptrees.c b/tests/dumptrees.c
index a49dbfab1567..87d1c3d8440a 100644
--- a/tests/dumptrees.c
+++ b/tests/dumptrees.c
@@ -29,11 +29,11 @@
#include "testdata.h"
-struct {
+static struct {
void *blob;
const char *filename;
} trees[] = {
-#define TREE(name) { &_##name, #name ".dtb" }
+#define TREE(name) { &name, #name ".dtb" }
TREE(test_tree1),
TREE(bad_node_char), TREE(bad_node_format), TREE(bad_prop_char),
TREE(ovf_size_strings),
diff --git a/tests/fdtoverlay-runtest.sh b/tests/fdtoverlay-runtest.sh
new file mode 100755
index 000000000000..06c1169baad3
--- /dev/null
+++ b/tests/fdtoverlay-runtest.sh
@@ -0,0 +1,40 @@
+#! /bin/sh
+
+# Run script for fdtoverlay tests
+# We run fdtoverlay to generate a target device tree, thn fdtget to check it
+
+# Usage
+# fdtoverlay-runtest.sh name expected_output dtb_file node property flags value
+
+. ./tests.sh
+
+LOG=tmp.log.$$
+EXPECT=tmp.expect.$$
+rm -f $LOG $EXPECT
+trap "rm -f $LOG $EXPECT" 0
+
+expect="$1"
+echo $expect >$EXPECT
+node="$2"
+property="$3"
+flags="$4"
+basedtb="$5"
+targetdtb="$6"
+shift 6
+overlays="$@"
+
+# First run fdtoverlay
+verbose_run_check $VALGRIND "$FDTOVERLAY" -i "$basedtb" -o "$targetdtb" $overlays
+
+# Now fdtget to read the value
+verbose_run_log_check "$LOG" $VALGRIND "$DTGET" "$targetdtb" "$node" "$property" $flags
+
+if cmp $EXPECT $LOG >/dev/null; then
+ PASS
+else
+ if [ -z "$QUIET_TEST" ]; then
+ echo "EXPECTED :-:"
+ cat $EXPECT
+ fi
+ FAIL "Results differ from expected"
+fi
diff --git a/tests/include7.dts b/tests/include7.dts
index 2f6eb890f1fa..ab2c948f0f69 100644
--- a/tests/include7.dts
+++ b/tests/include7.dts
@@ -5,6 +5,7 @@
subsubnode {
compatible = "subsubnode1", "subsubnode";
+ placeholder = "this is a placeholder string", "string2";
prop-int = <0xdeadbeef>;
};
diff --git a/tests/integer-expressions.c b/tests/integer-expressions.c
index 57e2ff670ded..ed1f967bba25 100644
--- a/tests/integer-expressions.c
+++ b/tests/integer-expressions.c
@@ -30,7 +30,7 @@
#include "tests.h"
#include "testdata.h"
-struct test_expr {
+static struct test_expr {
const char *expr;
uint32_t result;
} expr_table[] = {
@@ -70,7 +70,7 @@ struct test_expr {
int main(int argc, char *argv[])
{
void *fdt;
- const uint32_t *res;
+ const fdt32_t *res;
int reslen;
int i;
diff --git a/tests/node_check_compatible.c b/tests/node_check_compatible.c
index 4bdf09194c8b..486f9c69e2b8 100644
--- a/tests/node_check_compatible.c
+++ b/tests/node_check_compatible.c
@@ -45,6 +45,23 @@ static void check_compatible(const void *fdt, const char *path,
FAIL("%s is not compatible with \"%s\"", path, compat);
}
+static void check_not_compatible(const void *fdt, const char *path,
+ const char *compat)
+{
+ int offset, err;
+
+ offset = fdt_path_offset(fdt, path);
+ if (offset < 0)
+ FAIL("fdt_path_offset(%s): %s", path, fdt_strerror(offset));
+
+ err = fdt_node_check_compatible(fdt, offset, compat);
+ if (err < 0)
+ FAIL("fdt_node_check_compatible(%s): %s", path,
+ fdt_strerror(err));
+ if (err == 0)
+ FAIL("%s is incorrectly compatible with \"%s\"", path, compat);
+}
+
int main(int argc, char *argv[])
{
void *fdt;
@@ -55,8 +72,10 @@ int main(int argc, char *argv[])
check_compatible(fdt, "/", "test_tree1");
check_compatible(fdt, "/subnode@1/subsubnode", "subsubnode1");
check_compatible(fdt, "/subnode@1/subsubnode", "subsubnode");
+ check_not_compatible(fdt, "/subnode@1/subsubnode", "subsubnode2");
check_compatible(fdt, "/subnode@2/subsubnode", "subsubnode2");
check_compatible(fdt, "/subnode@2/subsubnode", "subsubnode");
+ check_not_compatible(fdt, "/subnode@2/subsubnode", "subsubnode1");
PASS();
}
diff --git a/tests/node_offset_by_prop_value.c b/tests/node_offset_by_prop_value.c
index 9212a4efeffc..286f1e7aa15c 100644
--- a/tests/node_offset_by_prop_value.c
+++ b/tests/node_offset_by_prop_value.c
@@ -69,7 +69,7 @@ static void check_search_str(void *fdt, const char *propname,
#define check_search_cell(fdt, propname, propval, ...) \
{ \
- uint32_t val = cpu_to_fdt32(propval); \
+ fdt32_t val = cpu_to_fdt32(propval); \
check_search((fdt), (propname), &val, sizeof(val), \
##__VA_ARGS__); \
}
diff --git a/tests/nopulate.c b/tests/nopulate.c
index cd79872bc4a9..94ce8adbb98a 100644
--- a/tests/nopulate.c
+++ b/tests/nopulate.c
@@ -45,7 +45,7 @@ static int nopulate_struct(char *buf, const char *fdt)
nextoffset - offset);
p += nextoffset - offset;
- *((uint32_t *)p) = cpu_to_fdt32(FDT_NOP);
+ *((fdt32_t *)p) = cpu_to_fdt32(FDT_NOP);
p += FDT_TAGSIZE;
} while (tag != FDT_END);
diff --git a/tests/path-references.c b/tests/path-references.c
index c8d25fb85fdd..5e332e8f32ca 100644
--- a/tests/path-references.c
+++ b/tests/path-references.c
@@ -66,7 +66,7 @@ int main(int argc, char *argv[])
void *fdt;
const char *p;
int len, multilen;
- int n1, n2;
+ int n1, n2, n3, n4;
test_init(argc, argv);
fdt = load_blob_arg(argc, argv);
@@ -92,6 +92,16 @@ int main(int argc, char *argv[])
if ((!streq(p, "/node1") || !streq(p + strlen("/node1") + 1, "/node2")))
FAIL("multiref has wrong value");
+ /* Check reference to nested nodes with common prefix */
+ n3 = fdt_path_offset(fdt, "/foo/baz");
+ if (n3 < 0)
+ FAIL("fdt_path_offset(/foo/baz): %s", fdt_strerror(n3));
+ n4 = fdt_path_offset(fdt, "/foobar/baz");
+ if (n4 < 0)
+ FAIL("fdt_path_offset(/foobar/baz): %s", fdt_strerror(n4));
+ check_ref(fdt, n3, "/foobar/baz");
+ check_ref(fdt, n4, "/foo/baz");
+
check_rref(fdt);
PASS();
diff --git a/tests/path-references.dts b/tests/path-references.dts
index b00fd79061fa..8c66d8057bbd 100644
--- a/tests/path-references.dts
+++ b/tests/path-references.dts
@@ -12,4 +12,17 @@
ref = &{/node1}; /* reference after target */
lref = &n1;
};
+ /* Check references to nested nodes with common prefix */
+ foobar {
+ n3: baz {
+ ref = &{/foo/baz};
+ lref = &n4;
+ };
+ };
+ foo {
+ n4: baz {
+ ref = &{/foobar/baz};
+ lref = &n3;
+ };
+ };
};
diff --git a/tests/pci-bridge-bad1.dts b/tests/pci-bridge-bad1.dts
new file mode 100644
index 000000000000..17aac04aec5d
--- /dev/null
+++ b/tests/pci-bridge-bad1.dts
@@ -0,0 +1,16 @@
+/dts-v1/;
+
+/ {
+ compatible = "example,pci-bridge-ok";
+ #address-cells = < 2 >;
+ #size-cells = < 2 >;
+ abadname@0 {
+ device_type = "pci";
+ compatible = "example,pci-bridge";
+ #address-cells = < 3 >;
+ #size-cells = < 2 >;
+ reg = <0 0 0 0x1000>;
+ bus-range = <0 0xff>;
+ ranges = <0 0 0 0 0 0 0x10000>;
+ };
+};
diff --git a/tests/pci-bridge-bad2.dts b/tests/pci-bridge-bad2.dts
new file mode 100644
index 000000000000..a7e5c054ac41
--- /dev/null
+++ b/tests/pci-bridge-bad2.dts
@@ -0,0 +1,16 @@
+/dts-v1/;
+
+/ {
+ compatible = "example,pci-bridge-ok";
+ #address-cells = < 2 >;
+ #size-cells = < 2 >;
+ p@0 {
+ device_type = "pci";
+ compatible = "example,pci-bridge";
+ #address-cells = < 3 >;
+ #size-cells = < 2 >;
+ reg = <0 0 0 0x1000>;
+ bus-range = <0 0xff>;
+ ranges = <0 0 0 0 0 0 0x10000>;
+ };
+};
diff --git a/tests/pci-bridge-ok.dts b/tests/pci-bridge-ok.dts
new file mode 100644
index 000000000000..02e32e01a982
--- /dev/null
+++ b/tests/pci-bridge-ok.dts
@@ -0,0 +1,25 @@
+/dts-v1/;
+
+/ {
+ compatible = "example,pci-bridge-ok";
+ #address-cells = < 2 >;
+ #size-cells = < 2 >;
+ pci@0 {
+ device_type = "pci";
+ compatible = "example,pci-bridge";
+ #address-cells = < 3 >;
+ #size-cells = < 2 >;
+ reg = <0 0 0 0x1000>;
+ bus-range = <0 0xff>;
+ ranges = <0 0 0 0 0 0 0x10000>;
+ };
+ pcie@10000000000 {
+ device_type = "pci";
+ compatible = "example,pcie-bridge";
+ #address-cells = < 3 >;
+ #size-cells = < 2 >;
+ reg = <0x10 0x00000000 0 0x1000>;
+ bus-range = <0 0xff>;
+ ranges = <0 0 0 0 0 0 0x10000>;
+ };
+};
diff --git a/tests/property_iterate.c b/tests/property_iterate.c
index 0f3959cb8c22..b5cedbeef399 100644
--- a/tests/property_iterate.c
+++ b/tests/property_iterate.c
@@ -33,7 +33,7 @@
static void test_node(void *fdt, int parent_offset)
{
- fdt32_t properties;
+ uint32_t properties;
const fdt32_t *prop;
int offset, property;
int count;
@@ -48,7 +48,7 @@ static void test_node(void *fdt, int parent_offset)
FAIL("Missing/invalid test-properties property at '%s'",
fdt_get_name(fdt, parent_offset, NULL));
}
- properties = cpu_to_fdt32(*prop);
+ properties = fdt32_to_cpu(*prop);
count = 0;
offset = fdt_first_subnode(fdt, parent_offset);
diff --git a/tests/pylibfdt_tests.py b/tests/pylibfdt_tests.py
new file mode 100644
index 000000000000..95d911aebbd7
--- /dev/null
+++ b/tests/pylibfdt_tests.py
@@ -0,0 +1,334 @@
+# pylibfdt - Tests for Flat Device Tree manipulation in Python
+# Copyright (C) 2017 Google, Inc.
+# Written by Simon Glass <sjg@chromium.org>
+#
+# libfdt is dual licensed: you can use it either under the terms of
+# the GPL, or the BSD license, at your option.
+#
+# a) This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 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 General Public License for more details.
+#
+# You should have received a copy of the GNU 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
+#
+# Alternatively,
+#
+# b) Redistribution and use in source and binary forms, with or
+# without modification, are permitted provided that the following
+# conditions are met:
+#
+# 1. Redistributions of source code must retain the above
+# copyright notice, this list of conditions and the following
+# disclaimer.
+# 2. Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following
+# disclaimer in the documentation and/or other materials
+# provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+import sys
+import types
+import unittest
+
+sys.path.insert(0, '../pylibfdt')
+import libfdt
+from libfdt import FdtException, QUIET_NOTFOUND, QUIET_ALL
+
+def get_err(err_code):
+ """Convert an error code into an error message
+
+ Args:
+ err_code: Error code value (FDT_ERR_...)
+
+ Returns:
+ String error code
+ """
+ return 'pylibfdt error %d: %s' % (-err_code, libfdt.strerror(-err_code))
+
+def _ReadFdt(fname):
+ """Read a device tree file into an Fdt object, ready for use
+
+ Args:
+ fname: Filename to read from
+
+ Returns:
+ Fdt bytearray suitable for passing to libfdt functions
+ """
+ return libfdt.Fdt(open(fname).read())
+
+class PyLibfdtTests(unittest.TestCase):
+ """Test class for pylibfdt
+
+ Properties:
+ fdt: Device tree file used for testing
+ """
+
+ def setUp(self):
+ """Read in the device tree we use for testing"""
+ self.fdt = _ReadFdt('test_tree1.dtb')
+
+ def GetPropList(self, node_path):
+ """Read a list of properties from a node
+
+ Args:
+ node_path: Full path to node, e.g. '/subnode@1/subsubnode'
+
+ Returns:
+ List of property names for that node, e.g. ['compatible', 'reg']
+ """
+ prop_list = []
+ node = self.fdt.path_offset(node_path)
+ poffset = self.fdt.first_property_offset(node, QUIET_NOTFOUND)
+ while poffset > 0:
+ prop = self.fdt.get_property_by_offset(poffset)
+ prop_list.append(prop.name)
+ poffset = self.fdt.next_property_offset(poffset, QUIET_NOTFOUND)
+ return prop_list
+
+ def testImport(self):
+ """Check that we can import the library correctly"""
+ self.assertEquals(type(libfdt), types.ModuleType)
+
+ def testBadFdt(self):
+ """Check that a filename provided accidentally is not accepted"""
+ with self.assertRaises(FdtException) as e:
+ fdt = libfdt.Fdt('a string')
+ self.assertEquals(e.exception.err, -libfdt.BADMAGIC)
+
+ def testSubnodeOffset(self):
+ """check that we can locate a subnode by name"""
+ node1 = self.fdt.path_offset('/subnode@1')
+ self.assertEquals(self.fdt.subnode_offset(0, 'subnode@1'), node1)
+
+ with self.assertRaises(FdtException) as e:
+ self.fdt.subnode_offset(0, 'missing')
+ self.assertEquals(e.exception.err, -libfdt.NOTFOUND)
+
+ node2 = self.fdt.path_offset('/subnode@1/subsubnode')
+ self.assertEquals(self.fdt.subnode_offset(node1, 'subsubnode'), node2)
+
+ def testPathOffset(self):
+ """Check that we can find the offset of a node"""
+ self.assertEquals(self.fdt.path_offset('/'), 0)
+ self.assertTrue(self.fdt.path_offset('/subnode@1') > 0)
+ with self.assertRaises(FdtException) as e:
+ self.fdt.path_offset('/wibble')
+ self.assertEquals(e.exception.err, -libfdt.NOTFOUND)
+ self.assertEquals(self.fdt.path_offset('/wibble', QUIET_NOTFOUND),
+ -libfdt.NOTFOUND)
+
+ def testPropertyOffset(self):
+ """Walk through all the properties in the root node"""
+ offset = self.fdt.first_property_offset(0)
+ self.assertTrue(offset > 0)
+ for i in range(5):
+ next_offset = self.fdt.next_property_offset(offset)
+ self.assertTrue(next_offset > offset)
+ offset = next_offset
+ self.assertEquals(self.fdt.next_property_offset(offset, QUIET_NOTFOUND),
+ -libfdt.NOTFOUND)
+
+ def testPropertyOffsetExceptions(self):
+ """Check that exceptions are raised as expected"""
+ with self.assertRaises(FdtException) as e:
+ self.fdt.first_property_offset(107)
+ self.assertEquals(e.exception.err, -libfdt.BADOFFSET)
+
+ # Quieten the NOTFOUND exception and check that a BADOFFSET
+ # exception is still raised.
+ with self.assertRaises(FdtException) as e:
+ self.fdt.first_property_offset(107, QUIET_NOTFOUND)
+ self.assertEquals(e.exception.err, -libfdt.BADOFFSET)
+ with self.assertRaises(FdtException) as e:
+ self.fdt.next_property_offset(107, QUIET_NOTFOUND)
+ self.assertEquals(e.exception.err, -libfdt.BADOFFSET)
+
+ # Check that NOTFOUND can be quietened.
+ node = self.fdt.path_offset('/subnode@1/ss1')
+ self.assertEquals(self.fdt.first_property_offset(node, QUIET_NOTFOUND),
+ -libfdt.NOTFOUND)
+ with self.assertRaises(FdtException) as e:
+ self.fdt.first_property_offset(node)
+ self.assertEquals(e.exception.err, -libfdt.NOTFOUND)
+
+ def testGetName(self):
+ """Check that we can get the name of a node"""
+ self.assertEquals(self.fdt.get_name(0), '')
+ node = self.fdt.path_offset('/subnode@1/subsubnode')
+ self.assertEquals(self.fdt.get_name(node), 'subsubnode')
+
+ with self.assertRaises(FdtException) as e:
+ self.fdt.get_name(-2)
+ self.assertEquals(e.exception.err, -libfdt.BADOFFSET)
+
+ def testGetPropertyByOffset(self):
+ """Check that we can read the name and contents of a property"""
+ root = 0
+ poffset = self.fdt.first_property_offset(root)
+ prop = self.fdt.get_property_by_offset(poffset)
+ self.assertEquals(prop.name, 'compatible')
+ self.assertEquals(prop.value, 'test_tree1\0')
+
+ with self.assertRaises(FdtException) as e:
+ self.fdt.get_property_by_offset(-2)
+ self.assertEquals(e.exception.err, -libfdt.BADOFFSET)
+ self.assertEquals(
+ -libfdt.BADOFFSET,
+ self.fdt.get_property_by_offset(-2, [libfdt.BADOFFSET]))
+
+ def testGetProp(self):
+ """Check that we can read the contents of a property by name"""
+ root = self.fdt.path_offset('/')
+ value = self.fdt.getprop(root, "compatible")
+ self.assertEquals(value, 'test_tree1\0')
+ self.assertEquals(-libfdt.NOTFOUND, self.fdt.getprop(root, 'missing',
+ QUIET_NOTFOUND))
+
+ with self.assertRaises(FdtException) as e:
+ self.fdt.getprop(root, 'missing')
+ self.assertEquals(e.exception.err, -libfdt.NOTFOUND)
+
+ node = self.fdt.path_offset('/subnode@1/subsubnode')
+ value = self.fdt.getprop(node, "compatible")
+ self.assertEquals(value, 'subsubnode1\0subsubnode\0')
+
+ def testStrError(self):
+ """Check that we can get an error string"""
+ self.assertEquals(libfdt.strerror(-libfdt.NOTFOUND),
+ 'FDT_ERR_NOTFOUND')
+
+ def testFirstNextSubnodeOffset(self):
+ """Check that we can walk through subnodes"""
+ node_list = []
+ node = self.fdt.first_subnode(0, QUIET_NOTFOUND)
+ while node >= 0:
+ node_list.append(self.fdt.get_name(node))
+ node = self.fdt.next_subnode(node, QUIET_NOTFOUND)
+ self.assertEquals(node_list, ['subnode@1', 'subnode@2'])
+
+ def testFirstNextSubnodeOffsetExceptions(self):
+ """Check except handling for first/next subnode functions"""
+ node = self.fdt.path_offset('/subnode@1/subsubnode', QUIET_NOTFOUND)
+ self.assertEquals(self.fdt.first_subnode(node, QUIET_NOTFOUND),
+ -libfdt.NOTFOUND)
+ with self.assertRaises(FdtException) as e:
+ self.fdt.first_subnode(node)
+ self.assertEquals(e.exception.err, -libfdt.NOTFOUND)
+
+ node = self.fdt.path_offset('/subnode@1/ss1', QUIET_NOTFOUND)
+ self.assertEquals(self.fdt.next_subnode(node, QUIET_NOTFOUND),
+ -libfdt.NOTFOUND)
+ with self.assertRaises(FdtException) as e:
+ self.fdt.next_subnode(node)
+ self.assertEquals(e.exception.err, -libfdt.NOTFOUND)
+
+ def testDeleteProperty(self):
+ """Test that we can delete a property"""
+ node_name = '/subnode@1'
+ self.assertEquals(self.GetPropList(node_name),
+ ['compatible', 'reg', 'prop-int'])
+ node = self.fdt.path_offset('/%s' % node_name)
+ self.assertEquals(self.fdt.delprop(node, 'reg'), 0)
+ self.assertEquals(self.GetPropList(node_name),
+ ['compatible', 'prop-int'])
+
+ def testHeader(self):
+ """Test that we can access the header values"""
+ self.assertEquals(self.fdt.totalsize(), len(self.fdt._fdt))
+ self.assertEquals(self.fdt.off_dt_struct(), 88)
+
+ def testPack(self):
+ """Test that we can pack the tree after deleting something"""
+ orig_size = self.fdt.totalsize()
+ node = self.fdt.path_offset('/subnode@2', QUIET_NOTFOUND)
+ self.assertEquals(self.fdt.delprop(node, 'prop-int'), 0)
+ self.assertEquals(orig_size, self.fdt.totalsize())
+ self.assertEquals(self.fdt.pack(), 0)
+ self.assertTrue(self.fdt.totalsize() < orig_size)
+
+ def testBadPropertyOffset(self):
+ """Test that bad property offsets are detected"""
+ with self.assertRaises(FdtException) as e:
+ self.fdt.get_property_by_offset(13)
+ self.assertEquals(e.exception.err, -libfdt.BADOFFSET)
+ with self.assertRaises(FdtException) as e:
+ self.fdt.first_property_offset(3)
+ self.assertEquals(e.exception.err, -libfdt.BADOFFSET)
+ with self.assertRaises(FdtException) as e:
+ self.fdt.next_property_offset(3)
+ self.assertEquals(e.exception.err, -libfdt.BADOFFSET)
+
+ def testBadPathOffset(self):
+ """Test that bad path names are detected"""
+ with self.assertRaisesRegexp(FdtException, get_err(libfdt.BADPATH)):
+ self.fdt.path_offset('not-present')
+
+ def testQuietAll(self):
+ """Check that exceptions can be masked by QUIET_ALL"""
+ self.assertEquals(-libfdt.NOTFOUND,
+ self.fdt.path_offset('/missing', QUIET_ALL))
+ self.assertEquals(-libfdt.BADOFFSET,
+ self.fdt.get_property_by_offset(13, QUIET_ALL))
+ self.assertEquals(-libfdt.BADPATH,
+ self.fdt.path_offset('missing', QUIET_ALL))
+
+ def testIntegers(self):
+ """Check that integers can be passed and returned"""
+ self.assertEquals(0, libfdt.fdt_get_phandle(self.fdt._fdt, 0))
+ node2 = self.fdt.path_offset('/subnode@2')
+ self.assertEquals(0x2000, libfdt.fdt_get_phandle(self.fdt._fdt, node2))
+
+ def testGetPhandle(self):
+ """Test for the get_phandle() method"""
+ self.assertEquals(0, self.fdt.get_phandle(0))
+ node2 = self.fdt.path_offset('/subnode@2')
+ self.assertEquals(0x2000, self.fdt.get_phandle(node2))
+
+ def testParentOffset(self):
+ """Test for the parent_offset() method"""
+ self.assertEquals(-libfdt.NOTFOUND,
+ self.fdt.parent_offset(0, QUIET_NOTFOUND))
+ with self.assertRaises(FdtException) as e:
+ self.fdt.parent_offset(0)
+ self.assertEquals(e.exception.err, -libfdt.NOTFOUND)
+
+ node1 = self.fdt.path_offset('/subnode@2')
+ self.assertEquals(0, self.fdt.parent_offset(node1))
+ node2 = self.fdt.path_offset('/subnode@2/subsubnode@0')
+ self.assertEquals(node1, self.fdt.parent_offset(node2))
+
+ def testNodeOffsetByPhandle(self):
+ """Test for the node_offset_by_phandle() method"""
+ self.assertEquals(-libfdt.NOTFOUND,
+ self.fdt.node_offset_by_phandle(1, QUIET_NOTFOUND))
+ node1 = self.fdt.path_offset('/subnode@2')
+ self.assertEquals(node1, self.fdt.node_offset_by_phandle(0x2000))
+ node2 = self.fdt.path_offset('/subnode@2/subsubnode@0')
+ self.assertEquals(node2, self.fdt.node_offset_by_phandle(0x2001))
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/tests/references.c b/tests/references.c
index 46662fc0faa7..cab70f6579af 100644
--- a/tests/references.c
+++ b/tests/references.c
@@ -29,7 +29,7 @@
static void check_ref(const void *fdt, int node, uint32_t checkref)
{
- const uint32_t *p;
+ const fdt32_t *p;
uint32_t ref;
int len;
@@ -58,7 +58,7 @@ static void check_ref(const void *fdt, int node, uint32_t checkref)
static void check_rref(const void *fdt)
{
- const uint32_t *p;
+ const fdt32_t *p;
uint32_t ref;
int len;
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index ed489dbdd269..3fa7c0a7fc98 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -6,6 +6,11 @@ if [ -z "$CC" ]; then
CC=gcc
fi
+# stat differs between platforms
+if [ -z "$STATSZ" ]; then
+ STATSZ="stat -c %s"
+fi
+
export QUIET_TEST=1
STOP_ON_FAIL=0
@@ -114,7 +119,7 @@ run_wrap_error_test () {
# $2: align base
check_align () {
shorten_echo "check_align $@: "
- local size=$(stat -c %s "$1")
+ local size=$($STATSZ "$1")
local align="$2"
(
if [ $(($size % $align)) -eq 0 ] ;then
@@ -157,7 +162,15 @@ run_fdtdump_test() {
file="$1"
shorten_echo fdtdump-runtest.sh "$file"
printf ": "
- base_run_test sh fdtdump-runtest.sh "$file"
+ base_run_test sh fdtdump-runtest.sh "$file" 2>/dev/null
+}
+
+run_fdtoverlay_test() {
+ expect="$1"
+ shift
+ shorten_echo fdtoverlay-runtest.sh "$expect" "$@"
+ printf ": "
+ base_run_test sh fdtoverlay-runtest.sh "$expect" "$@"
}
BAD_FIXUP_TREES="bad_index \
@@ -197,6 +210,12 @@ libfdt_overlay_tests () {
run_test overlay overlay_base_manual_symbols.test.dtb overlay_overlay_manual_fixups.test.dtb
+ # test simplified plugin syntax
+ run_dtc_test -@ -I dts -O dtb -o overlay_overlay_simple.dtb overlay_overlay_simple.dts
+
+ # verify non-generation of local fixups
+ run_test check_path overlay_overlay_simple.dtb not-exists "/__local_fixups__"
+
# Bad fixup tests
for test in $BAD_FIXUP_TREES; do
tree="overlay_bad_fixup_$test"
@@ -420,7 +439,7 @@ dtc_tests () {
run_dtc_test -I dts -O dtb -o dtc_path-references.test.dtb path-references.dts
run_test path-references dtc_path-references.test.dtb
- run_test phandle_format dtc_references.test.dtb both
+ run_test phandle_format dtc_references.test.dtb epapr
for f in legacy epapr both; do
run_dtc_test -I dts -O dtb -H $f -o dtc_references.test.$f.dtb references.dts
run_test phandle_format dtc_references.test.$f.dtb $f
@@ -532,7 +551,10 @@ dtc_tests () {
check_tests bad-name-property.dts name_properties
check_tests bad-ncells.dts address_cells_is_cell size_cells_is_cell interrupt_cells_is_cell
- check_tests bad-string-props.dts device_type_is_string model_is_string status_is_string
+ check_tests bad-string-props.dts device_type_is_string model_is_string status_is_string label_is_string compatible_is_string_list names_is_string_list
+ check_tests bad-chosen.dts chosen_node_is_root
+ check_tests bad-chosen.dts chosen_node_bootargs
+ check_tests bad-chosen.dts chosen_node_stdout_path
check_tests bad-reg-ranges.dts reg_format ranges_format
check_tests bad-empty-ranges.dts ranges_format
check_tests reg-ranges-root.dts reg_format ranges_format
@@ -540,6 +562,12 @@ dtc_tests () {
check_tests obsolete-chosen-interrupt-controller.dts obsolete_chosen_interrupt_controller
check_tests reg-without-unit-addr.dts unit_address_vs_reg
check_tests unit-addr-without-reg.dts unit_address_vs_reg
+ check_tests unit-addr-leading-0x.dts unit_address_format
+ check_tests unit-addr-leading-0s.dts unit_address_format
+ check_tests bad-phandle-cells.dts interrupts_extended_property
+ check_tests bad-gpio.dts gpios_property
+ run_sh_test dtc-checkfails.sh deprecated_gpio_property -- -Wdeprecated_gpio_property -I dts -O dtb bad-gpio.dts
+ check_tests bad-interrupt-cells.dts interrupts_property
run_sh_test dtc-checkfails.sh node_name_chars -- -I dtb -O dtb bad_node_char.dtb
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
@@ -554,6 +582,10 @@ dtc_tests () {
run_test check_path test_tree1.dtb exists "/subnode@1"
run_test check_path test_tree1.dtb not-exists "/subnode@10"
+ check_tests pci-bridge-ok.dts -n pci_bridge
+ check_tests pci-bridge-bad1.dts pci_bridge
+ check_tests pci-bridge-bad2.dts pci_bridge
+
# Check warning options
run_sh_test dtc-checkfails.sh address_cells_is_cell interrupt_cells_is_cell -n size_cells_is_cell -- -Wno_size_cells_is_cell -I dts -O dtb bad-ncells.dts
run_sh_test dtc-fails.sh -n test-warn-output.test.dtb -I dts -O dtb bad-ncells.dts
@@ -690,7 +722,7 @@ fdtput_tests () {
text=lorem.txt
# Allow just enough space for $text
- run_dtc_test -O dtb -p $(stat -c %s $text) -o $dtb $dts
+ run_dtc_test -O dtb -p $($STATSZ $text) -o $dtb $dts
# run_fdtput_test <expected-result> <file> <node> <property> <flags> <value>
run_fdtput_test "a_model" $dtb / model -ts "a_model"
@@ -709,7 +741,7 @@ fdtput_tests () {
run_fdtput_test "$(cat $text $text)" $dtb /randomnode blob -ts "$(cat $text $text)"
# Start again with a fresh dtb
- run_dtc_test -O dtb -p $(stat -c %s $text) -o $dtb $dts
+ run_dtc_test -O dtb -p $($STATSZ $text) -o $dtb $dts
# Node creation
run_wrap_error_test $DTPUT $dtb -c /baldrick sod
@@ -737,7 +769,7 @@ fdtput_tests () {
run_wrap_test $DTPUT $dtb -cp /chosen/son
# Start again with a fresh dtb
- run_dtc_test -O dtb -p $(stat -c %s $text) -o $dtb $dts
+ run_dtc_test -O dtb -p $($STATSZ $text) -o $dtb $dts
# Node delete
run_wrap_test $DTPUT $dtb -c /chosen/node1 /chosen/node2 /chosen/node3
@@ -769,6 +801,55 @@ fdtdump_tests () {
run_fdtdump_test fdtdump.dts
}
+fdtoverlay_tests() {
+ base=overlay_base.dts
+ basedtb=overlay_base.fdoverlay.test.dtb
+ overlay=overlay_overlay_manual_fixups.dts
+ overlaydtb=overlay_overlay_manual_fixups.fdoverlay.test.dtb
+ targetdtb=target.fdoverlay.test.dtb
+
+ run_dtc_test -@ -I dts -O dtb -o $basedtb $base
+ run_dtc_test -@ -I dts -O dtb -o $overlaydtb $overlay
+
+ # test that the new property is installed
+ run_fdtoverlay_test foobar "/test-node" "test-str-property" "-ts" ${basedtb} ${targetdtb} ${overlaydtb}
+
+ stacked_base=stacked_overlay_base.dts
+ stacked_basedtb=stacked_overlay_base.fdtoverlay.test.dtb
+ stacked_bar=stacked_overlay_bar.dts
+ stacked_bardtb=stacked_overlay_bar.fdtoverlay.test.dtb
+ stacked_baz=stacked_overlay_baz.dts
+ stacked_bazdtb=stacked_overlay_baz.fdtoverlay.test.dtb
+ stacked_targetdtb=stacked_overlay_target.fdtoverlay.test.dtb
+
+ run_dtc_test -@ -I dts -O dtb -o $stacked_basedtb $stacked_base
+ run_dtc_test -@ -I dts -O dtb -o $stacked_bardtb $stacked_bar
+ run_dtc_test -@ -I dts -O dtb -o $stacked_bazdtb $stacked_baz
+
+ # test that baz correctly inserted the property
+ run_fdtoverlay_test baz "/foonode/barnode/baznode" "baz-property" "-ts" ${stacked_basedtb} ${stacked_targetdtb} ${stacked_bardtb} ${stacked_bazdtb}
+}
+
+pylibfdt_tests () {
+ TMP=/tmp/tests.stderr.$$
+ python pylibfdt_tests.py -v 2> $TMP
+
+ # Use the 'ok' message meaning the test passed, 'ERROR' meaning it failed
+ # and the summary line for total tests (e.g. 'Ran 17 tests in 0.002s').
+ # We could add pass + fail to get total tests, but this provides a useful
+ # sanity check.
+ pass_count=$(grep "\.\.\. ok$" $TMP | wc -l)
+ fail_count=$(grep "^ERROR: " $TMP | wc -l)
+ total_tests=$(sed -n 's/^Ran \([0-9]*\) tests.*$/\1/p' $TMP)
+ cat $TMP
+ rm $TMP
+
+ # Extract the test results and add them to our totals
+ tot_fail=$((tot_fail + $fail_count))
+ tot_pass=$((tot_pass + $pass_count))
+ tot_tests=$((tot_tests + $total_tests))
+}
+
while getopts "vt:me" ARG ; do
case $ARG in
"v")
@@ -787,7 +868,12 @@ while getopts "vt:me" ARG ; do
done
if [ -z "$TESTSETS" ]; then
- TESTSETS="libfdt utilfdt dtc dtbs_equal fdtget fdtput fdtdump"
+ TESTSETS="libfdt utilfdt dtc dtbs_equal fdtget fdtput fdtdump fdtoverlay"
+
+ # Test pylibfdt if the libfdt Python module is available.
+ if [ -f ../pylibfdt/_libfdt.so ]; then
+ TESTSETS="$TESTSETS pylibfdt"
+ fi
fi
# Make sure we don't have stale blobs lying around
@@ -816,6 +902,12 @@ for set in $TESTSETS; do
"fdtdump")
fdtdump_tests
;;
+ "pylibfdt")
+ pylibfdt_tests
+ ;;
+ "fdtoverlay")
+ fdtoverlay_tests
+ ;;
esac
done
@@ -830,3 +922,4 @@ fi
echo "* Strange test result: $tot_strange"
echo "**********"
+[ "$tot_tests" -eq "$tot_pass" ] || exit 1
diff --git a/tests/sized_cells.c b/tests/sized_cells.c
index 94da03b8a077..0b2b8dc56626 100644
--- a/tests/sized_cells.c
+++ b/tests/sized_cells.c
@@ -54,9 +54,9 @@ int main(int argc, char *argv[])
TEST_CHAR4,
TEST_CHAR5,
TEST_VALUE_1 >> 24};
- uint16_t expected_16[6];
- uint32_t expected_32[6];
- uint64_t expected_64[6];
+ fdt16_t expected_16[6];
+ fdt32_t expected_32[6];
+ fdt64_t expected_64[6];
int i;
for (i = 0; i < 5; ++i) {
diff --git a/tests/stacked_overlay_bar.dts b/tests/stacked_overlay_bar.dts
new file mode 100644
index 000000000000..c64639952f4c
--- /dev/null
+++ b/tests/stacked_overlay_bar.dts
@@ -0,0 +1,13 @@
+/dts-v1/;
+/plugin/;
+/ {
+ fragment@1 {
+ target = <&foo>;
+ __overlay__ {
+ overlay-1-property;
+ bar: barnode {
+ bar-property = "bar";
+ };
+ };
+ };
+};
diff --git a/tests/stacked_overlay_base.dts b/tests/stacked_overlay_base.dts
new file mode 100644
index 000000000000..29164230d6f6
--- /dev/null
+++ b/tests/stacked_overlay_base.dts
@@ -0,0 +1,6 @@
+/dts-v1/;
+/ {
+ foo: foonode {
+ foo-property = "foo";
+ };
+};
diff --git a/tests/stacked_overlay_baz.dts b/tests/stacked_overlay_baz.dts
new file mode 100644
index 000000000000..a52f0cc600e3
--- /dev/null
+++ b/tests/stacked_overlay_baz.dts
@@ -0,0 +1,13 @@
+/dts-v1/;
+/plugin/;
+/ {
+ fragment@1 {
+ target = <&bar>;
+ __overlay__ {
+ overlay-2-property;
+ baz: baznode {
+ baz-property = "baz";
+ };
+ };
+ };
+};
diff --git a/tests/stringlist.c b/tests/stringlist.c
index a9d3e73920ca..23cfece021dd 100644
--- a/tests/stringlist.c
+++ b/tests/stringlist.c
@@ -60,10 +60,11 @@ static void check_expected_failure(const void *fdt, const char *path,
FAIL("empty string not found in #address-cells: %d\n", err);
/*
- * fdt_get_string() can successfully extract strings from non-string
- * properties. This is because it doesn't necessarily parse the whole
- * property value, which would be necessary for it to determine if a
- * valid string or string list is present.
+ * fdt_getprop_string() can successfully extract strings from
+ * non-string properties. This is because it doesn't
+ * necessarily parse the whole property value, which would be
+ * necessary for it to determine if a valid string or string
+ * list is present.
*/
}
diff --git a/tests/subnode_iterate.c b/tests/subnode_iterate.c
index 0fb5c901ebd7..7be5706eeb30 100644
--- a/tests/subnode_iterate.c
+++ b/tests/subnode_iterate.c
@@ -33,7 +33,7 @@
static void test_node(void *fdt, int parent_offset)
{
- fdt32_t subnodes;
+ uint32_t subnodes;
const fdt32_t *prop;
int offset;
int count;
@@ -45,7 +45,7 @@ static void test_node(void *fdt, int parent_offset)
FAIL("Missing/invalid subnodes property at '%s'",
fdt_get_name(fdt, parent_offset, NULL));
}
- subnodes = cpu_to_fdt32(*prop);
+ subnodes = fdt32_to_cpu(*prop);
count = 0;
fdt_for_each_subnode(offset, fdt, parent_offset)
diff --git a/tests/sw_tree1.c b/tests/sw_tree1.c
index 6d4c53102967..386b05f6f720 100644
--- a/tests/sw_tree1.c
+++ b/tests/sw_tree1.c
@@ -42,14 +42,14 @@ static void realloc_fdt(void **fdt, size_t *size, bool created)
switch (alloc_mode) {
case FIXED:
if (!(*fdt))
- fdt = xmalloc(*size);
+ *fdt = xmalloc(*size);
else
FAIL("Ran out of space");
return;
case RESIZE:
if (!(*fdt)) {
- fdt = xmalloc(SPACE);
+ *fdt = xmalloc(SPACE);
} else if (*size < SPACE) {
*size += 1;
fdt_resize(*fdt, *fdt, *size);
@@ -85,6 +85,9 @@ int main(int argc, char *argv[])
size_t size;
int err;
bool created = false;
+ void *place;
+ const char place_str[] = "this is a placeholder string\0string2";
+ int place_len = sizeof(place_str);
test_init(argc, argv);
@@ -108,6 +111,8 @@ int main(int argc, char *argv[])
CONFIG("Bad allocation mode \"%s\" specified",
argv[1]);
}
+ } else {
+ CONFIG("sw_tree1 <dtb file> [<allocation mode>]");
}
fdt = xmalloc(size);
@@ -135,6 +140,8 @@ int main(int argc, char *argv[])
CHECK(fdt_begin_node(fdt, "subsubnode"));
CHECK(fdt_property(fdt, "compatible", "subsubnode1\0subsubnode",
23));
+ CHECK(fdt_property_placeholder(fdt, "placeholder", place_len, &place));
+ memcpy(place, place_str, place_len);
CHECK(fdt_property_cell(fdt, "prop-int", TEST_VALUE_1));
CHECK(fdt_end_node(fdt));
CHECK(fdt_begin_node(fdt, "ss1"));
diff --git a/tests/test_tree1.dts b/tests/test_tree1.dts
index 67ecfd0ea28f..77ea3256947b 100644
--- a/tests/test_tree1.dts
+++ b/tests/test_tree1.dts
@@ -18,6 +18,7 @@
subsubnode {
compatible = "subsubnode1", "subsubnode";
+ placeholder = "this is a placeholder string", "string2";
prop-int = <0xdeadbeef>;
};
diff --git a/tests/test_tree1_label_noderef.dts b/tests/test_tree1_label_noderef.dts
index b2b194c6df64..cfe5946f8462 100644
--- a/tests/test_tree1_label_noderef.dts
+++ b/tests/test_tree1_label_noderef.dts
@@ -18,6 +18,7 @@
subsubnode {
compatible = "subsubnode1", "subsubnode";
+ placeholder = "this is a placeholder string", "string2";
prop-int = <0xdeadbeef>;
};
diff --git a/tests/testdata.h b/tests/testdata.h
index 3588778ad159..c30f0c8a7698 100644
--- a/tests/testdata.h
+++ b/tests/testdata.h
@@ -4,15 +4,25 @@
#define ASM_CONST_LL(x) (x##ULL)
#endif
-#define TEST_ADDR_1 ASM_CONST_LL(0xdeadbeef00000000)
-#define TEST_SIZE_1 ASM_CONST_LL(0x100000)
-#define TEST_ADDR_2 ASM_CONST_LL(123456789)
-#define TEST_SIZE_2 ASM_CONST_LL(010000)
+#define TEST_ADDR_1H ASM_CONST_LL(0xdeadbeef)
+#define TEST_ADDR_1L ASM_CONST_LL(0x00000000)
+#define TEST_ADDR_1 ((TEST_ADDR_1H << 32) | TEST_ADDR_1L)
+#define TEST_SIZE_1H ASM_CONST_LL(0x00000000)
+#define TEST_SIZE_1L ASM_CONST_LL(0x00100000)
+#define TEST_SIZE_1 ((TEST_SIZE_1H << 32) | TEST_SIZE_1L)
+#define TEST_ADDR_2H ASM_CONST_LL(0)
+#define TEST_ADDR_2L ASM_CONST_LL(123456789)
+#define TEST_ADDR_2 ((TEST_ADDR_2H << 32) | TEST_ADDR_2L)
+#define TEST_SIZE_2H ASM_CONST_LL(0)
+#define TEST_SIZE_2L ASM_CONST_LL(010000)
+#define TEST_SIZE_2 ((TEST_SIZE_2H << 32) | TEST_SIZE_2L)
#define TEST_VALUE_1 0xdeadbeef
#define TEST_VALUE_2 123456789
-#define TEST_VALUE64_1 ASM_CONST_LL(0xdeadbeef01abcdef)
+#define TEST_VALUE64_1H ASM_CONST_LL(0xdeadbeef)
+#define TEST_VALUE64_1L ASM_CONST_LL(0x01abcdef)
+#define TEST_VALUE64_1 ((TEST_VALUE64_1H << 32) | TEST_VALUE64_1L)
#define PHANDLE_1 0x2000
#define PHANDLE_2 0x2001
@@ -31,10 +41,10 @@
#define TEST_CHAR5 '\xff'
#ifndef __ASSEMBLY__
-extern struct fdt_header _test_tree1;
-extern struct fdt_header _truncated_property;
-extern struct fdt_header _bad_node_char;
-extern struct fdt_header _bad_node_format;
-extern struct fdt_header _bad_prop_char;
-extern struct fdt_header _ovf_size_strings;
+extern struct fdt_header test_tree1;
+extern struct fdt_header truncated_property;
+extern struct fdt_header bad_node_char;
+extern struct fdt_header bad_node_format;
+extern struct fdt_header bad_prop_char;
+extern struct fdt_header ovf_size_strings;
#endif /* ! __ASSEMBLY */
diff --git a/tests/tests.h b/tests/tests.h
index 56a843cd25d8..df38b773cc37 100644
--- a/tests/tests.h
+++ b/tests/tests.h
@@ -1,5 +1,5 @@
-#ifndef _TESTS_H
-#define _TESTS_H
+#ifndef TESTS_H
+#define TESTS_H
/*
* libfdt - Flat Device Tree manipulation
* Testcase definitions
@@ -99,7 +99,7 @@ void check_property(void *fdt, int nodeoffset, const char *name,
int len, const void *val);
#define check_property_cell(fdt, nodeoffset, name, val) \
({ \
- uint32_t x = cpu_to_fdt32(val); \
+ fdt32_t x = cpu_to_fdt32(val); \
check_property(fdt, nodeoffset, name, sizeof(x), &x); \
})
@@ -108,12 +108,12 @@ const void *check_getprop(void *fdt, int nodeoffset, const char *name,
int len, const void *val);
#define check_getprop_cell(fdt, nodeoffset, name, val) \
({ \
- uint32_t x = cpu_to_fdt32(val); \
+ fdt32_t x = cpu_to_fdt32(val); \
check_getprop(fdt, nodeoffset, name, sizeof(x), &x); \
})
#define check_getprop_64(fdt, nodeoffset, name, val) \
({ \
- uint64_t x = cpu_to_fdt64(val); \
+ fdt64_t x = cpu_to_fdt64(val); \
check_getprop(fdt, nodeoffset, name, sizeof(x), &x); \
})
#define check_getprop_string(fdt, nodeoffset, name, s) \
@@ -126,4 +126,4 @@ void *open_blob_rw(void *blob);
#include "util.h"
-#endif /* _TESTS_H */
+#endif /* TESTS_H */
diff --git a/tests/tests.sh b/tests/tests.sh
index 818fd09c2ff0..8dda6e105635 100755
--- a/tests/tests.sh
+++ b/tests/tests.sh
@@ -22,6 +22,7 @@ DTC=../dtc
DTGET=../fdtget
DTPUT=../fdtput
FDTDUMP=../fdtdump
+FDTOVERLAY=../fdtoverlay
verbose_run () {
if [ -z "$QUIET_TEST" ]; then
diff --git a/tests/trees.S b/tests/trees.S
index 3d24aa2dcbc8..6898cf97320c 100644
--- a/tests/trees.S
+++ b/tests/trees.S
@@ -7,20 +7,9 @@
.byte ((val) >> 8) & 0xff ; \
.byte (val) & 0xff ;
-#define FDTQUAD(val) \
- .byte ((val) >> 56) & 0xff ; \
- .byte ((val) >> 48) & 0xff ; \
- .byte ((val) >> 40) & 0xff ; \
- .byte ((val) >> 32) & 0xff ; \
- .byte ((val) >> 24) & 0xff ; \
- .byte ((val) >> 16) & 0xff ; \
- .byte ((val) >> 8) & 0xff ; \
- .byte (val) & 0xff ;
-
#define TREE_HDR(tree) \
.balign 8 ; \
- .globl _##tree ; \
-_##tree: \
+ .globl tree ; \
tree: \
FDTLONG(FDT_MAGIC) ; \
FDTLONG(tree##_end - tree) ; \
@@ -33,14 +22,16 @@ tree: \
FDTLONG(tree##_strings_end - tree##_strings) ; \
FDTLONG(tree##_struct_end - tree##_struct) ;
-#define RSVMAP_ENTRY(addr, len) \
- FDTQUAD(addr) ; \
- FDTQUAD(len) ; \
+#define RSVMAP_ENTRY(addrh, addrl, lenh, lenl) \
+ FDTLONG(addrh) ; \
+ FDTLONG(addrl) ; \
+ FDTLONG(lenh) ; \
+ FDTLONG(lenl)
#define EMPTY_RSVMAP(tree) \
.balign 8 ; \
tree##_rsvmap: ; \
- RSVMAP_ENTRY(0, 0) \
+ RSVMAP_ENTRY(0, 0, 0, 0) \
tree##_rsvmap_end: ;
#define PROPHDR(tree, name, len) \
@@ -52,9 +43,10 @@ tree##_rsvmap_end: ;
PROPHDR(tree, name, 4) \
FDTLONG(val) ;
-#define PROP_INT64(tree, name, val) \
+#define PROP_INT64(tree, name, valh, vall) \
PROPHDR(tree, name, 8) \
- FDTQUAD(val) ;
+ FDTLONG(valh) ; \
+ FDTLONG(vall) ;
#define PROP_STR(tree, name, str) \
PROPHDR(tree, name, 55f - 54f) \
@@ -81,16 +73,16 @@ tree##_##name: ; \
.balign 8
test_tree1_rsvmap:
- RSVMAP_ENTRY(TEST_ADDR_1, TEST_SIZE_1)
- RSVMAP_ENTRY(TEST_ADDR_2, TEST_SIZE_2)
- RSVMAP_ENTRY(0, 0)
+ RSVMAP_ENTRY(TEST_ADDR_1H, TEST_ADDR_1L, TEST_SIZE_1H, TEST_SIZE_1L)
+ RSVMAP_ENTRY(TEST_ADDR_2H, TEST_ADDR_2L, TEST_SIZE_2H, TEST_SIZE_2L)
+ RSVMAP_ENTRY(0, 0, 0, 0)
test_tree1_rsvmap_end:
test_tree1_struct:
BEGIN_NODE("")
PROP_STR(test_tree1, compatible, "test_tree1")
PROP_INT(test_tree1, prop_int, TEST_VALUE_1)
- PROP_INT64(test_tree1, prop_int64, TEST_VALUE64_1)
+ PROP_INT64(test_tree1, prop_int64, TEST_VALUE64_1H, TEST_VALUE64_1L)
PROP_STR(test_tree1, prop_str, TEST_STRING_1)
PROP_INT(test_tree1, address_cells, 1)
PROP_INT(test_tree1, size_cells, 0)
@@ -102,6 +94,7 @@ test_tree1_struct:
BEGIN_NODE("subsubnode")
PROP_STR(test_tree1, compatible, "subsubnode1\0subsubnode")
+ PROP_STR(test_tree1, placeholder, "this is a placeholder string\0string2")
PROP_INT(test_tree1, prop_int, TEST_VALUE_1)
END_NODE
@@ -141,6 +134,7 @@ test_tree1_strings:
STRING(test_tree1, linux_phandle, "linux,phandle")
STRING(test_tree1, phandle, "phandle")
STRING(test_tree1, reg, "reg")
+ STRING(test_tree1, placeholder, "placeholder")
STRING(test_tree1, address_cells, "#address-cells")
STRING(test_tree1, size_cells, "#size-cells")
test_tree1_strings_end:
@@ -213,8 +207,7 @@ bad_prop_char_end:
/* overflow_size_strings */
.balign 8
- .globl _ovf_size_strings
-_ovf_size_strings:
+ .globl ovf_size_strings
ovf_size_strings:
FDTLONG(FDT_MAGIC)
FDTLONG(ovf_size_strings_end - ovf_size_strings)
diff --git a/tests/truncated_property.c b/tests/truncated_property.c
index f820d99e3f5d..71619bbce2a9 100644
--- a/tests/truncated_property.c
+++ b/tests/truncated_property.c
@@ -30,7 +30,7 @@
int main(int argc, char *argv[])
{
- void *fdt = &_truncated_property;
+ void *fdt = &truncated_property;
const void *prop;
int len;
diff --git a/tests/unit-addr-leading-0s.dts b/tests/unit-addr-leading-0s.dts
new file mode 100644
index 000000000000..cc017e9431a2
--- /dev/null
+++ b/tests/unit-addr-leading-0s.dts
@@ -0,0 +1,12 @@
+/dts-v1/;
+
+/ {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ bus {
+ node@001 {
+ reg = <1 0>;
+ };
+ };
+};
diff --git a/tests/unit-addr-leading-0x.dts b/tests/unit-addr-leading-0x.dts
new file mode 100644
index 000000000000..74f19678c98c
--- /dev/null
+++ b/tests/unit-addr-leading-0x.dts
@@ -0,0 +1,12 @@
+/dts-v1/;
+
+/ {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ bus {
+ node@0x1 {
+ reg = <1 0>;
+ };
+ };
+};
diff --git a/tests/value-labels.c b/tests/value-labels.c
index dcf20593d5c1..8aced74e28e7 100644
--- a/tests/value-labels.c
+++ b/tests/value-labels.c
@@ -36,13 +36,13 @@ struct val_label {
int propoff;
};
-struct val_label labels1[] = {
+static struct val_label labels1[] = {
{ "start1", 0 },
{ "mid1", 2 },
{ "end1", -1 },
};
-struct val_label labels2[] = {
+static struct val_label labels2[] = {
{ "start2", 0 },
{ "innerstart2", 0 },
{ "innermid2", 4 },
@@ -50,7 +50,7 @@ struct val_label labels2[] = {
{ "end2", -1 },
};
-struct val_label labels3[] = {
+static struct val_label labels3[] = {
{ "start3", 0 },
{ "innerstart3", 0 },
{ "innermid3", 1 },