Commit graph

20 commits

Author SHA1 Message Date
David Gibson
d2a9da0458 libfdt: Make unit address optional for finding nodes
At present, the fdt_subnode_offset() and fdt_path_offset() functions
in libfdt require the exact name of the nodes in question be passed,
including unit address.

This is contrary to traditional OF-like finddevice() behaviour, which
allows the unit address to be omitted (which is useful when the device
name is unambiguous without the address).

This patch introduces similar behaviour to
fdt_subnode_offset_namelen(), and hence to fdt_subnode_offset() and
fdt_path_offset() which are implemented in terms of the former.  The
unit address can be omitted from the given node name.  If this is
ambiguous, the first such node in the flattened tree will be selected
(this behaviour is consistent with IEEE1275 which specifies only that
an arbitrary node matching the given information be selected).

This very small change is then followed by many more diffs which
change the test examples and testcases to exercise this behaviour.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-10-15 08:27:24 -05:00
David Gibson
02a5556850 libfdt: Test rw functions on more trees
At present, the testcases for read/write functions (setprop,
del_property and del_node) are only invoked on the single
asm-generated tree, not on any of the other tree images which should
be equivalent.  The functions in question will (correctly) not work on
the "unfinished" tree output from sw_tree1, but should work on most of
the others.

This patch extends the run_tests script to invoke the r/w testcases on
more example trees.  The testsuite still passes clean with this
addition.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-10-15 08:26:11 -05:00
David Gibson
63dc9c7113 dtc: Whitespace cleanup
This large patch removes all trailing whitespace from dtc (including
libfdt, the testsuite and documentation).  It also removes a handful
of redundant blank lines (at the end of functions, or when there are
two blank lines together for no particular reason).

As well as anything else, this means that quilt won't whinge when I go
to convert the whole of libfdt into a patch to apply to the kernel.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-09-18 09:43:26 -05:00
David Gibson
8d59bd3b17 dtc: Add basic testcases for dtc
This patch adds a handful of simple testcases for dtc.  It adds a dts
file which should generate the same sample tree as is used for the
libfdt testcases, and tests invoking dtc on this dts, plus the
standard batch of libfdt cases on the resulting dtb, which effectively
checks that the dtb is correct.

Because the test framework assumes each testcase is an executable with
the right output conventions, we use a little shell script, dtc.sh, as
a wrapper around dtc itself.  It simply invokes dtc and returns a PASS
or FAIL depending on whether dtc returned an error.

It's not much, but it's a start.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-09-18 08:40:36 -05:00
David Gibson
ef90baa0c6 dtc: Cleanup testsuite organization
run_tests.sh from the dtc testsuite currently has a facility ro run
just "functional" or just "stress" tests.  This distinction is carried
over from libhugetlbfs where the test framework originated, and where
it made sense.

