aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRafal Jaworowski <raj@FreeBSD.org>2010-02-27 20:38:41 +0000
committerRafal Jaworowski <raj@FreeBSD.org>2010-02-27 20:38:41 +0000
commitb7b62f41399c6bc3ef3f9583dbc35cbd0a28101f (patch)
tree4a3082cc96b5344610019e2defaf32a043234c98 /tests
parentcb591ed2094735990f9316644c81ffd8534e7228 (diff)
downloadsrc-b7b62f41399c6bc3ef3f9583dbc35cbd0a28101f.tar.gz
src-b7b62f41399c6bc3ef3f9583dbc35cbd0a28101f.zip
Update DTC to git d75b33af676d0beac8398651a7f09037555a550b.vendor/dtc/dtc-d75b33af
Obtained from: git://git.jdl.com/software/dtc.git
Notes
Notes: svn path=/vendor/dtc/dist/; revision=204433 svn path=/vendor/dtc/dtc-d75b33af/; revision=204434; tag=vendor/dtc/dtc-d75b33af
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.tests25
-rw-r--r--tests/aliases.dts21
-rw-r--r--tests/asm_tree_dump.c62
-rw-r--r--tests/base01.dts24
-rw-r--r--tests/data.S3
-rw-r--r--tests/dtbs_equal_ordered.c4
-rw-r--r--tests/empty.dts2
-rw-r--r--tests/escapes.dts2
-rw-r--r--tests/extra-terminating-null.c59
-rw-r--r--tests/extra-terminating-null.dts11
-rw-r--r--tests/get_alias.c58
-rw-r--r--tests/get_name.c2
-rw-r--r--tests/get_path.c14
-rw-r--r--tests/get_phandle.c2
-rw-r--r--tests/incbin.c2
-rw-r--r--tests/include1.dts5
-rw-r--r--tests/include7.dts3
-rw-r--r--tests/label01.dts38
-rw-r--r--tests/mangle-layout.c6
-rw-r--r--tests/node_check_compatible.c3
-rw-r--r--tests/node_offset_by_compatible.c2
-rw-r--r--tests/node_offset_by_phandle.c2
-rw-r--r--tests/node_offset_by_prop_value.c7
-rw-r--r--tests/nopulate.c2
-rw-r--r--tests/notfound.c2
-rw-r--r--tests/parent_offset.c4
-rw-r--r--tests/path-references.c2
-rw-r--r--tests/path_offset.c2
-rw-r--r--tests/path_offset_aliases.c59
-rw-r--r--tests/phandle_format.c78
-rw-r--r--tests/references.c15
-rw-r--r--tests/references.dts13
-rw-r--r--tests/references_dts0.dts15
-rwxr-xr-xtests/run_tests.sh79
-rw-r--r--tests/rw_tree1.c18
-rw-r--r--tests/set_name.c2
-rw-r--r--tests/subnode_offset.c13
-rw-r--r--tests/supernode_atdepth_offset.c10
-rw-r--r--tests/sw_tree1.c7
-rw-r--r--tests/test01.dts38
-rw-r--r--tests/test_tree1.dts8
-rw-r--r--tests/test_tree1_dts0.dts24
-rw-r--r--tests/tests.h1
-rw-r--r--tests/trees.S13
-rw-r--r--tests/value-labels.c128
-rw-r--r--tests/value-labels.dts8
46 files changed, 750 insertions, 148 deletions
diff --git a/tests/Makefile.tests b/tests/Makefile.tests
index 704c95da8c59..ac21adee3da4 100644
--- a/tests/Makefile.tests
+++ b/tests/Makefile.tests
@@ -4,20 +4,26 @@ LIB_TESTS_L = get_mem_rsv \
get_path supernode_atdepth_offset parent_offset \
node_offset_by_prop_value node_offset_by_phandle \
node_check_compatible node_offset_by_compatible \
+ get_alias \
notfound \
setprop_inplace nop_property nop_node \
sw_tree1 \
move_and_save mangle-layout nopulate \
open_pack rw_tree1 set_name setprop del_property del_node \
- string_escapes references path-references boot-cpuid incbin \
+ string_escapes references path-references phandle_format \
+ boot-cpuid incbin \
+ extra-terminating-null \
dtbs_equal_ordered \
- add_subnode_with_nops
+ add_subnode_with_nops path_offset_aliases
LIB_TESTS = $(LIB_TESTS_L:%=$(TESTS_PREFIX)%)
LIBTREE_TESTS_L = truncated_property
LIBTREE_TESTS = $(LIBTREE_TESTS_L:%=$(TESTS_PREFIX)%)
-TESTS = $(LIB_TESTS) $(LIBTREE_TESTS)
+DL_LIB_TESTS_L = asm_tree_dump value-labels
+DL_LIB_TESTS = $(DL_LIB_TESTS_L:%=$(TESTS_PREFIX)%)
+
+TESTS = $(LIB_TESTS) $(LIBTREE_TESTS) $(DL_LIB_TESTS)
TESTS_TREES_L = test_tree1.dtb
TESTS_TREES = $(TESTS_TREES_L:%=$(TESTS_PREFIX)%)
@@ -28,16 +34,19 @@ TESTS_DEPFILES = $(TESTS:%=%.d) \
$(addprefix $(TESTS_PREFIX),testutils.d trees.d dumptrees.d)
TESTS_CLEANFILES_L = *.output vglog.* vgcore.* *.dtb *.test.dts *.dtsv1 tmp.*
-TESTS_CLEANFILES = $(TESTS_CLEANFILES_L:%=$(TESTS_PREFIX)%)
-
-BIN += $(TESTS) $(TESTS_PREFIX)dumptrees
+TESTS_CLEANFILES_L += dumptrees
+TESTS_CLEANFILES = $(TESTS) $(TESTS_CLEANFILES_L:%=$(TESTS_PREFIX)%)
.PHONY: tests
tests: $(TESTS) $(TESTS_TREES)
-$(LIB_TESTS): %: $(TESTS_PREFIX)testutils.o $(LIBFDT_lib)
+$(LIB_TESTS): %: $(TESTS_PREFIX)testutils.o $(LIBFDT_archive)
+
+$(DL_LIB_TESTS): %: %.o $(TESTS_PREFIX)testutils.o $(LIBFDT_archive)
+ @$(VECHO) LD [libdl] $@
+ $(LINK.c) -o $@ $^ -ldl
-$(LIBTREE_TESTS): %: $(TESTS_PREFIX)testutils.o $(TESTS_PREFIX)trees.o $(LIBFDT_lib)
+$(LIBTREE_TESTS): %: $(TESTS_PREFIX)testutils.o $(TESTS_PREFIX)trees.o $(LIBFDT_archive)
$(TESTS_PREFIX)dumptrees: $(TESTS_PREFIX)trees.o
diff --git a/tests/aliases.dts b/tests/aliases.dts
new file mode 100644
index 000000000000..39d88ffc8594
--- /dev/null
+++ b/tests/aliases.dts
@@ -0,0 +1,21 @@
+/dts-v1/;
+
+/ {
+ aliases {
+ s1 = &sub1;
+ ss1 = &subsub1;
+ sss1 = &subsubsub1;
+ };
+
+ sub1: subnode@1 {
+ compatible = "subnode1";
+
+ subsub1: subsubnode {
+ compatible = "subsubnode1", "subsubnode";
+
+ subsubsub1: subsubsubnode {
+ compatible = "subsubsubnode1", "subsubsubnode";
+ };
+ };
+ };
+};
diff --git a/tests/asm_tree_dump.c b/tests/asm_tree_dump.c
new file mode 100644
index 000000000000..5ff50872c8ef
--- /dev/null
+++ b/tests/asm_tree_dump.c
@@ -0,0 +1,62 @@
+/*
+ * libfdt - Flat Device Tree manipulation
+ * Tests if an asm tree built into a shared object matches a given dtb
+ * Copyright (C) 2008 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 <errno.h>
+
+#include <dlfcn.h>
+
+#include <fdt.h>
+#include <libfdt.h>
+
+#include "tests.h"
+#include "testdata.h"
+
+int main(int argc, char *argv[])
+{
+ void *sohandle;
+ void *fdt;
+ int err;
+
+ test_init(argc, argv);
+ if (argc != 3)
+ CONFIG("Usage: %s <so file> <dtb file>", argv[0]);
+
+ sohandle = dlopen(argv[1], RTLD_NOW);
+ if (!sohandle)
+ FAIL("Couldn't dlopen() %s", argv[1]);
+
+ fdt = dlsym(sohandle, "dt_blob_start");
+ if (!fdt)
+ FAIL("Couldn't locate \"dt_blob_start\" symbol in %s",
+ argv[1]);
+
+ err = fdt_check_header(fdt);
+ if (err != 0)
+ FAIL("%s contains invalid tree: %s", argv[1],
+ fdt_strerror(err));
+
+ save_blob(argv[2], fdt);
+
+ PASS();
+}
diff --git a/tests/base01.dts b/tests/base01.dts
index f84bc49620ca..97a5dd50b290 100644
--- a/tests/base01.dts
+++ b/tests/base01.dts
@@ -1,3 +1,5 @@
+/dts-v1/;
+
/ {
model = "SomeModel";
compatible = "Nothing";
@@ -6,26 +8,26 @@
memory@0 {
device_type = "memory";
- reg = <00000000 00000000 00000000 20000000>;
+ reg = <0x00000000 0x00000000 0x00000000 0x20000000>;
};
cpus {
#address-cells = <1>;
#size-cells = <0>;
- d10 = <d# 10>; // hex: 0xa
- d23 = <d# 23>; // hex: 0x17
- b101 = <b# 101>; // hex: 0x5
- o17 = <o# 17>; // hex: 0xf
- hd00d = <h# d00d>; // hex: 0xd00d
+ d10 = < 10>; // hex: 0xa
+ d23 = < 23>; // hex: 0x17
+ b101 = < 0x5>; // hex: 0x5
+ o17 = < 017>; // hex: 0xf
+ hd00d = < 0xd00d>; // hex: 0xd00d
// hex: 0x4d2 0x163e 0x2334 0xd80
- stuff = <d# 1234 d# 5678 d# 9012 d# 3456>;
+ stuff = < 1234 5678 9012 3456>;
- bad-d-1 = <d# abc123>; // Hrm. 0
- bad-d-2 = <d# 123456789012345>;
- bad-o-1 = <o# 891>;
- bad-o-2 = <o# 123456123456>;
+ bad-d-1 = < 0>; // Hrm. 0
+ bad-d-2 = < 123456789012345>;
+ bad-o-1 = < 00>;
+ bad-o-2 = < 0123456123456>;
};
};
diff --git a/tests/data.S b/tests/data.S
new file mode 100644
index 000000000000..86ad539f2a59
--- /dev/null
+++ b/tests/data.S
@@ -0,0 +1,3 @@
+/* Used in combination with dtc -Oasm output to embed
+ * a device tree in the data section of a .o */
+ .data
diff --git a/tests/dtbs_equal_ordered.c b/tests/dtbs_equal_ordered.c
index a0b42aecc7e0..ed9278c4f30a 100644
--- a/tests/dtbs_equal_ordered.c
+++ b/tests/dtbs_equal_ordered.c
@@ -29,7 +29,7 @@
#include "tests.h"
#include "testdata.h"
-void compare_mem_rsv(const void *fdt1, const void *fdt2)
+static void compare_mem_rsv(const void *fdt1, const void *fdt2)
{
int i;
uint64_t addr1, size1, addr2, size2;
@@ -56,7 +56,7 @@ void compare_mem_rsv(const void *fdt1, const void *fdt2)
}
}
-void compare_structure(const void *fdt1, const void *fdt2)
+static void compare_structure(const void *fdt1, const void *fdt2)
{
int nextoffset1 = 0, nextoffset2 = 0;
int offset1, offset2;
diff --git a/tests/empty.dts b/tests/empty.dts
index 336d7a250678..e160dad6a643 100644
--- a/tests/empty.dts
+++ b/tests/empty.dts
@@ -1,2 +1,4 @@
+/dts-v1/;
+
/ {
};
diff --git a/tests/escapes.dts b/tests/escapes.dts
index f1b8dbc8409f..e05ab46bcc91 100644
--- a/tests/escapes.dts
+++ b/tests/escapes.dts
@@ -1,3 +1,5 @@
+/dts-v1/;
+
/ {
compatible = "test_string_escapes";
escape-str = "nastystring: \a\b\t\n\v\f\r\\\"";
diff --git a/tests/extra-terminating-null.c b/tests/extra-terminating-null.c
new file mode 100644
index 000000000000..bb71b1ab34c7
--- /dev/null
+++ b/tests/extra-terminating-null.c
@@ -0,0 +1,59 @@
+/*
+ * libfdt - Flat Device Tree manipulation
+ * Testcase for properties with more than one terminating null
+ * Copyright (C) 2009 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 <fdt.h>
+#include <libfdt.h>
+
+#include "tests.h"
+#include "testdata.h"
+
+void check_extranull(void *fdt, const char *prop, const char *str, int numnulls)
+{
+ int len = strlen(str);
+ char checkbuf[len+numnulls];
+
+ memset(checkbuf, 0, sizeof(checkbuf));
+ memcpy(checkbuf, TEST_STRING_1, len);
+
+ check_getprop(fdt, 0, prop, len+numnulls, checkbuf);
+}
+
+int main(int argc, char *argv[])
+{
+ void *fdt;
+
+ test_init(argc, argv);
+
+ fdt = load_blob_arg(argc, argv);
+
+ check_extranull(fdt, "extranull0", TEST_STRING_1, 1);
+ check_extranull(fdt, "extranull1,1", TEST_STRING_1, 2);
+ check_extranull(fdt, "extranull1,2", TEST_STRING_1, 2);
+ check_extranull(fdt, "extranull2,1", TEST_STRING_1, 3);
+ check_extranull(fdt, "extranull2,2", TEST_STRING_1, 3);
+ check_extranull(fdt, "extranull2,3", TEST_STRING_1, 3);
+ check_extranull(fdt, "extranull2,4", TEST_STRING_1, 3);
+
+ PASS();
+}
diff --git a/tests/extra-terminating-null.dts b/tests/extra-terminating-null.dts
new file mode 100644
index 000000000000..b6cc19c1827d
--- /dev/null
+++ b/tests/extra-terminating-null.dts
@@ -0,0 +1,11 @@
+/dts-v1/;
+
+/ {
+ extranull0 = "hello world";
+ extranull1,1 = "hello world\0";
+ extranull1,2 = "hello world", "";
+ extranull2,1 = "hello world\0\0";
+ extranull2,2 = "hello world", "", "";
+ extranull2,3 = "hello world\0", "";
+ extranull2,4 = "hello world", "\0";
+};
diff --git a/tests/get_alias.c b/tests/get_alias.c
new file mode 100644
index 000000000000..8eeaee4a9bd2
--- /dev/null
+++ b/tests/get_alias.c
@@ -0,0 +1,58 @@
+/*
+ * libfdt - Flat Device Tree manipulation
+ * Testcase for fdt_get_alias()
+ * Copyright (C) 2006 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 <fdt.h>
+#include <libfdt.h>
+
+#include "tests.h"
+#include "testdata.h"
+
+void check_alias(void *fdt, const char *path, const char *alias)
+{
+ const char *aliaspath;
+
+ aliaspath = fdt_get_alias(fdt, alias);
+
+ if (path && !aliaspath)
+ FAIL("fdt_get_alias(%s) failed\n", alias);
+
+ if (strcmp(aliaspath, path) != 0)
+ FAIL("fdt_get_alias(%s) returned %s instead of %s\n",
+ alias, aliaspath, path);
+}
+
+int main(int argc, char *argv[])
+{
+ void *fdt;
+
+ test_init(argc, argv);
+ fdt = load_blob_arg(argc, argv);
+
+ check_alias(fdt, "/subnode@1", "s1");
+ check_alias(fdt, "/subnode@1/subsubnode", "ss1");
+ check_alias(fdt, "/subnode@1/subsubnode/subsubsubnode", "sss1");
+
+ PASS();
+}
diff --git a/tests/get_name.c b/tests/get_name.c
index 22003b4703ef..0262a120d1f3 100644
--- a/tests/get_name.c
+++ b/tests/get_name.c
@@ -28,7 +28,7 @@
#include "tests.h"
#include "testdata.h"
-void check_name(void *fdt, const char *path)
+static void check_name(void *fdt, const char *path)
{
int offset;
const char *getname, *getname2, *checkname;
diff --git a/tests/get_path.c b/tests/get_path.c
index 0d208bb020af..1e05f7c21163 100644
--- a/tests/get_path.c
+++ b/tests/get_path.c
@@ -30,7 +30,7 @@
#define POISON ('\xff')
-void check_path_buf(void *fdt, const char *path, int pathlen, int buflen)
+static void check_path_buf(void *fdt, const char *path, int pathlen, int buflen)
{
int offset;
char buf[buflen+1];
@@ -43,6 +43,8 @@ void check_path_buf(void *fdt, const char *path, int pathlen, int buflen)
memset(buf, POISON, sizeof(buf)); /* poison the buffer */
len = fdt_get_path(fdt, offset, buf, buflen);
+ verbose_printf("get_path() %s -> %d -> %s\n", path, offset, buf);
+
if (buflen <= pathlen) {
if (len != -FDT_ERR_NOSPACE)
FAIL("fdt_get_path([%d bytes]) returns %d with "
@@ -51,9 +53,9 @@ void check_path_buf(void *fdt, const char *path, int pathlen, int buflen)
if (len < 0)
FAIL("fdt_get_path([%d bytes]): %s", buflen,
fdt_strerror(len));
- if (len != pathlen)
- FAIL("fdt_get_path([%d bytes]) reports length %d "
- "instead of %d", buflen, len, pathlen);
+ if (len != 0)
+ FAIL("fdt_get_path([%d bytes]) returns %d "
+ "instead of 0", buflen, len);
if (strcmp(buf, path) != 0)
FAIL("fdt_get_path([%d bytes]) returns \"%s\" "
"instead of \"%s\"", buflen, buf, path);
@@ -63,13 +65,15 @@ void check_path_buf(void *fdt, const char *path, int pathlen, int buflen)
FAIL("fdt_get_path([%d bytes]) overran buffer", buflen);
}
-void check_path(void *fdt, const char *path)
+static void check_path(void *fdt, const char *path)
{
int pathlen = strlen(path);
check_path_buf(fdt, path, pathlen, 1024);
check_path_buf(fdt, path, pathlen, pathlen+1);
check_path_buf(fdt, path, pathlen, pathlen);
+ check_path_buf(fdt, path, pathlen, 0);
+ check_path_buf(fdt, path, pathlen, 2);
}
int main(int argc, char *argv[])
diff --git a/tests/get_phandle.c b/tests/get_phandle.c
index f7650b85b0f2..5735733fadbf 100644
--- a/tests/get_phandle.c
+++ b/tests/get_phandle.c
@@ -28,7 +28,7 @@
#include "tests.h"
#include "testdata.h"
-void check_phandle(void *fdt, const char *path, uint32_t checkhandle)
+static void check_phandle(void *fdt, const char *path, uint32_t checkhandle)
{
int offset;
uint32_t phandle;
diff --git a/tests/incbin.c b/tests/incbin.c
index 5ab35082e939..76d86262644c 100644
--- a/tests/incbin.c
+++ b/tests/incbin.c
@@ -31,7 +31,7 @@
#define CHUNKSIZE 1024
-char *load_file(const char *name, int *len)
+static char *load_file(const char *name, int *len)
{
FILE *f;
char *buf = NULL;
diff --git a/tests/include1.dts b/tests/include1.dts
index 0c7f42e03fab..5d59d8337555 100644
--- a/tests/include1.dts
+++ b/tests/include1.dts
@@ -15,9 +15,12 @@
prop-int = <123456789>;
/include/ "include8.dts"
- linux,phandle = <0x2001>;
+ phandle = <0x2001>;
compatible = "subsubnode2", "subsubnode";
prop-int = <0726746425>;
};
+
+ ss2 {
+ };
};
};
diff --git a/tests/include7.dts b/tests/include7.dts
index fa726f9c3b9e..dba5e470559a 100644
--- a/tests/include7.dts
+++ b/tests/include7.dts
@@ -6,4 +6,7 @@
compatible = "subsubnode1", "subsubnode";
prop-int = <0xdeadbeef>;
};
+
+ ss1 {
+ };
};
diff --git a/tests/label01.dts b/tests/label01.dts
index 372b17aa486d..a8958034f75e 100644
--- a/tests/label01.dts
+++ b/tests/label01.dts
@@ -1,6 +1,8 @@
-/memreserve/ 1000000000000000 0000000002000000;
-memrsv2: /memreserve/ 2000000000000000-20ffffffffffffff;
-/memreserve/ 0-13;
+/dts-v1/;
+
+/memreserve/ 0x1000000000000000 0x0000000002000000;
+memrsv2: /memreserve/ 0x2000000000000000 0x0100000000000000;
+/memreserve/ 0x0000000000000000 0x0000000000000014;
/ {
model = "MyBoardName";
@@ -9,28 +11,28 @@ memrsv2: /memreserve/ 2000000000000000-20ffffffffffffff;
#size-cells = <2>;
cpus {
- linux,phandle = <1>;
+ linux,phandle = <0x1>;
#address-cells = <1>;
#size-cells = <0>;
PowerPC,970@0 {
name = "PowerPC,970";
device_type = "cpu";
- reg = <0>;
- clock-frequency = <5f5e1000>;
- timebase-frequency = <1FCA055>;
+ reg = <0x00000000>;
+ clock-frequency = <1600000000>;
+ timebase-frequency = <33333333>;
linux,boot-cpu;
- i-cache-size = <10000>;
- d-cache-size = <8000>;
+ i-cache-size = <65536>;
+ d-cache-size = <32768>;
};
PowerPC,970@1 {
name = "PowerPC,970";
device_type = "cpu";
- reg = <1>;
- clock-frequency = <5f5e1000>;
- timebase-frequency = <1FCA055>;
- i-cache-size = <10000>;
- d-cache-size = <8000>;
+ reg = <0x00000001>;
+ clock-frequency = <1600000000>;
+ timebase-frequency = <33333333>;
+ i-cache-size = <65536>;
+ d-cache-size = <32768>;
};
};
@@ -38,8 +40,8 @@ memrsv2: /memreserve/ 2000000000000000-20ffffffffffffff;
node: randomnode {
prop: string = str: "foo", str_mid: "stuffstuff\t\t\t\n\n\n" str_end: ;
blob = [byte: 0a 0b 0c 0d byte_mid: de ea ad be ef byte_end: ];
- ref = < cell: &/memory@0 0 cell_mid: ffffffff cell_end: >;
- mixed = "abc", pre: [1234] post: , gap: < aligned: a b c>;
+ ref = < cell: &{/memory@0} 0x0 cell_mid: 0xffffffff cell_end: >;
+ mixed = "abc", pre: [1234] post: , gap: < aligned: 0xa 0xb 0xc>;
tricky1 = [61 lt1: 62 63 00];
subnode: child {
};
@@ -49,12 +51,12 @@ memrsv2: /memreserve/ 2000000000000000-20ffffffffffffff;
memory@0 {
device_type = "memory";
- memreg: reg = <00000000 00000000 00000000 20000000>;
+ memreg: reg = <0x00000000 0x00000000 0x00000000 0x20000000>;
};
chosen {
bootargs = "root=/dev/sda2";
- linux,platform = <00000600>;
+ linux,platform = <0x600>;
};
};
diff --git a/tests/mangle-layout.c b/tests/mangle-layout.c
index bd6ac406943c..5be28b9af999 100644
--- a/tests/mangle-layout.c
+++ b/tests/mangle-layout.c
@@ -35,7 +35,7 @@ struct bufstate {
int size;
};
-void expand_buf(struct bufstate *buf, int newsize)
+static void expand_buf(struct bufstate *buf, int newsize)
{
buf->buf = realloc(buf->buf, newsize);
if (!buf->buf)
@@ -43,7 +43,7 @@ void expand_buf(struct bufstate *buf, int newsize)
buf->size = newsize;
}
-void new_header(struct bufstate *buf, int version, const void *fdt)
+static void new_header(struct bufstate *buf, int version, const void *fdt)
{
int hdrsize;
@@ -63,7 +63,7 @@ void new_header(struct bufstate *buf, int version, const void *fdt)
fdt_set_boot_cpuid_phys(buf->buf, fdt_boot_cpuid_phys(fdt));
}
-void add_block(struct bufstate *buf, int version, char block, const void *fdt)
+static void add_block(struct bufstate *buf, int version, char block, const void *fdt)
{
int align, size;
const void *src;
diff --git a/tests/node_check_compatible.c b/tests/node_check_compatible.c
index 04b6b4083769..23abbf529d9e 100644
--- a/tests/node_check_compatible.c
+++ b/tests/node_check_compatible.c
@@ -29,7 +29,8 @@
#include "tests.h"
#include "testdata.h"
-void check_compatible(const void *fdt, const char *path, const char *compat)
+static void check_compatible(const void *fdt, const char *path,
+ const char *compat)
{
int offset, err;
diff --git a/tests/node_offset_by_compatible.c b/tests/node_offset_by_compatible.c
index 02e9874bb7be..23179300f012 100644
--- a/tests/node_offset_by_compatible.c
+++ b/tests/node_offset_by_compatible.c
@@ -29,7 +29,7 @@
#include "tests.h"
#include "testdata.h"
-void check_search(void *fdt, const char *compat, ...)
+static void check_search(void *fdt, const char *compat, ...)
{
va_list ap;
int offset = -1, target;
diff --git a/tests/node_offset_by_phandle.c b/tests/node_offset_by_phandle.c
index e9fd9392d806..a8442f15a6b0 100644
--- a/tests/node_offset_by_phandle.c
+++ b/tests/node_offset_by_phandle.c
@@ -29,7 +29,7 @@
#include "tests.h"
#include "testdata.h"
-void check_search(void *fdt, uint32_t phandle, int target)
+static void check_search(void *fdt, uint32_t phandle, int target)
{
int offset;
diff --git a/tests/node_offset_by_prop_value.c b/tests/node_offset_by_prop_value.c
index c55110a1be01..0f2a34512ae2 100644
--- a/tests/node_offset_by_prop_value.c
+++ b/tests/node_offset_by_prop_value.c
@@ -29,7 +29,7 @@
#include "tests.h"
#include "testdata.h"
-void vcheck_search(void *fdt, const char *propname, const void *propval,
+static void vcheck_search(void *fdt, const char *propname, const void *propval,
int proplen, va_list ap)
{
int offset = -1, target;
@@ -48,7 +48,7 @@ void vcheck_search(void *fdt, const char *propname, const void *propval,
} while (target >= 0);
}
-void check_search(void *fdt, const char *propname, const void *propval,
+static void check_search(void *fdt, const char *propname, const void *propval,
int proplen, ...)
{
va_list ap;
@@ -58,7 +58,8 @@ void check_search(void *fdt, const char *propname, const void *propval,
va_end(ap);
}
-void check_search_str(void *fdt, const char *propname, const char *propval, ...)
+static void check_search_str(void *fdt, const char *propname,
+ const char *propval, ...)
{
va_list ap;
diff --git a/tests/nopulate.c b/tests/nopulate.c
index e56839a2a69f..3cbbe2113c79 100644
--- a/tests/nopulate.c
+++ b/tests/nopulate.c
@@ -30,7 +30,7 @@
#include "tests.h"
#include "testdata.h"
-int nopulate_struct(char *buf, const char *fdt)
+static int nopulate_struct(char *buf, const char *fdt)
{
int offset, nextoffset = 0;
uint32_t tag;
diff --git a/tests/notfound.c b/tests/notfound.c
index ae28c44d2efc..38918ad2d463 100644
--- a/tests/notfound.c
+++ b/tests/notfound.c
@@ -28,7 +28,7 @@
#include "tests.h"
#include "testdata.h"
-void check_error(const char *s, int err)
+static void check_error(const char *s, int err)
{
if (err != -FDT_ERR_NOTFOUND)
FAIL("%s return error %s instead of -FDT_ERR_NOTFOUND", s,
diff --git a/tests/parent_offset.c b/tests/parent_offset.c
index 8336c72f1276..e7affcc39afc 100644
--- a/tests/parent_offset.c
+++ b/tests/parent_offset.c
@@ -28,7 +28,7 @@
#include "tests.h"
#include "testdata.h"
-int path_parent_len(const char *path)
+static int path_parent_len(const char *path)
{
const char *p = strrchr(path, '/');
@@ -40,7 +40,7 @@ int path_parent_len(const char *path)
return p - path;
}
-void check_path(struct fdt_header *fdt, const char *path)
+static void check_path(struct fdt_header *fdt, const char *path)
{
char *parentpath;
int nodeoffset, parentoffset, parentpathoffset, pathparentlen;
diff --git a/tests/path-references.c b/tests/path-references.c
index b96c5b2f496a..9f363b3af3cb 100644
--- a/tests/path-references.c
+++ b/tests/path-references.c
@@ -28,7 +28,7 @@
#include "tests.h"
#include "testdata.h"
-void check_ref(const void *fdt, int node, const char *checkpath)
+static void check_ref(const void *fdt, int node, const char *checkpath)
{
const char *p;
int len;
diff --git a/tests/path_offset.c b/tests/path_offset.c
index 4b014ac194e0..bb092f114cab 100644
--- a/tests/path_offset.c
+++ b/tests/path_offset.c
@@ -28,7 +28,7 @@
#include "tests.h"
#include "testdata.h"
-int check_subnode(void *fdt, int parent, const char *name)
+static int check_subnode(void *fdt, int parent, const char *name)
{
int offset;
const struct fdt_node_header *nh;
diff --git a/tests/path_offset_aliases.c b/tests/path_offset_aliases.c
new file mode 100644
index 000000000000..191edd2b8113
--- /dev/null
+++ b/tests/path_offset_aliases.c
@@ -0,0 +1,59 @@
+/*
+ * libfdt - Flat Device Tree manipulation
+ * Testcase for fdt_path_offset()
+ * Copyright (C) 2006 David Gibson, IBM Corporation.
+ * Copyright 2008 Kumar Gala, Freescale Semiconductor, Inc.
+ *
+ * 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 <fdt.h>
+#include <libfdt.h>
+
+#include "tests.h"
+#include "testdata.h"
+
+void check_alias(void *fdt, const char *full_path, const char *alias_path)
+{
+ int offset, offset_a;
+
+ offset = fdt_path_offset(fdt, full_path);
+ offset_a = fdt_path_offset(fdt, alias_path);
+
+ if (offset != offset_a)
+ FAIL("Mismatch between %s path_offset (%d) and %s path_offset alias (%d)",
+ full_path, offset, alias_path, offset_a);
+}
+
+int main(int argc, char *argv[])
+{
+ void *fdt;
+
+ test_init(argc, argv);
+ fdt = load_blob_arg(argc, argv);
+
+ check_alias(fdt, "/subnode@1", "s1");
+ check_alias(fdt, "/subnode@1/subsubnode", "ss1");
+ check_alias(fdt, "/subnode@1/subsubnode", "s1/subsubnode");
+ check_alias(fdt, "/subnode@1/subsubnode/subsubsubnode", "sss1");
+ check_alias(fdt, "/subnode@1/subsubnode/subsubsubnode", "ss1/subsubsubnode");
+ check_alias(fdt, "/subnode@1/subsubnode/subsubsubnode", "s1/subsubnode/subsubsubnode");
+
+ PASS();
+}
diff --git a/tests/phandle_format.c b/tests/phandle_format.c
new file mode 100644
index 000000000000..7e4d81630e08
--- /dev/null
+++ b/tests/phandle_format.c
@@ -0,0 +1,78 @@
+/*
+ * libfdt - Flat Device Tree manipulation
+ * Testcase for phandle format options
+ * Copyright (C) 2009 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 <fdt.h>
+#include <libfdt.h>
+
+#include "tests.h"
+#include "testdata.h"
+
+#define PHANDLE_LEGACY 0x1
+#define PHANDLE_EPAPR 0x2
+#define PHANDLE_BOTH 0x3
+
+int main(int argc, char *argv[])
+{
+ void *fdt;
+ int phandle_format;
+ int n4;
+ uint32_t h4;
+
+ if (argc != 3)
+ CONFIG("Usage: %s <dtb file> <legacy|epapr|both>\n", argv[0]);
+
+ test_init(argc, argv);
+ fdt = load_blob(argv[1]);
+
+ if (streq(argv[2], "legacy"))
+ phandle_format = PHANDLE_LEGACY;
+ else if (streq(argv[2], "epapr"))
+ phandle_format = PHANDLE_EPAPR;
+ else if (streq(argv[2], "both"))
+ phandle_format = PHANDLE_BOTH;
+ else
+ CONFIG("Usage: %s <dtb file> <legacy|epapr|both>\n", argv[0]);
+
+ n4 = fdt_path_offset(fdt, "/node4");
+ if (n4 < 0)
+ FAIL("fdt_path_offset(/node4): %s", fdt_strerror(n4));
+
+ h4 = fdt_get_phandle(fdt, n4);
+ if ((h4 == 0) || (h4 == -1))
+ FAIL("/node4 has bad phandle 0x%x\n", h4);
+
+ if (phandle_format & PHANDLE_LEGACY)
+ check_getprop_cell(fdt, n4, "linux,phandle", h4);
+ else
+ if (fdt_getprop(fdt, n4, "linux,phandle", NULL))
+ FAIL("linux,phandle property present in non-legacy mode");
+
+ if (phandle_format & PHANDLE_EPAPR)
+ check_getprop_cell(fdt, n4, "phandle", h4);
+ else
+ if (fdt_getprop(fdt, n4, "phandle", NULL))
+ FAIL("phandle property present in legacy-only mode");
+
+ PASS();
+}
diff --git a/tests/references.c b/tests/references.c
index e98d450d4a53..b20f21fdeca0 100644
--- a/tests/references.c
+++ b/tests/references.c
@@ -28,7 +28,7 @@
#include "tests.h"
#include "testdata.h"
-void check_ref(const void *fdt, int node, uint32_t checkref)
+static void check_ref(const void *fdt, int node, uint32_t checkref)
{
const uint32_t *p;
uint32_t ref;
@@ -60,8 +60,8 @@ void check_ref(const void *fdt, int node, uint32_t checkref)
int main(int argc, char *argv[])
{
void *fdt;
- int n1, n2, n3, n4;
- uint32_t h1, h2, h4;
+ int n1, n2, n3, n4, n5;
+ uint32_t h1, h2, h4, h5;
test_init(argc, argv);
fdt = load_blob_arg(argc, argv);
@@ -78,10 +78,14 @@ int main(int argc, char *argv[])
n4 = fdt_path_offset(fdt, "/node4");
if (n4 < 0)
FAIL("fdt_path_offset(/node4): %s", fdt_strerror(n4));
+ n5 = fdt_path_offset(fdt, "/node5");
+ if (n5 < 0)
+ FAIL("fdt_path_offset(/node5): %s", fdt_strerror(n5));
h1 = fdt_get_phandle(fdt, n1);
h2 = fdt_get_phandle(fdt, n2);
h4 = fdt_get_phandle(fdt, n4);
+ h5 = fdt_get_phandle(fdt, n5);
if (h1 != 0x2000)
FAIL("/node1 has wrong phandle, 0x%x instead of 0x%x",
@@ -92,6 +96,11 @@ int main(int argc, char *argv[])
if ((h4 == 0x2000) || (h4 == 0x1) || (h4 == 0))
FAIL("/node4 has bad phandle, 0x%x", h4);
+ if ((h5 == 0) || (h5 == -1))
+ FAIL("/node5 has bad phandle, 0x%x", h5);
+ if ((h5 == h4) || (h5 == h2) || (h5 == h1))
+ FAIL("/node5 has duplicate phandle, 0x%x", h5);
+
check_ref(fdt, n1, h2);
check_ref(fdt, n2, h1);
check_ref(fdt, n3, h4);
diff --git a/tests/references.dts b/tests/references.dts
index 36b6f51d7763..640c9315911c 100644
--- a/tests/references.dts
+++ b/tests/references.dts
@@ -8,7 +8,7 @@
lref = <&n2>;
};
n2: node2 {
- linux,phandle = <0x1>;
+ phandle = <0x1>;
ref = <&{/node1}>; /* reference after target */
lref = <&n1>;
};
@@ -20,4 +20,15 @@
};
n4: node4 {
};
+
+ /* Explicit phandle with implicit value */
+ /* This self-reference is the standard way to tag a node as requiring
+ * a phandle (perhaps for reference by nodes that will be dynamically
+ * added) without explicitly allocating it a phandle.
+ * The self-reference requires some special internal handling, though
+ * so check it actually works */
+ n5: node5 {
+ linux,phandle = <&n5>;
+ phandle = <&n5>;
+ };
};
diff --git a/tests/references_dts0.dts b/tests/references_dts0.dts
index df82c23465f3..d34dbb2913fd 100644
--- a/tests/references_dts0.dts
+++ b/tests/references_dts0.dts
@@ -1,21 +1,26 @@
+/dts-v1/;
+
/ {
/* Explicit phandles */
n1: node1 {
- linux,phandle = <2000>;
- ref = <&/node2>; /* reference precedes target */
+ linux,phandle = <0x2000>;
+ ref = <&{/node2}>; /* reference precedes target */
lref = <&n2>;
};
n2: node2 {
- linux,phandle = <1>;
- ref = <&/node1>; /* reference after target */
+ linux,phandle = <0x1>;
+ ref = <&{/node1}>; /* reference after target */
lref = <&n1>;
};
/* Implicit phandles */
n3: node3 {
- ref = <&/node4>;
+ ref = <&{/node4}>;
lref = <&n4>;
};
n4: node4 {
};
+ n5: node5 {
+ linux,phandle = <&n5>;
+ };
};
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index 7bfc399e5637..c532030f109b 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -2,6 +2,10 @@
. ./tests.sh
+if [ -z "$CC" ]; then
+ CC=gcc
+fi
+
export QUIET_TEST=1
export VALGRIND=
@@ -71,11 +75,12 @@ run_dtc_test () {
base_run_test wrap_test $VALGRIND $DTC "$@"
}
-CONVERT=../convert-dtsv0
+asm_to_so () {
+ $CC -shared -o $1.test.so data.S $1.test.s
+}
-run_convert_test () {
- echo -n "convert-dtsv0 $@: "
- base_run_test wrap_test $VALGRIND $CONVERT "$@"
+asm_to_so_test () {
+ run_wrap_test asm_to_so "$@"
}
tree1_tests () {
@@ -201,6 +206,9 @@ dtc_tests () {
run_dtc_test -I dts -O dtb -o dtc_escapes.test.dtb escapes.dts
run_test string_escapes dtc_escapes.test.dtb
+ run_dtc_test -I dts -O dtb -o dtc_extra-terminating-null.test.dtb extra-terminating-null.dts
+ run_test extra-terminating-null dtc_extra-terminating-null.test.dtb
+
run_dtc_test -I dts -O dtb -o dtc_references.test.dtb references.dts
run_test references dtc_references.test.dtb
@@ -210,10 +218,21 @@ 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
+ 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
+ done
+
run_dtc_test -I dts -O dtb -o dtc_comments.test.dtb comments.dts
run_dtc_test -I dts -O dtb -o dtc_comments-cmp.test.dtb comments-cmp.dts
run_test dtbs_equal_ordered dtc_comments.test.dtb dtc_comments-cmp.test.dtb
+ # Check aliases support in fdt_path_offset
+ run_dtc_test -I dts -O dtb -o aliases.dtb aliases.dts
+ run_test get_alias aliases.dtb
+ run_test path_offset_aliases aliases.dtb
+
# Check /include/ directive
run_dtc_test -I dts -O dtb -o includes.test.dtb include0.dts
run_test dtbs_equal_ordered includes.test.dtb test_tree1.dtb
@@ -230,8 +249,22 @@ dtc_tests () {
run_dtc_test -I dtb -O dtb -o boot_cpuid_preserved_test_tree1.test.dtb boot_cpuid_test_tree1.test.dtb
run_test dtbs_equal_ordered boot_cpuid_preserved_test_tree1.test.dtb boot_cpuid_test_tree1.test.dtb
+ # Check -Oasm mode
+ for tree in test_tree1.dts escapes.dts references.dts path-references.dts \
+ comments.dts aliases.dts include0.dts incbin.dts \
+ value-labels.dts ; do
+ run_dtc_test -I dts -O asm -o oasm_$tree.test.s $tree
+ asm_to_so_test oasm_$tree
+ run_dtc_test -I dts -O dtb -o $tree.test.dtb $tree
+ run_test asm_tree_dump ./oasm_$tree.test.so oasm_$tree.test.dtb
+ run_wrap_test cmp oasm_$tree.test.dtb $tree.test.dtb
+ done
+
+ run_test value-labels ./oasm_value-labels.dts.test.so
+
# Check -Odts mode preserve all dtb information
- for tree in test_tree1.dtb dtc_tree1.test.dtb dtc_escapes.test.dtb ; do
+ for tree in test_tree1.dtb dtc_tree1.test.dtb dtc_escapes.test.dtb \
+ dtc_extra-terminating-null.test.dtb dtc_references.test.dtb; do
run_dtc_test -I dtb -O dts -o odts_$tree.test.dts $tree
run_dtc_test -I dts -O dtb -o odts_$tree.test.dtb odts_$tree.test.dts
run_test dtbs_equal_ordered $tree odts_$tree.test.dtb
@@ -283,21 +316,6 @@ dtc_tests () {
run_sh_test dtc-fatal.sh -I fs -O dtb nosuchfile
}
-convert_tests () {
- V0_DTS="test_tree1_dts0.dts references_dts0.dts empty.dts escapes.dts \
- test01.dts label01.dts"
- for dts in $V0_DTS; do
- run_dtc_test -I dts -O dtb -o cvtraw_$dts.test.dtb $dts
- run_dtc_test -I dts -O dts -o cvtdtc_$dts.test.dts $dts
- run_dtc_test -I dts -O dtb -o cvtdtc_$dts.test.dtb cvtdtc_$dts.test.dts
- run_convert_test $dts
- run_dtc_test -I dts -O dtb -o cvtcvt_$dts.test.dtb ${dts}v1
-
- run_wrap_test cmp cvtraw_$dts.test.dtb cvtdtc_$dts.test.dtb
- run_wrap_test cmp cvtraw_$dts.test.dtb cvtcvt_$dts.test.dtb
- done
-}
-
while getopts "vt:m" ARG ; do
case $ARG in
"v")
@@ -313,7 +331,7 @@ while getopts "vt:m" ARG ; do
done
if [ -z "$TESTSETS" ]; then
- TESTSETS="libfdt dtc convert"
+ TESTSETS="libfdt dtc"
fi
# Make sure we don't have stale blobs lying around
@@ -327,20 +345,17 @@ for set in $TESTSETS; do
"dtc")
dtc_tests
;;
- "convert")
- convert_tests
- ;;
esac
done
-echo -e "********** TEST SUMMARY"
-echo -e "* Total testcases: $tot_tests"
-echo -e "* PASS: $tot_pass"
-echo -e "* FAIL: $tot_fail"
-echo -e "* Bad configuration: $tot_config"
+echo "********** TEST SUMMARY"
+echo "* Total testcases: $tot_tests"
+echo "* PASS: $tot_pass"
+echo "* FAIL: $tot_fail"
+echo "* Bad configuration: $tot_config"
if [ -n "$VALGRIND" ]; then
- echo -e "* valgrind errors: $tot_vg"
+ echo "* valgrind errors: $tot_vg"
fi
-echo -e "* Strange test result: $tot_strange"
-echo -e "**********"
+echo "* Strange test result: $tot_strange"
+echo "**********"
diff --git a/tests/rw_tree1.c b/tests/rw_tree1.c
index 8f335c96a188..f0bce88bda0b 100644
--- a/tests/rw_tree1.c
+++ b/tests/rw_tree1.c
@@ -50,7 +50,7 @@ int main(int argc, char *argv[])
{
void *fdt;
int err;
- int offset;
+ int offset, s1, s2;
test_init(argc, argv);
@@ -77,21 +77,25 @@ int main(int argc, char *argv[])
CHECK(fdt_setprop_string(fdt, 0, "prop-str", TEST_STRING_1));
OFF_CHECK(offset, fdt_add_subnode(fdt, 0, "subnode@1"));
- CHECK(fdt_setprop_string(fdt, offset, "compatible", "subnode1"));
- CHECK(fdt_setprop_cell(fdt, offset, "prop-int", TEST_VALUE_1));
- OFF_CHECK(offset, fdt_add_subnode(fdt, offset, "subsubnode"));
+ s1 = offset;
+ CHECK(fdt_setprop_string(fdt, s1, "compatible", "subnode1"));
+ CHECK(fdt_setprop_cell(fdt, s1, "prop-int", TEST_VALUE_1));
+ OFF_CHECK(offset, fdt_add_subnode(fdt, s1, "subsubnode"));
CHECK(fdt_setprop(fdt, offset, "compatible",
"subsubnode1\0subsubnode", 23));
CHECK(fdt_setprop_cell(fdt, offset, "prop-int", TEST_VALUE_1));
+ OFF_CHECK(offset, fdt_add_subnode(fdt, s1, "ss1"));
OFF_CHECK(offset, fdt_add_subnode(fdt, 0, "subnode@2"));
- CHECK(fdt_setprop_cell(fdt, offset, "linux,phandle", PHANDLE_1));
- CHECK(fdt_setprop_cell(fdt, offset, "prop-int", TEST_VALUE_2));
- OFF_CHECK(offset, fdt_add_subnode(fdt, offset, "subsubnode@0"));
+ s2 = offset;
+ CHECK(fdt_setprop_cell(fdt, s2, "linux,phandle", PHANDLE_1));
+ CHECK(fdt_setprop_cell(fdt, s2, "prop-int", TEST_VALUE_2));
+ OFF_CHECK(offset, fdt_add_subnode(fdt, s2, "subsubnode@0"));
CHECK(fdt_setprop_cell(fdt, offset, "linux,phandle", PHANDLE_2));
CHECK(fdt_setprop(fdt, offset, "compatible",
"subsubnode2\0subsubnode", 23));
CHECK(fdt_setprop_cell(fdt, offset, "prop-int", TEST_VALUE_2));
+ OFF_CHECK(offset, fdt_add_subnode(fdt, s2, "ss2"));
CHECK(fdt_pack(fdt));
diff --git a/tests/set_name.c b/tests/set_name.c
index 49817a9ed981..5d1149e002cd 100644
--- a/tests/set_name.c
+++ b/tests/set_name.c
@@ -28,7 +28,7 @@
#include "tests.h"
#include "testdata.h"
-void check_set_name(void *fdt, const char *path, const char *newname)
+static void check_set_name(void *fdt, const char *path, const char *newname)
{
int offset;
const char *getname, *oldname;
diff --git a/tests/subnode_offset.c b/tests/subnode_offset.c
index ac2f32e18a3b..b961070905d6 100644
--- a/tests/subnode_offset.c
+++ b/tests/subnode_offset.c
@@ -28,7 +28,7 @@
#include "tests.h"
#include "testdata.h"
-int check_subnode(struct fdt_header *fdt, int parent, const char *name)
+static int check_subnode(struct fdt_header *fdt, int parent, const char *name)
{
int offset;
const struct fdt_node_header *nh;
@@ -60,6 +60,7 @@ int main(int argc, char *argv[])
void *fdt;
int subnode1_offset, subnode2_offset;
int subsubnode1_offset, subsubnode2_offset, subsubnode2_offset2;
+ int ss11_off, ss12_off, ss21_off, ss22_off;
test_init(argc, argv);
fdt = load_blob_arg(argc, argv);
@@ -84,5 +85,15 @@ int main(int argc, char *argv[])
if (subsubnode2_offset != subsubnode2_offset2)
FAIL("Different offsets with and without unit address");
+ ss11_off = check_subnode(fdt, subnode1_offset, "ss1");
+ ss21_off = fdt_subnode_offset(fdt, subnode2_offset, "ss1");
+ if (ss21_off != -FDT_ERR_NOTFOUND)
+ FAIL("Incorrectly found ss1 in subnode2");
+
+ ss12_off = fdt_subnode_offset(fdt, subnode1_offset, "ss2");
+ if (ss12_off != -FDT_ERR_NOTFOUND)
+ FAIL("Incorrectly found ss2 in subnode1");
+ ss22_off = check_subnode(fdt, subnode2_offset, "ss2");
+
PASS();
}
diff --git a/tests/supernode_atdepth_offset.c b/tests/supernode_atdepth_offset.c
index 1245813d267a..73f41aecf93c 100644
--- a/tests/supernode_atdepth_offset.c
+++ b/tests/supernode_atdepth_offset.c
@@ -28,7 +28,7 @@
#include "tests.h"
#include "testdata.h"
-int path_depth(const char *path)
+static int path_depth(const char *path)
{
const char *p;
int depth = 0;
@@ -49,7 +49,7 @@ int path_depth(const char *path)
return depth;
}
-int path_prefix(const char *path, int depth)
+static int path_prefix(const char *path, int depth)
{
const char *p;
int i;
@@ -67,7 +67,7 @@ int path_prefix(const char *path, int depth)
return p - path;
}
-void check_supernode_atdepth(struct fdt_header *fdt, const char *path,
+static void check_supernode_atdepth(struct fdt_header *fdt, const char *path,
int depth)
{
int pdepth = path_depth(path);
@@ -106,7 +106,7 @@ void check_supernode_atdepth(struct fdt_header *fdt, const char *path,
"instead of %d", nodedepth, pdepth);
}
-void check_supernode_overdepth(struct fdt_header *fdt, const char *path)
+static void check_supernode_overdepth(struct fdt_header *fdt, const char *path)
{
int pdepth = path_depth(path);
int nodeoffset, err;
@@ -121,7 +121,7 @@ void check_supernode_overdepth(struct fdt_header *fdt, const char *path)
"of FDT_ERR_NOTFOUND", path, pdepth+1, err);
}
-void check_path(struct fdt_header *fdt, const char *path)
+static void check_path(struct fdt_header *fdt, const char *path)
{
int i;
diff --git a/tests/sw_tree1.c b/tests/sw_tree1.c
index 2a94b63985a8..f2c430ab38ca 100644
--- a/tests/sw_tree1.c
+++ b/tests/sw_tree1.c
@@ -66,17 +66,22 @@ int main(int argc, char *argv[])
23));
CHECK(fdt_property_cell(fdt, "prop-int", TEST_VALUE_1));
CHECK(fdt_end_node(fdt));
+ CHECK(fdt_begin_node(fdt, "ss1"));
+ CHECK(fdt_end_node(fdt));
CHECK(fdt_end_node(fdt));
CHECK(fdt_begin_node(fdt, "subnode@2"));
CHECK(fdt_property_cell(fdt, "linux,phandle", PHANDLE_1));
CHECK(fdt_property_cell(fdt, "prop-int", TEST_VALUE_2));
CHECK(fdt_begin_node(fdt, "subsubnode@0"));
- CHECK(fdt_property_cell(fdt, "linux,phandle", PHANDLE_2));
+ CHECK(fdt_property_cell(fdt, "phandle", PHANDLE_2));
CHECK(fdt_property(fdt, "compatible", "subsubnode2\0subsubnode",
23));
CHECK(fdt_property_cell(fdt, "prop-int", TEST_VALUE_2));
CHECK(fdt_end_node(fdt));
+ CHECK(fdt_begin_node(fdt, "ss2"));
+ CHECK(fdt_end_node(fdt));
+
CHECK(fdt_end_node(fdt));
CHECK(fdt_end_node(fdt));
diff --git a/tests/test01.dts b/tests/test01.dts
index ed2b178e1845..f9fd165340f9 100644
--- a/tests/test01.dts
+++ b/tests/test01.dts
@@ -1,6 +1,8 @@
-/memreserve/ 1000000000000000 0000000002000000;
-/memreserve/ 2000000000000000-20ffffffffffffff;
-/memreserve/ 0-13;
+/dts-v1/;
+
+/memreserve/ 0x1000000000000000 0x0000000002000000;
+/memreserve/ 0x2000000000000000 0x0100000000000000;
+/memreserve/ 0x0000000000000000 0x0000000000000014;
/ {
model = "MyBoardName";
@@ -9,28 +11,28 @@
#size-cells = <2>;
cpus {
- linux,phandle = <1>;
+ linux,phandle = <0x1>;
#address-cells = <1>;
#size-cells = <0>;
PowerPC,970@0 {
name = "PowerPC,970";
device_type = "cpu";
- reg = <0>;
- clock-frequency = <5f5e1000>;
- timebase-frequency = <1FCA055>;
+ reg = <0x00000000>;
+ clock-frequency = <1600000000>;
+ timebase-frequency = <33333333>;
linux,boot-cpu;
- i-cache-size = <10000>;
- d-cache-size = <8000>;
+ i-cache-size = <65536>;
+ d-cache-size = <32768>;
};
PowerPC,970@1 {
name = "PowerPC,970";
device_type = "cpu";
- reg = <1>;
- clock-frequency = <5f5e1000>;
- timebase-frequency = <1FCA055>;
- i-cache-size = <10000>;
- d-cache-size = <8000>;
+ reg = <0x00000001>;
+ clock-frequency = <1600000000>;
+ timebase-frequency = <33333333>;
+ i-cache-size = <65536>;
+ d-cache-size = <32768>;
};
};
@@ -38,18 +40,18 @@
randomnode {
string = "\xff\0stuffstuff\t\t\t\n\n\n";
blob = [0a 0b 0c 0d de ea ad be ef];
- ref = < &/memory@0 >;
- mixed = "abc", [1234], <a b c>;
+ ref = < &{/memory@0} >;
+ mixed = "abc", [1234], <0xa 0xb 0xc>;
};
memory@0 {
device_type = "memory";
- memreg: reg = <00000000 00000000 00000000 20000000>;
+ memreg: reg = <0x00000000 0x00000000 0x00000000 0x20000000>;
};
chosen {
bootargs = "root=/dev/sda2";
- linux,platform = <00000600>;
+ linux,platform = <0x600>;
};
};
diff --git a/tests/test_tree1.dts b/tests/test_tree1.dts
index 27602af45bf3..218c38206314 100644
--- a/tests/test_tree1.dts
+++ b/tests/test_tree1.dts
@@ -16,6 +16,9 @@
compatible = "subsubnode1", "subsubnode";
prop-int = <0xdeadbeef>;
};
+
+ ss1 {
+ };
};
subnode@2 {
@@ -23,9 +26,12 @@
prop-int = <123456789>;
subsubnode@0 {
- linux,phandle = <0x2001>;
+ phandle = <0x2001>;
compatible = "subsubnode2", "subsubnode";
prop-int = <0726746425>;
};
+
+ ss2 {
+ };
};
};
diff --git a/tests/test_tree1_dts0.dts b/tests/test_tree1_dts0.dts
index bc65819033fc..032d540abc08 100644
--- a/tests/test_tree1_dts0.dts
+++ b/tests/test_tree1_dts0.dts
@@ -1,9 +1,11 @@
-/memreserve/ deadbeef00000000-deadbeef000fffff;
-/memreserve/ 75bcd15 1000;
+/dts-v1/;
+
+/memreserve/ 0xdeadbeef00000000 0x0000000000100000;
+/memreserve/ 0x00000000075bcd15 0x0000000000001000;
/ {
compatible = "test_tree1";
- prop-int = <deadbeef>;
+ prop-int = <0xdeadbeef>;
prop-str = "hello world";
subnode@1 {
@@ -12,18 +14,24 @@
subsubnode {
compatible = "subsubnode1", "subsubnode";
- prop-int = <h# deadbeef>;
+ prop-int = < 0xdeadbeef>;
+ };
+
+ ss1 {
};
};
subnode@2 {
- linux,phandle = <2000>;
- prop-int = <d# 123456789>;
+ linux,phandle = <0x2000>;
+ prop-int = < 123456789>;
subsubnode@0 {
- linux,phandle = <2001>;
+ linux,phandle = <0x2001>;
compatible = "subsubnode2", "subsubnode";
- prop-int = <o# 0726746425>;
+ prop-int = < 0726746425>;
+ };
+
+ ss2 {
};
};
};
diff --git a/tests/tests.h b/tests/tests.h
index c273f3cec0b2..fcb2b2af6763 100644
--- a/tests/tests.h
+++ b/tests/tests.h
@@ -34,6 +34,7 @@ void test_init(int argc, char *argv[]);
#define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1))
#define PALIGN(p, a) ((void *)ALIGN((unsigned long)(p), (a)))
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#define streq(s1, s2) (strcmp((s1),(s2)) == 0)
diff --git a/tests/trees.S b/tests/trees.S
index cedf5f948a53..66adf3f7464d 100644
--- a/tests/trees.S
+++ b/tests/trees.S
@@ -96,10 +96,14 @@ test_tree1_struct:
PROP_STR(test_tree1, compatible, "subsubnode1\0subsubnode")
PROP_INT(test_tree1, prop_int, TEST_VALUE_1)
END_NODE
+
+ BEGIN_NODE("ss1")
+ END_NODE
+
END_NODE
BEGIN_NODE("subnode@2")
- PROP_INT(test_tree1, phandle, PHANDLE_1)
+ PROP_INT(test_tree1, linux_phandle, PHANDLE_1)
PROP_INT(test_tree1, prop_int, TEST_VALUE_2)
BEGIN_NODE("subsubnode@0")
@@ -107,6 +111,10 @@ test_tree1_struct:
PROP_STR(test_tree1, compatible, "subsubnode2\0subsubnode")
PROP_INT(test_tree1, prop_int, TEST_VALUE_2)
END_NODE
+
+ BEGIN_NODE("ss2")
+ END_NODE
+
END_NODE
END_NODE
@@ -117,7 +125,8 @@ test_tree1_strings:
STRING(test_tree1, compatible, "compatible")
STRING(test_tree1, prop_int, "prop-int")
STRING(test_tree1, prop_str, "prop-str")
- STRING(test_tree1, phandle, "linux,phandle")
+ STRING(test_tree1, linux_phandle, "linux,phandle")
+ STRING(test_tree1, phandle, "phandle")
test_tree1_strings_end:
test_tree1_end:
diff --git a/tests/value-labels.c b/tests/value-labels.c
new file mode 100644
index 000000000000..c5aea8f7833d
--- /dev/null
+++ b/tests/value-labels.c
@@ -0,0 +1,128 @@
+/*
+ * libfdt - Flat Device Tree manipulation
+ * Test labels within values
+ * Copyright (C) 2008 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 <errno.h>
+
+#include <dlfcn.h>
+
+#include <fdt.h>
+#include <libfdt.h>
+
+#include "tests.h"
+#include "testdata.h"
+
+struct val_label {
+ const char *labelname;
+ int propoff;
+};
+
+struct val_label labels1[] = {
+ { "start1", 0 },
+ { "mid1", 2 },
+ { "end1", -1 },
+};
+
+struct val_label labels2[] = {
+ { "start2", 0 },
+ { "innerstart2", 0 },
+ { "innermid2", 4 },
+ { "innerend2", -1 },
+ { "end2", -1 },
+};
+
+struct val_label labels3[] = {
+ { "start3", 0 },
+ { "innerstart3", 0 },
+ { "innermid3", 1 },
+ { "innerend3", -1 },
+ { "end3", -1 },
+};
+
+void check_prop_labels(void *sohandle, void *fdt, const char *name,
+ const struct val_label* labels, int n)
+{
+ const struct fdt_property *prop;
+ const char *p;
+ int len;
+ int i;
+
+ prop = fdt_get_property(fdt, 0, name, &len);
+ if (!prop)
+ FAIL("Couldn't locate property \"%s\"", name);
+
+ p = dlsym(sohandle, name);
+ if (!p)
+ FAIL("Couldn't locate label symbol \"%s\"", name);
+
+ if (p != (const char *)prop)
+ FAIL("Label \"%s\" does not point to correct property", name);
+
+ for (i = 0; i < n; i++) {
+ int off = labels[i].propoff;
+
+ if (off == -1)
+ off = len;
+
+ p = dlsym(sohandle, labels[i].labelname);
+ if (!p)
+ FAIL("Couldn't locate label symbol \"%s\"", name);
+
+ if ((p - prop->data) != off)
+ FAIL("Label \"%s\" points to offset %ld instead of %d"
+ "in property \"%s\"", labels[i].labelname,
+ (long)(p - prop->data), off, name);
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ void *sohandle;
+ void *fdt;
+ int err;
+
+ test_init(argc, argv);
+ if (argc != 2)
+ CONFIG("Usage: %s <so file>", argv[0]);
+
+ sohandle = dlopen(argv[1], RTLD_NOW);
+ if (!sohandle)
+ FAIL("Couldn't dlopen() %s", argv[1]);
+
+ fdt = dlsym(sohandle, "dt_blob_start");
+ if (!fdt)
+ FAIL("Couldn't locate \"dt_blob_start\" symbol in %s",
+ argv[1]);
+
+ err = fdt_check_header(fdt);
+ if (err != 0)
+ FAIL("%s contains invalid tree: %s", argv[1],
+ fdt_strerror(err));
+
+
+ check_prop_labels(sohandle, fdt, "prop1", labels1, ARRAY_SIZE(labels1));
+ check_prop_labels(sohandle, fdt, "prop2", labels2, ARRAY_SIZE(labels2));
+ check_prop_labels(sohandle, fdt, "prop3", labels3, ARRAY_SIZE(labels3));
+
+ PASS();
+}
diff --git a/tests/value-labels.dts b/tests/value-labels.dts
new file mode 100644
index 000000000000..490c609f7fb0
--- /dev/null
+++ b/tests/value-labels.dts
@@ -0,0 +1,8 @@
+/dts-v1/;
+
+/ {
+ prop1: prop1 = start1: "a", mid1: "b" end1:;
+ prop2: prop2 = start2: < innerstart2: 0xdeadbeef innermid2: 0xabcd1234 innerend2: > end2:;
+ prop3: prop3 = start3: [ innerstart3: ab innermid3: cd innerend3: ] end3:;
+};
+