In dtc, we have no stress tests, so running these subsections isn't
particularly interesting.  This patch removes these test subsets,
instead defining a single "libfdt" test subset for testcases related
to libfdt (and not dtc proper only.  Currently that's all of the
testcases, but with any luck we'll have some dtc testcases in the
future.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-09-17 14:18:27 -05:00
David Gibson
874ff219af libfdt: Consistently use big-endian property data in testcases
Flat device trees always have integers in their structure stored as
big-endian.  From this point of view, property values are
bags-of-bytes and any endianness is up to users of the device tree to
determine.

The libfdt testcases which use properties with integer values,
currently use native endian format for the architecture on which the
testcases are run.  This works ok for now, since both the creation and
checking of the example device trees happen in the same endianness.

This will become a problem, however, for tests of dtc which we want to
add in the nearish future.  dtc always uses big-endian format for
'cell' format data in properties; as it needs to in order to produce
powerpc-usable device trees when hosted on a little-endian
architecture.

This patch, therefore, changes the libfdt testsuite to use big-endian
format always for integer format data, in order to interoperate sanely
with future dtc testcases.  This also means that the example trees
created by the testsuite should now be byte-for-byte identical
regardless of dtc and libfdt's host platform, which is arguably an
advantage.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-09-17 14:18:19 -05:00
David Gibson
ae1454b311 libfdt: Add fdt_node_offset_by_prop_value()
This patch adds a function to libfdt to locate nodes containing a
property with a specific value.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-09-17 13:18:09 -05:00
David Gibson
bf94497031 dtc: Optimise by default, fix warnings thus uncovered
This patch turns on optimisation in the Makefile by default.  With the
optimizer on, some uninitialized variable warnings (one real, two
bogus) are now generated.  This patch also squashes those again.
2007-08-31 08:34:18 -05:00
David Gibson
7ca330865e dtc: Fix summary calculation in testsuite
The bookkeeping for producing the testsuite summary (total number of
tests passed, failed and so forth) is broken.  It uses $? across
several tests, but for checks after the first, the value of $? will no
longer contain the original return code, but just that from the
previous test.  This patch fixes the problem.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-08-30 08:43:40 -05:00
David Gibson
1248237c7e libfdt: Add fdt_parent_offset() and supporting functions
This patch adds an fdt_parent_offset() function which returns an
offset to the parent node of a given node.  It also adds two helper
functions which are used to implement fdt_parent_offset() but are also
exported: fdt_supernode_atdepth_offset() which returns the ancestor of
a given node at a specified depth from the root of the tree, and
fdt_node_depth() which returns the depth of a given node.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-08-30 08:43:12 -05:00
David Gibson
037db263e0 libfdt: Add fdt_get_path() function
This patch adds an fdt_get_path() function to libfdt, which returns
the full path of a given node in a caller supplied buffer.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-08-30 08:43:06 -05:00
David Gibson
9d26eabdc6 libfdt: Add fdt_get_name() to retrieve a node's name
This patch adds a new fdt_get_name() function to libfdt which will
return a node's name string (including unit address, if any).

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-08-30 08:42:59 -05:00
David Gibson
bd2ae2f41c libfdt: Fix handling of trailing / in fdt_path_offset()
Currently, fdt_path_offset() returns FDL_ERR_BADOFFSET if given a path
with a trailing '/'.  In particular this means that
fdt_path_offset("/") returns FDT_ERR_BADOFFSET rather than 0 as one
would expect.

This patch fixes the function to accept and ignore trailing '/'
characters.  As well as allowing fdt_path_offset("/") this means that
fdt_path_offset("/foo/") will return the same as
fdt_path_offset("/foo") which seems in keeping with the principle of
least surprise.

This also adds a testcase to ensure that fdt_path_offset("/") returns
0 as it should.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-08-30 08:42:45 -05:00
Milton Miller
9670eed1bc dtc: add a testcase with labels
Create a source file with labels for use as a testcase
to check parsing dts files.

Signed-off-by: Milton Miller <miltonm@bga.com>
2007-07-07 10:14:15 -05:00
David Gibson
d9d679fb96 dtc: Improve and better integrate dtc and libfdt Makefiles
This patch substantially revamps the dtc Makefiles, in particular
better integrating the Makefile for dtc proper with the Makefiles
imported from libfdt for libfdt and the shared testsuite.  Notable
changes:
	- No recursive make calls.  Instead subsidiary Makefiles are
included into the top-level Makefile so we get a complete dependency
information.
	- Common pattern rules, CFLAGS etc. shared between dtc, libfdt
and testsuite, rather than separate copies.
	- Vaguely Kbuild-like non-verbose mode used by default, which
makes warnings more prominent.
	- libfdt Makefile consists only of variable definitions and
helper rules, to make it more easily embeddable into other Makefile
systems.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-06-25 21:50:14 -05:00
David Gibson
0c7cd1a087 dtc: Count testcases and results in the dtc/libfdt testsuite
There are quite a lot of testcases in the dtc testsuite (recently
imported from libfdt).  It can be easy to miss a stray FAIL result in
the midst of all the rest.  To improve this, this patch adds a summary
to the end of the testsuite results giving the total number of tests
along with the number of PASSes FAILs and other results.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-06-25 21:43:03 -05:00
David Gibson
12578976fe Merge libfdt into dtc.
Having pulled the libfdt repository into dtc, merge the makefiles and
testsuites so that they build together usefully.
2007-06-14 15:05:55 +10:00
Jon Loeliger
fd84d97dee Add some initial test cases.
Add the original simple test case and a case with
different based cell values.  Correct output asm
files as well as stderr is captured.

Signed-off-by: Jon Loeliger <jdl@freescale.com>
2007-02-15 11:02:44 -06:00
David Gibson
363f1ea846 Add missing file. 2005-07-04 13:51:09 +10:00
David Gibson
fc14dad769 Initial commit 2005-06-08 17:18:34 +10:00